帧视界壹通告,付费看视频的微信小程序
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.
 
 
 

145 lines
3.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: '',
},
competitionBanner : '',//比赛页面背景图片
idCardOpenStatus : false,//实名认证状态
paySeeTime : '',//付费查看联系方式,可查看的时间
},
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 => {
// 比赛页面背景图片
if(n.keyValue == 'banner'){
state.competitionBanner = n.content
}
// 付费查看联系方式,可查看的时间
if(n.keyValue == 'time'){
state.paySeeTime = n.content
}
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){
if(state.configList.open && state.configList.open.content != 'Y'){
state.userInfo.headImage = 'https://tennis-oss.xzaiyp.top/2024-10-09/385774b4-d94a-4d45-993a-ae4ddd0b2751.jpg'
state.userInfo.nickName = '帧视界' + Math.floor(Math.random() * 1000000)
api('infoUpdateInfo', {
headImage: state.userInfo.headImage,
nickName: state.userInfo.nickName,
})
return uni.navigateBack(-1)
}
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 || {}
// 实名认证审核状态
state.idCardOpenStatus = state.certifiedIndividual && state.certifiedIndividual.state == 1
}
})
},
},
actions: {},
})
export default store