绿满眶商城微信小程序-uniapp
zxl
6 小时以前 a0cad73799c962f2c9d5b45ed25f9579953d5d22
绑定用户
1个文件已修改
42 ■■■■■ 已修改文件
pages/tabbar/user/my.vue 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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();
@@ -220,6 +207,16 @@
      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() {
    this.getUserOrderNum();
@@ -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,