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

update

上级 47cdbb03
HNvRVFt0FD3vltU7
\ No newline at end of file
......@@ -45,3 +45,7 @@ export function importPeople(data) {
withCredentials: true
})
}
// 获取openid
export function getOpenid(data) {
return httpRequest.post('/api/register/v2/frontend/wechat/get-openid', data)
}
......@@ -108,7 +108,7 @@
</template>
<script>
import { getPayInfo } from '../api'
import { getPayInfo, getOpenid } from '../api'
import PayDetail from './PayDetail.vue'
import Commonheader from '../components/Commonheader.vue'
import OfflinePay from '../components/OfflinePay.vue'
......@@ -251,7 +251,23 @@ export default {
onSubmit() {
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() {
// 判断是否是支付宝
const isAlipay = /AlipayClient/.test(window.navigator.userAgent)
// 判断微信
const isWx = /MicroMessenger/.test(window.navigator.userAgent)
// let ua = window.navigator.userAgent.toLowerCase()
// 选择微信和支付宝支付走这
if (this.payMode !== '3') {
......@@ -262,7 +278,8 @@ export default {
join_rand: this.data.payData.join_rand,
pay_type: this.payMode === '1' ? '1' : '11'
}
if (/AlipayClient/.test(window.navigator.userAgent)) {
// 支付宝环境支付
if (isAlipay) {
params.pay_type = '12'
const url =
window.location.href.indexOf('?') === -1
......@@ -271,6 +288,27 @@ export default {
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)
// }
this.getPayInfo(params, isAlipay)
} else {
// 线下支付
this.data.params = {
pay_record_ids: this.selctOrderData.map(item => item.pay_record.id).toString(),
join_rand: this.data.payData.join_rand
}
this.isQrPageShow = true
}
},
getPayInfo(params, isAlipay) {
// 获取支付二维码 订单id
getPayInfo(params).then(res => {
this.data.payMode = this.payMode
......@@ -278,8 +316,8 @@ export default {
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 (/AlipayClient/.test(window.navigator.userAgent)) {
// window.localStorage.payUrl = res.data.url
// 支付宝
if (isAlipay) {
window.location.href = res.data.url
}
this.isQrPageShow = true
......@@ -296,14 +334,6 @@ export default {
this.stepList.length === this.data.num ? this.$router.push('/') : this.$emit('next')
}
})
} else {
// 线下支付
this.data.params = {
pay_record_ids: this.selctOrderData.map(item => item.pay_record.id).toString(),
join_rand: this.data.payData.join_rand
}
this.isQrPageShow = true
}
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论