Просмотр исходного кода

新增定时器刷新前提交

李万涛 2 лет назад
Родитель
Сommit
e4bb5d9c05

+ 3 - 0
App.vue

xqd
@@ -12,6 +12,9 @@
 			// // #endif		
 
 		},
+		onShow() {
+			// uni.removeStorageSync('clickStudyBtn')
+		}
 	};
 </script>
 

+ 1 - 1
pages.json

xqd
@@ -403,7 +403,7 @@
 			"path": "pages/user/score/record/index",
 			"style": {
 				"navigationBarTitleText": "",
-				"enablePullDownRefresh": false,
+				"enablePullDownRefresh": true,
 				"navigationBarBackgroundColor": "#26B3A0",
 				"navigationBarTextStyle": "white",
 				"navigationStyle": "custom",

+ 8 - 1
pages/chat/chat.vue

xqd
@@ -155,7 +155,14 @@
 		computed: {
 
 		},
-
+		onShow() {
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
+		},
 		async onLoad() {
 			let ress = await sysParms()
 			console.log('gpt页系统设置信息返回值', ress.data[6].value);

+ 9 - 0
pages/index/index.vue

xqd xqd xqd
@@ -147,6 +147,13 @@
 
 		},
 		async onShow() {
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
+
 			let ress = await taskList({
 				is_new: 1,
 				page: this.page,
@@ -201,6 +208,7 @@
 		onUnload() {
 
 		},
+
 		methods: {
 			async test() {
 				let res = await sendGpt({
@@ -215,6 +223,7 @@
 				})
 			},
 			goScoreDetail(id) {
+				uni.setStorageSync('from', 'index')
 				uni.navigateTo({
 					url: '/pages/index/scoreDetail/index?id=' + id
 				})

+ 157 - 36
pages/index/scoreDetail/index.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -47,7 +47,7 @@
 			<view class="iconBox" @click="jumpToKefu">
 				<u-icon class="icon" name="server-fill" color="#26B3A0" size="22"></u-icon>
 			</view>
-			<view class="btn" @click="goStudy(detail.id)">
+			<view class="btn" @click="pay(detail.id)">
 				立即学习
 			</view>
 		</view>
@@ -85,7 +85,9 @@
 				detail: {},
 				course_id: '',
 				scoreOrderList: [],
-				currPayOrderList: []
+				currPayOrderList: [],
+				from: '',
+				currOrder: {}
 			};
 		},
 		computed: {
@@ -95,6 +97,7 @@
 
 		},
 		async onLoad(o) {
+			// this.from = o.from
 			this.course_id = o.id
 			let res = await courseDetail({
 				course_id: o.id
@@ -104,20 +107,83 @@
 			}
 			console.log('课程详情返回值', res);
 
+			window.addEventListener('beforeunload', this.handleRefresh)
 
-
-
+			// uni.showToast({
+			// 	title: '支付失败!-onLoadonLoad',
+			// 	icon: 'none',
+			// 	duration: 1500
+			// })
 		},
 		onReady() {
 
 		},
-		onShow() {
+		async onShow() {
+			let pages = getCurrentPages();
+			let prePage = pages[pages.length - 2].route
+			console.log('prePage', prePage);
+			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')
+						uni.navigateTo({
+							url: '/pages/index/scorePaySuc/index?id=' + this
+								.course_id
+						})
+					} else if (!this.currOrder.status && uni.getStorageSync('clickStudyBtn')) {
+						uni.removeStorageSync('clickStudyBtn')
+						uni.showToast({
+							title: '支付失败,请稍后重试!',
+							icon: 'error',
+							duration: 1500
+						})
+					}
+				} else {
+					if (uni.getStorageSync('clickStudyBtn')) {
+						uni.removeStorageSync('clickStudyBtn')
+					}
+				}
+			}
 		},
 		onUnload() {
+			window.removeEventListener('beforeunload', this.handleRefresh)
+		},
+		destroyed() {
+
+		},
+		beforeDestroy() {
 
 		},
 		methods: {
+			pay(course_id) {
+				if (isWechat()) {
+					this.goStudy(course_id)
+				} else {
+					this.goStudy2(course_id)
+				}
+			},
+
+			handleRefresh() {
+				uni.setStorageSync('from', 'index')
+			},
+			async isPaySuc() {
+
+			},
+
 			async hasWaitingPayOrder() {
 				let resss = await myScoreOrder()
 				if (resss.code == 0) {
@@ -129,41 +195,101 @@
 				}
 			},
 
-			// jumpToKefu() {
-			// 	uni.navigateTo({
-			// 		url: '/pages/user/public/kefu'
-			// 	})
-			// },
 			jumpToKefu() {
 				window.open('https://work.weixin.qq.com/kfid/kfc807229b723286051')
 			},
-			async goStudy(course_id) {
 
-				// return uni.navigateTo({
-				// 	url: '/pages/index/scorePaySuc/index?id=' + this
-				// 		.course_id
-				// })
-				if (!isWechat()) {
-					uni.showToast({
-						title: '请用微信内置浏览器打开本网站,进行课程购买!',
-						icon: 'none'
+			// 微信H5支付
+			async goStudy2(course_id) {
+				// 判断是否存在待支付的订单
+				let resss = await myScoreOrder()
+				if (resss.code == 0) {
+					this.scoreOrderList = resss.data
+
+					console.log('课程详情页-订单列表', this.scoreOrderList);
+					this.currOrder = resss.data.find((item, index) => {
+						return item.course_id == this.course_id
+					})
+
+					console.log('判断支付状态的那一项订单', this.currOrder);
+					// return
+				}
+				if (this.currOrder) {
+					if (this.currOrder.status) {
+						uni.showToast({
+							title: '你已购买过该课程,请勿重复购买!',
+							icon: 'none',
+							duration: 1500
+						})
+					} else {
+						let res2 = await wxPayPamars({
+							order_id: this.currOrder.id,
+							type: 'h5'
+						})
+						console.log('res2-1', res2);
+
+						if (res2.code == 0) {
+							uni.setStorageSync('clickStudyBtn', true)
+
+							// location.href = res2.data
+							window.open(res2.data)
+						} else {
+							uni.showToast({
+								title: res2.msg,
+								icon: 'none',
+								duration: 1500
+							})
+						}
+					}
+				} else {
+					let res1 = await shopCourse({
+						course_id
 					})
-					return
+					if (res1.code == 0) {
+						let res2 = await wxPayPamars({
+							order_id: res1.data.id,
+							type: 'h5'
+						})
+						console.log('res2-2', res2);
+						if (res2.code == 0) {
+							uni.setStorageSync('clickStudyBtn', true)
+							// location.href = res2.data
+							window.open(res2.data)
+						} else {
+							uni.showToast({
+								title: res2.msg,
+								icon: 'none',
+								duration: 1500
+							})
+						}
+					} else {
+						uni.showToast({
+							title: res1.msg,
+							icon: 'none',
+							duration: 1500
+						})
+					}
 				}
+			},
+
+
+			// 微信公众号内部支付
+			async goStudy(course_id) {
 
-				// this.hasWaitingPayOrder(
 				// 判断是否存在待支付的订单
 				let resss = await myScoreOrder()
 				if (resss.code == 0) {
 					this.scoreOrderList = resss.data
-
-					this.currPayOrderList = this.scoreOrderList.filter((item, index) => {
+					console.log('课程详情页-订单列表2', this.scoreOrderList);
+					this.currOrder = resss.data.find((item, index) => {
 						return item.course_id == this.course_id
 					})
+
+					console.log('判断支付状态的那一项订单2', this.currOrder);
 				}
-				if (this.currPayOrderList.length != 0) {
-					console.log('当前购买课程的待支付订单列表', this.currPayOrderList, resss);
-					if (this.currPayOrderList[0].status) {
+				if (this.currOrder) {
+					// console.log('当前购买课程的待支付订单列表', this.currPayOrderList, resss);
+					if (this.currOrder.status) {
 						uni.showToast({
 							title: '你已购买过该课程,请勿重复购买!',
 							icon: 'none',
@@ -171,7 +297,7 @@
 						})
 					} else {
 						let res2 = await wxPayPamars({
-							order_id: this.currPayOrderList[0].id
+							order_id: this.currOrder.id
 						})
 						let url = window.location.href.split('#')[0]
 						let res3 = await wxConfigPamars({
@@ -180,11 +306,6 @@
 						if (res2.code == 0 && res3.code == 0) {
 							wxsdk.wxpay(res3.data, res2.data, (res) => {
 								if (res.errMsg == "chooseWXPay:ok") {
-									// uni.showToast({
-									// 	title: '付款成功',
-									// 	icon: 'success',
-									// 	duration: 1500
-									// })
 									setTimeout(() => {
 										uni.navigateTo({
 											url: '/pages/index/scorePaySuc/index?id=' + this
@@ -202,13 +323,13 @@
 						} else {
 							if (res2.code != 0) {
 								uni.showToast({
-									title: res.msg,
+									title: res2.msg,
 									icon: 'none',
 									duration: 1500
 								})
 							} else if (res3.code != 0) {
 								uni.showToast({
-									title: res.msg,
+									title: res3.msg,
 									icon: 'none',
 									duration: 1500
 								})
@@ -254,13 +375,13 @@
 						} else {
 							if (res2.code != 0) {
 								uni.showToast({
-									title: res.msg,
+									title: res2.msg,
 									icon: 'none',
 									duration: 1500
 								})
 							} else if (res3.code != 0) {
 								uni.showToast({
-									title: res.msg,
+									title: res3.msg,
 									icon: 'none',
 									duration: 1500
 								})

+ 42 - 3
pages/index/scorePaySuc/index.vue

xqd xqd xqd xqd xqd xqd
@@ -2,7 +2,8 @@
 	<view class="container">
 		<!-- #ifdef H5 -->
 		<view style="color: #fff;">
-			<tn-nav-bar backgroundColor="#26B3A0" :bottomShadow="false" @rightClick="jumpScoreRed">支付状态
+			<tn-nav-bar @back="handleBack" backgroundColor="#26B3A0" :bottomShadow="false"
+				@rightClick="jumpScoreRed">支付状态
 				<!-- 	<template slot="right">
 					课程购买记录
 				</template> -->
@@ -12,6 +13,7 @@
 		<!-- #endif -->
 
 
+		<!-- <view class="content" v-if="orderDetail.status"> -->
 		<view class="content">
 			<view class="topIcon">
 				<!-- <image src="../../../static/posImg.png" mode=""></image> -->
@@ -31,6 +33,16 @@
 				</view>
 			</view>
 		</view>
+
+
+		<!-- 	<view class="content" v-else>
+			<view class="topIcon">
+				<icon type="info" size="54" color="red" />
+				<view class="txt" style="color: red;">
+					支付失败
+				</view>
+			</view>
+		</view> -->
 	</view>
 </template>
 
@@ -41,6 +53,10 @@
 	import {
 		downLoad2
 	} from '@/utils/download2.js'
+
+	import {
+		myScoreOrderDetail
+	} from '@/api/my/index.js'
 	export default {
 		components: {},
 		data() {
@@ -48,7 +64,11 @@
 				detail: {},
 
 				tobheight: 45,
-				resShow: false
+				resShow: false,
+
+				orderDetail: {
+					status: 0
+				}
 			};
 		},
 		computed: {
@@ -64,18 +84,37 @@
 			if (res.code == 0) {
 				this.detail = res.data
 			}
+
+
+			// let res1 = await myScoreOrderDetail({
+			// 	course_order_id: o.orderId
+			// })
+			// if (res1.code == 0) {
+			// 	this.orderDetail = res1.data
+			// 	// this.orderDetail.status = 1
+			// }
+			// console.log('支付状态页-订单状态返回值:', res1);
 			console.log('支付成功--课程详情返回值', res);
 		},
+
 		onReady() {
 
 		},
 		onShow() {
-
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
 		},
 		onUnload() {
 
 		},
 		methods: {
+			handleBack() {
+				uni.setStorageSync('from', 'index')
+			},
 			handleShowRes() {
 				this.resShow = !this.resShow
 			},

+ 209 - 0
pages/index/scorePaySuc/index1.vue

xqd
@@ -0,0 +1,209 @@
+<template>
+	<view class="container">
+		<!-- #ifdef H5 -->
+		<view style="color: #fff;">
+			<tn-nav-bar backgroundColor="#26B3A0" :bottomShadow="false" @rightClick="jumpScoreRed">支付状态
+				<!-- 	<template slot="right">
+					课程购买记录
+				</template> -->
+			</tn-nav-bar>
+			<view :style="{ height: tobheight + 'px' }"></view>
+		</view>
+		<!-- #endif -->
+
+
+		<view class="content">
+			<view class="topIcon">
+				<!-- <image src="../../../static/posImg.png" mode=""></image> -->
+				<icon :type="currScoreOrder.status?'success':'error'" size="54"
+					:color="currScoreOrder.status?'#26B3A0':'red'" />
+				<view class="txt" :style="{color:currScoreOrder.status?'#26B3A0':'red'}">
+					{{currScoreOrder.status?'支付成功':'支付失败'}}
+				</view>
+			</view>
+			<view class="btn" @click="handleShowRes" v-if="currScoreOrder.status">
+				{{resShow?'收起学习资料':'查看学习资料'}}
+			</view>
+
+			<view class="res" v-if="resShow&&this.detail.content">
+				<view class="inner" v-for="(i,index) in this.detail.content" @click="downLoad(i)">
+					<text style="text-decoration: underline;">
+						{{'学习资料'+(index+1)}}</text><text>{{i.slice(i.lastIndexOf('.'))}}</text>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {
+		courseDetail,
+	} from '@/api/score/index.js'
+
+	import {
+		myScoreOrder
+	} from '@/api/my/index.js'
+	import {
+		downLoad2
+	} from '@/utils/download2.js'
+	export default {
+		components: {},
+		data() {
+			return {
+				detail: {},
+
+				tobheight: 45,
+				resShow: false,
+				currScoreOrder: {}
+			};
+		},
+		computed: {
+
+		},
+		watch: {
+
+		},
+		async onLoad(o) {
+			let res = await courseDetail({
+				course_id: o.id
+			})
+			if (res.code == 0) {
+				this.detail = res.data
+			}
+
+			let res1 = await myScoreOrder({})
+			if (res1.code == 0) {
+				this.detail = res1.data
+
+				this.currScoreOrder = res1.data.find((item, index) => {
+					return item.course_id == o.id
+				})
+				// this.currScoreOrder.status = 1
+			}
+			console.log('支付成功--课程详情返回值', res);
+			console.log('支付成功--所有课程订单列表:', res1);
+			console.log('支付成功--需判断支付状态的课程订单:', this.currScoreOrder, this.currScoreOrder.status);
+
+
+		},
+		onReady() {
+
+		},
+		onShow() {
+
+		},
+		onUnload() {
+
+		},
+		methods: {
+			handleShowRes() {
+				this.resShow = !this.resShow
+			},
+
+
+			downLoad(fileName) {
+				let _this = this
+				//判断是否在微信
+				var ua = navigator.userAgent.toLowerCase();
+				var isWeixin = ua.indexOf('micromessenger') != -1;
+
+				const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
+					navigator.userAgent) ? false : true;
+
+				if (isWeixin) {
+					if (fileName.endsWith('.pdf')) {
+						uni.navigateTo({
+							url: '/pages/user/score/prePdf/index?url=' + fileName
+						})
+					} else if (fileName.endsWith('.mp4')) {
+						uni.navigateTo({
+							url: '/pages/user/score/preMp4/index?url=' + fileName
+						})
+					} else if (fileName.endsWith('.jpg') || fileName.endsWith('.png') || fileName.endsWith('.jpeg')) {
+						uni.navigateTo({
+							url: '/pages/user/score/preImg/index?url=' + fileName
+						})
+					} else if (fileName.endsWith('.zip') || fileName.endsWith('.rar')) {
+						let _that = this
+						uni.showModal({
+							title: '温馨提示',
+							content: '微信浏览器不支持直接打开zip或rar类型的文件,请复制链接至手机浏览器打开哦~',
+							confirmText: '复制',
+							confirmColor: '#26B3A0',
+							success: function(res) {
+								if (res.confirm) {
+									console.log('用户点击确定');
+									uni.setClipboardData({
+										data: fileName,
+										success: function() {
+											console.log('success');
+											uni.showToast({
+												title: "复制成功",
+												icon: 'success',
+											})
+										}
+									});
+								} else if (res.cancel) {
+									console.log('用户点击取消');
+								}
+							}
+						})
+					}
+
+				} else if (detectDeviceType()) {
+					// pc端
+					uni.downloadFile({
+						url: fileName, //文件链接
+						success: (res) => {
+							if (res.statusCode === 200) {
+								var oA = document.createElement("a");
+								oA.download = _this.detail.course.name + '-学习资料'; // 设置下载的文件名,默认是'下载'	
+								oA.href = res.tempFilePath; //临时路径再保存到本地
+								document.body.appendChild(oA);
+								oA.click();
+								oA.remove(); // 下载之后把创建的元素删除
+							}
+						},
+						fail: (err) => {
+							uni.showToast({
+								icon: 'none',
+								mask: true,
+								title: '失败请重新下载',
+							});
+						},
+					})
+				} else {
+					// 其他手机浏览器
+					if (fileName.endsWith('.pdf')) {
+						uni.navigateTo({
+							url: '/pages/user/score/prePdf/index?url=' + fileName
+						})
+					} else if (fileName.endsWith('.mp4')) {
+						uni.navigateTo({
+							url: '/pages/user/score/preMp4/index?url=' + fileName
+						})
+					} else if (fileName.endsWith('.jpg') || fileName.endsWith('.png') || fileName.endsWith('.jpeg')) {
+						uni.navigateTo({
+							url: '/pages/user/score/preImg/index?url=' + fileName
+						})
+					} else if (fileName.endsWith('.zip') || fileName.endsWith('.rar')) {
+						downLoad2(fileName, this.detail.course.name + '-学习资料', 'application/zip')
+						// window.open(
+						// 	fileName
+						// )
+					}
+				}
+			},
+
+			goPay() {
+				uni.navigateTo({
+					url: '/pages/index/scorePaySuc/index'
+				})
+			}
+		}
+	};
+</script>
+
+<style lang="scss" scoped>
+	@import './index.scss';
+</style>

+ 6 - 0
pages/tusk/index.vue

xqd
@@ -310,6 +310,12 @@
 
 		},
 		onShow() {
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
 			this.fetchTuskList()
 		},
 		onUnload() {

+ 14 - 1
pages/user/score/index.vue

xqd xqd
@@ -2,7 +2,8 @@
 	<view>
 		<!-- #ifdef H5 -->
 		<view style="color: #fff;">
-			<tn-nav-bar backgroundColor="#26B3A0" :bottomShadow="false" @rightClick="jumpScoreRed">课程详情
+			<tn-nav-bar @back="handleBack" backgroundColor="#26B3A0" :bottomShadow="false"
+				@rightClick="jumpScoreRed">课程详情
 			</tn-nav-bar>
 			<view :style="{ height: tobheight + 'px' }"></view>
 		</view>
@@ -117,7 +118,19 @@
 			}
 			console.log('课程详情', this.detail);
 		},
+		onShow() {
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
+
+		},
 		methods: {
+			handleBack() {
+				uni.setStorageSync('from', 'user')
+			},
 			handleShowRes() {
 				if (this.detail.status == 0) {
 					uni.showToast({

+ 190 - 48
pages/user/score/record/index.vue

xqd xqd
@@ -37,6 +37,9 @@
 </template>
 
 <script>
+	const isWechat = () => {
+		return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
+	}
 	import {
 		mapMutations,
 		mapActions,
@@ -70,94 +73,233 @@
 				tobheight: 45,
 
 				scoreOrderList: [],
-				course_id: ''
+				course_id: '',
+
+				timer: '',
+				currOrderId: -1
 			};
 		},
 		computed: {
 			...mapGetters(['appInfo', 'isLogin', 'userInfo'])
 		},
+		async onPullDownRefresh() {
+			let res = await myScoreOrder()
+			if (res.code == 0) {
+				this.scoreOrderList = res.data
+				uni.stopPullDownRefresh()
+			} else {
+				uni.stopPullDownRefresh()
+			}
+		},
 		async onLoad() {
-			// let res = await myScoreOrder()
-			// if (res.code == 0) {
-			// 	this.scoreOrderList = res.data
-			// }
-			// console.log('我的课程订单返回值', res);
+			window.addEventListener('beforeunload', this.handleRefresh)
 		},
 		async onShow() {
+			// 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'))
+				})
+
+				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'))
+						})
+
+						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')
+				}
 			}
 			console.log('我的课程订单返回值', res);
 		},
+		onHide() {
+			// clearInterval(this.timer)
+		},
+		onUnload() {
+			window.removeEventListener('beforeunload', this.handleRefresh)
+		},
 		methods: {
+			async isPaySuc() {
+				// let res = await myScoreOrder()
+				// if (res.code == 0) {
+				// 	console.log('订单定时器每次请求的数据:', res);
+				// 	let scoreOrderList = res.data
+				// 	if (scoreOrderList[0].status) {
+				// 		clearInterval(this.timer)
+				// 	}
+				// }
+			},
+
+			handleRefresh() {
+				uni.setStorageSync('from', 'user')
+
+				uni.removeStorageSync('clickStudyBtn')
+				uni.removeStorageSync('myScoreId')
+			},
 			async goScoreDetail(score) {
+				// this.currOrderId = score.id
+				uni.setStorageSync('myOrderId1', score.id)
+				// console.log('this.currOrderId', this.currOrderId);
+				// return
 				this.course_id = score.course_id
 
+				uni.setStorageSync('myScoreId', score.course_id)
+
+
 				if (score.status) {
+					uni.removeStorageSync('myScoreId')
+					uni.removeStorageSync('clickStudyBtn')
 					uni.navigateTo({
 						url: '/pages/user/score/index?id=' + score.id
 					})
 				} else {
+					let _this = this
 					uni.showModal({
 						title: '提示',
 						content: '当前订单状态为待支付,确认继续支付?',
 						confirmColor: 'rgb(38, 179, 160)',
 						success: async (res) => {
 							if (res.confirm) {
-								let res1 = await myScoreOrderDetail({
-									course_order_id: score.id
-								})
-								if (res1.code == 0) {
-									let res2 = await wxPayPamars({
-										order_id: res1.data.id
-									})
-									let url = window.location.href.split('#')[0]
-									let res3 = await wxConfigPamars({
-										url: url
+								// let test = encodeURIComponent(
+								// 	// 'http://localhost:8080/h5/pages/index/scorePaySuc/index?id=95&orderId=91'
+								// 	'https://ai5566.cn/h5/pages/index/scorePaySuc/index'
+								// )
+
+								// return location.href =
+								// 	'https://www.ai5566.cn/h5/pages/index/scorePaySuc/index'
+
+
+
+								console.log('isWechat()', isWechat());
+								// h5支付
+								if (!isWechat()) {
+									let res1 = await myScoreOrderDetail({
+										course_order_id: score.id
 									})
+									if (res1.code == 0) {
+										let res2 = await wxPayPamars({
+											order_id: res1.data.id,
+											type: 'h5'
+										})
+										console.log('res2', res2);
+										if (res2.code == 0) {
 
-									console.log('res2返回值', res2);
-									console.log('res3返回值', res3);
-									if (res2.code == 0 && res3.code == 0) {
-										wxsdk.wxpay(res3.data, res2.data, (res) => {
-											if (res.errMsg == "chooseWXPay:ok") {
-												setTimeout(() => {
-													uni.navigateTo({
-														url: '/pages/index/scorePaySuc/index?id=' +
-															this
-															.course_id
-													})
-												}, 1500)
-											} else {
-												uni.showToast({
-													title: '支付失败,请稍后重试!',
-													icon: 'error',
-													duration: 1500
-												})
-											}
-										});
-									} else {
-										if (res2.code != 0) {
-											uni.showToast({
-												title: res.msg,
-												icon: 'none',
-												duration: 1500
-											})
-										} else if (res3.code != 0) {
+											uni.setStorageSync('clickStudyBtn', true)
+											window.open(res2.data)
+
+											// console.log('h5支付返回的支付路径:', res2.data, _this
+											// 	.course_id);
+											// let redirect_url =
+											// 	'https://www.ai5566.cn/h5/pages/index/scorePaySuc/index?id=' +
+											// 	_this
+											// 	.course_id + '&orderId=' + score.id
+
+											// let addUrl = res2.data + '&redirect_url=' +
+											// 	encodeURIComponent(
+											// 		redirect_url)
+											// location.href = addUrl
+											// console.log('h5支付返回的支付路径+redirect_url:', addUrl);
+
+											// _this.timer = setInterval(async () => {
+											// 	let res = await myScoreOrder()
+											// 	if (res.code == 0) {
+											// 		console.log('订单定时器每次请求的数据:', res);
+											// 		_this.scoreOrderList = res.data
+											// 		if (_this.scoreOrderList[0].status) {
+											// 			clearInterval(_this.timer)
+											// 		}
+											// 	}
+											// }, 2000)
+										} else {
 											uni.showToast({
-												title: res.msg,
+												title: res2.msg,
 												icon: 'none',
 												duration: 1500
 											})
 										}
+									} else {
+										uni.showToast({
+											title: res.msg,
+											icon: 'none'
+										})
 									}
 								} else {
-									uni.showToast({
-										title: res.msg,
-										icon: 'none'
+									// 微信内部支付
+									let res1 = await myScoreOrderDetail({
+										course_order_id: score.id
 									})
+									if (res1.code == 0) {
+										let res2 = await wxPayPamars({
+											order_id: res1.data.id
+										})
+										let url = window.location.href.split('#')[0]
+										let res3 = await wxConfigPamars({
+											url: url
+										})
+
+										console.log('res2返回值', res2);
+										console.log('res3返回值', res3);
+										if (res2.code == 0 && res3.code == 0) {
+											wxsdk.wxpay(res3.data, res2.data, (res) => {
+												if (res.errMsg == "chooseWXPay:ok") {
+													setTimeout(() => {
+														uni.navigateTo({
+															url: '/pages/index/scorePaySuc/index?id=' +
+																this
+																.course_id
+														})
+													}, 1500)
+												} else {
+													uni.showToast({
+														title: '支付失败,请稍后重试!',
+														icon: 'error',
+														duration: 1500
+													})
+												}
+											});
+										} else {
+											if (res2.code != 0) {
+												uni.showToast({
+													title: res2.msg,
+													icon: 'none',
+													duration: 1500
+												})
+											} else if (res3.code != 0) {
+												uni.showToast({
+													title: res3.msg,
+													icon: 'none',
+													duration: 1500
+												})
+											}
+										}
+									} else {
+										uni.showToast({
+											title: res.msg,
+											icon: 'none'
+										})
+									}
 								}
+
 							} else if (res.cancel) {
 
 							}

+ 8 - 1
pages/user/signin.vue

xqd xqd
@@ -52,7 +52,7 @@
 								<view v-if="!showlogon" class="input u-flex align-center">
 									<u-icon name="account-fill" color="#26B3A0" size="24"></u-icon>
 									<input class="vs-flex-item" v-model="accountLogin.invite_code" :maxlength="11"
-										placeholder="请输入邀请码" />
+										placeholder="请输入邀请码(选填)" />
 								</view>
 								<view @tap="agree = !agree" class="flxe align-center justify-center"
 									style="margin-top: 50rpx;">
@@ -285,6 +285,13 @@
 			console.log('onUnload()-----------------');
 		},
 		onShow() {
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
+
 			if (uni.getStorageSync('invite_code')) {
 				this.accountLogin.invite_code = uni.getStorageSync('invite_code')
 			}

+ 14 - 1
pages/user/user.vue

xqd xqd xqd
@@ -54,7 +54,7 @@
 			<view class="com-item">
 				<view class="com-wrap">
 					<navigator class="cell" v-for="(item, index) in userList" :key="index"
-						:url="hasLogin ? item.url : '/pages/user/signin'" @click="">
+						@click="toScoreRecord(item.url)">
 						<view class="cell-left">
 							<u-icon v-if="item.ques" name="question-circle-fill" :color="item.color" size="22"></u-icon>
 							<i v-else class="iconfont" :class="item.iconName"
@@ -252,6 +252,13 @@
 		},
 
 		async onShow() {
+			if (uni.getStorageSync('clickStudyBtn')) {
+				uni.removeStorageSync('clickStudyBtn')
+			}
+			if (uni.getStorageSync('myScoreId')) {
+				uni.removeStorageSync('myScoreId')
+			}
+
 			let res = await userInfo()
 			console.log('用户个人信息返回值', res);
 			if (res.code == 0) {
@@ -293,6 +300,12 @@
 
 		},
 		methods: {
+			toScoreRecord(url) {
+				uni.setStorageSync('from', 'user')
+				uni.navigateTo({
+					url
+				})
+			},
 			openKefu() {
 				window.open('https://work.weixin.qq.com/kfid/kfc807229b723286051')
 			},

+ 1 - 0
tuniao-ui/components/tn-nav-bar/tn-nav-bar.vue

xqd
@@ -221,6 +221,7 @@
 			},
 			// 处理返回事件
 			async handlerBack() {
+				this.$emit('back')
 				if (this.beforeBack && typeof(this.beforeBack) === 'function') {
 					// 执行回调,同时传入索引当作参数
 					// 在微信,支付宝等环境(H5正常),会导致父组件定义的函数体中的this变成子组件的this