修改微信支付无法使用的问题
This commit is contained in:
109
main.js
109
main.js
@ -8,21 +8,14 @@ import dialog from './utils/dialog'
|
|||||||
import cookie from '@/utils/store/cookie'
|
import cookie from '@/utils/store/cookie'
|
||||||
import cuCustom from '@/components/colorui/components/cu-custom.vue'
|
import cuCustom from '@/components/colorui/components/cu-custom.vue'
|
||||||
|
|
||||||
import {
|
import { parseRoute, _router, parseQuery } from '@/utils'
|
||||||
parseRoute,
|
import { VUE_APP_RESOURCES_URL, VUE_APP_API_URL } from '@/config'
|
||||||
_router,
|
|
||||||
parseQuery
|
|
||||||
} from '@/utils'
|
|
||||||
import {
|
|
||||||
VUE_APP_RESOURCES_URL,
|
|
||||||
VUE_APP_API_URL
|
|
||||||
} from '@/config'
|
|
||||||
Vue.component('cu-custom', cuCustom)
|
Vue.component('cu-custom', cuCustom)
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.config.devtools = process.env.NODE_ENV !== 'production'
|
Vue.config.devtools = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
Vue.prototype.$validator = function(rule) {
|
Vue.prototype.$validator = function(rule) {
|
||||||
return new schema(rule)
|
return new schema(rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
@ -30,20 +23,20 @@ App.mpType = 'app'
|
|||||||
Vue.prototype.$store = store
|
Vue.prototype.$store = store
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
...App,
|
...App,
|
||||||
store,
|
store,
|
||||||
})
|
})
|
||||||
|
|
||||||
Object.defineProperty(Vue.prototype, '$yrouter', {
|
Object.defineProperty(Vue.prototype, '$yrouter', {
|
||||||
get() {
|
get() {
|
||||||
return _router
|
return _router
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
Object.defineProperty(Vue.prototype, '$yroute', {
|
Object.defineProperty(Vue.prototype, '$yroute', {
|
||||||
get() {
|
get() {
|
||||||
return this._route
|
return this._route
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
|
Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
|
||||||
@ -71,35 +64,19 @@ deviceType = 'routine'
|
|||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
// H5编译的代码
|
// H5编译的代码
|
||||||
|
|
||||||
import {
|
import { wechat, clearAuthStatus, oAuth, auth, toAuth, pay, openAddress, openShareAll, openShareAppMessage, openShareTimeline, wechatEvevt, ready, wxShowLocation } from '@/libs/wechat'
|
||||||
wechat,
|
|
||||||
clearAuthStatus,
|
|
||||||
oAuth,
|
|
||||||
auth,
|
|
||||||
toAuth,
|
|
||||||
pay,
|
|
||||||
openAddress,
|
|
||||||
openShareAll,
|
|
||||||
openShareAppMessage,
|
|
||||||
openShareTimeline,
|
|
||||||
wechatEvevt,
|
|
||||||
ready,
|
|
||||||
wxShowLocation
|
|
||||||
} from '@/libs/wechat'
|
|
||||||
|
|
||||||
import {
|
import { isWeixin } from '@/utils'
|
||||||
isWeixin
|
|
||||||
} from '@/utils'
|
|
||||||
const CACHE_KEY = 'clear_0.0.1'
|
const CACHE_KEY = 'clear_0.0.1'
|
||||||
|
|
||||||
if (!cookie.has(CACHE_KEY)) {
|
if (!cookie.has(CACHE_KEY)) {
|
||||||
cookie.clearAll()
|
cookie.clearAll()
|
||||||
cookie.set(CACHE_KEY, 1)
|
cookie.set(CACHE_KEY, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlSpread = parseQuery()['spread']
|
var urlSpread = parseQuery()['spread']
|
||||||
if (urlSpread) {
|
if (urlSpread) {
|
||||||
cookie.set('spread', urlSpread)
|
cookie.set('spread', urlSpread)
|
||||||
}
|
}
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
@ -108,16 +85,15 @@ if (urlSpread) {
|
|||||||
// H5编译的代码
|
// H5编译的代码
|
||||||
// 判断是否是微信浏览器
|
// 判断是否是微信浏览器
|
||||||
async function init() {
|
async function init() {
|
||||||
|
if (isWeixin()) {
|
||||||
if (isWeixin()) {
|
deviceType = 'weixin'
|
||||||
deviceType = 'weixin'
|
let wechatInit = wechat()
|
||||||
let wechatInit = wechat();
|
if (wechatInit) {
|
||||||
if (wechatInit) {
|
await oAuth()
|
||||||
await oAuth()
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
deviceType = 'weixinh5'
|
||||||
deviceType = 'weixinh5'
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
// #endif
|
// #endif
|
||||||
@ -125,27 +101,22 @@ init()
|
|||||||
Vue.prototype.$deviceType = deviceType
|
Vue.prototype.$deviceType = deviceType
|
||||||
|
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
onLoad() {
|
onLoad() {
|
||||||
const {
|
const { $mp } = this.$root
|
||||||
$mp
|
this._route = parseRoute($mp)
|
||||||
} = this.$root
|
},
|
||||||
this._route = parseRoute($mp)
|
onShow() {
|
||||||
},
|
_router.app = this
|
||||||
onShow() {
|
_router.currentRoute = this._route
|
||||||
_router.app = this
|
},
|
||||||
_router.currentRoute = this._route
|
// 这里为了解决 .vue文件中 template 无法获取 VUE.prototype 绑定的变量
|
||||||
},
|
computed: {
|
||||||
// 这里为了解决 .vue文件中 template 无法获取 VUE.prototype 绑定的变量
|
$VUE_APP_RESOURCES_URL() {
|
||||||
computed: {
|
return VUE_APP_RESOURCES_URL
|
||||||
$VUE_APP_RESOURCES_URL() {
|
},
|
||||||
return VUE_APP_RESOURCES_URL
|
},
|
||||||
},
|
|
||||||
$deviceType() {
|
|
||||||
return deviceType
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
store.commit('updateDevicetype', deviceType)
|
store.commit('updateDevicetype', deviceType)
|
||||||
|
|
||||||
app.$mount()
|
app.$mount()
|
||||||
|
@ -268,7 +268,7 @@ export default {
|
|||||||
AddressWindow,
|
AddressWindow,
|
||||||
},
|
},
|
||||||
props: {},
|
props: {},
|
||||||
data: function () {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
offlinePayStatus: 2,
|
offlinePayStatus: 2,
|
||||||
from: this.$deviceType,
|
from: this.$deviceType,
|
||||||
@ -313,7 +313,7 @@ export default {
|
|||||||
this.computedPrice()
|
this.computedPrice()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onShow: function () {
|
onShow: function() {
|
||||||
let that = this
|
let that = this
|
||||||
this.$store.dispatch('getUser', true)
|
this.$store.dispatch('getUser', true)
|
||||||
that.getCartInfo()
|
that.getCartInfo()
|
||||||
@ -338,7 +338,7 @@ export default {
|
|||||||
path: '/pages/shop/StoreList/index',
|
path: '/pages/shop/StoreList/index',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addressType: function (index) {
|
addressType: function(index) {
|
||||||
if (index && !this.systemStore.id) {
|
if (index && !this.systemStore.id) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '暂无门店信息,您无法选择到店自提!',
|
title: '暂无门店信息,您无法选择到店自提!',
|
||||||
@ -350,7 +350,7 @@ export default {
|
|||||||
console.log(this)
|
console.log(this)
|
||||||
this.shipping_type = index
|
this.shipping_type = index
|
||||||
},
|
},
|
||||||
changeUseIntegral: function (e) {
|
changeUseIntegral: function(e) {
|
||||||
// this.computedPrice();
|
// this.computedPrice();
|
||||||
if (this.isIntegral) {
|
if (this.isIntegral) {
|
||||||
return
|
return
|
||||||
@ -410,7 +410,7 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addressTap: function () {
|
addressTap: function() {
|
||||||
this.showAddress = true
|
this.showAddress = true
|
||||||
if (!this.addressLoaded) {
|
if (!this.addressLoaded) {
|
||||||
this.addressLoaded = true
|
this.addressLoaded = true
|
||||||
@ -421,10 +421,10 @@ export default {
|
|||||||
this.addressLoaded = false
|
this.addressLoaded = false
|
||||||
this.showAddress = false
|
this.showAddress = false
|
||||||
},
|
},
|
||||||
couponTap: function () {
|
couponTap: function() {
|
||||||
this.showCoupon = true
|
this.showCoupon = true
|
||||||
},
|
},
|
||||||
changeCoupon: function (coupon) {
|
changeCoupon: function(coupon) {
|
||||||
if (!coupon) {
|
if (!coupon) {
|
||||||
this.usableCoupon = {
|
this.usableCoupon = {
|
||||||
couponTitle: '不使用优惠券',
|
couponTitle: '不使用优惠券',
|
||||||
@ -435,7 +435,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.computedPrice()
|
this.computedPrice()
|
||||||
},
|
},
|
||||||
payItem: function (index) {
|
payItem: function(index) {
|
||||||
this.active = index
|
this.active = index
|
||||||
},
|
},
|
||||||
changeAddress(addressInfo) {
|
changeAddress(addressInfo) {
|
||||||
@ -508,6 +508,7 @@ export default {
|
|||||||
if (this.$deviceType == 'app') {
|
if (this.$deviceType == 'app') {
|
||||||
from.from = 'app'
|
from.from = 'app'
|
||||||
}
|
}
|
||||||
|
console.log(this.$deviceType)
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
subscribeMessage()
|
subscribeMessage()
|
||||||
// #endif
|
// #endif
|
||||||
|
Reference in New Issue
Block a user