shop_uniapp/App.vue

93 lines
2.0 KiB
Vue
Raw Normal View History

2024-06-06 09:55:01 +08:00
<script>
import {
mapActions,
mapMutations
} from 'vuex'
import {
getConfig
} from '@/api/app'
import {
sendMsg
} from '@/api/shop'
2024-06-06 09:55:01 +08:00
import {
strToParams
} from '@/utils/tools'
import {
bindSuperior
} from '@/api/user'
import {INVITE_CODE} from '@/config/cachekey'
import Cache from '@/utils/cache'
import { getWxCode } from "@/utils/login";
2024-06-06 09:55:01 +08:00
export default {
onLaunch: function(options) {
//#ifdef MP-WEIXIN
this.checkMpUpdate()
//#endif
this.getConfigFun()
this.getUser()
this.getSystemInfo()
},
onShow: function(options) {
this.bindCode(options)
},
methods: {
...mapActions(['getSystemInfo', 'getUser', 'wxShare', 'initLocationFunc']),
...mapMutations(['setConfig']),
async getConfigFun() {
const {
code,
data
} = await getConfig()
if (code == 1) {
this.setConfig(data)
if(data.is_open_nearby) {
this.initLocationFunc()
}
this.wxShare()
}
},
2024-06-21 16:09:49 +08:00
async bindCode(options, code) {
2024-06-06 09:55:01 +08:00
if(!options.query) return
2024-08-09 15:05:59 +08:00
if (options.query.path == 'goods_details') return
2024-06-06 09:55:01 +08:00
let invite_code = options.query.invite_code || strToParams(decodeURIComponent(options.query.scene))
.invite_code
if (invite_code) {
2024-06-21 16:09:49 +08:00
uni.setStorageSync('invite_code', invite_code)
2024-06-06 09:55:01 +08:00
const {
data,
code
} = await bindSuperior({
2024-06-21 16:09:49 +08:00
code: code || await getWxCode(),
invite_code
2024-06-06 09:55:01 +08:00
})
2024-06-21 16:09:49 +08:00
2024-06-06 09:55:01 +08:00
if (code == -1) {
Cache.set(INVITE_CODE, invite_code)
}
}
},
//#ifdef MP-WEIXIN
checkMpUpdate() {
const updateManager = wx.getUpdateManager()
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已准备好,是否重启?',
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
}
//#endif
}
}
</script>
<style lang="scss">
@import 'styles/common.scss';
@import "components/uview-ui/index.scss";
@import url('@/plugin/emoji-awesome/css/apple.css');
</style>