123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <template>
- <view class=""><tui-skeleton v-if="true" :loadingType="3" :isLoading="true"></tui-skeleton></view>
- </template>
- <script>
- import { mapActions, mapMutations } from 'vuex'
- import shareEntry from './mixins/share-entry.js'
- // 页面初始化
- export default {
- mixins: [shareEntry],
- data() {
- return {
- scene: '',
- state_str: ''
- }
- },
- onLoad(options) {
- this.scene = options.scene
- this.state_str = options.state_str
- this.init()
- },
- methods: {
- ...mapMutations('user', ['SET_USER_INFO']),
- ...mapActions('user', ['wxAutoLogin', 'getAccessToken']),
- ...mapActions('coupon', ['initCouponCount']),
- ...mapActions('cart', ['fetchCartKindCount']),
- async init() {
- await this.getAccessToken()
- await this.initUserInfo()
- await this.initCouponCount()
- await this.fetchCartKindCount()
- },
- // 初始化用户信息
- async initUserInfo() {
- this.$setStorage('ENTRY_MARK_TYPE', 'YES')
- const user = this.$getStorage('USER_INFO')
- if (user) {
- // 用户已登录
- this.SET_USER_INFO(user)
- this.redirectToEntry()
- return Promise.resolve()
- }
- try {
- // 微信登录
- this.wxAutoLogin()
- this.redirectToEntry()
- return Promise.resolve()
- } catch (e) {
- console.log(e)
- }
- },
- // 跳转入口页面
- redirectToEntry() {
- if (this.scene) {
- // 处理分享信息
- this.shareHandle(this.scene, 'scene')
- } else if (this.state_str) {
- this.shareHandle(this.state_str, 'state_str')
- } else {
- // 默认调整首页
- this.$router.switchTab('home')
- }
- }
- }
- }
- </script>
|