Преглед изворни кода

直播间优化提示,安卓以及ios扫码权限判定

lemon橪 пре 4 година
родитељ
комит
4599b02a41
4 измењених фајлова са 39 додато и 46 уклоњено
  1. 8 17
      pages/mine/set/personMsg.vue
  2. 10 1
      pages/promotion/lives.vue
  3. 20 28
      pages/tabbar/home/views.vue
  4. 1 0
      utils/storage.js

+ 8 - 17
pages/mine/set/personMsg.vue

@@ -98,23 +98,14 @@ export default {
      * 提交保存
      */
     submit() {
-      if (this.form.regionId.length != 0 && this.birthday) {
-        delete this.form.___path;
-        let params = JSON.parse(JSON.stringify(this.form));
-        saveUserInfo(params).then((res) => {
-       
-          if (res.statusCode == 200) {
-            storage.setUserInfo(res.data.result);
-            uni.navigateBack();
-          }
-        });
-      } else {
-        uni.showToast({
-          title: "请填写生日和城市!",
-          duration: 2000,
-          icon: "none",
-        });
-      }
+      delete this.form.___path;
+      let params = JSON.parse(JSON.stringify(this.form));
+      saveUserInfo(params).then((res) => {
+        if (res.statusCode == 200) {
+          storage.setUserInfo(res.data.result);
+          uni.navigateBack();
+        }
+      });
     },
 
     /**

+ 10 - 1
pages/promotion/lives.vue

@@ -104,7 +104,6 @@ export default {
     this.params[this.current].pageNumber = 1;
     this.liveList = [];
     this.getLives();
-
     this.getRecommendLives();
   },
   onReachBottom() {
@@ -225,6 +224,7 @@ export default {
      * 进入直播间
      */
     handleLivePlayer(val) {
+      // #ifdef MP-WEIXIN
       let roomId = val.roomId; // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
       let customParams = encodeURIComponent(
         JSON.stringify({ path: "pages/index/index", pid: 1 })
@@ -236,6 +236,15 @@ export default {
           "&custom_params=" +
           customParams,
       });
+      // #endif
+
+      // #ifndef MP-WEIXIN
+      uni.showToast({
+        title: "请从微信小程序中预览直播功能",
+        duration: 2000,
+        icon: "none",
+      });
+      // #endif
     },
   },
 };

+ 20 - 28
pages/tabbar/home/views.vue

@@ -68,6 +68,7 @@ export default {
     return {
       config,
       pageData: "", //楼层页面数据
+      isIos: "",
     };
   },
   components: {
@@ -96,10 +97,10 @@ export default {
     this.init();
     // #ifdef MP-WEIXIN
     // 小程序默认分享
-    uni.showShareMenu({ withShareTicket: true, });
+    uni.showShareMenu({ withShareTicket: true });
     // #endif
   },
- 
+
   methods: {
     /**
      * 实例化首页数据楼层
@@ -137,9 +138,6 @@ export default {
               }, 100);
             }
           });
-
-          // let
-          // 扫码成功后跳转到webview页面
         },
       });
     },
@@ -153,9 +151,7 @@ export default {
         content: "您已经关闭相机权限,去设置",
         success: function (res) {
           if (res.confirm) {
-            let isIos = plus.os.name == "iOS";
-
-            if (isIos) {
+            if (this.isIos) {
               plus.runtime.openURL("app-settings:");
             } else {
               permision.gotoAppPermissionSetting();
@@ -171,31 +167,27 @@ export default {
      */
     async scan() {
       // #ifdef APP-PLUS
-      let isIos = plus.os.name == "iOS";
+      this.isIos = plus.os.name == "iOS";
       // 判断是否是Ios
-      if (isIos) {
-        if (permision.judgeIosPermission("camera")) {
+      if (this.isIos) {
+        const iosFirstCamera = uni.getStorageSync("iosFirstCamera"); //是不是第一次开启相机
+        if (iosFirstCamera !== "false") {
+          uni.setStorageSync("iosFirstCamera", "false"); //设为false就代表不是第一次开启相机
           this.seacnCode();
         } else {
-          // 没有权限提醒是否去申请权限
-          uni.showModal({
-            title: "提示",
-            content: "您已经关闭相机权限,去设置",
-            success: function (res) {
-              if (res.confirm) {
-                plus.runtime.openURL("app-settings:");
-              }
-            },
-          });
+          if (permision.judgeIosPermission("camera")) {
+            this.seacnCode();
+          } else {
+            // 没有权限提醒是否去申请权限
+            this.tipsGetSettings();
+          }
         }
       } else {
-        // 安卓
-        const result = await permision.requestAndroidPermission("CAMERA");
-        if (result == 1 || result == 0) {
-          this.seacnCode();
-        } else {
-          this.tipsGetSettings();
-        }
+        /**
+         * TODO 安卓 权限已经授权了,调用api总是显示用户已永久拒绝申请。人傻了
+         * TODO 如果xdm有更好的办法请在 https://gitee.com/beijing_hongye_huicheng/lilishop/issues 提下谢谢
+         */
+        this.seacnCode();
       }
 
       // #endif

+ 1 - 0
utils/storage.js

@@ -9,6 +9,7 @@ const FACE_LOGIN = isDev ? "face_login_dev" : "face_login";
 const FINGER_LOGIN = isDev ? "finger_login_dev" : "finger_login";
 const CART_BACKBTN = isDev ? "cart_backbtn_dev" : "cart_backbtn";
 export default {
+
   // 获取face id登录
   getFaceLogin() {
     return uni.getStorageSync(FACE_LOGIN);