diff --git a/api/order.js b/api/order.js
index eb99775..11f53f2 100644
--- a/api/order.js
+++ b/api/order.js
@@ -25,5 +25,6 @@ export default {
receive:(orderid)=>request.post(`/api/order/${orderid}/deliveryman/receive`),
pickup:(orderid)=>request.post(`/api/order/${orderid}/deliveryman/pickup`),
complete:(orderid,images)=>request.post(`/api/order/${orderid}/deliveryman/complete`,{images:images}),
- cancel:(orderid,reason)=>request.post(`/api/order/${orderid}/deliveryman/cancel`,{reason})
+ cancel:(orderid,reason)=>request.post(`/api/order/${orderid}/deliveryman/cancel`,{reason}),
+ check:()=>request.get('/api/order/deliveryman/check_new_order')
}
\ No newline at end of file
diff --git a/api/user.js b/api/user.js
index 5b28b06..55980b5 100644
--- a/api/user.js
+++ b/api/user.js
@@ -53,5 +53,19 @@ export default {
task.onProgressUpdate(progress);
}
});
+ },
+ downloadFile(url,filePath){
+ return new Promise((rs,rj)=>{
+ wx.downloadFile({
+ url: url,
+ filePath: filePath,
+ success: (result) => {
+ rs()
+ },
+ fail: (res) => {
+ rj()
+ }
+ })
+ })
}
}
\ No newline at end of file
diff --git a/app.js b/app.js
index 5daca23..2df36c2 100644
--- a/app.js
+++ b/app.js
@@ -5,6 +5,9 @@ const date = new Date();
App({
verifyCodeWaitingTime:60,
onLaunch() {
+ wx.setInnerAudioOption({
+ obeyMuteSwitch:false
+ });
if(!token){
wx.reLaunch({
url: '/pages/login/index',
@@ -16,6 +19,9 @@ App({
}
})
},
+ onHide(){
+ console.log('app on hide');
+ },
resetUserInfoUpdateTag(){
this.globalData.userInfoGetTime = null;
},
diff --git a/app.json b/app.json
index 00cd0e5..4c5da5e 100644
--- a/app.json
+++ b/app.json
@@ -21,5 +21,8 @@
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
- "lazyCodeLoading": "requiredComponents"
+ "lazyCodeLoading": "requiredComponents",
+ "requiredBackgroundModes": [
+ "audio"
+ ]
}
\ No newline at end of file
diff --git a/app.wxss b/app.wxss
index 69e1b3c..b4e11f7 100644
--- a/app.wxss
+++ b/app.wxss
@@ -370,4 +370,25 @@ navigator button{
}
list-view{
display: block;
+}
+
+
+switch .wx-switch-input.wx-switch-input-checked {
+ background-color:var(--main-color);
+ border-color: var(--main-color);
+}
+switch .wx-switch-input::after {
+ width: 40rpx;
+ height: 40rpx;
+}
+
+
+
+
+
+
+.weui-loading{
+ font-size:16px;width:1em;height:1em;display:inline-block;vertical-align:middle;
+ background:transparent url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient x1='94.0869141%25' y1='0%25' x2='94.0869141%25' y2='90.559082%25' id='linearGradient-1'%3E%3Cstop stop-color='%23606060' stop-opacity='0' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient x1='100%25' y1='8.67370605%25' x2='100%25' y2='90.6286621%25' id='linearGradient-2'%3E%3Cstop stop-color='%23606060' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='url(%23linearGradient-1)'%3E%3C/path%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='url(%23linearGradient-2)'%3E%3C/path%3E%3Ccircle id='Oval' fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3CanimateTransform attributeName='transform' begin='0s' dur='1s' type='rotate' values='0 40 40;360 40 40' repeatCount='indefinite'/%3E%3C/g%3E%3C/svg%3E%0A") no-repeat;
+ background-size:100%
}
\ No newline at end of file
diff --git a/assets/audio/order_complete.wav b/assets/audio/order_complete.wav
new file mode 100644
index 0000000..15a4f02
Binary files /dev/null and b/assets/audio/order_complete.wav differ
diff --git a/components/background-notice/index.js b/components/background-notice/index.js
new file mode 100644
index 0000000..c15cc55
--- /dev/null
+++ b/components/background-notice/index.js
@@ -0,0 +1,114 @@
+import userApi from '../../api/user';
+
+Component({
+
+ /**
+ * 组件的属性列表
+ */
+ properties: {
+ start:{
+ type:Boolean,
+ value:false
+ }
+ },
+
+ /**
+ * 组件的初始数据
+ */
+ data: {
+ emptyAudio:'',
+ haveOrderAudio:'',
+ initing:true
+ },
+ lifetimes:{
+ attached(){
+ this.data.initing = true;
+ this.downloadResource().then(()=>{
+ this.bgam = wx.getBackgroundAudioManager();
+ this.bgam.title = '后台通知';
+ this.bgam.audioType = 'music';
+ this.bgam.coverImgUrl = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/20250227/DoADoEhKi4U4ab75d180b27fa14b7c34ae7969762809_d7ee9018-828e-43c7-8b2b-29d4352c0277.jpg?imageMogr2/thumbnail/800x800/format/webp';
+ this.bgam.onEnded(()=>{
+ this.bgam.src = this.data.emptyAudio;
+ });
+ this.triggerEvent('initSuccess');
+ }).catch(()=>{
+ this.triggerEvent('initError');
+ })
+
+ }
+ },
+ observers:{
+ "start"(s){
+ if(s){
+ this.start();
+ }else{
+ this.stop();
+ }
+ }
+ },
+ /**
+ * 组件的方法列表
+ */
+ methods: {
+ async downloadResource(){
+ this.data.emptyAudio = `${wx.env.USER_DATA_PATH}/empty.mp3`;
+ 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'
+ await this.download(this.data.emptyAudio,emptyServerPath);
+ await this.download(this.data.haveOrderAudio,haveOrderPath);
+ },
+ async download(localPath,serverPath){
+ try {
+ //判断文件是否存在
+ const fs = wx.getFileSystemManager();
+ fs.accessSync(localPath);
+ } catch (error) {
+ await userApi.downloadFile(serverPath,localPath);
+ }
+ },
+ start(){
+ this.bgam.src = this.data.emptyAudio;
+ if(this.loopOrderTimer){
+ clearInterval(this.loopOrderTimer);
+ }
+ this.loopOrderTimer = setInterval(()=>{
+ this.triggerEvent('onTrigger');
+ },10000);
+ },
+ stop(){
+ if(this.loopOrderTimer){
+ clearInterval(this.loopOrderTimer);
+ }
+ if(this.emptyAutioPlayTimer){
+ clearTimeout(this.emptyAutioPlayTimer)
+ }
+ if(this.bgam){
+ this.bgam.stop();
+ }
+ },
+ notice(){
+ if(this.emptyAutioPlayTimer){
+ clearTimeout(this.emptyAutioPlayTimer)
+ }
+
+ // this.bgam.src = this.data.haveOrderAudio;
+ // this.bgam.onEnded(()=>{
+ // console.log('notice onend');
+ // this.emptyAutioPlayTimer = setTimeout(()=>{
+ // this.bgam.src = this.data.emptyAudio;
+ // },1000)
+ // });
+
+ const innerAudioContext = wx.createInnerAudioContext({
+ useWebAudioImplement:true
+ })
+ innerAudioContext.src = this.data.haveOrderAudio;
+ innerAudioContext.play();
+ innerAudioContext.onEnded(()=>{
+ innerAudioContext.destroy();
+ })
+ }
+ }
+})
\ No newline at end of file
diff --git a/components/background-notice/index.json b/components/background-notice/index.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/components/background-notice/index.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/components/background-notice/index.wxml b/components/background-notice/index.wxml
new file mode 100644
index 0000000..386f4b7
--- /dev/null
+++ b/components/background-notice/index.wxml
@@ -0,0 +1,2 @@
+
+components/background-notice/index.wxml
\ No newline at end of file
diff --git a/components/background-notice/index.wxss b/components/background-notice/index.wxss
new file mode 100644
index 0000000..5fb7434
--- /dev/null
+++ b/components/background-notice/index.wxss
@@ -0,0 +1 @@
+/* components/background-notice/index.wxss */
\ No newline at end of file
diff --git a/components/swipeButton/index.js b/components/swipeButton/index.js
index 5b6be68..f08cb6d 100644
--- a/components/swipeButton/index.js
+++ b/components/swipeButton/index.js
@@ -79,7 +79,6 @@ Component({
},
observers:{
"loading"(l){
- console.log('loading',l);
if(!l){
this.setData({
moveViewX:0,
diff --git a/pages/index/index.js b/pages/index/index.js
index 54279b5..468624e 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -6,6 +6,7 @@ const app = getApp();
Page({
currentOrder:null,
+ haveNewOrder:false,
data: {
statusBarHeight:0,
snBarHeight:0,
@@ -52,9 +53,19 @@ Page({
completing:false,
- isShowRefundConfirm:false
+ isShowRefundConfirm:false,
+
+ isStartLoopOrder:false,
+
+ bgNoticeLoadResult:{
+ error:false,
+ loading:true
+ },
+ unReadOrderCount:0
},
onLoad(){
+ console.log(wx.env.USER_DATA_PATH);
+ this.orderBackgroundNotice = this.selectComponent('#orderBackgroundNotice');
const snHeight = getStatusNavBarHeight();
this.setData({
statusBarHeight:snHeight.statusBar,
@@ -74,6 +85,52 @@ Page({
});
});
},
+ findNewOrder(){
+ // app.forceGetUserInfo().then((data)=>{
+ // if(data.nickname=='仙人模斗'){
+ // this.haveNewOrder = true;
+ // this.orderBackgroundNotice.notice();
+ // }
+ // })
+ // return;
+ orderApi.check().then((data)=>{
+ if(data.has_new_order){
+ this.orderBackgroundNotice.notice();
+ this.setData({
+ unReadOrderCount:this.data.unReadOrderCount+data.order_ids.length
+ })
+ }
+ })
+ },
+ bgNoticeSuccess(){
+ this.setData({
+ bgNoticeLoadResult:{
+ error:false,
+ loading:false
+ }
+ })
+ },
+ bgNoticeError(){
+ wx.showToast({
+ icon:'error',
+ title: '资源加载失败',
+ })
+ this.setData({
+ bgNoticeLoadResult:{
+ error:true,
+ loading:false
+ }
+ })
+ },
+ bgNoticeRetry(){
+ this.setData({
+ bgNoticeLoadResult:{
+ error:false,
+ loading:true
+ }
+ })
+ this.orderBackgroundNotice.downloadResource();
+ },
async getUserInfo(){
await app.forceGetUserInfo().then((data)=>{
this.setData({
@@ -203,12 +260,16 @@ Page({
pItem.receivedAll = this.getPackageReceiveStatus(item.orderid,pItem);
})
})
- this.setData({
+ let needSetData = {
list:this.data.list,
pager:this.data.pager,
statusDetailKey:this.data.statusDetailKey,
buildingIndex:this.data.buildingIndex
- });
+ }
+ if(this.data.statusDetailKey==this.data.statusDetail.created.key.toLowerCase()){
+ needSetData.unReadOrderCount = 0;
+ }
+ this.setData(needSetData);
})
},
@@ -384,7 +445,6 @@ Page({
})
return;
}
- console.log(this.data.tempImgs);
this.setData({
completing:true
})
@@ -469,6 +529,12 @@ Page({
})
this.setData(needRefreshData);
}
+ if(this.haveNewOrder){
+ this.data.statusDetailKey = this.data.statusDetail.created.key.toLowerCase();
+ this.data.buildingIndex = 0;
+ this.refreshList();
+ this.haveNewOrder = false;
+ }
},
getPackageReceiveStatus(orderId,pkg){
let receivedInfo = wx.getStorageSync(orderId);
@@ -477,5 +543,10 @@ Page({
return true;
}
return false;
+ },
+ loopOrderChange(event){
+ this.setData({
+ isStartLoopOrder:event.detail.value
+ })
}
})
diff --git a/pages/index/index.json b/pages/index/index.json
index be659f5..d7d0bc7 100644
--- a/pages/index/index.json
+++ b/pages/index/index.json
@@ -2,7 +2,8 @@
"usingComponents": {
"list-view":"/components/listView",
"swipe-button":"/components/swipeButton",
- "modal-view":"/components/modalView"
+ "modal-view":"/components/modalView",
+ "background-notice":"/components/background-notice"
},
"navigationStyle": "custom",
"navigationBarTextStyle": "white"
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 56d8ec4..c188d15 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -3,15 +3,25 @@
-
@@ -182,4 +192,8 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/pages/index/index.wxss b/pages/index/index.wxss
index 70d5a18..8e90934 100644
--- a/pages/index/index.wxss
+++ b/pages/index/index.wxss
@@ -8,6 +8,11 @@
display: flex;
align-items: center;
}
+.nav-bar .retry{
+ text-decoration: underline;
+ color: rgb(250, 67, 67);
+ padding:14rpx;
+}
.nav-bar .left-btn{
width:56rpx;
height:56rpx;
@@ -26,6 +31,23 @@
width:20rpx;height:20rpx;
margin-right:8rpx;
}
+.nav-bar .loop-order-switch{
+ background: rgba(255, 255, 255, 0.08);
+ border-radius: 40rpx;
+ color: #fff;
+ padding:4rpx 4rpx 4rpx 18rpx;
+ margin-left:24rpx;
+ display: flex;
+ align-items: center;
+ gap: 14rpx;
+ font-size: 28rpx;
+}
+.nav-bar .loop-order-switch .switch .wx-switch-input{
+ width:84rpx;
+ height: 48rpx;
+ --switch-checked-color:red;
+ --switch-node-size: 16rpx;
+}
.head{
display: flex;
background-color: #111111;
@@ -42,11 +64,20 @@
flex:1;
text-align: center;
padding:39rpx 0 19rpx 0;
+ position: relative;
}
.head .item.current{
color:#ffffff;
font-weight: 500;
}
+.head .item .red-bubble{
+ position: absolute;
+ right:8rpx;top:20rpx;
+ background-color: red;
+ border-radius: 50%;
+ font-size: 24rpx;
+ padding:4rpx 8rpx;
+}
.building{
display: flex;
overflow-x: auto;
diff --git a/pages/test/audio.js b/pages/test/audio.js
new file mode 100644
index 0000000..01ceebf
--- /dev/null
+++ b/pages/test/audio.js
@@ -0,0 +1,94 @@
+// pages/test/audio.js
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ time:0
+ },
+ gbam:null,
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+
+ this.bgam = wx.getBackgroundAudioManager();
+ this.bgam.src = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/empty.mp3';
+ this.bgam.title = '后台通知';
+ this.bgam.audioType = 'music';
+ this.bgam.coverImgUrl = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/20250227/DoADoEhKi4U4ab75d180b27fa14b7c34ae7969762809_d7ee9018-828e-43c7-8b2b-29d4352c0277.jpg?imageMogr2/thumbnail/800x800/format/webp';
+ this.bgam.play();
+ this.bgam.onPlay();
+ this.bgam.onEnded(()=>{
+ console.log('end');
+ // this.bgam.src = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/empty.mp3';
+ // this.bgam.play();
+ })
+ // const innerAudioContext = wx.createInnerAudioContext({
+ // useWebAudioImplement:true
+ // })
+ // innerAudioContext.src = '/assets/audio/order_complete.wav';
+ // innerAudioContext.play();
+ },
+ playAudio(){
+ setInterval(()=>{
+ this.setData({
+ time:this.data.time+1
+ });
+ },1000);
+ setInterval(()=>{
+ this.bgam.src = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/new_order.mp3';
+ this.bgam.play();
+ },10000)
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload() {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh() {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom() {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage() {
+
+ }
+})
\ No newline at end of file
diff --git a/pages/test/audio.json b/pages/test/audio.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/pages/test/audio.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/pages/test/audio.wxml b/pages/test/audio.wxml
new file mode 100644
index 0000000..7139558
--- /dev/null
+++ b/pages/test/audio.wxml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/pages/test/audio.wxss b/pages/test/audio.wxss
new file mode 100644
index 0000000..04f5fe0
--- /dev/null
+++ b/pages/test/audio.wxss
@@ -0,0 +1 @@
+/* pages/test/audio.wxss */
\ No newline at end of file
diff --git a/pages/user/income/index.wxml b/pages/user/income/index.wxml
index e64201d..dd6d578 100644
--- a/pages/user/income/index.wxml
+++ b/pages/user/income/index.wxml
@@ -1,7 +1,7 @@
今日收益(元)
- {{summary.total_income}}
+ {{summary.today_income}}