Przeglądaj źródła

8.11h5支付后跳转逻辑完善

李万涛 2 lat temu
rodzic
commit
5370d12a46

+ 18 - 1
pages.json

xqd
@@ -115,7 +115,24 @@
 		{
 			"path": "pages/index/scorePaySuc/index",
 			"style": {
-				"navigationBarTitleText": "课程支付成功",
+				"navigationBarTitleText": "课程支付状态",
+				"enablePullDownRefresh": false,
+				"navigationBarTextStyle": "black",
+				// #ifdef H5
+				"navigationStyle": "custom",
+				// #endif
+				"navigationBarBackgroundColor": "#F5FFFD",
+				"backgroundColor": "#F2F2F2"
+			},
+			"meta": {
+				"auth": true,
+				"title": ""
+			}
+		},
+		{
+			"path": "pages/index/scorePayMiddle/index",
+			"style": {
+				"navigationBarTitleText": "支付结果查询",
 				"enablePullDownRefresh": false,
 				"navigationBarTextStyle": "black",
 				// #ifdef H5

+ 17 - 104
pages/index/scoreDetail/index.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -52,8 +52,8 @@
 			</view>
 		</view>
 
-		<u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="#26b3a0"
-			@confirm="isPaySuc"></u-modal>
+		<!-- <u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="#26b3a0"
+			@confirm="isPaySuc"></u-modal> -->
 	</view>
 </template>
 
@@ -92,7 +92,7 @@
 				from: '',
 				currOrder: {},
 
-				payVisiable: false
+				// payVisiable: false
 			};
 		},
 		computed: {
@@ -114,48 +114,12 @@
 
 			window.addEventListener('beforeunload', this.handleRefresh)
 
-			// uni.showToast({
-			// 	title: '支付失败!-onLoadonLoad',
-			// 	icon: 'none',
-			// 	duration: 1500
-			// })
 		},
 		onReady() {
 
 		},
 		async onShow() {
-			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);
-				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)
@@ -167,47 +131,6 @@
 
 		},
 		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)
@@ -219,10 +142,6 @@
 			handleRefresh() {
 				uni.setStorageSync('from', 'index')
 			},
