diff --git a/components/background-notice/index.js b/components/background-notice/index.js index d9f73b8..4e45025 100644 --- a/components/background-notice/index.js +++ b/components/background-notice/index.js @@ -1,5 +1,3 @@ -import userApi from '../../api/user'; - Component({ /** @@ -8,7 +6,15 @@ Component({ properties: { start:{ 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: { 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'; - this.data.haveOrderAudio = `${wx.env.USER_DATA_PATH}/haveorder.wav`; - const haveOrderPath = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/new_order.mp3' + this.data.haveOrderAudio = `${wx.env.USER_DATA_PATH}/haveorder.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.haveOrderAudio,haveOrderPath); }, @@ -68,7 +65,7 @@ Component({ const fs = wx.getFileSystemManager(); fs.accessSync(localPath); } catch (error) { - await userApi.downloadFile(serverPath,localPath); + await this.downloadFile(serverPath,localPath); } }, start(){ @@ -102,6 +99,23 @@ Component({ // innerAudioContext.onEnded(()=>{ // 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() + } + }) + }) } } }) \ No newline at end of file diff --git a/components/navBar/index.wxss b/components/navBar/index.wxss index 3605b44..81f9202 100644 --- a/components/navBar/index.wxss +++ b/components/navBar/index.wxss @@ -1,4 +1,3 @@ -/* components/navBar.wxss */ .nav-bar{ } .nav-bar-content{ @@ -48,4 +47,5 @@ flex:1; text-align: center; } -.nav-bar-content .right{flex:1;} \ No newline at end of file +.nav-bar-content .right{flex:1;} + diff --git a/pages/index/index.js b/pages/index/index.js index e25cf35..435b932 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -371,13 +371,11 @@ Page({ wx.chooseMedia({ count:this.data.maxChooseImgCount - this.data.tempImgs.length, mediaType:['image'], - sourceType:['camera'], success:(res)=>{ this.setData({ tempImgs:this.data.tempImgs.concat(res.tempFiles) }); wx.nextTick(()=>{ - console.log('nextTick'); this.uploadImages(); }) }