提交 18b01cd9 authored 作者: lihuihui's avatar lihuihui

update

上级 40899535
...@@ -24,6 +24,12 @@ modules({ router, store }) ...@@ -24,6 +24,12 @@ modules({ router, store })
router.beforeEach(beforeEnter) router.beforeEach(beforeEnter)
// const originalPush = Router.prototype.push
// Router.prototype.push = function push(location) {
// return originalPush.call(this, location).catch(err => err)
// }
new Vue({ new Vue({
store, store,
router, router,
......
...@@ -47,5 +47,5 @@ export function importPeople(data) { ...@@ -47,5 +47,5 @@ export function importPeople(data) {
} }
// 获取openid // 获取openid
export function getOpenid(data) { export function getOpenid(data) {
return httpRequest.post('/api/register/v2/frontend/wechat/get-openid', data) return httpRequest.post('/api/usercenter/v2/frontend/wechat/get-openid', data)
} }
...@@ -132,7 +132,11 @@ export default { ...@@ -132,7 +132,11 @@ export default {
payDetail: {}, payDetail: {},
selctOrderData: [], // 选中的数据 selctOrderData: [], // 选中的数据
stepOrderInfo: [], stepOrderInfo: [],
payType: [] payType: [],
// 判断是否是支付宝
isAlipay: /AlipayClient/.test(window.navigator.userAgent),
// 判断微信
isWx: /MicroMessenger/.test(window.navigator.userAgent)
} }
}, },
...@@ -161,15 +165,14 @@ export default { ...@@ -161,15 +165,14 @@ export default {
} }
}, },
created() { created() {
if (this.$route.query.qr !== undefined) { // if (this.$route.query.qr !== undefined) {
this.payDetail = JSON.parse(window.localStorage.payDetail) // this.payDetail = JSON.parse(window.localStorage.payDetail)
} // }
}, },
mounted() { mounted() {
if (this.isPc()) { if (this.isPc()) {
document.getElementById('main_footer').style.width = '400px' document.getElementById('main_footer').style.width = '400px'
} }
// console.log(JSON.parse(window.localStorage.stepData), 'data')
this.payMode = this.data.pay_type[0] this.payMode = this.data.pay_type[0]
}, },
methods: { methods: {
...@@ -255,7 +258,7 @@ export default { ...@@ -255,7 +258,7 @@ export default {
wxAuthorize(call) { wxAuthorize(call) {
if (!this.$route.query.code) { if (!this.$route.query.code) {
const url = encodeURIComponent(window.location.href) const url = encodeURIComponent(window.location.href)
console.log(url, '123', window.location.href) console.log(url)
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa41d0081d4889921&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect` window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa41d0081d4889921&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
} else { } else {
getOpenid({ code: this.$route.query.code, identity: 'road' }).then(res => { getOpenid({ code: this.$route.query.code, identity: 'road' }).then(res => {
...@@ -264,11 +267,6 @@ export default { ...@@ -264,11 +267,6 @@ export default {
} }
}, },
getPayDetail() { getPayDetail() {
// 判断是否是支付宝
const isAlipay = /AlipayClient/.test(window.navigator.userAgent)
// 判断微信
const isWx = /MicroMessenger/.test(window.navigator.userAgent)
// let ua = window.navigator.userAgent.toLowerCase()
// 选择微信和支付宝支付走这 // 选择微信和支付宝支付走这
if (this.payMode !== '3') { if (this.payMode !== '3') {
// const ua = window.navigator.userAgent.toLowerCase() // const ua = window.navigator.userAgent.toLowerCase()
...@@ -279,26 +277,32 @@ export default { ...@@ -279,26 +277,32 @@ export default {
pay_type: this.payMode === '1' ? '1' : '11' pay_type: this.payMode === '1' ? '1' : '11'
} }
// 支付宝环境支付 // 支付宝环境支付
if (isAlipay) { // if (this.isAlipay) {
params.pay_type = '12' // params.pay_type = '12'
const url = // const url =
window.location.href.indexOf('?') === -1 // window.location.href.indexOf('?') === -1
? `${encodeURIComponent(window.location.href)}?qr=1` // ? `${encodeURIComponent(window.location.href)}?qr=1`
: `${encodeURIComponent(window.location.href)}&qr=1` // : `${encodeURIComponent(window.location.href)}&qr=1`
params.redirect_url = // params.redirect_url =
window.location.href.indexOf('qr') !== -1 ? encodeURIComponent(window.location.href) : url // window.location.href.indexOf('qr') !== -1 ? encodeURIComponent(window.location.href) : url
}
// 微信环境支付
console.log(isWx)
// if (isWx) {
// this.wxAuthorize((res) => {
// this.getPayInfo(params, isAlipay)
// })
// params.pay_type = '3'
// } else {
// this.getPayInfo(params, isAlipay)
// } // }
this.getPayInfo(params, isAlipay) // 微信环境支付
if (this.isWx) {
params.pay_type = '3'
// 没有openid去授权获取
if (!window.localStorage.openId) {
this.wxAuthorize(res => {
params.openid = res.openid
window.localStorage.openId = res.openid
this.getPayInfo(params)
})
} else {
params.openid = window.localStorage.openId
this.getPayInfo(params)
}
} else {
this.getPayInfo(params)
}
} else { } else {
// 线下支付 // 线下支付
this.data.params = { this.data.params = {
...@@ -308,7 +312,7 @@ export default { ...@@ -308,7 +312,7 @@ export default {
this.isQrPageShow = true this.isQrPageShow = true
} }
}, },
getPayInfo(params, isAlipay) { getPayInfo(params) {
// 获取支付二维码 订单id // 获取支付二维码 订单id
getPayInfo(params).then(res => { getPayInfo(params).then(res => {
this.data.payMode = this.payMode this.data.payMode = this.payMode
...@@ -317,9 +321,20 @@ export default { ...@@ -317,9 +321,20 @@ export default {
this.payDetail.order_id = res.data.order_id this.payDetail.order_id = res.data.order_id
window.localStorage.payDetail = JSON.stringify(this.payDetail) window.localStorage.payDetail = JSON.stringify(this.payDetail)
// 支付宝 // 支付宝
if (isAlipay) { if (this.isAlipay) {
window.location.href = res.data.url window.location.href = res.data.url
} }
if (this.isWx) {
// 拉起微信支付
window.WeixinJSBridge.invoke('getBrandWCPayRequest', JSON.parse(res.data.more_info), res => {
// if (res.err_msg === 'get_brand_wcpay_request:ok') {
// console.log(res, 'zhifu')
// } else {
// console.log(res, 'zhifu2')
// }
})
}
window.sessionStorage.isCodePage = true
this.isQrPageShow = true this.isQrPageShow = true
} }
if (res.code === 100) { if (res.code === 100) {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
:stepList="stepList" :stepList="stepList"
@prev="handlePrev" @prev="handlePrev"
@next="handleNext" @next="handleNext"
v-if="setpItem.type === 2" v-if="setpItem.type === 2 && stepList.length"
/> />
<!-- 支付页面 --> <!-- 支付页面 -->
<order-confirm <order-confirm
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
@next="handleNext" @next="handleNext"
:stepList="stepList" :stepList="stepList"
:data="setpItem" :data="setpItem"
v-if="setpItem.type === 3" v-if="setpItem.type === 3 && stepList.length"
></order-confirm> ></order-confirm>
</template> </template>
</div> </div>
...@@ -55,22 +55,18 @@ export default { ...@@ -55,22 +55,18 @@ export default {
}, },
computed: { computed: {
setpItem() { setpItem() {
// return this.stepList[2] // console.log(this.stepList, this.$route.query.index)
return this.stepList[this.stepIndex] let item = {}
// return this.stepList[this.$route.query.id ? this.stepIndex : this.stepIndex + 1] const queryIndex = parseInt(this.$route.query.index)
if (queryIndex && queryIndex !== 0) {
item = JSON.parse(window.localStorage.stepData).stepList[queryIndex]
} else {
item = this.stepList[this.stepIndex]
}
// return this.stepList[this.$route.query.index !== undefined ? parseInt(this.$route.query.index) : this.stepIndex]
return item
} }
}, },
// watch: {
// '$route.query': {
// immediate: true,
// handler(query) {
// console.log(query)
// if (query.stepIndex) {
// this.stepIndex = query.stepIndex
// }
// }
// }
// },
mounted() { mounted() {
if (this.$route.query.qr === undefined) { if (this.$route.query.qr === undefined) {
if (this.$route.query.id) { if (this.$route.query.id) {
...@@ -244,6 +240,7 @@ export default { ...@@ -244,6 +240,7 @@ export default {
if (this.$route.query.stepIndex !== undefined) { if (this.$route.query.stepIndex !== undefined) {
this.stepIndex = this.$route.query.stepIndex this.stepIndex = this.$route.query.stepIndex
} }
console.log(this.stepList, '12331')
}, },
handlePrev() { handlePrev() {
if (this.stepIndex <= 0) { if (this.stepIndex <= 0) {
...@@ -251,6 +248,7 @@ export default { ...@@ -251,6 +248,7 @@ export default {
} else { } else {
this.stepIndex-- this.stepIndex--
} }
this.setQuery()
}, },
handleNext(data) { handleNext(data) {
if (this.setpItem.num !== this.stepList[this.stepList.length - 1].num) { if (this.setpItem.num !== this.stepList[this.stepList.length - 1].num) {
...@@ -262,7 +260,28 @@ export default { ...@@ -262,7 +260,28 @@ export default {
index: this.stepIndex, index: this.stepIndex,
stepList: this.stepList stepList: this.stepList
} }
this.setQuery()
window.localStorage.stepData = JSON.stringify(stringData) window.localStorage.stepData = JSON.stringify(stringData)
this.$route.query.index = this.stepIndex
}
},
setQuery() {
const query = {
id: this.$route.query.id,
index: this.stepIndex
}
if (this.$route.query.index) {
if (this.stepIndex !== parseInt(this.$route.query.index)) {
this.$router.push({
path: window.location.pathname,
query: query
})
}
} else {
this.$router.push({
path: window.location.pathname,
query: query
})
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论