|
@@ -1,84 +1,92 @@
|
|
// 首页数据
|
|
// 首页数据
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
-import { mapState,mapMutations} from 'vuex'
|
|
|
|
|
|
+import { mapState, mapMutations } from 'vuex'
|
|
import authorize from '@/common/config/authorize.js'
|
|
import authorize from '@/common/config/authorize.js'
|
|
const homeMiXins = {
|
|
const homeMiXins = {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
nvabarData: {
|
|
nvabarData: {
|
|
- // 顶部自定义导航
|
|
|
|
- showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
|
|
|
|
- showSearch: 0,
|
|
|
|
- title: '联合丽格集采商城', // 导航栏 中间的标题
|
|
|
|
- haveBack: false,
|
|
|
|
- textLeft: this.$store.state.isIphone,
|
|
|
|
- textColor: '#FFFFFF'
|
|
|
|
|
|
+ // 顶部自定义导航
|
|
|
|
+ showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
|
|
|
|
+ showSearch: 0,
|
|
|
|
+ title: '联合丽格集采商城', // 导航栏 中间的标题
|
|
|
|
+ haveBack: false,
|
|
|
|
+ textLeft: this.$store.state.isIphone,
|
|
|
|
+ textColor: '#FFFFFF'
|
|
},
|
|
},
|
|
CustomBar: this.CustomBar, // 顶部导航栏高度
|
|
CustomBar: this.CustomBar, // 顶部导航栏高度
|
|
skeletonShow: false,
|
|
skeletonShow: false,
|
|
- clubId: 0,
|
|
|
|
- clubStatus: '',
|
|
|
|
|
|
+ userId: 0,
|
|
current: 0,
|
|
current: 0,
|
|
mode: 'round',
|
|
mode: 'round',
|
|
userIdentity: 0,
|
|
userIdentity: 0,
|
|
bannerList: [], // 轮播
|
|
bannerList: [], // 轮播
|
|
mainmenu: [], // 导航分类
|
|
mainmenu: [], // 导航分类
|
|
floorList: [], // 楼层
|
|
floorList: [], // 楼层
|
|
- mallTheme:{}, //活动专题
|
|
|
|
|
|
+ mallTheme: {}, //活动专题
|
|
isScrollTop: false,
|
|
isScrollTop: false,
|
|
|
|
+ authParams: {
|
|
|
|
+ code: '',
|
|
|
|
+ encryptedData: '',
|
|
|
|
+ iv: ''
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['hasLogin', 'userInfo', 'isWxAuthorize'])
|
|
...mapState(['hasLogin', 'userInfo', 'isWxAuthorize'])
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- ...mapMutations(['login', 'logout','updateNoticeNum']),
|
|
|
|
|
|
+ ...mapMutations(['login', 'logout', 'updateNoticeNum']),
|
|
async mallOrganizeHome() {
|
|
async mallOrganizeHome() {
|
|
//初始化首页数据
|
|
//初始化首页数据
|
|
- try{
|
|
|
|
|
|
+ try {
|
|
const res = await this.CommonService.mallOrganizeHome({ organizeId: 4 })
|
|
const res = await this.CommonService.mallOrganizeHome({ organizeId: 4 })
|
|
let data = res.data
|
|
let data = res.data
|
|
this.bannerList = data.bannerList
|
|
this.bannerList = data.bannerList
|
|
this.mainmenu = data.mainmenu
|
|
this.mainmenu = data.mainmenu
|
|
this.floorList = data.floorList
|
|
this.floorList = data.floorList
|
|
this.mallTheme = data.mallTheme
|
|
this.mallTheme = data.mallTheme
|
|
- // if (this.hasLogin) {
|
|
|
|
- // // this.initShoppingCartCount()
|
|
|
|
- // }
|
|
|
|
|
|
+ if (this.hasLogin) {
|
|
|
|
+ this.updateCartCount()
|
|
|
|
+ }
|
|
this.skeletonShow = true
|
|
this.skeletonShow = true
|
|
- }catch(error){
|
|
|
|
|
|
+ } catch (error) {
|
|
//TODO handle the exception
|
|
//TODO handle the exception
|
|
- console.log('error',error)
|
|
|
|
|
|
+ console.log('error', error)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async authApplets() {
|
|
async authApplets() {
|
|
- 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.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)
|
|
|
|
- })
|
|
|
|
- .catch(error => {
|
|
|
|
- this.logout()
|
|
|
|
- uni.setStorageSync('unionId', error.data.unionId)
|
|
|
|
- this.$store.commit('updateStatus', error.data)
|
|
|
|
- })
|
|
|
|
|
|
+ try {
|
|
|
|
+ // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
|
|
|
|
+ const wechatCode = await authorize.getCode('weixin')
|
|
|
|
+ const getUserInfo = await authorize.getUserInfo('weixin')
|
|
|
|
+ this.authParams.code = wechatCode
|
|
|
|
+ this.authParams.encryptedData = getUserInfo.encryptedData
|
|
|
|
+ this.authParams.iv = getUserInfo.iv
|
|
|
|
+ // 调用授权登录
|
|
|
|
+ const res = await this.UserService.UserLoginAuthApplets(this.authParams)
|
|
|
|
+ this.userId = res.data.userId
|
|
|
|
+ this.$store.commit('updateStatus', res.data)
|
|
|
|
+ this.login(res.data)
|
|
|
|
+ uni.setStorageSync('token', res.data.token)
|
|
|
|
+ uni.setStorageSync('unionId', res.data.unionId)
|
|
|
|
+ this.mallOrganizeHome()
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.logout()
|
|
|
|
+ uni.setStorageSync('unionId', error.data.unionId)
|
|
|
|
+ this.$store.commit('updateStatus', error.data)
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- initShoppingCartCount() {
|
|
|
|
- // 获取购物车数量
|
|
|
|
- this.OrderService.ShoppingCartCount({ userId: this.userID }).then(res => {
|
|
|
|
- this.$store.commit('updateAllNum', res.data)
|
|
|
|
- })
|
|
|
|
|
|
+ async updateCartCount() {
|
|
|
|
+ // 获取购物车数量
|
|
|
|
+ try {
|
|
|
|
+ const res = await this.OrderService.ShoppingCartCount({ userId: this.userId })
|
|
|
|
+ this.$store.commit('updateAllNum', res.data)
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log('获取购物车数量异常')
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-export default homeMiXins
|
|
|
|
|
|
+export default homeMiXins
|