12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <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 {
- state_str: ''
- }
- },
- onLoad(options) {
- this.state_str = options.state_str
- this.init()
- },
- methods: {
- ...mapMutations('user', ['SET_USER_INFO']),
- ...mapActions('user', ['wxAutoLogin']),
- ...mapActions('coupon', ['initCouponCount']),
- ...mapActions('cart', ['fetchCartKindCount']),
- async init() {
- await this.initUserInfo()
- await this.initCouponCount()
- await this.fetchCartKindCount()
- },
- // 初始化用户信息
- async initUserInfo() {
- 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.state_str) {
- this.shareHandle(this.state_str)
- } else {
- this.$router.switchTab('home')
- }
- }
- }
- }
- </script>
|