瀏覽代碼

支付测试优化

zhengjinyi 5 年之前
父節點
當前提交
66c716752d

+ 1 - 1
components/cm-custom/cu-custom.vue

@@ -2,7 +2,7 @@
 	<!-- 自定义导航栏 -->
 	<view class='navbar-wrap' :style="{height:CustomBar+'px',paddingTop:StatusBar+'px',background:navbarData.bgColor ? navbarData.bgColor : '#FFFFFF'}"> 
 	  	<view class="navbar-text" 
-			  :style="{color:navbarData.textColor ? navbarData.textColor:'',lineHeight:(CustomBar - StatusBar)+'px;',fontSize:fontSizeSetting+'px;',paddingLeft:navbarData.textLeft ? '' : (capsule.height+5)+'px'}" :class="platformClass">
+			  :style="{color:navbarData.textColor ? navbarData.textColor:'',lineHeight:(CustomBar - StatusBar)+'px;',fontSize:fontSizeSetting+'px;',paddingLeft:navbarData.textLeft ? '' : (capsule.height+10)+'px'}" :class="platformClass">
 	    	  {{navbarData.title ? navbarData.title : " "}}
 	  	</view>
 	  	<view class="navbar-icon" v-if="navbarData.showCapsule == 1 ? true : false" 

+ 2 - 0
pages/user/order/create-order.vue

@@ -192,11 +192,13 @@
 						this.hanldFreight = this.freightData.freight
 						this.hanldFreePostFlag = data
 						this.payAllPrice =this.allPrice + this.hanldFreight
+						this.attributePallPrice()
 						break
 					case -1:
 						this.hanldFreight = 0
 						this.hanldFreePostFlag = data
 						this.payAllPrice = this.allPrice
+						this.attributePallPrice()
 						break
 				}
 			},

+ 1 - 1
pages/user/order/order-details.vue

@@ -12,7 +12,7 @@
 			<!-- 发票信息 -->
 			<invoice-tent ref="invoice" v-if="isRequest" :orderInvoice="orderInvoice"></invoice-tent>
 			<!-- 转账信息 -->
-			<transfe-record ref="transfe" v-if="onlinePayFlag != 0"></transfe-record>
+			<transfe-record ref="transfe" v-if="btnStatus == 11 || btnStatus == 111"></transfe-record>
 			<!-- 支付记录 -->
 			<payment-record ref="payment" v-if="isRequest" :discernReceiptList="discernReceiptList" :receiptAmount="receiptAmount"></payment-record>
 			<!-- 退款记录 -->

+ 36 - 11
pages/user/order/order-pay.vue

@@ -7,16 +7,16 @@
 					<view class="pay-top">
 						<view class="pay-paid">
 							<text class="txt-m">待付金额</text>
-							<text class="txt-b"><text class="small">¥</text>{{payableAmount.toFixed(2)}}</text>
+							<text class="txt-b"><text class="small">¥</text>{{payableAmount|NumFormat}}</text>
 						</view>
 						<view class="pay-payd">
 							<view class="pay-paids">
 								<text class="txt-m">应付总额</text>
-								<text class="txt-b">¥{{payTotalFee.toFixed(2)}}</text>
+								<text class="txt-b">¥{{payTotalFee|NumFormat}}</text>
 							</view>
 							<view class="pay-paids">
 								<text class="txt-m">已支付金额</text>
-								<text class="txt-b">¥{{receiptAmount.toFixed(2)}}</text>
+								<text class="txt-b">¥{{receiptAmount|NumFormat}}</text>
 							</view>
 						</view>
 					</view>
@@ -37,7 +37,7 @@
 									placeholder-class="placeholder"/>
 						</view>
 						<view class="bot-resid">
-							<text>应付剩余¥{{balanceAmount.toFixed(2)}}</text>
+							<text>应付剩余¥{{balanceAmount|NumFormat}}</text>
 						</view>
 					</view>
 				</view>
@@ -46,7 +46,7 @@
 					<view class="record-list">
 						<view class="list-main" v-if="discernReceipt.length>0">
 							<view class="list-item" v-for="(item,index) in discernReceipt" :key="index">
-								<text class="text row-1">¥{{toFixedFn(item.receiptAmount)}}</text>
+								<text class="text row-1">¥{{item.receiptAmount | NumFormat}}</text>
 								<text class="text row-2">{{payTypeText(item.payType)}}</text>
 								<text class="text row-3">{{item.receiptDate}}</text>
 							</view>
@@ -126,6 +126,28 @@
 		onLoad(option) {
 			this.initData(option)
 		},
