Ver Fonte

保客活动-支持浏览器提交

duanshenglang há 7 meses atrás
pai
commit
e5fc38561a
1 ficheiros alterados com 22 adições e 8 exclusões
  1. 22 8
      lottery/registrationActivity.html

+ 22 - 8
lottery/registrationActivity.html

@@ -472,7 +472,13 @@
         this.httpUrl = 'http://test.wefanbot.com:18993'
       }
       localStorage.removeItem('openId')
-      this.ifH5Type()
+      if (this.isWeChatBrowser()) {
+        // 微信浏览器
+        this.ifH5Type()
+      } else {
+        // 不是微信浏览器
+        this.lightenShare()
+      }
     },
     beforeDestroy() {
       this.clearIntervalTask() // 在组件销毁前清除定时任务
@@ -622,11 +628,11 @@
         })
       },
       lightenShare () {
-        let externalUserid = this.getQueryParam('externalUserid')
-        let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
+        let externalUserid = this.getQueryParam('externalUserid') || ''
+        let openId = this.getQueryParam('openId') || localStorage.getItem('openId') || ''
         const headers = new Headers();
         headers.append('police', 110);
-        fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-share/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
+        fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-share/p/lottery?clientId=${localStorage.getItem('bkClientId') || ''}&externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
           method: 'GET',
           headers: headers
         })
@@ -636,6 +642,9 @@
             let { data, code, msg } = result
             if (code === 1) {
               this.toshopData = data
+              if (!this.isWeChatBrowser()) {
+                localStorage.setItem('bkClientId', data.client.id)
+              }
               this.getCityLevel()
               if (data.client.state === 1) {
                 // 未提交表单
@@ -678,7 +687,7 @@
         }, 10000); // 每10秒调用一次
       },
       sendDataToServer(browseId, elapsedTime) {
-        let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
+        let openId = this.getQueryParam('openId') || localStorage.getItem('openId') || ''
         fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-client-browse-history/p/updateBrowseDuration?openId=${openId}`, {
           method: 'post',
           body: JSON.stringify({
@@ -733,9 +742,9 @@
               value: item.type === 10 ? [item.value.join('')] : [item.value],
             }
           })
-          let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
+          let openId = this.getQueryParam('openId') || localStorage.getItem('openId') || ''
           this.loading = true
-          fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-share/p/formData?openId=${openId}`, {
+          fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-share/p/formData?clientId=${localStorage.getItem('bkClientId') || ''}&openId=${openId}`, {
             method: 'post',
             body: JSON.stringify({
               bid: this.bId,
@@ -774,7 +783,7 @@
                 type: 'warning'
               })
             }
-          }).fiqually(() => {
+          }).finally(() => {
             this.loading = false
           })
         }
@@ -842,6 +851,11 @@
         // 返回指定参数的值,如果不存在则返回null  
         return urlParams.get(paramName);
       },
+      // 判断当前是否为微信浏览器
+      isWeChatBrowser() {
+        const ua = navigator.userAgent.toLowerCase();
+        return ua.includes('micromessenger');
+      },
     }
   })   
 </script>