beefast-mini-deliveryman/pages/index/index.js
2025-02-17 03:11:35 +08:00

124 lines
2.9 KiB
JavaScript

Page({
data: {
statusBarHeight:0,
list:[{}],
moveEvent:null,
moveViewX:0,
tipsOpacity:1,
tipsRight:120,
moveAreaWidth:0,
moveViewWidth:92,
receiving:false,
scrollViewHeight:0,
isShowConfirm:false,
isShowLeftPanel:false,
tempImgs:[],
maxChooseImgCount:10
},
onLoad(){
const windowInfo = wx.getWindowInfo();
console.log(windowInfo);
this.setData({
statusBarHeight:windowInfo.statusBarHeight,
scrollViewHeight:windowInfo.windowHeight-windowInfo.statusBarHeight-44 - 125
});
//增加列表之后 放在列表加载之后 优化动画效果
this.createSelectorQuery().select('#moveArea0').boundingClientRect((res)=>{
console.log(res);
this.data.moveAreaWidth = res.width;
}).exec();
},
confirmSend(){
this.setData({
isShowConfirm:true
})
},
openLeftPanel(){
this.setData({
isShowLeftPanel:true
})
},
closeLeftPanel(){
this.setData({
isShowLeftPanel:false
})
},
refund(){
wx.showModal({
title: '取消订单需联系客户说明原因',
content: '',
placeholderText:'请输入退款原因',
editable:true,
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
}
}
})
},
chooseImage(){
wx.chooseMedia({
count:this.data.maxChooseImgCount - this.data.tempImgs.length,
success:(res)=>{
console.log(res);
this.setData({
tempImgs:this.data.tempImgs.concat(res.tempFiles)
});
}
});
},
navToOrderDetail(){
wx.navigateTo({
url: '/pages/order-detail/index',
})
},
buttonOnMove(event){
if(this.data.receiving)return;
this.setData({
moveEvent:event
});
const index = event.currentTarget.dataset.index;
if(!this.data.moveAreaWidth){
this.createSelectorQuery().select('#moveArea'+index).boundingClientRect((res)=>{
this.data.moveAreaWidth = res.width;
}).exec();
}
let x = this.data.moveEvent.detail.x;
let opacity = 1 - x/(this.data.moveAreaWidth - this.data.moveViewWidth);
let right = opacity*120
this.setData({
tipsOpacity:opacity,
tipsRight:right
})
},
buttonMoveCancel(event){
if(this.data.receiving)return;
const index = event.currentTarget.dataset.index;
this.createSelectorQuery().select('#moveArea'+index).boundingClientRect((res)=>{
const x = this.data.moveEvent.detail.x;
const moveAreaWidth = res.width;
//给 10 像素边界
//moveAreaWidth - this.data.moveViewWidth - 10 <= x
if((moveAreaWidth - this.data.moveViewWidth)/3*2 < x){
console.log('success');
this.setData({
moveViewX:moveAreaWidth - this.data.moveViewWidth,
receiving:true
});
}else{
this.setData({
moveViewX:0
});
}
}).exec();
}
})