Browse Source

支付接口, 调整优化

zhengkaixin 5 months ago
parent
commit
bf775b01c4
2 changed files with 61 additions and 14 deletions
  1. 8 0
      apis/mall.js
  2. 53 14
      pages/bindingHomePile/homeInfo.vue

+ 8 - 0
apis/mall.js

@@ -11,6 +11,14 @@ export function mallDetails(data) {
 	})
 }
 
+export function trafficCardMallList(data) { 
+	return request({
+		method: 'post',
+		data:data ,
+		url: '/mobile/mall/trafficCardMallList'
+	})
+}
+
 export function myOrderDetails(data) { 
 	return requestWhite({
 		method: 'post',

+ 53 - 14
pages/bindingHomePile/homeInfo.vue

@@ -129,7 +129,7 @@
 							<view class="row">
 								<view class="name">有效期至</view>
 								<view class="value">{{obj.expirationTime?obj.expirationTime.split(' ')[0]:''}}
-								<u-button type="primary" v-if="0"  @click="popupShowWL=true" v-if="obj.expirationTime"
+								<u-button type="primary"    @click="popupShowWL=true" v-if="obj.expirationTime&&mallProductList.length"
 								style="margin-left: 8px;" size="mini" shape="circle"  >立即续期</u-button>
 								</view>
 							</view>
@@ -192,12 +192,12 @@
 						</span>
 					</view>
 					<view  class="cardList">
-						<view  class="cardInfo"  v-for="(item,i) in cardList" :key="i"
+						<view  class="cardInfo"  v-for="(item,i) in mallProductList" :key="i"
 						@click="wlkid=item.id"
 						 :class="{
 						 	cardInfoCk:item.id==wlkid
 						 }"  >
-							<view class="name">{{item.name}}</view>
+							<view class="name">{{item.remark}}</view>
 							<view class="price">{{item.price}}元</view>
 						</view>
 					</view>
@@ -297,7 +297,7 @@
 	
 	import * as API from '@/apis/mall.js'
 	import * as WxJsApi from '@/utils/wxJsApi.js'
-	
+	import QRCode from 'qrcodejs2'
 	import * as API_apply from '@/apis/apply.js'
 	import {
 		convertCanvasToImage
@@ -336,7 +336,8 @@
 					qrCodeImg: "",
 					submitForm:{},
 					submitType:"0",
-					wlkid:"c4474038-2921-4cd1-8cf9-93755de7ec2c",
+					wlkid:"",
+					mallProductList:[],
 				cardList:[
 					{
 						name:"包年",
@@ -374,10 +375,24 @@
 		},
 		onLoad(op) {
 			this.myApplyList()
-		
+			this.trafficCardMallList()
 		},
 		methods: {
+			confirmzfb(){
+				this.popupShowWL=false;
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				this.findDeviceByNo()
+			},
 			submitWLK(){
+				if(!this.wlkid){
+					uni.showToast({		
+						title: "请选择购买商品"
+					})
+					return 
+				}
 				var type=this.submitType
 				
 				
@@ -400,15 +415,17 @@
 				if (listcanvas.length > 0) {
 					document.getElementById("qrcode").removeChild(document.getElementsByTagName('canvas')[0]);
 				}
+				var item=this.applyList[0]
 				API.tradePrecreatePay({
-					productId: this.id,
-					opinions:this.opinions,
+					deviceNo:item.deviceNo,
+					productId: this.wlkid,
+					opinions:"",
 					buyNum:1,
-					receiver:this.receiver,
-					contactPhone:this.contactPhone,
-					deliveryAddress:this.deliveryAddress,
+					receiver:"x",
+					contactPhone:"x",
+					deliveryAddress:"x",
 				}).then((response) => {
-			
+				console.log(response)
 					let qrcode = new QRCode('qrcode', {
 						width: 200,
 						height: 200,
@@ -416,11 +433,12 @@
 						correctLevel: QRCode.CorrectLevel.M,
 			
 					})
-					this.outOrderNo = response.data.outOrderNo;
+					
+					//this.outOrderNo = response.data.outOrderNo;
 					var canvas = document.getElementsByTagName('canvas')[0];
 					this.qrCodeImg = convertCanvasToImage(canvas);
 					uni.hideLoading()
-					this.showModel = true
+					this.showModelzfb = true
 			
 				}).catch(error => {
 					uni.showToast({
@@ -430,7 +448,9 @@
 				})
 			},
 			wxpy() {
+				var item=this.applyList[0]
 				API.wxJsapiPay({
+					deviceNo:item.deviceNo,
 					productId: this.wlkid,
 					opinions:"",
 					buyNum:1,
@@ -543,6 +563,25 @@
 					url:'/pages/searchPile/stationAndPile/chargingPileDetails?isback=1&id='+item.gunNo
 				})
 			},
+			trafficCardMallList(){
+				
+				API.trafficCardMallList({
+					
+				}).then((res) => {
+					
+					 
+					this.mallProductList=res.data.mallProductList
+					if(this.mallProductList.length){
+						this.wlkid=this.mallProductList[0].id
+					}
+					
+					
+				}).catch(error => {
+					uni.showToast({
+						title: error
+					})
+				})
+			},
 			findDeviceByNo(){
 				var item=this.applyList[0]
 				API_apply.findDeviceByNoD({