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

---
 pages/tabbar/user/my.vue |   83 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/pages/tabbar/user/my.vue b/pages/tabbar/user/my.vue
index dc9f101..20ff12d 100644
--- a/pages/tabbar/user/my.vue
+++ b/pages/tabbar/user/my.vue
@@ -17,7 +17,7 @@
       </view>
       <u-icon style="display: flex;align-items: flex-start;" name="arrow-right"></u-icon>
     </view>
-	
+	<!-- <button  type="default" @click="goTOSuccess">绔嬪嵆鏌ョ湅</button> -->
 	<view class="member-gradient-bg">	
 	 <view class="member-content">
 	      <view class="vip-icon">
@@ -130,15 +130,17 @@
 	</view>
     <!-- 鎾戣捣涓嬫柟 -->
 	<view style="height:64px;">
+		
 	</view>
   <custom-tabbar bgColor="#ffffff" selected="my"></custom-tabbar>
+  
   </view>
 </template>
 <script>
 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'
@@ -160,7 +162,50 @@
       walletNum: "",
     };
   },
-  onLoad() {
+  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() {
@@ -188,6 +233,34 @@
 
   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" +
+	  // 		             "&payPrice=" +
+	  // 		             10,
+	  // 		         });
+	  // },
 	  // 鍒濆鍖栬吘璁簯cos瀹㈡埛绔�
 	  initCOS() {
 		  // 璋冪敤鍚庣鑾峰彇sts涓存椂璁块棶鍑瘉
@@ -233,6 +306,7 @@
 </script>
 
 <style lang="scss" scoped>
+	@import url("/pages/subComponents/static/bgStyle.css");
 html,
 body {
   overflow: auto;
@@ -324,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;
@@ -433,7 +507,6 @@
 	background: #fff;
 	border-radius: 20rpx;
 	box-shadow: 0 4rpx 24rpx 0 #f6f6f6;
-    transform: translateY(-30rpx);
 }
 
 .user-name {

--
Gitblit v1.8.0