From ccda9ec2fe70d8f51ef184eafc04b78d22dfbabd Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期三, 26 六月 2024 15:02:28 +0800 Subject: [PATCH] 小程序,教材,课程 --- pages/cart/paymentPage/index.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 46 insertions(+), 14 deletions(-) diff --git a/pages/cart/paymentPage/index.js b/pages/cart/paymentPage/index.js index 1e853ee..9e747a2 100644 --- a/pages/cart/paymentPage/index.js +++ b/pages/cart/paymentPage/index.js @@ -5,7 +5,7 @@ import { getPublicImage } from '../../../assets/js/middleGround/tool'; -import drawQrcode from './js/weapp.qrcode' + Page({ /** @@ -26,13 +26,17 @@ isPaySuccess: false, isPayComplete: false, type: '', - onNorderSaleMethod: '' + onNorderSaleMethod: '', + ImmediatelyReceive: '' }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + wx.setNavigationBarTitle({ + title: '鎻愪氦璁㈠崟' + }); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -100,7 +104,26 @@ wx.navigateBack(); }, - + // 閲戦鏄剧ず.00鏍煎紡 + numFormat(value) { + if (!value) return "0.00"; + value = Number(value).toFixed(2); + var intPart = Math.trunc(value); // 鑾峰彇鏁存暟閮ㄥ垎 + var intPartFormat = intPart + .toString() + .replace(/(\d)(?=(?:\d{3})+$)/g, "$1,"); // 灏嗘暣鏁伴儴鍒嗛�笁涓�鏂� + var floatPart = ".00"; // 棰勫畾涔夊皬鏁伴儴鍒� + var value2Array = value.split("."); + // =2琛ㄧず鏁版嵁鏈夊皬鏁颁綅 + if (value2Array.length === 2) { + floatPart = value2Array[1].toString(); // 鎷垮埌灏忔暟閮ㄥ垎 + if (floatPart.length === 1) { + return `${intPartFormat}.${floatPart}0`; + } + return `${intPartFormat}.${floatPart}`; + } + return intPartFormat + floatPart; + }, getOrderByOrderNumData() { console.log(this.data.orderNumber, 'this.data.orderNumber'); let query = { @@ -108,32 +131,26 @@ fields: { content: [], subtitle: [], - - } } app.MG.store.getOrderByOrderNum(query).then(res => { - console.log(res, 'res'); this.setData({ orderGoods: res.orderNumber }) - console.log(this.data.orderGoods, 'res.orderNumber'); - - console.log(res.payPrice); this.setData({ - payPrice: res.payPrice.toFixed(2) + payPrice: res.payPrice.toFixed(2), + ImmediatelyReceive: res.payPrice }) + console.log(this.data.ImmediatelyReceive); res.saleMethodLinks.forEach(item => { - console.log(item.type, 'item.type'); - const type = item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product'; item.type = type; // 灏唗ype璁剧疆涓篿tem瀵硅薄鐨勫睘鎬э紝鑰屼笉鏄娇鐢╯etData item.paymentIcon = getPublicImage(item.orderSaleMethod.product.icon) - console.log(item.type, 'item'); + item.payPrice = this.numFormat(item.payPrice) + console.log(item, 'item'); }) this.setData({ productList: res.saleMethodLinks, - // type: item.orderSaleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' loading: false, hidden: false, }) @@ -241,4 +258,19 @@ // 杩斿洖 wx.navigateBack() }, + onReceive() { + let query = { + orderNum: this.data.orderGoods + } + app.MG.store.confirmOrder(query).then(res => { + Toast({ + context: this, + selector: '#t-toast', + message: '棰嗗彇鎴愬姛', + theme: 'success', + direction: 'column', + }); + wx.navigateBack() + }) + } }) \ No newline at end of file -- Gitblit v1.9.1