From ad876a6fea2df6e2a831d4c9d95cf724855610f4 Mon Sep 17 00:00:00 2001
From: Liuyi <candymxq888@outlook.com>
Date: 星期六, 14 十二月 2024 16:43:35 +0800
Subject: [PATCH] 修复用户微信扫码进入小程序无法跳转及登录问题,修改会员卡解绑接口

---
 unpackage/dist/dev/mp-weixin/pages/index/index.js |  101 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 86 insertions(+), 15 deletions(-)

diff --git a/unpackage/dist/dev/mp-weixin/pages/index/index.js b/unpackage/dist/dev/mp-weixin/pages/index/index.js
index 18cf45a..c86f8c0 100644
--- a/unpackage/dist/dev/mp-weixin/pages/index/index.js
+++ b/unpackage/dist/dev/mp-weixin/pages/index/index.js
@@ -17,6 +17,7 @@
       userName: "微信用户",
       headImg: "",
       userPhone: "",
+      integral: "",
       waterCardNumber: "",
       balance: "",
       count: "",
@@ -33,6 +34,7 @@
     async function getVipInfo() {
       await api_index.getVipInfoApi().then((res) => {
         if (res.code == 200 && res.data.id) {
+          console.log("获取会员卡返回响应-首页", res);
           cardInfo.value.waterCardNumber = res.data.cardNumber;
           cardInfo.value.cardType = res.data.cardType;
           cardInfo.value.state = res.data.state == 2 ? true : false;
@@ -54,10 +56,12 @@
         if (res.code == 200) {
           cardInfo.value.userName = res.data.userInfo.userName ? res.data.userInfo.userName : cardInfo.value.userName;
           cardInfo.value.headImg = res.data.userInfo.headImg;
+          cardInfo.value.integral = res.data.userInfo.integral;
           cardInfo.value.userPhone = res.data.userInfo.userPhone;
           cardInfo.value.id = res.data.userInfo.id;
           await getVipInfo();
-          console.log("00000", cardInfo.value);
+          console.log("用户信息响应", res);
+          console.log("用户信息", cardInfo.value);
           common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value));
         }
       });
@@ -74,6 +78,7 @@
       });
     }
     const functionList = common_vendor.ref([
+      //isUrl:1:页面跳转,2:弹窗功能,3:弹窗功能,4:未开发
       { text: "余额记录", icon: "../../static/images/index/icon31.png", bgColor: "#16b387", url: "/pages/functionList/balanceRecord/index", isUrl: 1 },
       { text: "消费记录", icon: "../../static/images/index/icon32.png", bgColor: "#329ae8", url: "/pages/functionList/paymentRecord/index", isUrl: 1 },
       { text: "充值记录", icon: "../../static/images/index/icon33.png", bgColor: "#f0a50e", url: "/pages/functionList/rechargeRecord/index", isUrl: 1 },
@@ -144,7 +149,7 @@
               content: "确认注销会员卡?",
               success: async function(res) {
                 if (res.confirm) {
-                  await api_index.removeCardApi(cardInfo.value.waterCardNumber).then(async (res2) => {
+                  await api_index.removeBindingApi(cardInfo.value.waterCardNumber).then(async (res2) => {
                     if (res2.code == 200) {
                       common_vendor.index.showToast({
                         title: "已注销",
@@ -190,9 +195,73 @@
         icon: "none"
       });
     }
+    let userLocation = {
+      lat: "",
+      lon: ""
+    };
+    function getUserLocation() {
+      common_vendor.index.authorize({
+        scope: "scope.userLocation",
+        success() {
+          console.log("成功授权位置信息1");
+          storageLocation();
+        },
+        fail() {
+          console.log("用户拒绝授权位置信息,再次提示用户授权");
+          showToast();
+        }
+      });
+      function storageLocation() {
+        common_vendor.index.getLocation({
+          type: "gcj02",
+          isHighAccuracy: true,
+          success: (res) => {
+            userLocation.lat = res.latitude;
+            userLocation.lon = res.longitude;
+            common_vendor.index.setStorageSync("userLocation", JSON.stringify(userLocation));
+          },
+          fail: () => {
+            showToast();
+          }
+        });
+      }
+      function showToast() {
+        common_vendor.index.showModal({
+          title: "请求授权当前位置",
+          content: "请求获取您的位置,加载附近饮水设备信息!",
+          confirmText: "前往设置",
+          success: (res) => {
+            if (res.confirm) {
+              common_vendor.index.openSetting({
+                success: (res1) => {
+                  if (res1.authSetting["scope.userLocation"]) {
+                    console.log("用户二次授权成功");
+                    setTimeout(() => {
+                      storageLocation();
+                    }, 1e3);
+                  } else {
+                    showToast();
+                    console.log("用户拒绝授权");
+                  }
+                }
+              });
+            } else {
+              common_vendor.index.showToast({
+                title: "请先授权!",
+                duration: 2e3,
+                icon: "none"
+              });
+              showToast();
+            }
+          }
+        });
+      }
+    }
     common_vendor.onMounted(async () => {
       getTopHeight();
       await getInfo();
+      await getUserLocation();
+      console.log("进入首页了");
     });
     common_vendor.onShow(async () => {
       getTopHeight();
@@ -214,13 +283,13 @@
       }, cardInfo.value.headImg ? {
         b: common_vendor.unref(config_baseUrl.BASE_URL) + "/upload" + cardInfo.value.headImg
       } : {
-        c: common_assets.headImg
+        c: common_assets._imports_0$4
       }, {
         d: common_vendor.t(cardInfo.value.userName),
         e: common_vendor.o(($event) => navTo("/pages/userInfo/index")),
         f: common_vendor.o(($event) => navTo("/pages/userInfo/index")),
-        g: common_assets._imports_1$1,
-        h: common_assets._imports_0$1,
+        g: common_assets._imports_1$2,
+        h: common_assets._imports_0$3,
         i: isShareCard.value
       }, isShareCard.value ? {
         j: common_vendor.t(cardInfo.value.waterCardNumber)
@@ -229,7 +298,7 @@
       }, !isShareCard.value ? common_vendor.e({
         l: isVip.value
       }, isVip.value ? {
-        m: common_assets._imports_3
+        m: common_assets._imports_3$1
       } : {}, {
         n: isVip.value
       }, isVip.value ? {} : {}, {
@@ -249,7 +318,7 @@
       } : {}, {
         w: !isVip.value
       }, !isVip.value ? {
-        x: common_assets._imports_4,
+        x: common_assets._imports_4$1,
         y: common_vendor.o(($event) => navTo("/pages/addCard/index"))
       } : {}, {
         z: isVip.value
@@ -259,7 +328,7 @@
         B: topHeight.value + "rpx",
         C: common_assets._imports_5,
         D: common_vendor.o(upGrade),
-        E: common_assets._imports_1,
+        E: common_assets._imports_1$1,
         F: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
         G: common_assets._imports_7,
         H: common_vendor.o(($event) => toScan()),
@@ -274,13 +343,15 @@
         }),
         J: common_assets._imports_8,
         K: common_assets._imports_9,
-        L: common_vendor.o(($event) => navTo("/pages/pointsMall/index")),
-        M: common_assets._imports_10,
-        N: common_assets._imports_11,
-        O: common_vendor.o(($event) => navTo("/pages/station/index")),
-        P: common_assets._imports_12,
-        Q: common_assets._imports_11,
-        R: common_vendor.o(upGrade)
+        L: common_assets._imports_10,
+        M: common_assets._imports_11,
+        N: common_vendor.o(($event) => navTo("/pagesPoints/pointsMall/index")),
+        O: common_assets._imports_12,
+        P: common_assets._imports_13,
+        Q: common_vendor.o(($event) => navTo("/pages/station/index")),
+        R: common_assets._imports_14,
+        S: common_assets._imports_13,
+        T: common_vendor.o(upGrade)
       });
     };
   }

--
Gitblit v1.9.3