shop_uniapp/App.vue

104 lines
2.2 KiB
Vue
Raw Permalink 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'
2024-12-16 17:47:48 +08:00
import {
INVITE_CODE
} from '@/config/cachekey'
2024-06-06 09:55:01 +08:00
import Cache from '@/utils/cache'
2024-12-16 17:47:48 +08:00
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)
2024-12-16 17:47:48 +08:00
if (data.is_open_nearby) {
2024-06-06 09:55:01 +08:00
this.initLocationFunc()
}
this.wxShare()
}
},
2024-06-21 16:09:49 +08:00
async bindCode(options, code) {
2024-12-16 17:47:48 +08:00
if (!options.query) return
2025-01-05 13:16:38 +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
2025-01-05 13:16:38 +08:00
let source = options.query.source || ''
2024-06-06 09:55:01 +08:00
if (invite_code) {
2025-01-05 13:16:38 +08:00
if (uni.getLaunchOptionsSync().scene == 1154 && source == 'pyq') {
//朋友圈单页不走登录
return
}
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-12-16 17:47:48 +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()
2024-12-16 17:47:48 +08:00
if (updateManager) {
updateManager.onUpdateReady(function() {
wx.showModal({
title: '更新提示',
content: '新版本已准备好,是否重启?',
success: function(res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
}
2024-06-06 09:55:01 +08:00
}
//#endif
}
}
</script>
<style lang="scss">
@import 'styles/common.scss';
@import "components/uview-ui/index.scss";
@import url('@/plugin/emoji-awesome/css/apple.css');
2024-12-16 17:47:48 +08:00
</style>