소스 검색

隐私弹窗

wangxin 2 년 전
부모
커밋
cceb4d951f

+ 1 - 0
miniprogram/app.json

@@ -1,4 +1,5 @@
 {
+  "__usePrivacyCheck__": true,
 	"pages": [
 		"pages/index/index",
 		"pages/login/login",

+ 4 - 0
miniprogram/component/privacy-popup/privacy-popup.json

@@ -0,0 +1,4 @@
+{
+	"component": true,
+	"usingComponents": {}
+}

+ 25 - 0
miniprogram/component/privacy-popup/privacy-popup.scss

@@ -0,0 +1,25 @@
+/* component/privacy-popup/privacy-popup.wxss */
+.privacy-container {
+  height: 100vh;
+  width: 100vw;
+  background: rgba($color: #000000, $alpha: 0.6);
+  position: fixed;
+  left: 0;
+  top: 0;
+  z-index: 1;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.privacy-content {
+  width: 640rpx;
+  font-size: 32rpx;
+  font-family: PingFang SC-Bold, PingFang SC;
+  color: #333333;
+  text-align: center;
+  padding: 40rpx;
+  box-sizing: border-box;
+  background: #FFFFFF;
+  border-radius: 16rpx 16rpx 16rpx 16rpx;
+}

+ 23 - 0
miniprogram/component/privacy-popup/privacy-popup.ts

@@ -0,0 +1,23 @@
+// component/privacy-popup/privacy-popup.ts
+Component({
+	/**
+	 * 组件的属性列表
+	 */
+	properties: {
+
+	},
+
+	/**
+	 * 组件的初始数据
+	 */
+	data: {
+
+	},
+
+	/**
+	 * 组件的方法列表
+	 */
+	methods: {
+
+	}
+})

+ 6 - 0
miniprogram/component/privacy-popup/privacy-popup.wxml

@@ -0,0 +1,6 @@
+<!--component/privacy-popup/privacy-popup.wxml-->
+<view class="privacy-container">
+  <view class="privacy-content">
+    <view class="privacy-title">用户隐私保护提示</view>
+  </view>
+</view>

+ 3 - 1
miniprogram/pages/login/login.json

@@ -1,4 +1,6 @@
 {
   "navigationStyle":"custom",
-  "usingComponents": {}
+  "usingComponents": {
+    "privacy-popup": "/component/privacy-popup/privacy-popup"
+  }
 }

+ 66 - 60
miniprogram/pages/login/login.ts

@@ -8,6 +8,7 @@ let codeInter: number = 0;
 let setInter: number = 0
 import { baseurl, captcha } from '../../config'
 import { getAuthCodeImpl, phoneLoginImpl } from "../../service/impl/hwUser.impl";
+import { getPrivacySetting } from "../../utils/util";
 Page({
 
 	/**
@@ -158,70 +159,75 @@ Page({
 	 * @code {string} 验证码
 	 * @register_from {注册来源} 0 小程序 1 APP 2 后台
 	 */
-	submit() {
-		// 首先判断是否可以登陆
-		const status = this.data.canLogin;
-		if (status) {
-			phoneLoginImpl({
-				phone: this.data.phone,
-				code: this.data.code,
-				register_from: 0
-			}).then(res => {
-				if (res.errCode === 0) {
-					// 请求成功 存入userID和userToken 并根据来源跳转不同的页面  后台账号跳转首页
-					wx.setStorage({
-						key: 'userId',
-						data: res.data.userInfo.id,
-						success: () => {
-							wx.setStorage({
-								key: 'userToken',
-								data: res.data.userInfo.userToken,
-								success: () => {
-									wx.setStorageSync('userInfo', res.data.userInfo)
-									wx.setStorageSync('firstLogin', true)
-									if (!wx.getStorageInfoSync().keys.length) {
-										wx.setStorageSync('hasClear', true)
-									}
-									// 提交是否登录信息
-									if (res.data.userInfo.isDemonstrate) {
-										wx.reLaunch({
-											url: '/pages/index/index'
-										})
-									} else {
-										wx.reLaunch({
-											url: '/pages/my-order/my-order'
-										})
-									}
-								}
-							})
-						}
-					})
-				}
-			})
-		} else {
-			let content = ''
-			if (!this.data.isCheck) {
-				content = '请勾选用用户协议与隐私政策'
-			}
-			if (!this.data.code) {
-				content = '请填写验证码'
-			}
-			if (!this.data.phone || !app.globalData.phone_zz.test(this.data.phone)) {
-				content = '电话号码格式错误'
-			}
-			wx.showModal({
-				title: '登录失败',
-				content,
-				showCancel: false,
-				confirmColor: '#31364C',
-			})
-		}
-	},
+  submit() {
+    // 首先判断是否可以登陆
+    const status = this.data.canLogin;
+    getPrivacySetting().then(data => {
+      if (data.needAuthorization) {
+        return
+      }
+      if (status) {
+        phoneLoginImpl({
+          phone: this.data.phone,
+          code: this.data.code,
+          register_from: 0
+        }).then(res => {
+          if (res.errCode === 0) {
+            // 请求成功 存入userID和userToken 并根据来源跳转不同的页面  后台账号跳转首页
+            wx.setStorage({
+              key: 'userId',
+              data: res.data.userInfo.id,
+              success: () => {
+                wx.setStorage({
+                  key: 'userToken',
+                  data: res.data.userInfo.userToken,
+                  success: () => {
+                    wx.setStorageSync('userInfo', res.data.userInfo)
+                    wx.setStorageSync('firstLogin', true)
+                    if (!wx.getStorageInfoSync().keys.length) {
+                      wx.setStorageSync('hasClear', true)
+                    }
+                    // 提交是否登录信息
+                    if (res.data.userInfo.isDemonstrate) {
+                      wx.reLaunch({
+                        url: '/pages/index/index'
+                      })
+                    } else {
+                      wx.reLaunch({
+                        url: '/pages/my-order/my-order'
+                      })
+                    }
+                  }
+                })
+              }
+            })
+          }
+        })
+      } else {
+        let content = ''
+        if (!this.data.isCheck) {
+          content = '请勾选用用户协议与隐私政策'
+        }
+        if (!this.data.code) {
+          content = '请填写验证码'
+        }
+        if (!this.data.phone || !app.globalData.phone_zz.test(this.data.phone)) {
+          content = '电话号码格式错误'
+        }
+        wx.showModal({
+          title: '登录失败',
+          content,
+          showCancel: false,
+          confirmColor: '#31364C',
+        })
+      }
+    })
+  },
 	/**
 	 * 生命周期函数--监听页面加载
 	 */
 	onLoad: function (options) {
-		this.options = options;
+    this.options = options;
 	},
 
 	/**

+ 2 - 1
miniprogram/pages/login/login.wxml

@@ -76,4 +76,5 @@
 	<view class="container-bottom">
 		<image src="../../assets/img/login_bottom.png"></image>
 	</view>
-</view>
+</view>
+<privacy-popup></privacy-popup>

+ 20 - 0
miniprogram/utils/util.ts

@@ -250,4 +250,24 @@ export function getStorageSync(key: string): any {
 	} else {
 		return wx.getStorageSync(key)
 	}
+}
+
+/**
+ * 获取隐私协议信息
+ */
+export function getPrivacySetting():Promise<{needAuthorization:boolean,privacyContractName:string}> {
+  return new Promise(resolve=>{
+    if (wx.canIUse('getPrivacySetting')) {
+      wx.getPrivacySetting({
+        success(res){
+          resolve(res)
+        }
+      })
+    }else{
+      resolve({
+        needAuthorization:false,
+        privacyContractName:''
+      })
+    }
+  })
 }

+ 13 - 16
project.config.json

@@ -1,18 +1,7 @@
 {
 	"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-	"packOptions": {
-		"ignore": [],
-		"include": []
-	},
 	"miniprogramRoot": "miniprogram/",
 	"compileType": "miniprogram",
-	"libVersion": "2.12.3",
-	"projectname": "Mina_B_T",
-	"scripts": {
-		"beforeCompile": "npm run  tsc",
-		"beforePreview": "npm run tsc",
-		"beforeUpload": "npm run tsc"
-	},
 	"setting": {
 		"urlCheck": true,
 		"es6": true,
@@ -26,15 +15,13 @@
 		"autoAudits": false,
 		"showShadowRootInWxmlPanel": true,
 		"scopeDataCheck": false,
-		"uglifyFileName": false,
+		"uglifyFileName": true,
 		"checkInvalidKey": true,
 		"checkSiteMap": true,
 		"uploadWithSourceMap": true,
 		"compileHotReLoad": true,
 		"lazyloadPlaceholderEnable": false,
 		"useMultiFrameRuntime": true,
-		"useApiHook": true,
-		"useApiHostProcess": true,
 		"babelSetting": {
 			"ignore": [],
 			"disablePlugins": [],
@@ -54,15 +41,25 @@
 		],
 		"minifyWXML": true,
 		"useStaticServer": true,
-		"condition": true
+		"condition": true,
+		"ignoreUploadUnusedFiles": true
 	},
 	"simulatorType": "wechat",
 	"simulatorPluginLibVersion": {},
-	"appid": "wx997164f2857c1a1d",
 	"condition": {},
 	"srcMiniprogramRoot": "miniprogram/",
 	"editorSetting": {
 		"tabIndent": "tab",
 		"tabSize": 2
+	},
+	"appid": "wx997164f2857c1a1d",
+	"packOptions": {
+		"ignore": [],
+		"include": []
+	},
+	"scripts": {
+		"beforeCompile": "npm run  tsc",
+		"beforePreview": "npm run tsc",
+		"beforeUpload": "npm run tsc"
 	}
 }

+ 3 - 3
project.private.config.json

@@ -2,7 +2,7 @@
 	"setting": {
 		"compileHotReLoad": true,
 		"urlCheck": false,
-		"autoAudits": true
+		"autoAudits": false
 	},
 	"condition": {
 		"miniprogram": {
@@ -45,7 +45,7 @@
 			]
 		}
 	},
-	"projectname": "mina-b-t",
+	"projectname": "Mina_B",
 	"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-	"libVersion": "2.30.2"
+	"libVersion": "3.0.1"
 }

+ 6 - 3
typings/types/wx/index.d.ts

@@ -24,9 +24,11 @@ SOFTWARE.
 /// <reference path="./lib.wx.page.d.ts" />
 /// <reference path="./lib.wx.api.d.ts" />
 /// <reference path="./lib.wx.cloud.d.ts" />
+/// <reference path="./lib.wx.canvas.d.ts" />
 /// <reference path="./lib.wx.component.d.ts" />
 /// <reference path="./lib.wx.behavior.d.ts" />
 /// <reference path="./lib.wx.event.d.ts" />
+/// <reference path="./lib.wx.wasm.d.ts" />
 
 declare namespace WechatMiniprogram {
     type IAnyObject = Record<string, any>
@@ -56,7 +58,8 @@ declare namespace WechatMiniprogram {
     type GainNode = any
     type BiquadFilterNode = any
     type PeriodicWaveNode = any
-    type BufferSourceNode = any
+    type AudioNode = any
+    type AudioParam = any
     type ChannelSplitterNode = any
     type ChannelMergerNode = any
     type DelayNode = any
@@ -71,8 +74,8 @@ declare namespace WechatMiniprogram {
     // TODO: fill worklet type
     type WorkletFunction = (...args: any) => any
     type AnimationObject = any
-    type SharedValue = any
-    type DerivedValue = any
+    type SharedValue<T = any> = T
+    type DerivedValue<T = any> = T
 }
 
 declare let console: WechatMiniprogram.Console

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 14153 - 11886
typings/types/wx/lib.wx.api.d.ts


+ 0 - 16
typings/types/wx/lib.wx.app.d.ts

@@ -21,22 +21,6 @@ SOFTWARE.
 ***************************************************************************** */
 
 declare namespace WechatMiniprogram.App {
-    interface ReferrerInfo {
-        /** 来源小程序或公众号或App的 appId
-         *
-         * 以下场景支持返回 referrerInfo.appId:
-         * - 1020(公众号 profile 页相关小程序列表): appId
-         * - 1035(公众号自定义菜单):来源公众号 appId
-         * - 1036(App 分享消息卡片):来源应用 appId
-         * - 1037(小程序打开小程序):来源小程序 appId
-         * - 1038(从另一个小程序返回):来源小程序 appId
-         * - 1043(公众号模板消息):来源公众号 appId
-         */
-        appId: string
-        /** 来源小程序传过来的数据,scene=1037或1038时支持 */
-        extraData?: any
-    }
-
     type SceneValues =
         | 1000
         | 1001

+ 4 - 0
typings/types/wx/lib.wx.cloud.d.ts

@@ -20,6 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 ***************************************************************************** */
 
+/**
+ * Common interfaces and types
+ */
+
 interface IAPIError {
     errMsg: string
 }

+ 2 - 2
typings/types/wx/lib.wx.component.d.ts

@@ -648,11 +648,11 @@ declare namespace WechatMiniprogram.Component {
         (res: UpdatePerformance<WithDataPath>): void
     }
     interface UpdatePerformance<WithDataPath> {
-        /** 此次更新过程的 ID */
+        /** 此次更新过程的 ID */
         updateProcessId: number
         /** 对于子更新,返回它所属的更新过程 ID */
         parentUpdateProcessId?: number
-        /** 是否是被合并更新,如果是,则 updateProcessId 表示被合并到的更新过程 ID */
+        /** 是否是被合并更新,如果是,则 updateProcessId 表示被合并到的更新过程 ID */
         isMergedUpdate: boolean
         /** 此次更新的 data 字段信息,只有 withDataPaths 设为 true 时才会返回 */
         dataPaths: WithDataPath extends true ? string[] : undefined

+ 10 - 1
typings/types/wx/lib.wx.page.d.ts

@@ -102,7 +102,12 @@ declare namespace WechatMiniprogram.Page {
         onShareAppMessage(
             /** 分享发起来源参数 */
             options: IShareAppMessageOption
-        ): ICustomShareContent | void
+        ):
+            | ICustomShareContent
+            | IAsyncCustomShareContent
+            | Promise<ICustomShareContent>
+            | void
+            | Promise<void>
         /**
          * 监听右上角菜单“分享到朋友圈”按钮的行为,并自定义分享内容
          *
@@ -176,6 +181,10 @@ declare namespace WechatMiniprogram.Page {
         imageUrl?: string
     }
 
+    interface IAsyncCustomShareContent extends ICustomShareContent {
+        promise: Promise<ICustomShareContent>
+    }
+
     interface ICustomTimelineContent {
         /** 自定义标题,即朋友圈列表页上显示的标题。默认值:当前小程序名称 */
         title?: string