Browse Source

校园报修添加支付接口

xiaoxin 2 năm trước cách đây
mục cha
commit
d1b99b6c9a

+ 4 - 4
pages/index/index.vue

@@ -23,10 +23,10 @@
 					<image src="../../static/images/air.png" mode=""></image>
 					<image src="../../static/images/air.png" mode=""></image>
 					<text>共享空调</text>
 					<text>共享空调</text>
 				</navigator>
 				</navigator>
-				<!-- <navigator :url="'/pagesRepairs/index/index'" open-type="navigate" class="menu_item">
+				<navigator :url="'/pagesRepairs/index/index'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/money.png" mode=""></image>
 					<image src="../../static/images/money.png" mode=""></image>
 					<text>报修</text>
 					<text>报修</text>
-				</navigator> -->
+				</navigator>
 				<!-- <navigator :url="'/pagesBus/bus/bus'" open-type="navigate" class="menu_item">
 				<!-- <navigator :url="'/pagesBus/bus/bus'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/bus.png" mode=""></image>
 					<image src="../../static/images/bus.png" mode=""></image>
 					<text>校车预约</text>
 					<text>校车预约</text>
@@ -42,9 +42,9 @@
 				<view class="menu_item">
 				<view class="menu_item">
 					<text></text>
 					<text></text>
 				</view>
 				</view>
-				<view class="menu_item">
+				<!-- <view class="menu_item">
 					<text></text>
 					<text></text>
-				</view>
+				</view> -->
 			</view>
 			</view>
 		</view>
 		</view>
 		<view v-if="showLogin">
 		<view v-if="showLogin">

+ 50 - 11
pagesRepairs/myRepairs/myRepairs.vue

@@ -440,26 +440,64 @@ export default {
 		// 点击支付按钮回调
 		// 点击支付按钮回调
 		async handlePay(item) {
 		async handlePay(item) {
 			const res = await this.$myRequest_repairs({
 			const res = await this.$myRequest_repairs({
-				url: '/repairPayRecord/repairPayment',
+				url: '/repairRecord/pay',
 				method: 'post',
 				method: 'post',
 				data: {
 				data: {
 					recordId: item.id,
 					recordId: item.id,
-					userId: this.userId,
-					price: item.price
+					openid: uni.getStorageSync('openId'),
+					totalPrice: item.price
 				}
 				}
 			})
 			})
 			// console.log(res)
 			// console.log(res)
-			if (res.cdoe === '200') {
+			if (res.code === '200') {
+				uni.requestPayment({
+					provider: 'wxpay',
+					timeStamp: res.data.timeStamp,
+					nonceStr: res.data.nonceStr,
+					package: 'prepay_id=' + res.data.prepay_id,
+					signType: res.data.signType,
+					paySign: res.data.paySign,
+					success: (res) => {
+						if (res.errMsg == 'requestPayment:ok') {
+							uni.showToast({
+								title: '支付成功',
+								icon: 'success',
+								mask: true
+							})
+							setTimeout(() => {
+								// 清空数组
+								this.list = []
+								// 重置当前页面可以滚动
+								this.scrollY = true
+								// 重置请求数据当前页参数
+								this.currentPage = 1
+								this.getRepairList()
+								this.getRepairCount()
+							}, 1500)
+						} else {
+							uni.showToast({
+								title: '支付失败',
+								icon: 'error',
+								mask: true
+							})
+						}
+					},
+					fail: (err) => {
+						if (err.errMsg === 'requestPayment:fail cancel') {
+							uni.showToast({
+								title: '支付已取消',
+								icon: 'none',
+								mask: true
+							})
+						}
+					}
+				})
+			} else {
 				uni.showToast({
 				uni.showToast({
-					title: '支付成功',
-					icon: 'success',
+					title: res.message,
+					icon: 'none',
 					mask: true
 					mask: true
 				})
 				})
-				setTimeout(() => {
-					this.list = []
-					this.currentPage = 1
-					this.getRepairList()
-				}, 1500)
 			}
 			}
 		},
 		},
 		// 点击录音播放回调
 		// 点击录音播放回调
@@ -644,6 +682,7 @@ export default {
 
 
 				.box_value2 {
 				.box_value2 {
 					display: flex;
 					display: flex;
+					align-items: center;
 
 
 					img {
 					img {
 						margin-top: -2rpx;
 						margin-top: -2rpx;