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

update

上级 251c4f3a
......@@ -131,7 +131,7 @@
import { Toast } from 'vant'
import BatchImport from '../components/BatchImport.vue'
import Commonheader from '../components/Commonheader.vue'
import { saveStepInfo } from '../api'
import { saveStepInfo, getOpenid } from '../api'
import allFormList from '@/utils/formList'
export default {
components: { Commonheader, BatchImport },
......@@ -192,6 +192,17 @@ export default {
isRemoveInfo(item) {
return !!item.find(f => f.enable_edit === false)
},
// 微信授权
wxAuthorize() {
if (!this.$route.query.code) {
const url = encodeURIComponent(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 => {
window.sessionStorage.openId = res.openid
})
}
},
// 提交
onSubmit() {
const params = {
......@@ -243,14 +254,22 @@ export default {
// 完成步骤跳转
this.$router.push({ path: '/' })
} else {
this.$emit('next', res.data)
if (!window.sessionStorage.openId) {
this.wxAuthorize()
} else {
this.$emit('next', res.data)
}
}
} else {
if (this.stepList[this.stepList.length - 1].num === this.data.num) {
// 完成步骤跳转
this.$router.push({ path: '/' })
} else {
this.$emit('next', res.data)
if (!window.sessionStorage.openId) {
this.wxAuthorize()
} else {
this.$emit('next', res.data)
}
}
}
this.checkedPay = false
......
......@@ -134,7 +134,7 @@ export default {
stepOrderInfo: [],
payType: [],
// 判断是否是支付宝
isAlipay: /AlipayClient/.test(window.navigator.userAgent),
isAlipay: !/AlipayClient/.test(window.navigator.userAgent),
// 判断微信
isWx: /MicroMessenger/.test(window.navigator.userAgent)
}
......@@ -290,14 +290,14 @@ export default {
if (this.isWx && parseInt(this.payMode) === 1) {
params.pay_type = '3'
// 没有openid去授权获取
if (!window.localStorage.openId) {
if (!window.sessionStorage.openId) {
this.wxAuthorize(res => {
params.openid = res.openid
window.localStorage.openId = res.openid
window.sessionStorage.openId = res.openid
this.getPayInfo(params)
})
} else {
params.openid = window.localStorage.openId
params.openid = window.sessionStorage.openId
this.getPayInfo(params)
}
} else {
......@@ -322,7 +322,8 @@ export default {
window.localStorage.payDetail = JSON.stringify(this.payDetail)
// 支付宝
if (this.isAlipay && parseInt(this.payMode) === 2) {
window.location.href = res.data.url
console.log(res.data.url, 'url')
// window.location.href = res.data.url
}
if (this.isWx && parseInt(this.payMode) === 1) {
// 拉起微信支付
......@@ -333,7 +334,7 @@ export default {
// console.log(res, 'zhifu2')
// }
})
window.sessionStorage.isCodePage = 'wx'
// window.sessionStorage.isCodePage = 'wx'
}
this.isQrPageShow = true
}
......
......@@ -55,15 +55,7 @@ export default {
},
computed: {
setpItem() {
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
return this.stepList[this.stepIndex]
}
},
mounted() {
......@@ -239,7 +231,6 @@ export default {
if (this.$route.query.stepIndex !== undefined) {
this.stepIndex = this.$route.query.stepIndex
}
console.log(this.stepList, '12331')
},
handlePrev() {
if (this.stepIndex <= 0) {
......@@ -247,7 +238,6 @@ export default {
} else {
this.stepIndex--
}
this.setQuery()
},
handleNext(data) {
if (this.setpItem.num !== this.stepList[this.stepList.length - 1].num) {
......@@ -259,9 +249,7 @@ export default {
index: this.stepIndex,
stepList: this.stepList
}
this.setQuery()
window.localStorage.stepData = JSON.stringify(stringData)
this.$route.query.index = this.stepIndex
}
},
setQuery() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论