From 354b1317aab21617881057c40f8c0580b8f28139 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期五, 26 九月 2025 18:46:45 +0800
Subject: [PATCH] 用户绑定商店

---
 pages/tabbar/user/my.vue |   73 ++++++++++++++++++++++++++++++++++--
 1 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/pages/tabbar/user/my.vue b/pages/tabbar/user/my.vue
index d86d2e2..48bf11a 100644
--- a/pages/tabbar/user/my.vue
+++ b/pages/tabbar/user/my.vue
@@ -140,7 +140,7 @@
 import '@/pages/subComponents/uview-components/uview-ui';
 import tool from "@/pages/tabbar/user/utils/tool.vue";
 import { getSTSToken } from "@/api/common.js";
-import { getCouponsNum, getFootprintNum } from "@/api/members.js";
+import { getCouponsNum, getFootprintNum,bindMemberAndStore } from "@/api/members.js";
 import { getUserWallet } from "@/api/members";
 import configs from '@/config/config'
 import storage from '@/utils/storage.js'
@@ -162,8 +162,51 @@
       walletNum: "",
     };
   },
-  onLoad() {
-	  this.initCOS()
+  onLoad(option) {
+    console.log('-----------鍒嗕韩鍑虹殑鏁版嵁---------->', option)
+    let shareStoreId = null;
+    let shareTime = null;
+    // 妫�鏌ユ槸鍚﹀瓨鍦╭鍙傛暟
+    if (option.q) {
+      // 鍙岄噸瑙g爜锛氬井淇″URL杩涜浜嗕袱娆$紪鐮�
+      const decodedUrl = decodeURIComponent(decodeURIComponent(option.q));
+      console.log('鍘熷URL:', decodedUrl);
+
+      // 瑙f瀽URL涓殑鏌ヨ鍙傛暟
+      const params = this.parseUrlParams(decodedUrl);
+      shareStoreId = params.shareStoreId;
+      try {
+        // 灏嗘暟鎹瓨鍌ㄥ埌鏈湴缂撳瓨
+        uni.setStorageSync('shareStoreId', shareStoreId);
+        //鍒涘缓涓�涓壂鐮佺殑鏃堕棿
+        // 鑾峰彇褰撳墠鏃堕棿骞舵牸寮忓寲涓� yyyy-MM-dd HH:mm:ss
+        const now = new Date();
+        const year = now.getFullYear();
+        const month = String(now.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮嬶紝闇�瑕�+1
+        const day = String(now.getDate()).padStart(2, '0');
+        const hours = String(now.getHours()).padStart(2, '0');
+        const minutes = String(now.getMinutes()).padStart(2, '0');
+        const seconds = String(now.getSeconds()).padStart(2, '0');
+
+        shareTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+        uni.setStorageSync('shareTime', shareTime);
+        console.log('鏁版嵁瀛樺偍鎴愬姛');
+      } catch (e) {
+        console.error('瀛樺偍澶辫触锛�', e);
+      }
+    }else{
+      shareStoreId = uni.getStorageSync('shareStoreId');
+      shareStoreId = uni.getStorageSync('shareTime');
+      console.log('浠庣紦瀛樿鍙栧弬鏁�:', { shareStoreId, shareTime });
+      // this.bindMemberAndStore(shareStoreId, shareTime)
+      if (shareStoreId && shareTime) {
+        console.log('妫�娴嬪埌鏈夋晥鍙傛暟锛岃皟鐢ㄥ悗绔帴鍙�');
+        this.bindMemberAndStore(shareStoreId, shareTime);
+      } else {
+        console.log('鏃犳湁鏁堝弬鏁帮紝鎵ц姝e父閫昏緫');
+      }
+    }
+    this.initCOS()
   },
   onShow() {
     this.userInfo = this.$options.filters.isLogin() || {};
@@ -190,6 +233,27 @@
 
   mounted() { },
   methods: {
+    async bindMemberAndStore(shareStoreId, shareTime){
+      let form ={
+        shareStoreId: shareStoreId,
+        shareTime: shareTime
+      }
+      // let form ={
+      // 			  shareStoreId: "1376433565247471616",
+      // 			  shareTime: "2025-09-26 16:18:00"
+      // }
+      try {
+        const res = await bindMemberAndStore(form);
+        if(res.statusCode === 200){
+          //娓呴櫎缂撳瓨
+          uni.removeStorageSync('shareStoreId');
+          uni.removeStorageSync('shareTime');
+        }
+      }
+      catch(error) {
+        console.error('鍑洪敊:', error);
+      };
+    },
 	  // goTOSuccess(){
 	  // 		 uni.redirectTo({
 	  // 		    url:"/pages/cart/payment/success?paymentMethod=WECHAT" +
@@ -242,6 +306,7 @@
 </script>
 
 <style lang="scss" scoped>
+	@import url("/pages/subComponents/static/bgStyle.css");
 html,
 body {
   overflow: auto;
@@ -333,7 +398,7 @@
     background-size: cover;
     border-bottom-left-radius: 30rpx;
     border-bottom-right-radius: 30rpx;
-    background-image: url("/pages/subComponents/static/img/main-bg.png");
+    background-image: var(--main-bg);
     background-position: bottom;
     background-repeat: no-repeat;
     color: #ffffff;

--
Gitblit v1.8.0