Kaynağa Gözat

feat: debug my record api

wangyuan 2 yıl önce
ebeveyn
işleme
7db48779c2
4 değiştirilmiş dosya ile 59 ekleme ve 15 silme
  1. 3 1
      api/my.js
  2. 7 5
      pages/myFile/myFile.js
  3. 38 3
      pages/myRecord/myRecord.js
  4. 11 6
      pages/myRecord/myRecord.wxml

+ 3 - 1
api/my.js

@@ -6,10 +6,12 @@ const bindMobileURL = '/user/bind/mobile' // 获取用户手机号
 const loginURL = '/user/login' // 登录
 const bindBaseInfoURL = '/user/bind/base/info' // 绑定用户头像昵称
 
+const chargeListURL = '/get/charge/list' // 我的充值记录
+
 export const ittLogin =  (data) => wxRequest(loginURL, data)
 
 export const bindMobile =  (data) => wxRequest(bindMobileURL, data)
 
 export const bindBaseInfo =  (data) => wxRequest(bindBaseInfoURL, data)
 
-
+export const chargeList =  (data) => wxRequest(chargeListURL, data)

+ 7 - 5
pages/myFile/myFile.js

@@ -38,11 +38,13 @@ Page({
   },
 
   onReachBottom () {
-    var _currentPag = this.data.currentPage + 1
-    this.setData({
-      currentPage: _currentPag
-    })
-    this.getDocumentList()
+    if (this.data.hasNext) {
+      var _currentPag = this.data.currentPage + 1
+      this.setData({
+        currentPage: _currentPag
+      })
+      this.getDocumentList()
+    }
   },
 
   /**

+ 38 - 3
pages/myRecord/myRecord.js

@@ -1,4 +1,5 @@
 // pages/myRecord/myRecord.js
+import { chargeList } from "../../api/my";
 Page({
 
   /**
@@ -6,8 +7,10 @@ Page({
    */
   data: {
     navItemActive: 0,
-    chargeRecordList: [1,1,1,1,1,1],
-    destoryRecordList: [1]
+    chargeRecordList: [],
+    destoryRecordList: [],
+    currentPage: 1,
+    hasNext: false
   },
 
   /**
@@ -28,7 +31,35 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
+    this.setData({
+      navItemActive: 0
+    })
+    this.getChargeList()
+  },
+
+  // 获取充值记录
+  getChargeList () {
+    var data = {
+      currentPage: this.data.currentPage
+    }
+    chargeList(data).then(res => {
+      this.setData({
+        hasNext: res.data.hasNext,
+        chargeRecordList: res.data.vos
+      })
+    })
+  },
 
+  onReachBottom () {
+    if (this.data.hasNext) {
+      var _currentPag = this.data.currentPage + 1
+      this.setData({
+        currentPage: _currentPag
+      })
+      if (this.data.navItemActive == 0) {
+        this.getChargeList()
+      }
+    }
   },
 
   /**
@@ -37,8 +68,12 @@ Page({
   handleChangeNav(e) {
     var navItemActive = e.currentTarget.dataset.index
     this.setData({
-      navItemActive: navItemActive
+      navItemActive: navItemActive,
+      currentPage: 1
     })
+    if (navItemActive == 0) {
+      this.getChargeList()
+    }
   },
 
   /**

+ 11 - 6
pages/myRecord/myRecord.wxml

@@ -16,21 +16,26 @@
       <block wx:if="{{chargeRecordList.length !== 0}}">
         <view class="record-item ittflex-jcs" wx:for="{{chargeRecordList}}" wx:key="index">
           <view class="left icon">
-          <!--  <image class="image" src="../../imaes/shiti@2x.png"></image> -->
-            <image class="image" src="../../imaes/dianzi@2x.png"></image>
+            <image class="image" src="{{item.goodsImg}}"></image>
           </view>
           <view class="center info">
-            <view class="title info-item">一次体验卡</view>
+            <view class="title info-item">
+              <!-- 充值类型 充值类型 【1、购买套餐,2、实体卡  3、体验卡  4、活动赠送 -->
+              <text wx:if="{{item.chargeType == 1}}">购买套餐</text>
+              <text wx:if="{{item.chargeType == 2}}">实体卡</text>
+              <text wx:if="{{item.chargeType == 3}}">体验卡</text>
+              <text wx:if="{{item.chargeType == 4}}">活动赠送</text>
+            </view>
             <view class="carno info-item">
               <text>卡编号:</text>
-              <text>2000202020202020</text>
+              <text>{{item.orderCode}}</text>
             </view>
             <view class="time info-item">
               <text>激活时间:</text>
-              <text>2022-10-10 22:22</text>
+              <text>{{item.addTime}}</text>
             </view>
           </view>
-          <view class="right count">+199</view>
+          <view class="right count">+{{item.useNumber}}</view>
         </view>
       </block>
     </view>