From 681efe897b7fb4dbe8bec5fa5056209e3e0edfdc Mon Sep 17 00:00:00 2001
From: Liuyi <candymxq888@outlook.com>
Date: 星期三, 20 十一月 2024 17:19:57 +0800
Subject: [PATCH] 添加积分商品详情,替换首页海报,调整样式,添加积分规则

---
 unpackage/dist/dev/mp-weixin/pages/index/index.js |  162 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 113 insertions(+), 49 deletions(-)

diff --git a/unpackage/dist/dev/mp-weixin/pages/index/index.js b/unpackage/dist/dev/mp-weixin/pages/index/index.js
index 104ed16..dd3a6a9 100644
--- a/unpackage/dist/dev/mp-weixin/pages/index/index.js
+++ b/unpackage/dist/dev/mp-weixin/pages/index/index.js
@@ -1,6 +1,7 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const common_assets = require("../../common/assets.js");
+const config_baseUrl = require("../../config/baseUrl.js");
 const api_index = require("../../api/index.js");
 const _sfc_main = {
   __name: "index",
@@ -16,11 +17,14 @@
       userName: "微信用户",
       headImg: "",
       userPhone: "",
+      integral: "",
       waterCardNumber: "",
       balance: "",
       count: "",
       state: "",
       //state:true:挂失,false:正常
+      cardType: "",
+      //卡类型01卡消费 02计次消费 03游客消费 04电子卡
       userCardType: ""
       //userCardType:true:共享卡,false:正常卡
     });
@@ -30,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;
@@ -51,6 +56,7 @@
         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();
@@ -64,22 +70,8 @@
         scanType: ["qrCode"],
         success: async function(res) {
           console.log("条码内容:" + res.result);
-          let data = {
-            cardType: cardInfo.value.cardType,
-            card: cardInfo.value.waterCardNumber,
-            sn: res.result
-          };
-          await api_index.buyWaterApi(data).then((res2) => {
-            if (res2.code == 200) {
-              common_vendor.index.navigateTo({
-                url: "/pages/scanWater/index"
-              });
-            } else {
-              common_vendor.index.showToast({
-                title: "扫码失败!",
-                icon: "none"
-              });
-            }
+          common_vendor.index.navigateTo({
+            url: `/pages/scanWater/index?facilityCode=${res.result}`
           });
         }
       });
@@ -92,7 +84,7 @@
       { text: "故障上报", icon: "../../static/images/index/icon35.png", bgColor: "#a88ff1", url: "/pages/infoBreakdown/index", isUrl: 1 },
       { text: "优惠卷", icon: "../../static/images/index/icon36.png", bgColor: "#18bfc4", url: "", isUrl: 4 },
       { text: "会员卡挂失", icon: "../../static/images/index/icon37.png", bgColor: "#4875f0", url: "", isUrl: 2 },
-      { text: "会员卡注销", icon: "../../static/images/index/icon38.png", bgColor: "#f45088", url: "", isUrl: 3 }
+      { text: "会员卡解绑", icon: "../../static/images/index/icon38.png", bgColor: "#f45088", url: "", isUrl: 3 }
     ]);
     function navTo(itemUrl) {
       if (itemUrl) {
@@ -197,13 +189,77 @@
     function upGrade() {
       common_vendor.index.showToast({
         title: "该功能正在升级中!",
-        duration: 2e3,
+        duration: 1e3,
         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();
@@ -223,27 +279,29 @@
       return common_vendor.e({
         a: cardInfo.value.headImg
       }, cardInfo.value.headImg ? {
-        b: cardInfo.value.headImg
+        b: common_vendor.unref(config_baseUrl.BASE_URL) + "/upload" + cardInfo.value.headImg
       } : {
-        c: common_assets._imports_0$2
+        c: common_assets._imports_0$3
       }, {
         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_2,
-        i: common_vendor.o(($event) => navTo("/pages/addCard/index")),
-        j: common_assets._imports_0$1,
-        k: isShareCard.value
+        h: common_assets._imports_0$2,
+        i: isShareCard.value
       }, isShareCard.value ? {
-        l: common_vendor.t(cardInfo.value.waterCardNumber)
+        j: common_vendor.t(cardInfo.value.waterCardNumber)
       } : {}, {
-        m: !isShareCard.value
+        k: !isShareCard.value
       }, !isShareCard.value ? common_vendor.e({
-        n: isVip.value
+        l: isVip.value
       }, isVip.value ? {
-        o: common_assets._imports_4
+        m: common_assets._imports_3
       } : {}, {
+        n: isVip.value
+      }, isVip.value ? {} : {}, {
+        o: !isVip.value
+      }, !isVip.value ? {} : {}, {
         p: isLoss.value && isVip.value
       }, isLoss.value && isVip.value ? {} : {}, {
         q: isVip.value
@@ -252,24 +310,27 @@
       } : {}, {
         s: isVip.value
       }, isVip.value ? {} : {}, {
-        t: !isVip.value
-      }, !isVip.value ? {} : {}, {
-        v: isVip.value
+        t: isVip.value
       }, isVip.value ? {
-        w: common_vendor.t(cardInfo.value.balance)
+        v: common_vendor.t(cardInfo.value.balance)
       } : {}, {
-        x: isVip.value
+        w: !isVip.value
+      }, !isVip.value ? {
+        x: common_assets._imports_4,
+        y: common_vendor.o(($event) => navTo("/pages/addCard/index"))
+      } : {}, {
+        z: isVip.value
       }, isVip.value ? {
-        y: common_vendor.o(($event) => navTo("/pages/recharge/index"))
+        A: common_vendor.o(($event) => navTo("/pages/recharge/index"))
       } : {}) : {}, {
-        z: topHeight.value + "rpx",
-        A: common_assets._imports_5,
-        B: common_vendor.o(($event) => upGrade()),
-        C: common_assets._imports_1,
-        D: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
-        E: common_assets._imports_7,
-        F: common_vendor.o(($event) => toScan()),
-        G: common_vendor.f(functionList.value, (item, index, i0) => {
+        B: topHeight.value + "rpx",
+        C: common_assets._imports_5,
+        D: common_vendor.o(upGrade),
+        E: common_assets._imports_1,
+        F: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
+        G: common_assets._imports_7,
+        H: common_vendor.o(($event) => toScan()),
+        I: common_vendor.f(functionList.value, (item, index, i0) => {
           return {
             a: item.icon,
             b: item.bgColor,
@@ -278,14 +339,17 @@
             e: index
           };
         }),
-        H: common_assets._imports_8,
-        I: common_vendor.o(upGrade),
-        J: common_assets._imports_9,
-        K: common_assets._imports_10,
-        L: common_vendor.o(($event) => navTo("/pages/station/index")),
+        J: common_assets._imports_8,
+        K: common_assets._imports_9,
+        L: common_assets._imports_10,
         M: common_assets._imports_11,
-        N: common_assets._imports_10,
-        O: common_vendor.o(upGrade)
+        N: common_vendor.o(($event) => navTo("/pages/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