update:新增语音开关
This commit is contained in:
parent
c8ed6d1739
commit
0ffbddfd61
@ -4,6 +4,7 @@ import APPUpdate, { getCurrentNo } from "@/config/appUpdate";
|
||||
// #endif
|
||||
import { mapState, mapActions } from "vuex";
|
||||
import { webSocketManager } from "@/utils/socket.js";
|
||||
import {GetRingStatus} from '@/api/ring.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -142,14 +143,19 @@ export default {
|
||||
},
|
||||
// 新增方法 - 处理推送声音
|
||||
// 修改handlePushSound方法
|
||||
handlePushSound(pushData) {
|
||||
async handlePushSound(pushData) {
|
||||
console.log(pushData.payload);
|
||||
try {
|
||||
// 获取category决定使用哪种声音
|
||||
const category = pushData.payload.category;
|
||||
|
||||
var AUDIO = uni.createInnerAudioContext();
|
||||
|
||||
let res = await GetRingStatus();
|
||||
console.log("声音",res);
|
||||
if(res.data.ringtone_is_enable!==1){
|
||||
console.log("没声音");
|
||||
return;
|
||||
}
|
||||
// 设置音频源
|
||||
let soundFile = "";
|
||||
switch (category) {
|
||||
|
||||
21
java-mall-app-shop-admin/api/ring.js
Normal file
21
java-mall-app-shop-admin/api/ring.js
Normal file
@ -0,0 +1,21 @@
|
||||
import http from "../utils/http";
|
||||
import config from "../config/config";
|
||||
|
||||
export function GetRingStatus() {
|
||||
return http({
|
||||
url: '/shop/shop-store-base/get',
|
||||
method: 'get',
|
||||
baseURL: config.adminApi,
|
||||
});
|
||||
}
|
||||
export function UpdateRingStatus(formData) {
|
||||
return http({
|
||||
url: '/shop/shop-store-base/storeSetUp',
|
||||
method: 'post',
|
||||
baseURL: config.adminApi,
|
||||
data: formData, // 提交表单数据
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded' // 设置请求头为表单格式
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -271,6 +271,13 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的举报"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/my/rings/rings",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "铃声设置"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
iconStyle="marginRight:6px; color: #62BBAE"
|
||||
:border="false"
|
||||
isLink
|
||||
url="/pages/my/printer/printerList"
|
||||
url="/pages/my/rings/rings"
|
||||
icon="bell-fill"
|
||||
title="铃声设置"
|
||||
></u-cell>
|
||||
|
||||
107
java-mall-app-shop-admin/pages/my/rings/rings.vue
Normal file
107
java-mall-app-shop-admin/pages/my/rings/rings.vue
Normal file
@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="switch-container">
|
||||
<text>铃声状态:</text>
|
||||
<u-switch
|
||||
v-model="isSwitchOn"
|
||||
@change="handleSwitchChange"
|
||||
size="20"
|
||||
></u-switch>
|
||||
<text>{{ isSwitchOn ? '打开' : '关闭' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { GetRingStatus, UpdateRingStatus } from '../../../api/ring.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
ringtoneIsEnable: null,
|
||||
isSwitchOn: false,
|
||||
form: {}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getRingtoneStatus();
|
||||
},
|
||||
methods: {
|
||||
async getRingtoneStatus() {
|
||||
try {
|
||||
let res = await GetRingStatus();
|
||||
this.ringtoneIsEnable = res.data.ringtone_is_enable;
|
||||
this.isSwitchOn = res.data.ringtone_is_enable === 1;
|
||||
this.form = res.data;
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '获取状态失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async handleSwitchChange(value) {
|
||||
try {
|
||||
const status = value ? 1 : 2;
|
||||
this.form.ringtone_is_enable = status;
|
||||
|
||||
const formData = new URLSearchParams();
|
||||
for (const key in this.form) {
|
||||
if (this.form.hasOwnProperty(key)) {
|
||||
formData.append(key, this.form[key]);
|
||||
}
|
||||
}
|
||||
let res = await UpdateRingStatus(formData);
|
||||
this.ringtoneIsEnable = status;
|
||||
this.isSwitchOn = value;
|
||||
|
||||
uni.showToast({
|
||||
title: `铃声已${value ? '开启' : '关闭'}`,
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
});
|
||||
} catch (error) {
|
||||
this.isSwitchOn = !value;
|
||||
uni.showToast({
|
||||
title: '更新失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.switch-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 30rpx;
|
||||
gap: 15rpx;
|
||||
padding: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.switch-container text {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
margin-top: 30rpx;
|
||||
font-size: 30rpx;
|
||||
color: #666;
|
||||
padding: 20rpx;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user