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.
 
 
 
 
xxdj1/store/modules/config.js

126 lines
2.7 KiB

import $api from "@/api/index.js"
export default {
state: {
//主题颜色
configInfo: {
id: 0,
navBarHeight: uni.getSystemInfoSync().statusBarHeight * 1 + 44,
isIos: uni.getSystemInfoSync().system.includes('iOS'),
canIUseGetUserProfile: uni.getUserProfile ? true : false,
refund_img: 'https://lbqny.migugu.com/paotui/errand.png',
tabBar: [{
name: '首页',
default_img: 'iconshouye11',
selected_img: 'iconshouye21'
}, {
name: '技师',
default_img: 'iconanmo1',
selected_img: 'iconanmo2'
}, {
name: '订单',
default_img: 'icondingdan3',
selected_img: 'icondingdan2'
}, {
name: '我的',
default_img: 'iconwode11',
selected_img: 'iconwode2'
}],
curSysHeight: '',
tabbarHeight: ''
},
audioBg: {},
playBg: false,
isHaveAudio: false
},
mutations: {
//修改信息
updateConfigItem(state, item) {
let {
key,
val
} = item
state[key] = val
if (key !== 'configInfo') return
uni.setStorageSync('configInfo', val)
if (state.isHaveAudio) return
state.audioBg = uni.createInnerAudioContext();
state.isHaveAudio = true
let {
countdown_voice
} = val
state.audioBg.src = countdown_voice
// #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;
})
})
}
},
actions: {
// 获取基本配置
async getConfigInfo({
commit,
state
}, param) {
let config = await $api.base.configInfo()
if (!config.primaryColor) {
config.primaryColor = '#A40035'
}
if (!config.subColor) {
config.subColor = '#F1C06B'
}
if (!config.user_image) {
config.user_image = 'https://lbqny.migugu.com/admin/anmo/mine/bg.png'
}
if (!config.coach_image) {
config.coach_image = 'https://lbqny.migugu.com/admin/anmo/mine/bg.png'
}
if (!config.user_font_color) {
config.user_font_color = '#ffffff'
}
if (!config.coach_font_color) {
config.coach_font_color = '#ffffff'
}
let data = Object.assign(state.configInfo, config)
console.log(data,"1234567890")
commit('updateConfigItem', {
key: 'configInfo',
val: data
})
},
toPlayAudio({
commit,
state
}, param) {
console.log("播放")
if (state.playBg||param) {
state.audioBg.stop()
}else{
state.audioBg.play()
}
}
}
}