Просмотр исходного кода

积分详情界面添加判断一账通逻辑

xueyihao 4 месяцев назад
Родитель
Сommit
ceae1cb090
7 измененных файлов с 159 добавлено и 12 удалено
  1. 26 0
      src/api/index.js
  2. 1 1
      src/common/config.js
  3. 1 1
      src/main.js
  4. 12 0
      src/pages.json
  5. 3 0
      src/pages/index/index.vue
  6. 31 3
      src/pages/login/wxLogin.vue
  7. 85 7
      src/points/pointInfo/billPage.vue

+ 26 - 0
src/api/index.js

@@ -567,3 +567,29 @@ export function phoneLogin(data) {
     })
 }
 
+// 查询用户是否绑定一账通
+export function queryBind(data) {
+    return request({
+        method: 'post',
+        url: '/userCenter/userApp/queryBind',
+        data
+    })
+}
+
+// 广誉源账户绑定一账通
+export function useBind(data) {
+    return request({
+        method: 'post',
+        url: '/userCenter/userApp/bind',
+        data
+    })
+}
+
+// 一账通登录
+export function uuidLogin(data) {
+    return request({
+        method: 'post',
+        url: '/weChat/uuidLogin',
+        data
+    })
+}

+ 1 - 1
src/common/config.js

@@ -13,7 +13,7 @@ let h5Url = 'https://city.baoxianzhanggui.com/fragrance'
 if (process.env.NODE_ENV == 'development') {
     // baseUrl = 'https://test.baoxianzhanggui.com/locallive-java' // 测试环境
     //baseUrl = 'http://192.168.1.190:8087' // 靳
-    //baseUrl = 'http://192.168.1.222:8087' // 志珺
+    baseUrl = 'http://192.168.1.222:8087' // 志珺
 }
 
 // 同时导出所有变量(命名导出)

+ 1 - 1
src/main.js

@@ -19,7 +19,7 @@ import store from './store'
 Vue.prototype.$store = store
 
 Vue.config.productionTip = false
-
+Vue.config.ignoredElements.push('wx-open-launch-weapp');
 App.mpType = 'app'
 
 const app = new Vue({

+ 12 - 0
src/pages.json

@@ -512,6 +512,18 @@
 							"titleNView": false
 						}
 					}
+				},
+				{
+					"path": "myNew/webview",
+					"style": {
+						"navigationBarTitleText": "抽奖大转盘",
+						"navigationBarBackgroundColor": "#2cb8d4",
+						"navigationBarTextStyle": "white",
+						"app-plus": {
+							"softinputNavBar": "none",
+							"titleNView": false
+						}
+					}
 				}
 			]
 		},

+ 3 - 0
src/pages/index/index.vue

@@ -366,10 +366,13 @@ export default {
           if (res.data.code == 200) {
             uni.setStorageSync('wx_copenid', res.data.data.copenid)
             uni.setStorageSync('access-token', res.data.data.token)
+            uni.setStorageSync('userId', res.data.data.id)
             if(res.data.data.cphone === null || res.data.data.cphone === ''){
               uni.navigateTo({
                 url: '/setting/myNew/phone'
               })
+            }else{
+              uni.setStorageSync('wx_phone', res.data.data.cphone)
             }
           }
         })

+ 31 - 3
src/pages/login/wxLogin.vue

