|
@@ -37,6 +37,9 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ const isWechat = () => {
|
|
|
|
+ return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
|
|
|
|
+ }
|
|
import {
|
|
import {
|
|
mapMutations,
|
|
mapMutations,
|
|
mapActions,
|
|
mapActions,
|
|
@@ -70,94 +73,233 @@
|
|
tobheight: 45,
|
|
tobheight: 45,
|
|
|
|
|
|
scoreOrderList: [],
|
|
scoreOrderList: [],
|
|
- course_id: ''
|
|
|
|
|
|
+ course_id: '',
|
|
|
|
+
|
|
|
|
+ timer: '',
|
|
|
|
+ currOrderId: -1
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapGetters(['appInfo', 'isLogin', 'userInfo'])
|
|
...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() {
|
|
async onLoad() {
|
|
- // let res = await myScoreOrder()
|
|
|
|
- // if (res.code == 0) {
|
|
|
|
- // this.scoreOrderList = res.data
|
|
|
|
- // }
|
|
|
|
- // console.log('我的课程订单返回值', res);
|
|
|
|
|
|
+ window.addEventListener('beforeunload', this.handleRefresh)
|
|
},
|
|
},
|
|
async onShow() {
|
|
async onShow() {
|
|
|
|
+ // clearInterval(this.timer)
|
|
|
|
+
|
|
let res = await myScoreOrder()
|
|
let res = await myScoreOrder()
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
this.scoreOrderList = res.data
|
|
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);
|
|
console.log('我的课程订单返回值', res);
|
|
},
|
|
},
|
|
|
|
+ onHide() {
|
|
|
|
+ // clearInterval(this.timer)
|
|
|
|
+ },
|
|
|
|
+ onUnload() {
|
|
|
|
+ window.removeEventListener('beforeunload', this.handleRefresh)
|
|
|
|
+ },
|
|
methods: {
|
|
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) {
|
|
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
|
|
this.course_id = score.course_id
|
|
|
|
|
|
|
|
+ uni.setStorageSync('myScoreId', score.course_id)
|
|
|
|
+
|
|
|
|
+
|
|
if (score.status) {
|
|
if (score.status) {
|
|
|
|
+ uni.removeStorageSync('myScoreId')
|
|
|
|
+ uni.removeStorageSync('clickStudyBtn')
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
url: '/pages/user/score/index?id=' + score.id
|
|
url: '/pages/user/score/index?id=' + score.id
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
|
|
+ let _this = this
|
|
uni.showModal({
|
|
uni.showModal({
|
|
title: '提示',
|
|
title: '提示',
|
|
content: '当前订单状态为待支付,确认继续支付?',
|
|
content: '当前订单状态为待支付,确认继续支付?',
|
|
confirmColor: 'rgb(38, 179, 160)',
|
|
confirmColor: 'rgb(38, 179, 160)',
|
|
success: async (res) => {
|
|
success: async (res) => {
|
|
if (res.confirm) {
|
|
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({
|
|
uni.showToast({
|
|
- title: res.msg,
|
|
|
|
|
|
+ title: res2.msg,
|
|
icon: 'none',
|
|
icon: 'none',
|
|
duration: 1500
|
|
duration: 1500
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.msg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
}
|
|
}
|
|
} else {
|
|
} 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) {
|
|
} else if (res.cancel) {
|
|
|
|
|
|
}
|
|
}
|