diff --git a/src/views/agent/checkOrderList.vue b/src/views/agent/checkOrderList.vue index 8f24033..728fac1 100644 --- a/src/views/agent/checkOrderList.vue +++ b/src/views/agent/checkOrderList.vue @@ -2,19 +2,20 @@
- 允许未发货的有效订单提交检测(不可取消) + 允许未发货的有效订单提交检测(不可取消)
- 允许已发货小时订单提交论文检测 + 允许已发货小时订单提交论文检测
@@ -54,14 +58,16 @@ start-placeholder="开始日期" end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"> - + - + - + @@ -73,10 +79,12 @@

{{ pageTitle }}列表

- +
- +
@@ -133,7 +141,7 @@ - + - + - + @@ -308,6 +319,9 @@ export default { intervalId: null, + isMuted: true, + audioSrc: require('@/assets/msg.wav'), // 音频文件路径 + isIE: false // 是否是IE浏览器 } }, mounted() { @@ -315,14 +329,58 @@ export default { this.getOrderList() this.getConfig() this.startTimer(); + + this.checkBrowser(); + if (!this.isIE) { + this.$refs.audioPlayer.load(); // 预加载音频 + } + }, + beforeUpdate() { }, beforeDestroy() { this.stopTimer(); }, methods: { + unmute() { + this.isMuted = false; + if (this.$refs.audioPlayer) { + this.$refs.audioPlayer.muted = false; + } + }, + checkBrowser() { + const userAgent = window.navigator.userAgent.toLowerCase(); + this.isIE = userAgent.indexOf("ie") >= 0 || userAgent.indexOf("trident") >= 0; + }, + + // 播放声音 + playSound() { + this.$nextTick(() => { + if (this.isIE) { + // IE浏览器使用embed播放 + console.log('ienotice'); + } else { + // 现代浏览器使用audio播放 + try { + const audio = this.$refs.audioPlayer; + this.unmute() + if (audio) { + audio.play().then(() => { + console.log('notice'); + }).catch(e => { + console.error('音频播放失败:', e); + }); + } + } catch (e) { + console.error('播放出错:', e); + } + } + }); + }, startTimer() { this.intervalId = setInterval(() => { this.getOrderList() + // // 测试重复播放 -- is okk + // this.playSound() // 每隔5秒执行的代码 console.log('这个操作每隔5秒执行一次'); }, 10000); @@ -332,12 +390,7 @@ export default { clearInterval(this.intervalId); } }, - playSound() { - //const audio = new Audio('/assets/msg.wav'); // 确保路径正确 - //audio.play(); - console.log('播放声音'); - }, - getFilterParams(){ + getFilterParams() { var stime = ''; var etime = ''; if (this.searchDate && this.searchDate.length > 0) { @@ -352,9 +405,9 @@ export default { if (this.searchUid) params.uid = this.searchUid; this.getOrderList(params) - + }, - resetPageParams(){ + resetPageParams() { this.orderListTotalRecords = 0 this.isHasNextPage = true this.orderListCurrentPage = 1 @@ -363,7 +416,7 @@ export default { this.orderListPrevMaxId = 0 this.orderListEndPage = 0 }, - resetSearchParams(){ + resetSearchParams() { this.searchDate = '' this.searchStatus = 'all' this.searchType = '0' @@ -376,7 +429,7 @@ export default { }, getConfig() { this.$http('POST', '/agentnew/get_agent_config', { - + }, { headers: { 'Auth': this.token @@ -415,7 +468,7 @@ export default { }).then(response => { this.tableLoading = false this.$nextTick(() => { - if (this.intervalId && response.data.maxid && this.orderListPrevMaxId && response.data.maxid>this.orderListPrevMaxId) { + if (this.intervalId && response.data.maxid && this.orderListPrevMaxId && response.data.maxid > this.orderListPrevMaxId) { console.log('有新订单了'); this.playSound(); } @@ -438,7 +491,6 @@ export default { // this.end_page = 1; } // console.log(this.isHasNextPage, 'isHasNextPage') - }) }).catch(error => { console.error(error, 'error') @@ -465,13 +517,13 @@ export default { if (this.searchType) params.type = this.searchType; if (this.searchUid) params.uid = this.searchUid; - this.$http('GET', '/agentnew/export_order', params,{ - returnFullResponse: true , + this.$http('GET', '/agentnew/export_order', params, { + returnFullResponse: true, headers: { 'Auth': this.token, }, responseType: 'blob' - }).then(response => { + }).then(response => { const { headers, // 响应头(headers) data, // 响应体数据 @@ -481,24 +533,24 @@ export default { const blob = new Blob([data], { type: 'application/force-download' }); const downloadUrl = window.URL.createObjectURL(blob); - + const link = document.createElement('a'); link.href = downloadUrl; link.setAttribute('download', filename); - + document.body.appendChild(link); link.click(); - + document.body.removeChild(link); window.URL.revokeObjectURL(downloadUrl); }).catch(error => { console.error(error, 'error') }) }, - decodeRFC5987Filename(header) { + decodeRFC5987Filename(header) { // 匹配 RFC 5987 编码的文件名(如 filename*=utf8''xxx) const match = header.match(/filename\*=(?:utf8|UTF-8)''([^;]+)/i); - console.log(match,'match'); + console.log(match, 'match'); if (match) { return decodeURIComponent(match[1]); } @@ -516,8 +568,8 @@ export default { console.log(this.searchUid) }, changeSearchTid() { - console.log(this.searchTid,'this.searchTid') - this.getOrderList({orderid:this.searchTid}) + console.log(this.searchTid, 'this.searchTid') + this.getOrderList({ orderid: this.searchTid }) }, changeSearchType() { console.log(this.searchType) @@ -596,14 +648,14 @@ export default { pddSetting() { if (this.pddSettingActiveName == 1) { this.$http('GET', '/agentnew/export_pdd_tids', { - uid: this.pddExportUid, - },{ - returnFullResponse: true , + uid: this.pddExportUid, + }, { + returnFullResponse: true, headers: { 'Auth': this.token, }, responseType: 'blob' - }).then(response => { + }).then(response => { const { headers, // 响应头(headers) data, // 响应体数据 @@ -613,14 +665,14 @@ export default { const blob = new Blob([data], { type: 'application/force-download' }); const downloadUrl = window.URL.createObjectURL(blob); - + const link = document.createElement('a'); link.href = downloadUrl; link.setAttribute('download', filename); - + document.body.appendChild(link); link.click(); - + document.body.removeChild(link); window.URL.revokeObjectURL(downloadUrl); }).catch(error => { @@ -628,7 +680,7 @@ export default { }) } else if (this.pddSettingActiveName == 2) { this.$http('POST', '/agentnew/ajax_set_pdd_delivered_delayed_submit_hour', { - hour: this.selectAllowPddDeliveredDelayedSubmit===true ? this.pddDeliveredDelayedSubmitHour : 0, + hour: this.selectAllowPddDeliveredDelayedSubmit === true ? this.pddDeliveredDelayedSubmitHour : 0, }, { headers: { 'Auth': this.token @@ -646,7 +698,7 @@ export default { console.error(error, 'error') }) } - + }, handleClick() { console.log(this.pddSettingActiveName); @@ -679,14 +731,14 @@ export default { this.getOrderList(params) }, - + }, computed: { }, watch: { '$route.query'(newVal) { - + console.log('参数变化:', newVal); // 执行数据更新逻辑 this.pageTab = newVal.list @@ -699,7 +751,7 @@ export default { this.resetSearchParams() this.resetPageParams() } - + }, } @@ -750,6 +802,7 @@ export default { .mt-16 { margin-top: 16px; } + .mb-10 { margin-bottom: 10px; }