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.
240 lines
5.1 KiB
240 lines
5.1 KiB
import $util from "@/utils/index.js"
|
|
import $api from "@/api/index.js"
|
|
import $store from "@/store/index.js"
|
|
import {
|
|
req
|
|
} from '@/utils/req.js';
|
|
export default {
|
|
state: {
|
|
autograph: '',
|
|
userInfo: '',
|
|
appLogin: '',
|
|
commonOptions: {
|
|
coupon_atv_id: 0,
|
|
channel_id: 0
|
|
},
|
|
location: {},
|
|
wxlocation: {},
|
|
isShowAuth: true,
|
|
mineInfo: {},
|
|
isFinished:null,//1为登录,2为不登陆
|
|
userPageType: 1, // 1用户,2技师
|
|
audioBg: {},
|
|
playBg: false,
|
|
isHaveAudio: false
|
|
},
|
|
mutations: {
|
|
//更新内容
|
|
async updateUserItem(state, item) {
|
|
|
|
let {
|
|
key,
|
|
val
|
|
} = item
|
|
if (key == 'userInfo') {
|
|
let {
|
|
phone = '',
|
|
create_time,
|
|
} = val
|
|
if (phone) {
|
|
val.split_phone = phone.substring(0, 3) + '****' + phone.substring(7, 11)
|
|
}
|
|
val.create_date = $util.formatTime(create_time * 1000, 'YY-M-D')
|
|
}
|
|
state[key] = val
|
|
if (['autograph', 'userInfo', 'location', 'appLogin'].includes(key)) {
|
|
uni.setStorageSync(key, val)
|
|
}
|
|
},
|
|
setUnfinished(state,item){
|
|
console.log(item,"item")
|
|
state.isFinished = item
|
|
}
|
|
},
|
|
actions: {
|
|
//获取个人信息
|
|
async getUserInfo({
|
|
commit,
|
|
state
|
|
}, param) {
|
|
console.log("============user.js getUserInfo")
|
|
let data = await $api.user.userInfo()
|
|
commit('updateUserItem', {
|
|
key: 'userInfo',
|
|
val: data
|
|
})
|
|
},
|
|
//获取用户个人中心数据
|
|
async getMineInfo({
|
|
commit,
|
|
dispatch,
|
|
state
|
|
}, param) {
|
|
let data = await $api.mine.index()
|
|
let {
|
|
fx_status
|
|
} = data
|
|
// data.coach_status = 2
|
|
// data.service_time_long=25
|
|
commit('updateUserItem', {
|
|
key: 'mineInfo',
|
|
val: data
|
|
})
|
|
let timer;
|
|
let newList;
|
|
if(param==1){
|
|
if(data.coach_status==2){
|
|
newList = await $api.technician.orderList({
|
|
page: 1,pay_type: 2
|
|
})
|
|
if(newList.total!=0){
|
|
// dispatch('toPlayAudio1',1)
|
|
}
|
|
// timer = setInterval(async()=>{
|
|
// newList = await $api.technician.orderList({
|
|
// page: 1,pay_type: 2
|
|
// })
|
|
// if(newList.total!=0){
|
|
// dispatch('toPlayAudio1',1)
|
|
// }
|
|
// },300000)
|
|
// commit('setUnfinished', {haveUnfinished:haveUnfinished});
|
|
}
|
|
}else{
|
|
clearInterval(timer);
|
|
// state.audioBg = uni.createInnerAudioContext();
|
|
// state.audioBg.src=null;
|
|
// state.audioBg?state.audioBg.stop():null;
|
|
}
|
|
|
|
},
|
|
stopMusic({state}){
|
|
state.audioBg = uni.createInnerAudioContext();
|
|
state.audioBg.src=null;
|
|
// state.audioBg?state.audioBg.stop():null;
|
|
state.audioBg.stop()
|
|
},
|
|
// async toPlayAudio1({
|
|
// commit,
|
|
// state
|
|
// }, param) {
|
|
// console.log("播放",state.playBg)
|
|
|
|
// let val = await $api.base.configInfo()
|
|
|
|
// state.audioBg = uni.createInnerAudioContext();
|
|
// state.isHaveAudio = true
|
|
// let {
|
|
// countdown_voice
|
|
// } = val
|
|
// state.audioBg.src = countdown_voice
|
|
// state.playBg = true;
|
|
// // #ifndef APP-PLUS
|
|
// state.audioBg.obeyMuteSwitch = false
|
|
// // #endif
|
|
// let play_method = [{
|
|
// method: 'onPlay',
|
|
// msg: '开始播放',
|
|
// status: true,
|
|
// }, {
|
|
// method: 'onStop',
|
|
// msg: '结束播放',
|
|
// status: false,
|
|
// }, {
|
|
// method: 'onError',
|
|
// msg: '报错Error',
|
|
// status: false,
|
|
// }, {
|
|
// method: 'onEnded',
|
|
// msg: '自然结束播放',
|
|
// status: false,
|
|
// }];
|
|
// play_method.map(item => {
|
|
// state.audioBg[item.method](() => {
|
|
// console.log('bg=>', item.msg)
|
|
// state.playBg = item.status;
|
|
// })
|
|
// })
|
|
// if (!state.playBg||param==2) {
|
|
// console.log("999")
|
|
// state.audioBg.pause()
|
|
// }else{
|
|
// state.audioBg.play()
|
|
// }
|
|
// // state.audioBg.play()
|
|
|
|
// },
|
|
// 获取用户信息
|
|
async getAuthUserProfile({
|
|
commit,
|
|
state
|
|
}, param) {
|
|
let {
|
|
nickName,
|
|
avatarUrl
|
|
} = param
|
|
await $api.user.userUpdate(param)
|
|
let data = Object.assign(state.userInfo, {
|
|
nickName,
|
|
avatarUrl
|
|
})
|
|
commit('updateUserItem', {
|
|
key: 'userInfo',
|
|
val: data
|
|
})
|
|
},
|
|
// 获取手机号
|
|
async getAuthPhone({
|
|
commit,
|
|
state
|
|
}, {
|
|
e = {
|
|
detail: {}
|
|
},
|
|
must = false
|
|
} = {}) {
|
|
let {
|
|
encryptedData = '', iv = ''
|
|
} = e.detail;
|
|
let phone = ''
|
|
if (encryptedData && iv) {
|
|
let phone = await $api.user.reportPhone({
|
|
encryptedData,
|
|
iv
|
|
})
|
|
console.log(phone, "=====phone")
|
|
let data = Object.assign(state.userInfo, {
|
|
phone
|
|
})
|
|
commit('updateUserItem', {
|
|
key: 'userInfo',
|
|
val: data
|
|
})
|
|
console.log(data, state.userInfo, "===========")
|
|
return phone;
|
|
}
|
|
},
|
|
// 更新公共参数
|
|
async updateCommonOptions({
|
|
commit,
|
|
state
|
|
}, param) {
|
|
let target = {}
|
|
if (param.scene) {
|
|
let res = await $api.base.getWxCodeData({
|
|
code_id: param.scene
|
|
})
|
|
target = Object.assign({}, state.commonOptions, res.data)
|
|
} else {
|
|
target = Object.assign({}, state.commonOptions, param)
|
|
}
|
|
let data = $util.pick(target, ['id', 'coupon_atv_id', 'admin_id', 'channel_id'])
|
|
commit('updateUserItem', {
|
|
key: 'commonOptions',
|
|
val: data
|
|
})
|
|
console.log(target, "======target");
|
|
return target
|
|
},
|
|
}
|
|
}
|
|
|