Bladeren bron

8.8日ios跳转正常,支付状态需手动刷新

李万涛 2 jaren geleden
bovenliggende
commit
5c9d33da1f
5 gewijzigde bestanden met toevoegingen van 216 en 72 verwijderingen
  1. 15 15
      pages.json
  2. 4 0
      pages/index/index.vue
  3. 68 16
      pages/index/scoreDetail/index.vue
  4. 1 8
      pages/midPage/index.vue
  5. 128 33
      pages/user/score/record/index.vue

+ 15 - 15
pages.json

xqd
@@ -226,21 +226,21 @@
 				"title": ""
 			}
 		},
-		{
-			"path": "pages/test/index",
-			"style": {
-				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false,
-				"navigationBarBackgroundColor": "#26B3A0",
-				"navigationBarTextStyle": "white",
-				"navigationStyle": "custom",
-				"backgroundColor": "#fff"
-			},
-			"meta": {
-				"auth": true,
-				"title": ""
-			}
-		},
+		// {
+		// 	"path": "pages/test/index",
+		// 	"style": {
+		// 		"navigationBarTitleText": "",
+		// 		"enablePullDownRefresh": false,
+		// 		"navigationBarBackgroundColor": "#26B3A0",
+		// 		"navigationBarTextStyle": "white",
+		// 		"navigationStyle": "custom",
+		// 		"backgroundColor": "#fff"
+		// 	},
+		// 	"meta": {
+		// 		"auth": true,
+		// 		"title": ""
+		// 	}
+		// },
 		{
 			"path": "pages/user/public/paymentdetail",
 			"style": {

+ 4 - 0
pages/index/index.vue

xqd xqd xqd
@@ -73,6 +73,7 @@
 		</view>
 		<empty v-if="tuskList.length==0"></empty>
 		<u-loadmore v-if="tuskList.length!=0" :status="status" />
+
 		<wike-tabbar></wike-tabbar>
 	</view>
 </template>
@@ -102,6 +103,7 @@
 				totalElements: '',
 				// loadstatus: "noMore"
 				status: 'nomore',
+
 			};
 		},
 		computed: {
@@ -210,6 +212,8 @@
 		},
 
 		methods: {
+
+
 			async test() {
 				let res = await sendGpt({
 					message: '中国的首都是'

+ 68 - 16
pages/index/scoreDetail/index.vue

xqd xqd xqd xqd xqd xqd xqd
@@ -51,6 +51,9 @@
 				立即学习
 			</view>
 		</view>
+
+		<u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="#26b3a0"
+			@confirm="isPaySuc"></u-modal>
 	</view>
 </template>
 
@@ -87,7 +90,9 @@
 				scoreOrderList: [],
 				currPayOrderList: [],
 				from: '',
-				currOrder: {}
+				currOrder: {},
+
+				payVisiable: false
 			};
 		},
 		computed: {
@@ -119,24 +124,17 @@
 
 		},
 		async onShow() {
-			let pages = getCurrentPages();
-			let prePage = pages[pages.length - 2].route
-			console.log('prePage', prePage);
+			return
 			let resss = await myScoreOrder()
 			if (resss.code == 0) {
 				this.scoreOrderList = resss.data
 
-
 				console.log('课程详情页-订单列表3', this.scoreOrderList);
 				this.currOrder = resss.data.find((item, index) => {
 					return item.course_id == this.course_id
 				})
 
 				console.log('判断支付状态的那一项订单3', this.currOrder);
-
-				// this.currPayOrderList = this.scoreOrderList.filter((item, index) => {
-				// 	return item.course_id == this.course_id
-				// })
 				if (this.currOrder) {
 					if (this.currOrder.status && uni.getStorageSync('clickStudyBtn')) {
 						uni.removeStorageSync('clickStudyBtn')
@@ -169,6 +167,47 @@
 
 		},
 		methods: {
+			async isPaySuc() {
+				let resss = await myScoreOrder()
+				if (resss.code == 0) {
+					this.scoreOrderList = resss.data
+					this.currOrder = resss.data.find((item, index) => {
+						return item.course_id == this.course_id
+					})
+
+					if (this.currOrder) {
+						if (this.currOrder.status && uni.getStorageSync('clickStudyBtn')) {
+							this.payVisiable = false
+							uni.removeStorageSync('clickStudyBtn')
+							uni.navigateTo({
+								url: '/pages/index/scorePaySuc/index?id=' + this
+									.course_id
+							})
+						} else if (!this.currOrder.status && uni.getStorageSync('clickStudyBtn')) {
+							this.payVisiable = false
+							uni.removeStorageSync('clickStudyBtn')
+							uni.showToast({
+								title: '支付失败,请稍后重试!',
+								icon: 'error',
+								duration: 1500
+							})
+						}
+					} else {
+						this.payVisiable = false
+						if (uni.getStorageSync('clickStudyBtn')) {
+							uni.removeStorageSync('clickStudyBtn')
+						}
+					}
+				} else {
+					this.payVisiable = false
+					uni.showToast({
+						title: resss.msg,
+						icon: 'none',
+						duration: 1500
+					})
+				}
+
+			},
 			pay(course_id) {
 				if (isWechat()) {
 					this.goStudy(course_id)
@@ -180,9 +219,9 @@
 			handleRefresh() {
 				uni.setStorageSync('from', 'index')
 			},
-			async isPaySuc() {
+			// async isPaySuc() {
 
-			},
+			// },
 
 			async hasWaitingPayOrder() {
 				let resss = await myScoreOrder()
@@ -230,9 +269,14 @@
 
 						if (res2.code == 0) {
 							uni.setStorageSync('clickStudyBtn', true)
-
-							// location.href = res2.data
-							window.open(res2.data)
+							// let addRedirectUrl = res2.data + '&redirect_url=' +
+							// 	encodeURIComponent(
+							// 		'https://www.ai5566.cn/h5/pages/index/scoreDetail/index?id=' + this.course_id
+							// 	)
+							this.payVisiable = true
+							// location.href = addRedirectUrl
+							location.href = res2.data
+							// window.open(res2.data)
 						} else {
 							uni.showToast({
 								title: res2.msg,
@@ -253,8 +297,16 @@
 						console.log('res2-2', res2);
 						if (res2.code == 0) {
 							uni.setStorageSync('clickStudyBtn', true)
-							// location.href = res2.data
-							window.open(res2.data)
+
+							// let addRedirectUrl = res2.data + '&redirect_url=' +
+							// 	encodeURIComponent(
+							// 		'https://www.ai5566.cn/h5/pages/index/scoreDetail/index?id=' + this.course_id
+							// 	)
+
+							// location.href = addRedirectUrl
+							this.payVisiable = true
+							location.href = res2.data
+							// window.open(res2.data)
 						} else {
 							uni.showToast({
 								title: res2.msg,

+ 1 - 8
pages/test/index.vue → pages/midPage/index.vue

xqd
@@ -1,13 +1,6 @@
 <template>
 	<view class="content">
-		<image class="bg-set" src="/static/bj.png" :style=" {height:windowHeight +'px'} "> </image>
-		<!-- <image class="btn-set" src="/static/xz.png" @click="clickDownLoad"> </image> -->
-		<button @click="clickDownLoad">下载</button>
-		<view class="videoPoster" v-if="showVideo">
-			<video src="https://zhengda.oss-cn-chengdu.aliyuncs.com/yishulian/2023-06-29/Qb8M1CqlIUBj.mp4"
-				autoplay="autoplay">
-			</video>
-		</view>
+		中间
 
 	</view>
 </template>

+ 128 - 33
pages/user/score/record/index.vue

xqd xqd xqd xqd xqd
@@ -32,6 +32,9 @@
 				</view>
 			</view>
 			<empty v-else style="margin-top: 50%;"></empty>
+
+			<u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="#26b3a0"
+				@confirm="isPaySuc"></u-modal>
 		</view>
 	</view>
 </template>
@@ -76,7 +79,9 @@
 				course_id: '',
 
 				timer: '',
-				currOrderId: -1
+				currOrderId: -1,
+
+				payVisiable: false
 			};
 		},
 		computed: {
@@ -95,51 +100,103 @@
 			window.addEventListener('beforeunload', this.handleRefresh)
 		},
 		async onShow() {
+			// return
 			// clearInterval(this.timer)
 
 			let res = await myScoreOrder()
 			if (res.code == 0) {
 				this.scoreOrderList = res.data
 
-				let waitPayOrder = res.data.find((item, index) => {
-					return item.id == Number(uni.getStorageSync('myOrderId1'))
-				})
+				// let waitPayOrder = res.data.find((item, index) => {
+				// 	return item.id == Number(uni.getStorageSync('myOrderId1'))
+				// })
 
-				console.log('需要判断支付状态的那一项订单', waitPayOrder);
+				// console.log('需要判断支付状态的那一项订单', waitPayOrder);
 
-				console.log('存本地的ScoreId', Number(uni.getStorageSync('myScoreId')));
-				if (this.scoreOrderList.length != 0) {
-					if (waitPayOrder.status && uni.getStorageSync('clickStudyBtn')) {
-						uni.navigateTo({
-							url: '/pages/index/scorePaySuc/index?id=' + Number(uni.getStorageSync('myScoreId'))
-						})
+				// console.log('存本地的ScoreId', Number(uni.getStorageSync('myScoreId')));
+				// if (this.scoreOrderList.length != 0) {
+				// 	if (waitPayOrder.status && uni.getStorageSync('clickStudyBtn')) {
+				// 		uni.navigateTo({
+				// 			url: '/pages/index/scorePaySuc/index?id=' + Number(uni.getStorageSync('myScoreId'))
+				// 		})
 
-						uni.removeStorageSync('clickStudyBtn')
-						uni.removeStorageSync('myScoreId')
-					} else if (!waitPayOrder.status && uni.getStorageSync('clickStudyBtn')) {
-						uni.showToast({
-							title: '支付失败,请稍后重试!',
-							icon: 'error',
-							duration: 1500
-						})
-						uni.removeStorageSync('clickStudyBtn')
-						uni.removeStorageSync('myScoreId')
-					}
-				} else {
-					uni.removeStorageSync('clickStudyBtn')
-					uni.removeStorageSync('myScoreId')
-				}
+				// 		uni.removeStorageSync('clickStudyBtn')
+				// 		uni.removeStorageSync('myScoreId')
+				// 		uni.removeStorageSync('myOrderId1')
+				// 	} else if (!waitPayOrder.status && uni.getStorageSync('clickStudyBtn')) {
+				// 		// clearInterval(this.timer)
+
+
+				// 		// uni.showToast({
+				// 		// 	title: '支付失败,请稍后重试!',
+				// 		// 	icon: 'error',
+				// 		// 	duration: 1500
+				// 		// })
+				// 		uni.removeStorageSync('clickStudyBtn')
+				// 		uni.removeStorageSync('myScoreId')
+				// 		uni.removeStorageSync('myOrderId1')
+				// 	}
+				// } else {
+				// 	uni.removeStorageSync('clickStudyBtn')
+				// 	uni.removeStorageSync('myScoreId')
+				// 	uni.removeStorageSync('myOrderId1')
+				// }
 			}
 			console.log('我的课程订单返回值', res);
 		},
 		onHide() {
-			// clearInterval(this.timer)
+
+		},
+		beforeDestroy() {
+
 		},
 		onUnload() {
 			window.removeEventListener('beforeunload', this.handleRefresh)
 		},
 		methods: {
 			async isPaySuc() {
+				let res = await myScoreOrder()
+				if (res.code == 0) {
+					this.scoreOrderList = res.data
+					let waitPayOrder = res.data.find((item, index) => {
+						return item.id == Number(uni.getStorageSync('myOrderId1'))
+					})
+					if (this.scoreOrderList.length != 0) {
+						if (waitPayOrder.status && uni.getStorageSync('clickStudyBtn')) {
+							this.payVisiable = false
+							uni.navigateTo({
+								url: '/pages/index/scorePaySuc/index?id=' + Number(uni.getStorageSync(
+									'myScoreId'))
+							})
+
+							uni.removeStorageSync('clickStudyBtn')
+							uni.removeStorageSync('myScoreId')
+							uni.removeStorageSync('myOrderId1')
+						} else if (!waitPayOrder.status && uni.getStorageSync('clickStudyBtn')) {
+							this.payVisiable = false
+							uni.showToast({
+								title: '支付失败,请稍后重试!',
+								icon: 'error',
+								duration: 1500
+							})
+							uni.removeStorageSync('clickStudyBtn')
+							uni.removeStorageSync('myScoreId')
+							uni.removeStorageSync('myOrderId1')
+						}
+					} else {
+						this.payVisiable = false
+						uni.removeStorageSync('clickStudyBtn')
+						uni.removeStorageSync('myScoreId')
+						uni.removeStorageSync('myOrderId1')
+					}
+				} else {
+					this.payVisiable = false
+					uni.showToast({
+						title: res.msg,
+						icon: 'none',
+						duration: 1500
+					})
+				}
 				// let res = await myScoreOrder()
 				// if (res.code == 0) {
 				// 	console.log('订单定时器每次请求的数据:', res);
@@ -205,7 +262,37 @@
 										if (res2.code == 0) {
 
 											uni.setStorageSync('clickStudyBtn', true)
-											window.open(res2.data)
+
+											// _this.timer = setInterval(async () => {
+											// 	let res = await myScoreOrderDetail({
+											// 		course_order_id: score.id
+											// 	})
+											// 	if (res.code == 0) {
+											// 		console.log('订单定时器每次请求的数据:', res);
+											// 		if (res.status) {
+											// 			clearInterval(_this.timer)
+											// 			uni.navigateTo({
+											// 				url: '/pages/index/scorePaySuc/index?id=' +
+											// 					_this
+											// 					.course_id
+											// 			})
+											// 		}
+											// 	}
+											// }, 2000)
+
+											// let addRedirectUrl = res2.data + '&redirect_url=' +
+											// 	encodeURIComponent(
+											// 		'https://www.ai5566.cn/h5/pages/user/score/record/index'
+											// 	)
+											// return console.log('addRedirectUrl', addRedirectUrl);
+											// window.open(res2.data)
+											// window.open(addRedirectUrl)
+											this.payVisiable = true
+											location.href = res2.data
+											// return
+											// localStorage.setItem("payVisiable", true)
+
+											// location.href = addRedirectUrl
 
 											// console.log('h5支付返回的支付路径:', res2.data, _this
 											// 	.course_id);
@@ -231,11 +318,19 @@
 											// 	}
 											// }, 2000)
 										} else {
-											uni.showToast({
-												title: res2.msg,
-												icon: 'none',
-												duration: 1500
-											})
+											if (res2.msg == '订单不存在') {
+												uni.showToast({
+													title: '该订单已支付,请下拉更新支付状态',
+													icon: 'none',
+													duration: 2000
+												})
+											} else {
+												uni.showToast({
+													title: res2.msg,
+													icon: 'none',
+													duration: 1500
+												})
+											}
 										}
 									} else {
 										uni.showToast({