瀏覽代碼

计算器-分享优化测试

panyong 3 年之前
父節點
當前提交
dabb5ee6a3

+ 0 - 13
htmldev/loan/src/store/modules/loan.js

@@ -1,12 +1,5 @@
 const state = {
   checkMyBenfits: 0, // 是否是从个人中心去注册会员页,默认值0 0-不是 1-是
-  // 用户分享信息
-  userShareConfig: {
-    share: false, // 是否有权限分享(true是false无)
-    id: '', // 用户ID
-    userName: '', // 用户名称
-    userImgUrl: '' // 用户头像
-  },
   recommendedProduct: [], // 贷款计算器所推荐的产品
   userInfo: {} // 用户信息
 }
@@ -14,9 +7,6 @@ const state = {
 const getters = {
   checkMyBenfits (state) {
     return state.checkMyBenfits
-  },
-  userShareConfig (state) {
-    return state.userShareConfig
   }
 }
 
@@ -24,9 +14,6 @@ const mutations = {
   UPDATE_CHECKMYBENFITS_VALUE (state, value) {
     state.checkMyBenfits = value
   },
-  UPDATE_USERSHARECONFIG (state, value) {
-    state.userShareConfig = value
-  },
   UPDATE_RECOMMENDEDPRODUCT (state, value) {
     state.recommendedProduct = value
   },

+ 9 - 0
htmldev/loan/src/views/loan/explain/api/index.js

@@ -0,0 +1,9 @@
+import request from '@/api/request'
+
+/**
+ * 获取用户分享权限
+ */
+export const getUserShare = () => request({
+  method: 'GET',
+  url: '/home/user/userShare'
+})

+ 42 - 19
htmldev/loan/src/views/loan/explain/index.vue

@@ -10,7 +10,7 @@
       </router-link>
     </div>
     <!--妥妥:本人-->
-    <div class="footer myself" v-else-if="!recommendedUser.RId">
+    <div class="footer myself" v-else-if="!recommendedUser.id">
       <!--可以分享-->
       <template v-if="userShareConfig.share">
         <router-link class="btn-apply double"
@@ -29,13 +29,13 @@
     <!--妥妥:非本人-->
     <div class="footer other" v-else>
       <router-link class="btn-apply single"
-                   :to="{path: '/loan/apply/' + orderProductId, query: { RId: recommendedUser.RId }}">点击预约办理
+                   :to="{path: '/loan/apply/' + orderProductId, query: { RId: recommendedUser.id }}">点击预约办理
       </router-link>
       <div class="partner-info">
         <div class="partner-avatar">
-          <img :src="recommendedUser.RImgUrl" alt="">
+          <img :src="recommendedUser.userImgUrl" alt="">
         </div>
-        <p class="name">{{ recommendedUser.RName }} 邀请你</p>
+        <p class="name">{{ recommendedUser.userName }} 邀请你</p>
       </div>
     </div>
     <!--生成二维码使用-->
@@ -76,10 +76,11 @@
 </template>
 
 <script>
-import { Popup } from 'vant'
+import { Popup, Toast } from 'vant'
 import { funWxShare } from '../../../utils/wxShareConfig'
 import { getProductDetail } from '../../../api/common'
 import QRCode from 'qrcodejs2'
+import { getUserShare } from './api'
 
 export default {
   name: 'explain',
@@ -111,28 +112,50 @@ export default {
       qrcode: null,
       codeUrl: '', // 二维码地址
       showCode: false, // 是否显示二维码弹窗
-      booShareTip: false // 分享朋友、朋友圈提示
-    }
-  },
-  computed: {
-    userShareConfig: {
-      get () {
-        return this.$store.state.loan.userShareConfig
-      },
-      set (val) {
-        this.$store.commit('loan/UPDATE_USERSHARECONFIG', val)
+      booShareTip: false, // 分享朋友、朋友圈提示
+      userShareConfig: {
+        share: false, // 是否有权限分享(true是false无)
+        id: '', // 用户ID
+        userName: '', // 用户名称
+        userImgUrl: '' // 用户头像
       }
     }
   },
+  created () {
+    this.fetchUserShare()
+  },
   async mounted () {
-    const shareHref = this.partnerId ? `${location.origin}${location.pathname}?partnerId=${this.partnerId}` : `${location.origin}${location.pathname}?recommendedUser=${encodeURIComponent(JSON.stringify(this.userShareConfig))}`
-    console.log(shareHref)
-    funWxShare('驼驼银服', '家里用钱,就找驼驼银服,省心,省力,妥妥的!', shareHref, location.protocol + '//api.tuotuoyinfu.com/img/logo.jpg')
     await this.$nextTick()
     this.funGetProductDetail()
-    this.createQRCode(shareHref)
   },
   methods: {
+    // 获取用户分享权限
+    fetchUserShare () {
+      getUserShare().then(res => {
+        let shareHref = `${location.origin}${location.pathname}`
+        if (res.status) {
+          if (Object.prototype.toString.call(res.data) === '[object Object]') {
+            this.userShareConfig = res.data
+          }
+        } else {
+          Toast(res.msg)
+        }
+        if (this.partnerId) { // 合伙人
+          shareHref += `?partnerId=${this.partnerId}`
+        } else if (this.recommendedUser.id) { // 打开含有推荐人信息链接
+          shareHref += `?recommendedUser=${encodeURIComponent(JSON.stringify(this.recommendedUser))}`
+        } else if (Object.keys(this.userShareConfig).length) { // 默认本人打开、且有分享权限
+          shareHref += `?recommendedUser=${encodeURIComponent(JSON.stringify(this.userShareConfig))}`
+        }
+        funWxShare('驼驼银服', '家里用钱,就找驼驼银服,省心,省力,妥妥的!', shareHref, location.protocol + '//api.tuotuoyinfu.com/img/logo.jpg')
+        console.log(shareHref)
+        this.$nextTick(() => {
+          this.createQRCode(shareHref)
+        })
+      }).catch(err => {
+        Toast(err)
+      })
+    },
     funShowCode () {
       this.booInvite = false
       this.booCode = true

+ 1 - 33
htmldev/loan/src/views/loan/mall/index.vue

@@ -25,40 +25,8 @@
 </template>
 
 <script>
-import { getUserShare } from './api'
-import { Toast } from 'vant'
-
 export default {
-  name: 'index',
-  activated () {
-    this.fetchUserShare()
-  },
-  computed: {
-    userShareConfig: {
-      get () {
-        return this.$store.state.loan.userShareConfig
-      },
-      set (val) {
-        this.$store.commit('loan/UPDATE_USERSHARECONFIG', val)
-      }
-    }
-  },
-  methods: {
-    // 获取用户分享权限
-    fetchUserShare () {
-      getUserShare().then(res => {
-        if (res.status) {
-          if (Object.prototype.toString.call(res.data) === '[object Object]') {
-            this.userShareConfig = res.data
-          }
-        } else {
-          Toast(res.msg)
-        }
-      }).catch(err => {
-        Toast(err)
-      })
-    }
-  }
+  name: 'index'
 }
 </script>