提交 fe3e1690 authored 作者: pengxiaohui's avatar pengxiaohui

openid存储

上级 5f5f1dda
...@@ -68,7 +68,8 @@ export default { ...@@ -68,7 +68,8 @@ export default {
payment_order_id: '', payment_order_id: '',
payment_method: '12', payment_method: '12',
order_params: '', order_params: '',
order_details_url: window.location.origin + '/order-details' order_details_url: window.location.origin + '/order-details',
openId: ''
} }
}, },
computed: { computed: {
...@@ -81,17 +82,15 @@ export default { ...@@ -81,17 +82,15 @@ export default {
}, },
shop_id () { shop_id () {
return this.query.shop_id || '6800681447305773056' return this.query.shop_id || '6800681447305773056'
},
openId () {
let openId = window.localStorage.getItem('openId')
if (openId === 'undefined' || openId === 'null') openId = ''
return openId // 'oF3a-t9pFpmL2gWuTmtWs5HlDGkU'
} }
}, },
beforeMount() { beforeMount() {
this.fetchGoodsDetails() this.fetchGoodsDetails()
this.fetchShopDetails() this.fetchShopDetails()
if (this.isWxBrowser && !this.openId) { let openId = window.localStorage.getItem('openId')
if (openId === 'undefined' || openId === 'null') openId = ''
this.openId = openId // 'oF3a-t9pFpmL2gWuTmtWs5HlDGkU'
if (this.isWxBrowser && !openId) {
const { code } = this.$route.query const { code } = this.$route.query
if (code) this.fetchOpenId(code) if (code) this.fetchOpenId(code)
else this.getCode() else this.getCode()
...@@ -142,7 +141,10 @@ export default { ...@@ -142,7 +141,10 @@ export default {
fetchOpenId(code) { fetchOpenId(code) {
getOpenId({ code, identity: 'ezijing' }).then(response => { getOpenId({ code, identity: 'ezijing' }).then(response => {
if (response.code === 0) { if (response.code === 0) {
if (response.openid) window.localStorage.setItem('openId', response.openid || '') if (response.openid) {
this.openId = response.openid || ''
window.localStorage.setItem('openId', response.openid || '')
}
else window.localStorage.removeItem('openId') else window.localStorage.removeItem('openId')
} else { } else {
this.getCode() this.getCode()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论