|
|
@ -9,29 +9,29 @@ import i18n from '@/locale/index.js' |
|
|
|
//Vuex.Store 构造器选项
|
|
|
|
const store = new Vuex.Store({ |
|
|
|
state: { |
|
|
|
token:uni.getStorageSync('token') || '', |
|
|
|
token: uni.getStorageSync('token') || '', |
|
|
|
configList: {}, //配置列表
|
|
|
|
userInfo : uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')) : {}, //用户信息
|
|
|
|
userInfo: uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')) : {}, //用户信息
|
|
|
|
// riceInfo : {},//用户相关信息
|
|
|
|
areaList : [],//地区列表信息
|
|
|
|
selectArea : {},//当前选择的地区
|
|
|
|
areaList: [], //地区列表信息
|
|
|
|
selectArea: {}, //当前选择的地区
|
|
|
|
}, |
|
|
|
getters: { |
|
|
|
userInfo:state => state.userInfo, |
|
|
|
isLogin:state => state.token ? true : false |
|
|
|
userInfo: state => state.userInfo, |
|
|
|
isLogin: state => state.token ? true : false |
|
|
|
}, |
|
|
|
mutations: { |
|
|
|
// 初始化配置
|
|
|
|
initConfig(state){ |
|
|
|
initConfig(state) { |
|
|
|
api('getConfig', res => { |
|
|
|
if(res.code == 200){ |
|
|
|
if (res.code == 200) { |
|
|
|
res.result.forEach(n => { |
|
|
|
state.configList[n.keyName] = n.keyContent |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log("initConfig===============", res); |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// let config = ['getPrivacyPolicy', 'getUserAgreement']
|
|
|
|
// config.forEach(k => {
|
|
|
|
// api(k, res => {
|
|
|
@ -41,59 +41,60 @@ const store = new Vuex.Store({ |
|
|
|
// })
|
|
|
|
// })
|
|
|
|
}, |
|
|
|
login(state,commit){ |
|
|
|
login(state, commit) { |
|
|
|
uni.showLoading({ |
|
|
|
title: i18n.t('common.logging_in') // 登录中...
|
|
|
|
}) |
|
|
|
uni.login({ |
|
|
|
success(res) { |
|
|
|
if(res.errMsg != "login:ok"){ |
|
|
|
if (res.errMsg != "login:ok") { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let data = { |
|
|
|
code : res.code |
|
|
|
code: res.code |
|
|
|
} |
|
|
|
|
|
|
|
if(uni.getStorageSync('shareId')){ |
|
|
|
|
|
|
|
if (uni.getStorageSync('shareId')) { |
|
|
|
data.shareId = uni.getStorageSync('shareId') |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
api('wxLogin', data, res => { |
|
|
|
|
|
|
|
|
|
|
|
uni.hideLoading() |
|
|
|
|
|
|
|
if(res.code != 200){ |
|
|
|
|
|
|
|
if (res.code != 200) { |
|
|
|
return |
|
|
|
} |
|
|
|
state.userInfo = res.result.userInfo |
|
|
|
state.token = res.result.token |
|
|
|
uni.setStorageSync('token', res.result.token) |
|
|
|
if(!state.userInfo.nickName || !state.userInfo.headImage){ |
|
|
|
if (!state.userInfo.nickName || !state.userInfo.headImage) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages_login/wxUserInfo' |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
uni.switchTab({ |
|
|
|
url:'/pages/index/index' |
|
|
|
url: '/pages/index/index' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
getUserInfo(state){ |
|
|
|
getUserInfo(state) { |
|
|
|
api('getInfo', res => { |
|
|
|
if(res.code == 200){ |
|
|
|
uni.setStorageSync('userInfo',JSON.stringify(res.result)) |
|
|
|
if (res.code == 200) { |
|
|
|
uni.setStorageSync('userInfo', JSON.stringify(res.result)) |
|
|
|
state.userInfo = res.result |
|
|
|
|
|
|
|
if(!state.userInfo.nickName || |
|
|
|
!state.userInfo.headImage || |
|
|
|
!state.userInfo.phone || |
|
|
|
!state.userInfo.sex){ |
|
|
|
|
|
|
|
if (!state.userInfo.nickName || |
|
|
|
!state.userInfo.headImage || |
|
|
|
!state.userInfo.phone || |
|
|
|
!state.userInfo.sex) { |
|
|
|
uni.showToast({ |
|
|
|
title: i18n.t('pages_order.huodong_detail.complete_info_required') // 请您先完善必要信息
|
|
|
|
title: i18n.t( |
|
|
|
'pages_order.huodong_detail.complete_info_required') // 请您先完善必要信息
|
|
|
|
}) |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages_login/wxUserInfo' |
|
|
@ -112,7 +113,7 @@ const store = new Vuex.Store({ |
|
|
|
// })
|
|
|
|
// },
|
|
|
|
// 退出登录
|
|
|
|
logout(state){ |
|
|
|
logout(state) { |
|
|
|
uni.showModal({ |
|
|
|
title: i18n.t('common.confirm_logout'), // 确认退出登录吗
|
|
|
|
success(r) { |
|
|
@ -128,25 +129,32 @@ const store = new Vuex.Store({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 查询地区
|
|
|
|
getArea(state, fn){ |
|
|
|
getArea(state, fn) { |
|
|
|
api('getArea', res => { |
|
|
|
if(res.code == 200){ |
|
|
|
|
|
|
|
res.result.unshift({ |
|
|
|
city : i18n.t('common.all'), // 全部
|
|
|
|
id : '', |
|
|
|
}) |
|
|
|
|
|
|
|
if (res.code == 200) { |
|
|
|
|
|
|
|
res.result.unshift({ |
|
|
|
city: i18n.t('common.all'), // 全部
|
|
|
|
id: '', |
|
|
|
}) |
|
|
|
|
|
|
|
state.areaList = res.result |
|
|
|
fn && fn(res.result) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
setArea(state, index){ |
|
|
|
setArea(state, index) { |
|
|
|
state.selectArea = state.areaList[index] |
|
|
|
}, |
|
|
|
hanlderManager(state, fn){ |
|
|
|
api('joinRecruitInfo') |
|
|
|
.then(res => { |
|
|
|
fn && fn(res) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
actions: { |
|
|
|
}, |
|
|
|
actions: {}, |
|
|
|
}) |
|
|
|
|
|
|
|
export default store |