绿满眶商城微信小程序-uniapp
zxl
15 小时以前 a0cad73799c962f2c9d5b45ed25f9579953d5d22
pages/tabbar/user/my.vue
@@ -190,28 +190,15 @@
        shareTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
        uni.setStorageSync('shareTime', shareTime);
          this.bindMemberAndStore(shareStoreId, 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('无有效参数,执行正常逻辑');
      }
    }
    this.initCOS()
  },
  onShow() {
    this.userInfo = this.$options.filters.isLogin() || {};
    if (this.$options.filters.isLogin("auth")) {
      this.getUserOrderNum();
@@ -219,6 +206,16 @@
      this.walletNum = 0;
      this.couponNum = 0;
      this.footNum = 0;
    }
   let shareStoreId = uni.getStorageSync('shareStoreId');
   let shareTime = uni.getStorageSync('shareTime');
   console.log('从缓存读取参数:', { shareStoreId, shareTime });
   if (shareStoreId && shareTime) {
     console.log('检测到有效参数,调用后端接口');
     this.bindMemberAndStore(shareStoreId, shareTime);
   } else {
     console.log('无有效参数,执行正常逻辑');
    }
  },
  onPullDownRefresh() {
@@ -236,6 +233,23 @@
  mounted() { },
  methods: {
     // 解析URL参数
     parseUrlParams(url) {
        const params = {};
        // 处理可能存在的hash(如果有的话)
        const cleanUrl = url.split('#')[0];
        const queryStr = cleanUrl.split('?')[1] || '';
        queryStr.split('&').forEach(pair => {
           const [key, value] = pair.split('=');
           if (key) {
              // 如果值存在,则解码,否则设为空字符串
              params[key] = value ? decodeURIComponent(value) : '';
           }
        });
        return params;
     },
    async bindMemberAndStore(shareStoreId, shareTime){
      let form ={
        shareStoreId: shareStoreId,