-			// async isPaySuc() {
-
-			// },
-
 			async hasWaitingPayOrder() {
 				let resss = await myScoreOrder()
 				if (resss.code == 0) {
@@ -268,15 +187,12 @@
 						console.log('res2-1', res2);
 
 						if (res2.code == 0) {
-							uni.setStorageSync('clickStudyBtn', true)
-							// 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)
+							uni.setStorageSync('course_id', this.course_id)
+							let addRedirectUrl = res2.data + '&redirect_url=' +
+								encodeURIComponent(
+									'https://www.ai5566.cn/h5/pages/index/scorePayMiddle/index?id=' + this.course_id
+								)
+							location.href = addRedirectUrl
 						} else {
 							uni.showToast({
 								title: res2.msg,
@@ -296,17 +212,12 @@
 						})
 						console.log('res2-2', res2);
 						if (res2.code == 0) {
-							uni.setStorageSync('clickStudyBtn', true)
-
-							// 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)
+							uni.setStorageSync('course_id', this.course_id)
+							let addRedirectUrl = res2.data + '&redirect_url=' +
+								encodeURIComponent(
+									'https://www.ai5566.cn/h5/pages/index/scorePayMiddle/index?id=' + this.course_id
+								)
+							location.href = addRedirectUrl
 						} else {
 							uni.showToast({
 								title: res2.msg,
@@ -359,6 +270,7 @@
 							wxsdk.wxpay(res3.data, res2.data, (res) => {
 								if (res.errMsg == "chooseWXPay:ok") {
 									setTimeout(() => {
+										uni.setStorageSync('course_id', this.course_id)
 										uni.navigateTo({
 											url: '/pages/index/scorePaySuc/index?id=' + this
 												.course_id
@@ -411,6 +323,7 @@
 									// 	duration: 1500
 									// })
 									setTimeout(() => {
+										uni.setStorageSync('course_id', this.course_id)
 										uni.navigateTo({
 											url: '/pages/index/scorePaySuc/index?id=' + this
 												.course_id

+ 3 - 0
pages/index/scorePayMiddle/index.scss

xqd
@@ -0,0 +1,3 @@
+page {
+		background: #ededed;
+	}

+ 51 - 0
pages/index/scorePayMiddle/index.vue

xqd
@@ -0,0 +1,51 @@
+<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">
+			<u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="orange"
+				@confirm="isPaySuc"></u-modal>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		components: {},
+		data() {
+			return {
+				detail: {},
+
+				tobheight: 45,
+				resShow: false,
+				currScoreOrder: {},
+				payVisiable: true
+			};
+		},
+		async onLoad(o) {
+
+		},
+		methods: {
+			async isPaySuc() {
+				this.payVisiabl = false
+				uni.redirectTo({
+					url: '/pages/index/scorePaySuc/index'
+				})
+			}
+		}
+	};
+</script>
+
+<style lang="scss" scoped>
+	@import './index.scss';
+</style>

+ 27 - 45
pages/index/scorePaySuc/index.vue

xqd xqd xqd xqd xqd
@@ -2,8 +2,7 @@
 	<view class="container">
 		<!-- #ifdef H5 -->
 		<view style="color: #fff;">
-			<tn-nav-bar @back="handleBack" backgroundColor="#26B3A0" :bottomShadow="false"
-				@rightClick="jumpScoreRed">支付状态
+			<tn-nav-bar backgroundColor="#26B3A0" :bottomShadow="false" @rightClick="jumpScoreRed">支付状态
 				<!-- 	<template slot="right">
 					课程购买记录
 				</template> -->
@@ -13,16 +12,16 @@
 		<!-- #endif -->
 
 
-		<!-- <view class="content" v-if="orderDetail.status"> -->
 		<view class="content">
 			<view class="topIcon">
 				<!-- <image src="../../../static/posImg.png" mode=""></image> -->
-				<icon type="success" size="54" color="#26B3A0" />
-				<view class="txt">
-					支付成功
+				<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">
+			<view class="btn" @click="handleShowRes" v-if="currScoreOrder.status">
 				{{resShow?'收起学习资料':'查看学习资料'}}
 			</view>
 
@@ -33,30 +32,20 @@
 				</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>
 
 <script>
 	import {
-		courseDetail
+		courseDetail,
 	} from '@/api/score/index.js'
-	import {
-		downLoad2
-	} from '@/utils/download2.js'
 
 	import {
-		myScoreOrderDetail
+		myScoreOrder
 	} from '@/api/my/index.js'
+	import {
+		downLoad2
+	} from '@/utils/download2.js'
 	export default {
 		components: {},
 		data() {
@@ -65,10 +54,7 @@
 
 				tobheight: 45,
 				resShow: false,
-
-				orderDetail: {
-					status: 0
-				}
+				currScoreOrder: {}
 			};
 		},
 		computed: {
@@ -78,43 +64,39 @@
 
 		},
 		async onLoad(o) {
+			console.log('要查询支付状态的课程ID', Number(uni.getStorageSync('course_id')));
 			let res = await courseDetail({
-				course_id: o.id
+				course_id: Number(uni.getStorageSync('course_id'))
 			})
 			if (res.code == 0) {
 				this.detail = res.data
 			}
 
+			let res1 = await myScoreOrder({})
+			if (res1.code == 0) {
+				// this.detail = res1.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);
+				this.currScoreOrder = res1.data.find((item, index) => {
+					return item.course_id == Number(uni.getStorageSync('course_id'))
+				})
+				// this.currScoreOrder.status = 1
+			}
 			console.log('支付成功--课程详情返回值', res);
-		},
+			console.log('支付成功--所有课程订单列表:', res1);
+			console.log('支付成功--需判断支付状态的课程订单:', this.currScoreOrder, this.currScoreOrder.status);
+
 
+		},
 		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
 			},

+ 228 - 0
pages/index/scorePaySuc/index2.vue

xqd
@@ -0,0 +1,228 @@
+<template>
+	<view class="container">
+		<!-- #ifdef H5 -->
+		<view style="color: #fff;">
+			<tn-nav-bar @back="handleBack" backgroundColor="#26B3A0" :bottomShadow="false"
+				@rightClick="jumpScoreRed">支付状态
+				<!-- 	<template slot="right">
+					课程购买记录
+				</template> -->
+			</tn-nav-bar>
+			<view :style="{ height: tobheight + 'px' }"></view>
+		</view>
+		<!-- #endif -->
+
+
+		<!-- <view class="content" v-if="orderDetail.status"> -->
+		<view class="content">
+			<view class="topIcon">
+				<!-- <image src="../../../static/posImg.png" mode=""></image> -->
+				<icon type="success" size="54" color="#26B3A0" />
+				<view class="txt">
+					支付成功
+				</view>
+			</view>
+			<view class="btn" @click="handleShowRes">
+				{{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 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>
+
+<script>
+	import {
+		courseDetail
+	} from '@/api/score/index.js'
+	import {
+		downLoad2
+	} from '@/utils/download2.js'
+
+	import {
+		myScoreOrderDetail
+	} from '@/api/my/index.js'
+	export default {
+		components: {},
+		data() {
+			return {
+				detail: {},
+
+				tobheight: 45,
+				resShow: false,
+
+				orderDetail: {
+					status: 0
+				}
+			};
+		},
+		computed: {
+
+		},
+		watch: {
+
+		},
+		async onLoad(o) {
+			let res = await courseDetail({
+				course_id: o.id
+			})
+			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
+			},
+
+
+			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>

+ 60 - 0
pages/index/scorePaySuc1/index.scss

xqd
@@ -0,0 +1,60 @@
+page {
+		background: #ededed;
+	}
+.container {
+	padding-bottom: 160rpx;
+		.content{
+			.topIcon{
+				display: flex;
+				flex-direction: column;
+				align-items: center;
+				margin-top: 250rpx;
+				margin-bottom: 200rpx;
+				justify-content: center;
+				image{
+					width: 100rpx;
+					height: 100rpx;
+					border-radius: 50%;
+				}
+				.txt{
+					margin-top: 50rpx;
+					font-size: 34rpx;
+					color:#26B3A0 ;
+				}
+				
+			}
+			.btn{
+				width:90%;
+				background: #26B3A0;
+				height: 100rpx;
+				border-radius: 20rpx;
+				font-size: 30rpx;
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				color: #fff;
+				// font-weight: 600;
+				margin-left: 50%;
+				transform: translateX(-50%);
+			}
+		}
+		
+	}
+	
+	
+	
+	
+	.res{
+		padding-left: 60rpx;
+		padding-right: 30rpx;
+		word-break: break-all;
+		word-wrap: break-word;
+		margin-top: 30rpx;
+		.inner{
+			margin-bottom: 20rpx;
+			// text-decoration: underline;
+			font-size: 34rpx;
+		}
+	}
+	
+	

+ 228 - 0
pages/index/scorePaySuc1/index.vue

xqd
@@ -0,0 +1,228 @@
+<template>
+	<view class="container">
+		<!-- #ifdef H5 -->
+		<view style="color: #fff;">
+			<tn-nav-bar @back="handleBack" backgroundColor="#26B3A0" :bottomShadow="false"
+				@rightClick="jumpScoreRed">支付状态
+				<!-- 	<template slot="right">
+					课程购买记录
+				</template> -->
+			</tn-nav-bar>
+			<view :style="{ height: tobheight + 'px' }"></view>
+		</view>
+		<!-- #endif -->
+
+
+		<!-- <view class="content" v-if="orderDetail.status"> -->
+		<view class="content">
+			<view class="topIcon">
+				<!-- <image src="../../../static/posImg.png" mode=""></image> -->
+				<icon type="success" size="54" color="#26B3A0" />
+				<view class="txt">
+					支付成功
+				</view>
+			</view>
+			<view class="btn" @click="handleShowRes">
+				{{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 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>
+
+<script>
+	import {
+		courseDetail
+	} from '@/api/score/index.js'
+	import {
+		downLoad2
+	} from '@/utils/download2.js'
+
+	import {
+		myScoreOrderDetail
+	} from '@/api/my/index.js'
+	export default {
+		components: {},
+		data() {
+			return {
+				detail: {},
+
+				tobheight: 45,
+				resShow: false,
+
+				orderDetail: {
+					status: 0
+				}
+			};
+		},
+		computed: {
+
+		},
+		watch: {
+
+		},
+		async onLoad(o) {
+			let res = await courseDetail({
+				course_id: o.id
+			})
+			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
+			},
+
+
+			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>

+ 0 - 0
pages/index/scorePaySuc/index1.vue → pages/index/scorePaySuc1/index1.vue


+ 16 - 172
pages/user/score/record/index.vue

xqd xqd xqd xqd xqd xqd xqd
@@ -33,8 +33,8 @@
 			</view>
 			<empty v-else style="margin-top: 50%;"></empty>
 
-			<u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="#26b3a0"
-				@confirm="isPaySuc"></u-modal>
+			<!-- <u-modal :show="payVisiable" title="请确认支付是否已完成" content='' confirmText="查询支付结果" confirmColor="#26b3a0"
+				@confirm="isPaySuc"></u-modal> -->
 		</view>
 	</view>
 </template>
@@ -81,7 +81,7 @@
 				timer: '',
 				currOrderId: -1,
 
-				payVisiable: false
+				// payVisiable: false
 			};
 		},
 		computed: {
@@ -100,47 +100,9 @@
 			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'))
-				// })
-
-				// 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')
-				// 		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);
 		},
@@ -154,78 +116,14 @@
 			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);
-				// 	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)
-
 
+				this.course_id = score.course_id
 				if (score.status) {
-					uni.removeStorageSync('myScoreId')
-					uni.removeStorageSync('clickStudyBtn')
+
 					uni.navigateTo({
 						url: '/pages/user/score/index?id=' + score.id
 					})
@@ -237,17 +135,7 @@
 						confirmColor: 'rgb(38, 179, 160)',
 						success: async (res) => {
 							if (res.confirm) {
-								// 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({
@@ -261,62 +149,16 @@
 										console.log('res2', res2);
 										if (res2.code == 0) {
 
-											uni.setStorageSync('clickStudyBtn', true)
-
-											// _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);
-											// 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);
+											// uni.setStorageSync('clickStudyBtn', true)
+											uni.setStorageSync('course_id', this.course_id)
+											let addRedirectUrl = res2.data + '&redirect_url=' +
+												encodeURIComponent(
+													'https://www.ai5566.cn/h5/pages/index/scorePayMiddle/index?id=' +
+													this.course_id
+												)
+											// return console.log(addRedirectUrl);
+											location.href = addRedirectUrl
 
-											// _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 {
 											if (res2.msg == '订单不存在') {
 												uni.showToast({
@@ -358,6 +200,8 @@
 											wxsdk.wxpay(res3.data, res2.data, (res) => {
 												if (res.errMsg == "chooseWXPay:ok") {
 													setTimeout(() => {
+														uni.setStorageSync('course_id',
+															this.course_id)
 														uni.navigateTo({
 															url: '/pages/index/scorePaySuc/index?id=' +
 																this

+ 1 - 1
pages/user/takenotes/takenotes.vue

xqd
@@ -91,7 +91,7 @@
 				let res = await quesRecord(params)
 				if (res.code == 0) {
 					// this.jobList = res.data.data
-					this.$refs.paging.complete(res.data.data);
+					this.$refs.paging.complete(res.data.data.reverse());
 					this.isLoading = false;
 				}
 				console.log('问答记录返回值', res, this.jobList);

+ 1 - 1
utils/request/responseInterceptors.js

xqd
@@ -41,7 +41,7 @@ module.exports = (vm) => {
 				msg: response.data.msg
 			})
 			return uni.showToast({
-				title: response.data.msg,
+				title: '您的账号已过期',
 				icon: 'none'
 			});