From 917252ef3ea2b63c74d162cc67a6fbe103cb9b4d Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期五, 25 十月 2024 14:06:09 +0800
Subject: [PATCH] 1.开关阀记录界面。2.虚拟卡充值相关。3.问题反馈相关
---
pages/rechargeMoney/rechargMoney.js | 158 +++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 136 insertions(+), 22 deletions(-)
diff --git a/pages/rechargeMoney/rechargMoney.js b/pages/rechargeMoney/rechargMoney.js
index dfc163e..88e106e 100644
--- a/pages/rechargeMoney/rechargMoney.js
+++ b/pages/rechargeMoney/rechargMoney.js
@@ -1,4 +1,10 @@
// pages/rechargeMoney/rechargMoney.js
+//鍏呭�肩晫闈�
+const {
+ get,
+ post
+} = require('../../api/request.js');
+const md5 = require('js-md5');
Page({
/**
@@ -10,37 +16,29 @@
userCode: "15584236",
balance: "1025鍏�",
activeIndex: -1,
- allRechargeList: [{
- time: "2024-05-12:20:20",
- type: "杩滅▼",
- morny: "500鍏�"
- }, {
- time: "2024-05-12:20:20",
- type: "杩滅▼",
- morny: "500鍏�"
- }, {
- time: "2024-05-12:20:20",
- type: "杩滅▼",
- morny: "500鍏�"
- }, {
- time: "2024-05-12:20:20",
- type: "杩滅▼",
- morny: "500鍏�"
- }]
+ isClickable: false,
+ allRechargeList: [],
+ vcId: "",
+ pageCurr: 1, //鍏呭�艰褰曞綋鍓嶉〉鐮�
+ pageSize: 20, //鍏呭�艰褰曟瘡椤佃褰曟暟
+ loading: false, //鏄惁姝e湪鍔犺浇
+ hasMore: true,
},
/**
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
*/
onLoad(options) {
-
+ this.setData({
+ vcId: options.vcId
+ })
},
/**
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
*/
onReady() {
-
+ this.getRechargList()
},
/**
@@ -68,7 +66,10 @@
* 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
*/
onPullDownRefresh() {
-
+ this.setData({
+ pageCurr: 1
+ })
+ this.getRechargList()
},
/**
@@ -90,10 +91,123 @@
if (index !== undefined) {
this.setData({
activeIndex: parseInt(index),
+ isClickable: true
});
}
},
- onPullDownRefresh() {
- console.log("onPullDownRefresh")
+ //鍒涘缓璁㈠崟骞惰皟璧锋敮浠�
+ creatOrder() {
+ if (!this.data.isClickable) {
+ return;
+ }
+ const data = {
+ sessionId: getApp().globalData.sessionId,
+ vcId: this.data.vcId, //铏氭嫙鍗D
+ rechargeAmount: 1 //锛堝崟浣嶆槸鍒嗭級
+ };
+ console.log("postCloseValaue" + data);
+ post({
+ url: "wx/payment/placeOrder",
+ data: data
+ }).then(response => {
+ // 澶勭悊鎴愬姛鍝嶅簲
+ console.log('璇锋眰鎴愬姛:', response);
+ this.getOrderSign(response.content.prepay_id)
+ }).catch(error => {
+ if (error.code === "1002") {}
+ // 澶勭悊閿欒鍝嶅簲
+ console.error('璇锋眰澶辫触:', error);
+ });
+ },
+ //鑾峰彇璁㈠崟杩斿洖鐨刾repay_id鐨勭鍚�
+ getOrderSign(id) {
+ const params = {
+ url: 'wx/payment/signAgain',
+ data: {
+ prepayId: id
+ }
+ };
+ get(params).then(data => {
+ // 璋冭捣鏀粯
+ wx.requestPayment({
+ timeStamp: data.content.timeStamp,
+ nonceStr: data.content.nonceStr,
+ package: data.content.package,
+ signType: data.content.signType,
+ paySign: data.content.paySign,
+ success(res) {
+ console.log('鏀粯鎴愬姛', res);
+ },
+ fail(err) {
+ console.log('鏀粯澶辫触', err);
+ }
+ });
+ }).catch(err => {
+ wx.showToast({
+ title: err.msg,
+ icon: 'error',
+ duration: 3000
+ })
+ });
+ },
+ //鑾峰彇鍏呭�艰褰�
+ getRechargList() {
+ const params = {
+ url: 'wx/virtual_card/getVcRechargeRecords',
+ data: {
+ vcId: this.data.vcId,
+ pageCurr: this.data.pageCurr,
+ pageSize: this.data.pageSize,
+ }
+ };
+ get(params).then(data => {
+ this.setData({
+ allRechargeList:this.data.allRechargeList.concat( data.content.obj),
+ isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+ loading: false,
+ hasMore: !data.content.obj.pageTotal === this.data.pageCurr
+ })
+ this.updateDisplayText();
+ }).catch(err => {
+ // 閿欒鍥炶皟
+ this.setData({
+ isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+ loading: false
+ })
+ wx.showToast({
+ title: err.msg,
+ icon: 'error',
+ duration: 3000
+ })
+ });
+ },
+ // 鐢熸垚鏀粯绛惧悕鐨勫嚱鏁�
+ generatePaySign(params) {
+ const sortedKeys = Object.keys(params).sort();
+ const stringToSign = sortedKeys.map(key => `${key}=${params[key]}`).join('&') + `&key=your-mch-key`;
+ return md5(stringToSign).toUpperCase();
+ },
+ //鍔犺浇鏇村
+ loadMore() {
+ if (this.data.hasMore && !this.data.loading) {
+ this.setData({
+ loading: true,
+ pageCurr: this.data.pageCurr + 1
+ })
+ this.getRechargList();
+ }
+ },
+ updateDisplayText() {
+ const updatedList = this.data.allRechargeList.map(item => {
+ let morny = item.rechargeAmount / 100 + "鍏�"
+ return {
+ ...item,
+ morny
+ }; // 淇濈暀鎵�鏈夊叾浠栧瓧娈碉紝骞舵坊鍔� displayText 瀛楁
+ });
+ // 鏇存柊鍒楄〃鏁版嵁
+ this.setData({
+ allRechargeList: updatedList
+ });
}
})
\ No newline at end of file
--
Gitblit v1.8.0