提交 40899535 authored 作者: lihuihui's avatar lihuihui

update

上级 47cdbb03
HNvRVFt0FD3vltU7
\ No newline at end of file
...@@ -45,3 +45,7 @@ export function importPeople(data) { ...@@ -45,3 +45,7 @@ export function importPeople(data) {
withCredentials: true withCredentials: true
}) })
} }
// 获取openid
export function getOpenid(data) {
return httpRequest.post('/api/register/v2/frontend/wechat/get-openid', data)
}
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
</template> </template>
<script> <script>
import { getPayInfo } from '../api' import { getPayInfo, getOpenid } from '../api'
import PayDetail from './PayDetail.vue' import PayDetail from './PayDetail.vue'
import Commonheader from '../components/Commonheader.vue' import Commonheader from '../components/Commonheader.vue'
import OfflinePay from '../components/OfflinePay.vue' import OfflinePay from '../components/OfflinePay.vue'
...@@ -251,7 +251,23 @@ export default { ...@@ -251,7 +251,23 @@ export default {
onSubmit() { onSubmit() {
this.getPayDetail() this.getPayDetail()
}, },
// 微信授权
wxAuthorize(call) {
if (!this.$route.query.code) {
const url = encodeURIComponent(window.location.href)
console.log(url, '123', window.location.href)
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 => {
call(res)
})
}
},
getPayDetail() { getPayDetail() {
// 判断是否是支付宝
const isAlipay = /AlipayClient/.test(window.navigator.userAgent)
// 判断微信
const isWx = /MicroMessenger/.test(window.navigator.userAgent)
// let ua = window.navigator.userAgent.toLowerCase() // let ua = window.navigator.userAgent.toLowerCase()
// 选择微信和支付宝支付走这 // 选择微信和支付宝支付走这
if (this.payMode !== '3') { if (this.payMode !== '3') {
...@@ -262,7 +278,8 @@ export default { ...@@ -262,7 +278,8 @@ export default {
join_rand: this.data.payData.join_rand, join_rand: this.data.payData.join_rand,
pay_type: this.payMode === '1' ? '1' : '11' pay_type: this.payMode === '1' ? '1' : '11'
} }
if (/AlipayClient/.test(window.navigator.userAgent)) { // 支付宝环境支付
if (isAlipay) {
params.pay_type = '12' params.pay_type = '12'
const url = const url =
window.location.href.indexOf('?') === -1 window.location.href.indexOf('?') === -1
...@@ -271,31 +288,17 @@ export default { ...@@ -271,31 +288,17 @@ export default {
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
} }
// 获取支付二维码 订单id // 微信环境支付
getPayInfo(params).then(res => { console.log(isWx)
this.data.payMode = this.payMode // if (isWx) {
if (res.code === 0) { // this.wxAuthorize((res) => {
this.payDetail = Object.assign({ qrData: res.data }, this.data) // this.getPayInfo(params, isAlipay)
this.payDetail.order_id = res.data.order_id // })
window.localStorage.payDetail = JSON.stringify(this.payDetail) // params.pay_type = '3'
if (/AlipayClient/.test(window.navigator.userAgent)) { // } else {
// window.localStorage.payUrl = res.data.url // this.getPayInfo(params, isAlipay)
window.location.href = res.data.url // }
} this.getPayInfo(params, isAlipay)
this.isQrPageShow = true
}
if (res.code === 100) {
if (this.stepList.length === this.data.num) {
this.$router.push('/')
} else {
this.$emit('next')
}
}
// 订单为0元时,判断该步骤后面是否有步骤,若有就去下一步骤,否则返回首页
if (res.code === 999) {
this.stepList.length === this.data.num ? this.$router.push('/') : this.$emit('next')
}
})
} else { } else {
// 线下支付 // 线下支付
this.data.params = { this.data.params = {
...@@ -304,6 +307,33 @@ export default { ...@@ -304,6 +307,33 @@ export default {
} }
this.isQrPageShow = true this.isQrPageShow = true
} }
},
getPayInfo(params, isAlipay) {
// 获取支付二维码 订单id
getPayInfo(params).then(res => {
this.data.payMode = this.payMode
if (res.code === 0) {
this.payDetail = Object.assign({ qrData: res.data }, this.data)
this.payDetail.order_id = res.data.order_id
window.localStorage.payDetail = JSON.stringify(this.payDetail)
// 支付宝
if (isAlipay) {
window.location.href = res.data.url
}
this.isQrPageShow = true
}
if (res.code === 100) {
if (this.stepList.length === this.data.num) {
this.$router.push('/')
} else {
this.$emit('next')
}
}
// 订单为0元时,判断该步骤后面是否有步骤,若有就去下一步骤,否则返回首页
if (res.code === 999) {
this.stepList.length === this.data.num ? this.$router.push('/') : this.$emit('next')
}
})
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论