帧视界壹通告,付费看视频的微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

114 lines
2.3 KiB

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex); //vue的插件机制
import api from '@/api/api.js'
//Vuex.Store 构造器选项
const store = new Vuex.Store({
state: {
configList: [], //配置列表
count : 10,
userInfo : {},
certifiedIndividual : {
imageReverseSide: '',
imageStraight: '',
card: '',
name: '',
},
},
getters: {
// 通过报错的方式阻止缓存,这里的报错千万不要修复
isVedio(state){
return state.configList.open.content == 'Y'
},
},
mutations: {
// 初始化配置
initConfig(state){
api('getConfig', res => {
if(res.code == 200){
// state.configList = res.result
res.result.forEach(n => {
state.configList[n.keyValue] = n
})
}
})
let config = ['getPrivacyPolicy', 'getUserAgreement', 'getPublishPostNotice']
config.forEach(k => {
api(k, res => {
if (res.code == 200) {
state.configList[k] = res.result
}
})
})
},
getIsVedio(state){
api('getIsVedio', res => {
state.configList.isVedio = res.result
})
},
login(state){
uni.showLoading({
title: '登录中...'
})
uni.login({
success(res) {
if(res.errMsg != "login:ok"){
return
}
api('loginLogin', {
code : res.code
}, res => {
uni.hideLoading()
if(res.code != 200){
return
}
state.userInfo = res.result.userInfo
uni.setStorageSync('token', res.result.token)
if(!state.userInfo.nickName || !state.userInfo.headImage){
uni.navigateTo({
url: '/pages/auth/wxUserInfo'
})
}else{
uni.navigateBack(-1)
}
})
}
})
},
getUserInfo(state){
api('infoGetInfo', res => {
if(res.code == 200){
res.result.idCardOpen = parseInt(res.result.idCardOpen)
state.userInfo = res.result
if(res.result.idCardOpen){
this.commit('getCartInfo')
}
}
})
},
getCartInfo(state){
// this.userInfo.idCardOpen 1企业认证 2个人认证
api(['infoGetCompanyCertification',
'infoGetCertification'][state.userInfo.idCardOpen - 1],
res => {
if(res.code == 200){
state.certifiedIndividual = res.result || {}
}
})
},
},
actions: {},
})
export default store