ソースを参照

内嵌的积分明细对接领取积分接口

xueyihao 5 ヶ月 前
親
コミット
82065002ff
3 ファイル変更、89 行追加、22 行削除
  1. 9 0
      src/api/index.js
  2. 80 22
      src/points/pointInfo/billPage.vue
  3. 0 0
      src/utils/uni.webview.1.5.6.js

+ 9 - 0
src/api/index.js

@@ -593,3 +593,12 @@ export function uuidLogin(data) {
         data
     })
 }
+
+// 抽奖活动过来的 - 本地生活积分领取
+export function pointDraw(data) {
+    return request({
+        method: 'post',
+        url: '/user/point/draw',
+        data
+    })
+}

+ 80 - 22
src/points/pointInfo/billPage.vue

@@ -1,5 +1,14 @@
 <template>
+
   <view class="bill-page">
+    <u-navbar :autoBack="true"
+              :bgColor="'#fff'"
+              v-if="currentPlatform !== ''"
+              :placeholder="true"
+              :safeAreaInsetTop="true"
+              title="积分明细"
+              :titleStyle="{ color: '#303133' }"
+              @leftClick="back"/>
     <!-- 顶部积分信息 -->
     <view class="points-header">
       <view class="points-item">
@@ -76,8 +85,8 @@
 <script>
 import {mapState} from "vuex";
 import { getPointDetails } from '@/api/points';
-import {queryBind, useBind, uuidLogin} from "@/api/index";
-
+import {queryBind, useBind, uuidLogin,pointDraw} from "@/api/index";
+import webView from '@/utils/uni.webview.1.5.6.js';
 export default {
   name: "billPage",
   data() {
@@ -204,47 +213,96 @@ export default {
       // 用户ID    userId
       // 平台ID   clientId
       // 租户ID (晋掌柜用)   tenantId
-      // source 自己的平台,,,
+      // source 自己的平台
       // target 要绑的平台
+      var _this = this;
       queryBind({
-        userId : this.currentUser,
-        clientId :this.currentPlatform
+        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;
+          _this.uuId = res.data.data.filter(item=> item.clientId === 'gyy-aB4cD6eF8gH0iJ2kL4')[0]?.uuid;
           if(!uni.getStorageSync('access-token')){
-            this.uuLogin();
+            if(_this.uuId){
+              _this.uuLogin();
+            }else{
+              if (!_this.$utils.checkLogin({ type: 'navigate' })) return;
+            }
           }else{
-            this.fetchPointDetails()
+            _this.fetchPointDetails()
           }
         }else{
-          if (!this.$utils.checkLogin({ type: 'navigate' })) return;
+          if (!_this.$utils.checkLogin({ type: 'navigate' })) return;
         }
       })
     },
     bindAccount(){
+      var _this = this;
       useBind({
-        sourceUserId: this.currentUser,       //a项目的id
-        sourceClientId: this.currentPlatform, //a项目的来源平台
+        sourceUserId: _this.currentUser,       //a项目的id
+        sourceClientId: _this.currentPlatform, //a项目的来源平台
         targetUserId: uni.getStorageSync('userId'),            //b项目的id
-        targetClientId: this.nowPlatform,     //b项目的来源平台
+        targetClientId: _this.nowPlatform,     //b项目的来源平台
         userPhone:uni.getStorageSync('wx_phone')
-      }).then(res => {
-        this.fetchPointDetails()
+      }).then(async res => {
+        await pointDraw();
+        await _this.fetchPointDetails()
       })
     },
     uuLogin(){
       // 广誉源uuid登录
+      var _this = this;
       uuidLogin({
-        uuid: this.uuId,
+        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()
+        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.fetchPointDetails()
+        }
       })
-    }
+    },
+    back() {
+      console.log('back返回----')
+      // 1. 如果在 iframe 里(被 A 项目用 web-view/iframe 打开)
+      if (typeof window !== 'undefined' && window.self !== window.top) {
+        // 1.1 给 App / 小程序容器(有的话)
+        try {
+          webView.postMessage({
+            data: {
+              type: 'back',
+              data: ''
+            }
+          })
+        } catch (e) {}
+        // 1.2 给 H5 父窗口(A 项目)
+        window.parent.postMessage({
+              type: 'back',
+              data: ''
+            },
+            '*' // 线上建议写死成 A 项目的 origin
+        )
+        // 注意:在 iframe 里 **不要再自己后退**,否则就会出现“要点两次”的情况
+        return
+      }
+      // 2. 不在 iframe 里(直接访问 B 项目页面的情况)
+      // 优先用浏览器历史返回
+      if (typeof window !== 'undefined') {
+        if (window.history.length > 1) {
+          window.history.back()
+          return
+        }
+        // 没有历史记录时,兜底:跳到你想要的首页/列表页
+        // window.location.href = 'http://192.168.1.112:8080/custh5/#/' // 换成你 B 项目的首页路由
+        return
+      }
+      // 3. 再兜底 uni.navigateBack(主要给非 H5 平台用)
+      if (typeof uni !== 'undefined' && typeof uni.navigateBack === 'function') {
+        uni.navigateBack()
+      }
+    },
   }
 }
 </script>
@@ -252,7 +310,7 @@ export default {
 <style scoped lang="scss">
 .bill-page{
   width: 750rpx;
-  min-height: 100vh;
+  height: 100vh;
   background-image: url("@/static/points/pointBg.png");
   background-size: 100%;
   background-repeat: no-repeat;

ファイルの差分が大きいため隠しています
+ 0 - 0
src/utils/uni.webview.1.5.6.js


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません