96 lines
3.1 KiB
Vue
96 lines
3.1 KiB
Vue
<template>
|
|
<view class="page-wrapper">
|
|
<JCell v-for="(item, index) in vdata.defaultConfig" :key="item.configKey" :title="item.configName" color="#4D4D4D" borderWidth="40rpx" :isTouch="false">
|
|
<template #right>
|
|
<JSwitch
|
|
:bol="item.configVal === '1' ? true : false"
|
|
:tips="item.tips || `是否${item.configVal === '1' ? '关闭' : '开启'}${item.configName}`"
|
|
margin="0 35rpx 0 0"
|
|
@confirm="confirm($event, item)"
|
|
/>
|
|
</template>
|
|
</JCell>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { reactive, computed } from 'vue';
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import { $mchConfig, $orderConfig } from '@/http/apiManager.js';
|
|
import infoBox from '@/commons/utils/infoBox.js';
|
|
import storageManage from '@/commons/utils/storageManage.js';
|
|
// #ifdef MP-WEIXIN
|
|
// 控制 音乐播放 和暂停
|
|
import { startOrEndMusice } from '@/commons/utils/pushmsg/wxTextToSpeach.js';
|
|
// #endif
|
|
onLoad((options) => {
|
|
mchConfig();
|
|
});
|
|
const vdata = reactive({
|
|
defaultConfig: [
|
|
{
|
|
configKey: 'appVoice',
|
|
configName: 'app订单语音播报',
|
|
configVal: '0',
|
|
type: 'radio'
|
|
},
|
|
{
|
|
configKey: 'qrcEscaping',
|
|
configName: '码牌防逃单功能',
|
|
configVal: '0',
|
|
type: 'radio'
|
|
},
|
|
{
|
|
configKey: 'weChatVoice',
|
|
configName: '小程序语音推送',
|
|
configVal: '0',
|
|
type: 'radio'
|
|
}
|
|
] // 默认配置项
|
|
});
|
|
// 计算属性 用于计算 开关状态 提供不同提示语
|
|
const pushTips = computed(() => {
|
|
return vdata.isPush ? '是否确认关闭小程序语音推送?' : '注意“小程序语音推送功能会占用音乐播放器请勿关闭播放器, 请开启小程序浮窗以保证小程序正常播放订单消息”。';
|
|
});
|
|
const mchConfig = () => {
|
|
$mchConfig('orderConfig').then(({ bizData = [] }) => {
|
|
Object.assign(vdata.defaultConfig, bizData);
|
|
// 如果是app 则删除 微信推送开关
|
|
// #ifdef APP-PLUS
|
|
const index = vdata.defaultConfig.findIndex((v) => v.configKey == 'weChatVoice');
|
|
spliceIndex(index);
|
|
// #endif
|
|
// 如果是微信则删除 app 推送开关
|
|
// #ifdef MP-WEIXIN
|
|
const index = vdata.defaultConfig.findIndex((v) => v.configKey == 'appVoice');
|
|
const weChat = vdata.defaultConfig.find((v) => v.configKey == 'weChatVoice'); //获取 小程序数据实例
|
|
calcTips(weChat);
|
|
spliceIndex(index);
|
|
// #endif
|
|
});
|
|
};
|
|
const confirm = (e, item) => {
|
|
item.configVal = e ? 1 : 0;
|
|
$orderConfig(JSON.stringify(vdata.defaultConfig), vdata.defaultConfig[0].mchNo).then(() => {
|
|
if (item.configKey == 'weChatVoice') calcTips(item);
|
|
infoBox.showToast('设置成功');
|
|
// #ifdef MP-WEIXIN
|
|
if (item.configKey == 'weChatVoice') {
|
|
// 添加语音播报的消息推送
|
|
startOrEndMusice(item.configVal);
|
|
}
|
|
// #endif
|
|
});
|
|
};
|
|
function spliceIndex(i) {
|
|
if (i != '-1') vdata.defaultConfig.splice(i, 1);
|
|
}
|
|
// 用于计算 合适的提示用语
|
|
function calcTips(v) {
|
|
if (v != '-1')
|
|
v.tips = v.configVal == 1 ? '是否确认关闭小程序语音推送?' : '注意“小程序语音推送功能会占用音乐播放器请勿关闭播放器, 请开启小程序浮窗以保证小程序正常播放订单消息”。';
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped></style>
|