123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- // 首页数据
- import Vue from 'vue'
- import { mapState,mapMutations} from 'vuex'
- import authorize from '@/common/config/authorize.js'
- const homeMiXins = {
- data() {
- return {
- bankInfo:{}
- }
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity', 'isWxAuthorize'])
- },
- methods: {
- ...mapMutations(['login', 'logout','updateNoticeNum','updateRossShow']),
- async GetWxAuthorize() {
- const wechatCode = await authorize.getCode('weixin') // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- const getUserInfo = await authorize.getUserInfo('weixin')
- this.UserService.UserLoginAuthApplets({
- code: wechatCode,
- encryptedData: getUserInfo.encryptedData,
- iv: getUserInfo.iv
- })
- .then(response => {
- this.isLogin = true
- this.userID = response.data.userId
- this.clubId = response.data.clubId
- this.userIdentity = response.data.userIdentity
- this.clubStatus = response.data.clubStatus
- this.$store.commit('updateStatus', response.data)
- this.login(response.data)
- uni.setStorageSync('token', response.data.token)
- uni.setStorageSync('unionId', response.data.unionId)
- if (response.data.userIdentity == 1) {
- this.$api.redirectTo('/pages/seller/index/index')
- } else if (response.data.userIdentity === 3) {
- this.$api.redirectTo('/pages/supplier/index/index')
- }
- this.updateRossShow()
- this.GetInitBeansInfo()
- this.getHomeInformation()
- })
- .catch(error => {
- this.isLogin = false
- this.logout()
- uni.setStorageSync('unionId', error.data.unionId)
- this.$store.commit('updateStatus', error.data)
- this.updateRossShow()
- this.getHomeInformation()
- })
- },
- mallOrganizeHome() {
- //初始化首页数据
- this.CommonService.mallOrganizeHome({ organizeId: 1 })
- .then(res => {
- let data = res.data
- if (this.hasLogin) {
- // this.initShoppingCartCount()
- }
- this.skeletonShow = false
- })
- .catch(error => {
- this.$util.msg(error.msg, 2000)
- })
- },
- initShoppingCartCount() {
- // 获取购物车数量
- this.OrderService.ShoppingCartCount({ userId: this.userID }).then(res => {
- this.$store.commit('updateAllNum', res.data)
- })
- }
- }
- }
- export default homeMiXins
|