@@ -103,9 +103,35 @@
 				}
 			},
 			back() {
-				uni.switchTab({
-					url: '/pages/index/index'
-				})
+				let pages = getCurrentPages();
+				if (pages.length >= 2) {
+					let prevPage = pages[pages.length - 2];
+					let prevRoute = prevPage.route;
+					if (prevRoute && prevRoute !== 'pages/index/index') {
+						if (prevRoute.startsWith('pages/')) {
+							uni.switchTab({
+								url: '/' + prevRoute
+							})
+						} else {
+							uni.navigateBack({
+								delta: 1,
+								fail: () => {
+									uni.switchTab({
+										url: '/pages/index/index'
+									})
+								}
+							})
+						}
+					} else {
+						uni.switchTab({
+							url: '/pages/index/index'
+						})
+					}
+				} else {
+					uni.switchTab({
+						url: '/pages/index/index'
+					})
+				}
 			},
       // 手机号登录
       validatePhone(phone) {
@@ -187,6 +213,8 @@
             if (res.data.code == 200) {
               uni.setStorageSync('wx_copenid', res.data.data.copenid || '')
               uni.setStorageSync('access-token', res.data.data.token)
+              uni.setStorageSync('wx_phone', res.data.data.cphone)
+              uni.setStorageSync('userId', res.data.data.id)
               _this.isBinding = false;
               _this.back();
             }

+ 85 - 7
src/points/pointInfo/billPage.vue

@@ -50,7 +50,7 @@
             </text>
           </u-list-item>
           <!-- 空数据状态 -->
-          <u-empty 
+          <u-empty
             v-if="filteredRecords.length === 0 && !loading"
             text="暂无积分记录"
             mode="list"
@@ -60,7 +60,7 @@
             <u-loading-icon text="加载中..."></u-loading-icon>
           </view>
           <!-- 加载更多 -->
-          <u-loadmore 
+          <u-loadmore
             v-if="filteredRecords.length > 0"
             :status="loading ? 'loading' : (hasMore ? 'more' : 'nomore')"
             loading-text="加载中..."
@@ -75,7 +75,9 @@
 
 <script>
 import {mapState} from "vuex";
-import { getPointDetails } from '@/api/points'
+import { getPointDetails } from '@/api/points';
+import {queryBind, useBind, uuidLogin} from "@/api/index";
+
 export default {
   name: "billPage",
   data() {
@@ -94,7 +96,11 @@ export default {
       pageNum: 1,
       pageSize: 10,
       hasMore: true,
-      loading: false
+      loading: false,
+      currentUser:'',
+      currentPlatform:'',
+      nowPlatform:'gyy-aB4cD6eF8gH0iJ2kL4',
+      uuId:'',
     }
   },
   computed: {
@@ -118,9 +124,26 @@ export default {
       return this.pointRecords
     }
   },
+  onLoad(options) {
+    // #ifdef H5
+    window.addEventListener('popstate', this.__h5BackRefresh);
+    // #endif
+    if(options.currentPlatform && options.currentUser){
+      this.currentPlatform = options.currentPlatform;
+      this.currentUser = options.currentUser;
+      this.verificationAccount();
+    }else{
+      this.fetchPointDetails()
+    }
+  },
+  onUnload() {
+    // #ifdef H5
+    window.removeEventListener('popstate', this.__h5BackRefresh);
+    // #endif
+  },
   mounted() {
     // 初始获取数据
-    this.fetchPointDetails()
+    //this.fetchPointDetails()
   },
   methods: {
     // 切换标签
@@ -166,6 +189,61 @@ export default {
       } finally {
         this.loading = false
       }
+    },
+    // H5 返回强制刷新
+    __h5BackRefresh() {
+      if(this.currentPlatform && this.currentUser && uni.getStorageSync('access-token')){
+        this.bindAccount();//若没有登录。登录后获取绑定信息
+      }
+    },
+    verificationAccount(){
+      // jzg-7kP9xL2mN5vQ8zR1jW  ,晋掌柜
+      // gyy-aB4cD6eF8gH0iJ2kL4  ,广誉源
+      // bdsh-X9yZ1wV3uT5sR7qP9o  ,本地生活
+      // https://test.baoxianzhanggui.com/lxl-api/usercenter
+      // 用户ID    userId
+      // 平台ID   clientId
+      // 租户ID (晋掌柜用)   tenantId
+      // source 自己的平台,,,
+      // target 要绑的平台
+      queryBind({
+        userId : this.currentUser,
+        clientId :this.currentPlatform
+      }).then(res => {
+        if(res.data.code == 200){
+          this.uuId = res.data.data.filter(item=> item.clientId === 'gyy-aB4cD6eF8gH0iJ2kL4')[0].uuid;
+          if(!uni.getStorageSync('access-token')){
+            this.uuLogin();
+          }else{
+            this.fetchPointDetails()
+          }
+        }else{
+          if (!this.$utils.checkLogin({ type: 'navigate' })) return;
+        }
+      })
+    },
+    bindAccount(){
+      useBind({
+        sourceUserId: this.currentUser,       //a项目的id
+        sourceClientId: this.currentPlatform, //a项目的来源平台
+        targetUserId: uni.getStorageSync('userId'),            //b项目的id
+        targetClientId: this.nowPlatform,     //b项目的来源平台
+        userPhone:uni.getStorageSync('wx_phone')
+      }).then(res => {
+        this.fetchPointDetails()
+      })
+    },
+    uuLogin(){
+      // 广誉源uuid登录
+      uuidLogin({
+        uuid: this.uuId,
+      }).then(res => {
+        uni.setStorageSync('wx_copenid', res.data.data.copenid || '')
+        uni.setStorageSync('access-token', res.data.data.token)
+        uni.setStorageSync('wx_phone', res.data.data.cphone)
+        uni.setStorageSync('userId', res.data.data.id)
+        this.fetchPointDetails()
+      })
     }
   }
 }
@@ -259,10 +337,10 @@ export default {
   .u-empty{
     margin-top: 20vh!important;
   }
-  
+
   /* 加载中容器 */
   .loading-container {
     margin-top: 20vh!important;
   }
 }
-</style>
+</style>