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

update

上级 40899535
......@@ -24,6 +24,12 @@ modules({ router, store })
router.beforeEach(beforeEnter)
// const originalPush = Router.prototype.push
// Router.prototype.push = function push(location) {
// return originalPush.call(this, location).catch(err => err)
// }
new Vue({
store,
router,
......
......@@ -47,5 +47,5 @@ export function importPeople(data) {
}
// 获取openid
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 {
payDetail: {},
selctOrderData: [], // 选中的数据
stepOrderInfo: [],
payType: []
payType: [],
// 判断是否是支付宝
isAlipay: /AlipayClient/.test(window.navigator.userAgent),
// 判断微信
isWx: /MicroMessenger/.test(window.navigator.userAgent)
}
},
......@@ -161,15 +165,14 @@ export default {
}
},
created() {
if (this.$route.query.qr !== undefined) {
this.payDetail = JSON.parse(window.localStorage.payDetail)
}
// if (this.$route.query.qr !== undefined) {
// this.payDetail = JSON.parse(window.localStorage.payDetail)
// }
},
mounted() {
if (this.isPc()) {
document.getElementById('main_footer').style.width = '400px'
}
// console.log(JSON.parse(window.localStorage.stepData), 'data')
this.payMode = this.data.pay_type[0]
},
methods: {
......@@ -255,7 +258,7 @@ export default {
wxAuthorize(call) {
if (!this.$route.query.code) {
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`
} else {
getOpenid({ code: this.$route.query.code, identity: 'road' }).then(res => {
......@@ -264,11 +267,6 @@ export default {
}
},
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') {
// const ua = window.navigator.userAgent.toLowerCase()
......@@ -279,26 +277,32 @@ export default {
pay_type: this.payMode === '1' ? '1' : '11'
}
// 支付宝环境支付
if (isAlipay) {
params.pay_type = '12'
const url =
window.location.href.indexOf('?') === -1
? `${encodeURIComponent(window.location.href)}?qr=1`
: `${encodeURIComponent(window.location.href)}&qr=1`
params.redirect_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)
// if (this.isAlipay) {
// params.pay_type = '12'
// const url =
// window.location.href.indexOf('?') === -1
// ? `${encodeURIComponent(window.location.href)}?qr=1`
// : `${encodeURIComponent(window.location.href)}&qr=1`
// params.redirect_url =
// window.location.href.indexOf('qr') !== -1 ? encodeURIComponent(window.location.href) : url
// }
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 {
// 线下支付
this.data.params = {
......@@ -308,7 +312,7 @@ export default {
this.isQrPageShow = true
}
},
getPayInfo(params, isAlipay) {
getPayInfo(params) {
// 获取支付二维码 订单id
getPayInfo(params).then(res => {
this.data.payMode = this.payMode
......@@ -317,9 +321,20 @@ export default {
this.payDetail.order_id = res.data.order_id
window.localStorage.payDetail = JSON.stringify(this.payDetail)
// 支付宝
if (isAlipay) {
if (this.isAlipay) {
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
}
if (res.code === 100) {
......
......@@ -16,7 +16,7 @@
:stepList="stepList"
@prev="handlePrev"
@next="handleNext"
v-if="setpItem.type === 2"
v-if="setpItem.type === 2 && stepList.length"
/>
<!-- 支付页面 -->
<order-confirm
......@@ -24,7 +24,7 @@
@next="handleNext"
:stepList="stepList"
:data="setpItem"
v-if="setpItem.type === 3"
v-if="setpItem.type === 3 && stepList.length"
></order-confirm>
</template>
</div>
......@@ -55,22 +55,18 @@ export default {
},
computed: {
setpItem() {
// return this.stepList[2]
return this.stepList[this.stepIndex]
// return this.stepList[this.$route.query.id ? this.stepIndex : this.stepIndex + 1]
// console.log(this.stepList, this.$route.query.index)
let item = {}
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() {
if (this.$route.query.qr === undefined) {
if (this.$route.query.id) {
......@@ -244,6 +240,7 @@ export default {
if (this.$route.query.stepIndex !== undefined) {
this.stepIndex = this.$route.query.stepIndex
}
console.log(this.stepList, '12331')
},
handlePrev() {
if (this.stepIndex <= 0) {
......@@ -251,6 +248,7 @@ export default {
} else {
this.stepIndex--
}
this.setQuery()
},
handleNext(data) {
if (this.setpItem.num !== this.stepList[this.stepList.length - 1].num) {
......@@ -262,7 +260,28 @@ export default {
index: this.stepIndex,
stepList: this.stepList
}
this.setQuery()
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论