+		filters: {
+			NumFormat(value) {
+				if(!value) return '0.00';
+				/*原来用的是Number(value).toFixed(0),这样取整时有问题,例如0.51取整之后为1,感谢Nils指正*/
+				/*后来改成了 Number(value)|0,但是输入超过十一位就为负数了,具体见评论 */
+				var intPart = Number(value) - Number(value)%1; //获取整数部分(这里是windy93的方法)
+				var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断
+				var floatPart = ".00"; //预定义小数部分
+				var value2Array = value.toString().split(".");
+				//=2表示数据有小数位
+				if(value2Array.length == 2) {
+					floatPart = value2Array[1].toString(); //拿到小数部分
+					if(floatPart.length == 1) { //补0,实际上用不着
+						return intPartFormat + "." + floatPart + '0';
+					} else {
+						return intPartFormat + "." + floatPart;
+					}
+				} else {
+					return intPartFormat + floatPart;
+				}
+			}
+		},
 		methods:{
 			initData(e){
 				this.payType = e.type
@@ -149,9 +171,9 @@
 					this.discernReceipt = response.data.discernReceipt 		//支付记录
 					this.payTotalFee = response.data.order.payTotalFee  //已付金额
 					this.receiptAmount = response.data.order.receiptAmount  //已付金额
-					this.payableAmount = response.data.order.payableAmount - this.receiptAmount  //待付金额
-					this.payAmount = this.payableAmount.toFixed(2)	//自定义金额
-					this.balanceAmount = this.payableAmount - this.payAmount// 计算剩余支付金额
+					this.payableAmount = (response.data.order.payableAmount - this.receiptAmount).toFixed(2)//待付金额
+					this.payAmount = this.payableAmount	//自定义金额
+					this.balanceAmount = (this.payableAmount - this.payAmount).toFixed(2)// 计算剩余支付金额
 				}).catch(error =>{
 					this.$util.msg(error.msg,2000)
 				})
@@ -212,7 +234,7 @@
 						wx.reLaunch({url: '/pages/tabBar/user/user'});
 					},
 					'fail':function(res){
-						self.$util.msg('微信调用支付失败,请重新发起支付~')
+						self.$util.msg('用户取消支付~')
 					},
 					'complete':function(res){
 						
@@ -240,9 +262,9 @@
 				if(value == "" || value <0 ){
 					this.payAmount = '';
 					this.balanceAmount = this.payableAmount;
-				}else if(parseInt(value)>this.payableAmount){
+				}else if( value >this.payableAmount){
 					this.payAmount = this.payableAmount.toFixed(2)
-					this.balanceAmount = this.payableAmount - this.payAmount
+					this.balanceAmount = (this.payableAmount - this.payAmount).toFixed(2)
 				}else{
 					this.payAmount =Number(value).toFixed(2)
 					this.balanceAmount = this.payableAmount - this.payAmount
@@ -280,6 +302,9 @@
 					if (res) {
 						this.isShowTip = false;
 						this.$util.msg("复制成功",2000,true,'success');
+						setTimeout(()=>{
+							this.$api.navigateTo(`/pages/user/order/order-details?state=0&orderID=${this.orderID}`)
+						},2000)
 					} else {
 						this.$util.msg("复制失败",2000,true,'none');
 					}

+ 27 - 4
pages/user/order/order-payment.vue

@@ -8,7 +8,7 @@
 					<view class="pay-p"><text>待付金额</text></view>
 					<view class="pay-money">
 						<text class="pay-sm">¥</text>
-						<text class="pay-bg">{{payableAmount.toFixed(2)}}</text>
+						<text class="pay-bg">{{payableAmount | NumFormat}}</text>
 					</view>
 				</view>
 				<view class="pay-check">
@@ -81,7 +81,7 @@
 				payableAmount:0,
 				emptyWrapperH: '',
 				bankNumber:'6217 6803 0362 0897',
-				payOrderId:'#10226#',
+				payOrderId:'',
 				nvabarData: {		//顶部自定义导航
 					showCapsule:1, // 是否显示左上角图标  1表示显示  0表示不显示,
 					showSearch: 0,
@@ -105,9 +105,31 @@
 		onLoad(option) {
 			this.initData(option)
 		},
+		filters: {
+			NumFormat(value) {
+				if(!value) return '0.00';
+				/*原来用的是Number(value).toFixed(0),这样取整时有问题,例如0.51取整之后为1,感谢Nils指正*/
+				/*后来改成了 Number(value)|0,但是输入超过十一位就为负数了,具体见评论 */
+				var intPart = Number(value) - Number(value)%1; //获取整数部分(这里是windy93的方法)
+				var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断
+				var floatPart = ".00"; //预定义小数部分
+				var value2Array = value.toString().split(".");
+				//=2表示数据有小数位
+				if(value2Array.length == 2) {
+					floatPart = value2Array[1].toString(); //拿到小数部分
+			
+					if(floatPart.length == 1) { //补0,实际上用不着
+						return intPartFormat + "." + floatPart + '0';
+					} else {
+						return intPartFormat + "." + floatPart;
+					}
+				} else {
+					return intPartFormat + floatPart;
+				}
+			}
+		},
 		methods:{
 			initData(e){
-				console.log(this.orderID)
 				switch(e.type){
 					case 'confirm':
 						this.isConfirm = true
@@ -121,9 +143,10 @@
 						break;
 				}
 				this.orderID = e.orderID
+				this.payOrderId ='#'+e.orderID+'#';
 				this.PayService.PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
 					let data = response.data.order
-					this.payableAmount = data.payableAmount - data.receiptAmount  //待付金额
+					this.payableAmount = (data.payableAmount - data.receiptAmount).toFixed(2)  //待付金额
 					this.receiptStatus =  data.receiptStatus
 					if(this.receiptStatus =='2'){
 						this.payStatusText = '使用微信和企业网银支付全部金额后,供应商会在24小时后发货(周末、节假日顺延)。'