提交 9bc28c64 authored 作者: lihuihui's avatar lihuihui

updata

上级 22a04add
...@@ -23,5 +23,5 @@ export function getOpenid(data) { ...@@ -23,5 +23,5 @@ export function getOpenid(data) {
/* 监听支付状态 */ /* 监听支付状态 */
export function getOrderStatus() { export function getOrderStatus() {
return httpRequest.get('/v2/mall/order/status') return httpRequest.get('/zy/v2/mall/order/status')
} }
...@@ -51,11 +51,17 @@ export default { ...@@ -51,11 +51,17 @@ export default {
}) })
}, },
goBuy() { goBuy() {
if (this.isWeapp) { if (window.__wxjs_environment === 'miniprogram') {
wx.miniProgram.navigateTo({ url: `/pages/web/index?src=${window.location.origin}/pay` }) wx.miniProgram.navigateTo({
} else { // url: '/pages/pay/index?data=' + JSON.stringify(obj.data),
window.G.$instance_vue.$router.replace({ url: '/pages/pay/index?data=' + this.requestParam.product_id,
path: '/pay' events: {
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
acceptDataFromOpenedPage: function (data) {
console.log(data)
}
},
success: function (res) {}
}) })
} }
} }
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
<img src="../../assets/images/pages.png" alt=""> <img src="../../assets/images/pages.png" alt="">
<div class="pay-btn"> <div class="pay-btn">
<div class="num">¥<span>199</span>.00</div> <div class="num">¥<span>199</span>.00</div>
<div class="btn" @click="goPay">立即购买</div> <div class="btn" @click="goPay" v-if="orderStatus === 100">立即购买</div>
<div class="btn" v-if="orderStatus === 1" @click="goHome">已购买</div>
<div class="btn" v-if="orderStatus === -1" @click="goMyOrder">待支付</div>
</div> </div>
<!-- <van-button type="primary" @click="goPay" class="pay-btn">购买</van-button> --> <!-- <van-button type="primary" @click="goPay" class="pay-btn">购买</van-button> -->
<!-- <pay-h5 :requestParam="requestParam"></pay-h5> --> <!-- <pay-h5 :requestParam="requestParam"></pay-h5> -->
...@@ -28,24 +30,33 @@ export default { ...@@ -28,24 +30,33 @@ export default {
app_id: '', // 提前设定 app_id: '', // 提前设定
app_secret: '' // 提前设定 app_secret: '' // 提前设定
}, },
orderStatusTime: null orderStatusTime: null,
orderStatus: 100
} }
}, },
mounted() { mounted() {
Toast('222')
window.addEventListener('pageshow', function (event) {
Toast({
duration: 10000,
message: event.persisted
})
if ((event.persisted || window.performance) && window.performance.navigation.type === 2) {
Toast('页面返回')
}
}, false)
this.getOpenid() this.getOpenid()
this.getGoodsDetail() this.getOrderStatus()
}, },
methods: { methods: {
goHome() {
this.pushHistory()
window.addEventListener('popstate', function(e) {
window.location.href = '/'
}, false)
},
pushHistory() {
const state = {
title: '首页',
url: '#'
}
window.history.pushState(state, '首页', '#')
},
goMyOrder() {
this.$router.push({
name: 'buyCourses'
})
},
getOpenid() { getOpenid() {
getUser().then(res => { getUser().then(res => {
api.getOpenid({ id: res.id, identity: 'transport' }).then(res => { api.getOpenid({ id: res.id, identity: 'transport' }).then(res => {
...@@ -57,16 +68,7 @@ export default { ...@@ -57,16 +68,7 @@ export default {
}, },
getOrderStatus() { getOrderStatus() {
api.getOrderStatus().then(res => { api.getOrderStatus().then(res => {
switch (res.status) { this.orderStatus = res.status
case 1:
break
case -1:
break
case 100:
break
default:
}
Toast(res.status)
}) })
}, },
goPay () { goPay () {
...@@ -107,6 +109,9 @@ export default { ...@@ -107,6 +109,9 @@ export default {
// console.log(obj, '======') // console.log(obj, '======')
// }) // })
} }
},
beforeMount() {
window.removeEventListener('popstate', function(e) {}, false)
} }
} }
</script> </script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论