日常修改

This commit is contained in:
2025-03-31 20:35:08 +08:00
parent 257eab643e
commit fd6310b8f1
3 changed files with 32 additions and 20 deletions

View File

@ -1,5 +1,3 @@
import userApi from '../../api/user';
Component({ Component({
/** /**
@ -8,7 +6,15 @@ Component({
properties: { properties: {
start:{ start:{
type:Boolean, type:Boolean,
value:false value:false,
observer(s){
console.log(s);
if(s){
this.start();
}else{
this.stop();
}
}
} }
}, },
@ -41,24 +47,15 @@ Component({
} }
}, },
observers:{
"start"(s){
if(s){
this.start();
}else{
this.stop();
}
}
},
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
async downloadResource(){ async downloadResource(){
this.data.emptyAudio = `${wx.env.USER_DATA_PATH}/empty.mp3`; this.data.emptyAudio = `${wx.env.USER_DATA_PATH}/empty.wav`;
const emptyServerPath = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/silence_file.wav'; const emptyServerPath = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/silence_file.wav';
this.data.haveOrderAudio = `${wx.env.USER_DATA_PATH}/haveorder.wav`; this.data.haveOrderAudio = `${wx.env.USER_DATA_PATH}/haveorder.mp3`;
const haveOrderPath = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/new_order.mp3' const haveOrderPath = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/new_order.mp3';
await this.download(this.data.emptyAudio,emptyServerPath); await this.download(this.data.emptyAudio,emptyServerPath);
await this.download(this.data.haveOrderAudio,haveOrderPath); await this.download(this.data.haveOrderAudio,haveOrderPath);
}, },
@ -68,7 +65,7 @@ Component({
const fs = wx.getFileSystemManager(); const fs = wx.getFileSystemManager();
fs.accessSync(localPath); fs.accessSync(localPath);
} catch (error) { } catch (error) {
await userApi.downloadFile(serverPath,localPath); await this.downloadFile(serverPath,localPath);
} }
}, },
start(){ start(){
@ -102,6 +99,23 @@ Component({
// innerAudioContext.onEnded(()=>{ // innerAudioContext.onEnded(()=>{
// innerAudioContext.destroy(); // innerAudioContext.destroy();
// }) // })
},
downloadFile(url,filePath){
console.log('download',url,filePath);
return new Promise((rs,rj)=>{
wx.downloadFile({
url: url,
filePath: filePath,
success: (result) => {
console.log('success',result);
rs()
},
fail: (res) => {
console.log('error',res.errMsg,url,filePath);
rj()
}
})
})
} }
} }
}) })

View File

@ -1,4 +1,3 @@
/* components/navBar.wxss */
.nav-bar{ .nav-bar{
} }
.nav-bar-content{ .nav-bar-content{
@ -48,4 +47,5 @@
flex:1; flex:1;
text-align: center; text-align: center;
} }
.nav-bar-content .right{flex:1;} .nav-bar-content .right{flex:1;}

View File

@ -371,13 +371,11 @@ Page({
wx.chooseMedia({ wx.chooseMedia({
count:this.data.maxChooseImgCount - this.data.tempImgs.length, count:this.data.maxChooseImgCount - this.data.tempImgs.length,
mediaType:['image'], mediaType:['image'],
sourceType:['camera'],
success:(res)=>{ success:(res)=>{
this.setData({ this.setData({
tempImgs:this.data.tempImgs.concat(res.tempFiles) tempImgs:this.data.tempImgs.concat(res.tempFiles)
}); });
wx.nextTick(()=>{ wx.nextTick(()=>{
console.log('nextTick');
this.uploadImages(); this.uploadImages();
}) })
} }