Compare commits

...

4 Commits

Author SHA1 Message Date
tianyi 9c15595611 1 1 week ago
tianyi 60a7e7a070 1 1 week ago
tianyi 6c8587c366 1 1 week ago
tianyi 2c26426eca 1 1 week ago
  1. 36
      App.vue
  2. 618
      components/print/index.js
  3. 6
      components/tab-bar/myCenter.vue
  4. 9
      pages.json
  5. 17
      pages/index/index.vue
  6. 48
      pages/login/login.vue
  7. 553
      pages/shop/shopReturnOrder.vue
  8. 4
      pages/shop/transferDeliveryOrderList.vue
  9. 785
      pages/worker/index.vue
  10. 15
      pages/worker/partTimeJobCenter.vue

36
App.vue

@ -228,65 +228,42 @@
},
},
methods: {
/**
* 打印队列处理器取队头数据打印打印完成后删除队头继续处理下一条
* 保证同一时间只有一条消息在打印按接收顺序依次执行
*/
processPrintQueue() {
// 退
if (this.globalData.printData.length === 0) {
this.globalData.isPrinting = false
return
}
//
this.globalData.isPrinting = true
// onDone
printer.getData(() => {
//
this.globalData.printData.shift()
//
this.processPrintQueue()
})
},
//
handlePushClick(extras) {
if (!extras) return;
// AndroidJSONiOSObject
let data = extras;
if (typeof data === 'string') {
try {
data = JSON.parse(data);
} catch (e) {
console.error('解析推送extras失败', e);
return;
}
}
//
const targetUrl = `/pages/shop/orderDetail?id=${data.order_id}`;
//
uni.setStorageSync('push_jump_url', targetUrl);
//
const pages = getCurrentPages();
if (pages.length > 0) {
// 300ms
setTimeout(() => {
this.executeJump(targetUrl);
}, 300);
}
},
//
executeJump(url) {
uni.navigateTo({
url: url,
fail: (err) => {
// 10 navigateTo 使 redirectTo
console.warn('navigateTo失败,尝试redirectTo', err);
uni.redirectTo({
url: url
});
@ -361,8 +338,8 @@
}
})
} else {
jpushModule.isNotificationEnabled((result) => { //android
if (result.code == 0) { //0
jpushModule.isNotificationEnabled((result) => {
if (result.code == 0) {
this.noticMsgTool()
}
})
@ -370,7 +347,6 @@
},
noticMsgTool() {
if (uni.getSystemInfoSync().platform == "ios") {
//
uni.showModal({
title: '通知权限开启提醒',
content: '您还没有开启通知权限,无法接受到消息通知,请前往设置!',
@ -387,7 +363,6 @@
}
});
} else {
//android
var main = plus.android.runtimeMainActivity();
var pkName = main.getPackageName();
var uid = main.getApplicationInfo().plusGetAttribute("uid");
@ -400,20 +375,19 @@
if (res.confirm) {
var Intent = plus.android.importClass('android.content.Intent');
var Build = plus.android.importClass("android.os.Build");
//android 8.0
if (Build.VERSION.SDK_INT >= 26) {
var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
intent.putExtra('android.provider.extra.APP_PACKAGE', pkName);
} else if (Build.VERSION.SDK_INT >= 21) { //android 5.0-7.0
} else if (Build.VERSION.SDK_INT >= 21) {
var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
intent.putExtra("app_package", pkName);
intent.putExtra("app_uid", uid);
} else { //(<21)--
} else {
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
}
//
main.startActivity(intent);
}
}

618
components/print/index.js

@ -1,317 +1,315 @@
import PrinterJobs from '@/components/print/printerjobs.js'
import printerUtil from '@/components/print/printerutil.js'
import util from '@/components/print/util.js'
import drawQrcode from '@/components/print/weapp.qrcode.esm.js'
import Bluetooth from '@/components/print/bluetooth.js'
let bluetooth = new Bluetooth();
let isPrint= false
let data1 = {}
export default {
// onDone: 打印完成(或失败/跳过)后执行的回调,用于队列驱动
getData(onDone) {
var that = this;
if(uni.getStorageSync('bluetoothDeviceId')){
let id = uni.getStorageSync('bluetoothDeviceId')
const baseUrl = getApp().globalData.mainurl
uni.request({
url: baseUrl + "/mall/order/detail/"+ getApp().globalData.printData[0].order_id,
data: {},
method:'GET',
header: {
"content-type": 'application/x-www-form-urlencoded',
'accessToken':uni.getStorageSync('hiver_token')
},
success: function(res) {
if (res.data.code == 200) {
data1 = res.data.result
that.bindViewTap(id, false, onDone)
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
});
// 请求失败也需要通知队列继续处理下一条
if (typeof onDone === 'function') onDone();
return;
}
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
// 请求失败也需要通知队列继续处理下一条
if (typeof onDone === 'function') onDone();
}
})
}else{
uni.showModal({
title: '提示',
content: '您还没有连接打印机,将无法为您打印小票!',
confirmText:'连接蓝牙',
cancelText:'暂不连接',
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url:'/pages/myCenter/setPrint'
})
}
// 未连接打印机也通知队列继续(跳过当前条)
if (typeof onDone === 'function') onDone();
}
});
}
},
async bindViewTap(deviceId, state, onDone) {
var _this = this;
try {
//1.链接设备
await bluetooth.createBLEConnection(deviceId).then((res) => {
bluetooth.deviceId = deviceId;
}).catch((e) => {
throw e;
});
let server = [];
//2.寻找服务
await bluetooth.getBLEDeviceServices().then((res) => {
bluetooth.notifyId = '';
bluetooth.writeId = '';
bluetooth.num = 0;
bluetooth.serviceList = res
}).catch((e) => {
throw e;
});
//3.获取蓝牙设备所有服务
let result3 = await bluetooth.getBLEDeviceCharacteristics().then(res => {
uni.setStorageSync('bluetoothDeviceId', deviceId);
this.pickUpOnce(onDone)
}).catch((e) => {
throw e;
});
} catch (e) {
// 蓝牙连接异常也需要通知队列继续
import PrinterJobs from '@/components/print/printerjobs.js'
import printerUtil from '@/components/print/printerutil.js'
import util from '@/components/print/util.js'
import drawQrcode from '@/components/print/weapp.qrcode.esm.js'
import Bluetooth from '@/components/print/bluetooth.js'
let bluetooth = new Bluetooth();
let isPrint = false
let data1 = {}
export default {
getData(onDone) {
var that = this;
if (uni.getStorageSync('bluetoothDeviceId')) {
let id = uni.getStorageSync('bluetoothDeviceId')
const baseUrl = getApp().globalData.mainurl
uni.request({
url: baseUrl + "/mall/order/detail/" + getApp().globalData.printData[0].order_id,
data: {},
method: 'GET',
header: {
"content-type": 'application/x-www-form-urlencoded',
'accessToken': uni.getStorageSync('hiver_token')
},
success: function(res) {
if (res.data.code == 200) {
data1 = res.data.result
console.log('打印的数据----------',data1)
that.bindViewTap(id, false, onDone)
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if (typeof onDone === 'function') onDone();
return;
}
uni.hideLoading();
},
fail: function(err) {
uni.hideLoading();
if (typeof onDone === 'function') onDone();
}
},
//打印一次
pickUpOnce(onDone) {
isPrint = true;
bluetooth.notifyBLECharacteristicValue();
let self = this;
setTimeout(() => {
self.writeBLECharacteristicValue(onDone);
}, 500);
},
maskPhoneLastFour(phone) {
if (!phone) return '';
const str = String(phone);
if (str.length <= 4) return str; // 长度不足4位直接返回
return str.replace(/.(?=.{4})/g, '*');
},
//写入控制命令
async writeBLECharacteristicValue(onDone) {
let printerJobs = new PrinterJobs();
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(60).print(
(data1.deliveryType == 1 && data1.orderType == 3 ? data1.deliveryInfo.numberCode :data1.numberCode) + (
(data1.status == 7 || data1.status == 11) ? '待退款' :
data1.deliveryType == 1 && data1.orderType == 3 ? '面对面配送' :
data1.deliveryType == 1 ? '配送' :
data1.isPack == 0 ? '到店-堂食' :
data1.isPack == 1 ? '到店-打包' : '到店'
)
);
printerJobs.setSize(1, 1).setLineSpacing(40);
printerJobs.setAlign('lt').print(
'预计时间:' + (data1.deliveryInfo == null ? '暂无' : this.formatTime(data1.deliveryInfo.mustFinishTime))
);
printerJobs.setAlign('lt').print(data1.shopName);
printerJobs.print(printerUtil.fillLine('-', 1, 32));
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print(
data1.receiverName == null ? '暂无' : data1.receiverName
);
printerJobs.setSize(1, 1).setLineSpacing(40);
printerJobs.setAlign('lt').print('联系电话: ' + this.maskPhoneLastFour(data1.receiverPhone));
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print(
'地址:' + (data1.receiverAddress == null ? '暂无' : data1.receiverAddress)
);
printerJobs.setSize(1, 1).setLineSpacing(40);
printerJobs.setAlign('lt').print('顾客电话已被隐藏,您可登录商家端或骑手端查看');
printerJobs.print(printerUtil.fillLine('-', 1, 32));
// 商品列表
for (var i = 0; i < data1.goodsList.length; i++) {
var productName = this.removeEmojis(data1.goodsList[i].productName)
printerJobs.setAlign('lt').setSize(2, 2).print(productName);
if (data1.goodsList[i].specs) {
printerJobs.setSize(1, 1).print(this.delNode(data1.goodsList[i].specs));
}
printerJobs.setSize(2, 2);
printerJobs.setAlign('lt').text('¥'+data1.goodsList[i].price);
printerJobs.text(" ");
printerJobs.print('X' + data1.goodsList[i].quantity);
printerJobs.setSize(1, 1);
}
printerJobs.print(printerUtil.fillLine('-', 1, 32));
printerJobs.setAlign('lt').print('配送费:' + data1.deliveryFee);
printerJobs.print('合计金额:' + data1.totalAmount);
printerJobs.setSize(2, 2).print('备注:' + data1.remark);
printerJobs.setSize(1, 1).print(printerUtil.fillLine('-', 1, 32));
printerJobs.setAlign('lt').print('商品取到后,如有任何商品问题,请及时联系商家和平台,客服将为您服务,谢谢您的惠顾');
printerJobs.lineFeed(3);
let buffer = printerJobs.buffer();
this.sendPrint(buffer, onDone);
},
// 去除字符串中的 Emoji 表情
removeEmojis(str) {
if (!str) return '';
// 兼容性极好的 Emoji 正则表达式(支持各种运行环境,包括小程序和旧版浏览器)
var emojiRegex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;
return str.replace(emojiRegex, '');
},
formatTime(value) {
if (!value) return '';
if (value == '尽快送达') return '尽快送达';
const date = new Date(value);
// 获取年份
const year = date.getFullYear();
// 获取月份 (getMonth 返回 0-11,所以需要 +1),并补齐0
const month = String(date.getMonth() + 1).padStart(2, '0');
// 获取日 (getDate),并补齐0
const day = String(date.getDate()).padStart(2, '0');
// 获取小时 (getHours),并补齐0
const hour = String(date.getHours()).padStart(2, '0');
// 获取分钟 (getMinutes),并补齐0
const minute = String(date.getMinutes()).padStart(2, '0');
// 获取秒 (getSeconds),并补齐0
const second = String(date.getSeconds()).padStart(2, '0');
// 拼接格式:年-月-日 时:分:秒
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
},
delNode(data) {
// 1. 统一转为字符串
let str;
if (typeof data === 'object' && data !== null) {
// 对象或数组 → JSON 字符串
str = JSON.stringify(data);
} else if (typeof data === 'string') {
str = data;
} else {
// 其他类型(数字、布尔等)先转字符串
str = String(data);
})
} else {
uni.showModal({
title: '提示',
content: '您还没有连接打印机,将无法为您打印小票!',
confirmText: '连接蓝牙',
cancelText: '暂不连接',
success: function(res) {
if (res.confirm) {
uni.navigateTo({
url: '/pages/myCenter/setPrint'
})
}
if (typeof onDone === 'function') onDone();
}
});
}
},
async bindViewTap(deviceId, state, onDone) {
var _this = this;
try {
await bluetooth.createBLEConnection(deviceId).then((res) => {
bluetooth.deviceId = deviceId;
}).catch((e) => {
throw e;
});
let server = [];
await bluetooth.getBLEDeviceServices().then((res) => {
bluetooth.notifyId = '';
bluetooth.writeId = '';
bluetooth.num = 0;
bluetooth.serviceList = res
}).catch((e) => {
throw e;
});
let result3 = await bluetooth.getBLEDeviceCharacteristics().then(res => {
uni.setStorageSync('bluetoothDeviceId', deviceId);
this.pickUpOnce(onDone)
}).catch((e) => {
throw e;
});
} catch (e) {
if (typeof onDone === 'function') onDone();
}
},
//打印一次
pickUpOnce(onDone) {
isPrint = true;
bluetooth.notifyBLECharacteristicValue();
let self = this;
setTimeout(() => {
self.writeBLECharacteristicValue(onDone);
}, 500);
},
maskPhoneLastFour(phone) {
if (!phone) return '';
const str = String(phone);
if (str.length <= 4) return str;
return str.replace(/.(?=.{4})/g, '*');
},
//写入控制命令
async writeBLECharacteristicValue(onDone) {
let printerJobs = new PrinterJobs();
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(60).print(
data1.deliveryType == 1 && data1.orderType == 3 ? data1.deliveryInfo.numberCode : data1.numberCode
);
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(60).print(
(data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1 && data1.status != 7 && data1.status == 11)? '预约单':
(data1.status == 7 || data1.status == 11)? '申请退款':
(data1.deliveryType == 1 && data1.orderType == 3) ? '面对面配送':
(data1.status == 3 && data1.deliveryType == 2)? '待消费':
data1.status == 5? '已完成':
data1.status == 6? '已取消':
data1.status == 8? '已退款':
data1.status == 12? '已售后':
data1.isPack == 0 ? '到店-堂食':
data1.isPack == 1 ? '到店-打包':
data1.deliveryType == 1 ? '配送': ''
);
if(data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1){
printerJobs.setAlign('lt').print(
'要求送达时间:' + (data1.deliveryInfo == null ? ' ' : this.formatTime(data1.deliveryInfo.mustFinishTime))
);
}
printerJobs.setSize(1, 1).setLineSpacing(40);
printerJobs.setAlign('lt').print(data1.shopName);
printerJobs.setAlign('lt').print(
'下单时间:' + this.formatTime(data1.createTime)
);
if(data1.mallRefundRecord == null){
if(data1.deliveryType == 1){
printerJobs.setAlign('lt').print(
'预计送达时间:' + (data1.deliveryInfo == null ? ' ' : this.formatTime(data1.deliveryInfo.mustFinishTime))
);
}else if(data1.userRequireMake == 1){
printerJobs.setAlign('lt').print(
'核销时间:' + this.formatTime(data1.createTime)
);
}
}
if(data1.mallRefundRecord != null){
if(data1.userRequireMake == 1 && data1.deliveryType == 2){
printerJobs.setAlign('lt').print(
'核销时间:' + this.formatTime(data1.createTime)
);
}
printerJobs.setAlign('lt').print(
'申请退款时间:' + (data1.mallRefundRecord == null ? ' ' : this.formatTime(data1.mallRefundRecord[0].createTime))
);
// 2. 删除所有大括号 { } 和双引号 "
const result = str.replace(/[{}"]/g, '');
return result;
},
sendPrint(buffer, onDone) {
const maxChunk = 20; // 每次20字节
const delay = 50; // 间隔50ms
isPrint = true;
const totalLength = buffer.byteLength;
let currentIndex = 0;
// 创建源数据的视图,方便读取
const srcView = new Uint8Array(buffer);
const sendNextChunk = () => {
if (currentIndex >= totalLength) {
// 发送完毕
isPrint = false;
if (typeof onDone === 'function') onDone();
return;
}
const end = Math.min(currentIndex + maxChunk, totalLength);
const chunkLength = end - currentIndex;
const valueToSend = new ArrayBuffer(chunkLength);
const dstView = new Uint8Array(valueToSend);
dstView.set(srcView.subarray(currentIndex, end));
bluetooth.writeBLECharacteristicValue(valueToSend).then(() => {
currentIndex = end;
setTimeout(sendNextChunk, delay);
}).catch((err) => {
isPrint = false;
if (typeof onDone === 'function') onDone(err);
});
};
// 开始发送第一个包
sendNextChunk();
},
sendPrintData(buffer) {
bluetooth.writeBLECharacteristicValue(buffer).then(res => {});
},
startSearch(state) {
let that = this
bluetooth.openBluetoothAdapter().then(e => {
uni.startBluetoothDevicesDiscovery({
success: res => {
uni.onBluetoothDeviceFound(result => {
let arr = that.list;
let devices = [];
let list = result.devices;
for (let i = 0; i < list.length; ++i) {
if (list[i].name && list[i].name != "未知设备") {
let arrNew = arr.filter((item) => {
return item.deviceId == list[i].deviceId;
});
if (arrNew.length == 0) {
devices.push(list[i]);
}
if (uni.getStorageSync('bluetoothDeviceId') == list[i]
.deviceId) {
// that.bindViewTap(list[i].deviceId, state)
}
}
}
printerJobs.print(printerUtil.fillLine('-', 1, 32));
if(data1.deliveryType == 1 && data1.status != 7 && data1.status != 11 && data1.status != 5 && data1.status != 6 && data1.status != 8 && data1.status != 12){
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print(
data1.receiverName == null ? ' ' : data1.receiverName
);
}
printerJobs.setSize(1, 1).setLineSpacing(40);
printerJobs.setAlign('lt').print('联系电话: ' + this.maskPhoneLastFour(data1.receiverPhone));
if(data1.deliveryType == 1 && data1.status != 7 && data1.status != 11 && data1.status != 5 && data1.status != 6 && data1.status != 8 && data1.status != 12){
printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print(
'地址:' + (data1.receiverAddress == null ? ' ' : data1.receiverAddress)
);
}
printerJobs.setSize(1, 1).setLineSpacing(40);
printerJobs.setAlign('lt').print('顾客电话已被隐藏,您可登录商家端或骑手端查看');
printerJobs.print(printerUtil.fillLine('-', 1, 32));
for (var i = 0; i < data1.goodsList.length; i++) {
var productName = this.removeEmojis(data1.goodsList[i].productName)
printerJobs.setAlign('lt').setSize(2, 2).print(productName);
if (data1.goodsList[i].specs) {
printerJobs.setSize(1, 1).print(this.delNode(data1.goodsList[i].specs));
}
printerJobs.setSize(2, 2);
printerJobs.setAlign('lt').text('¥' + data1.goodsList[i].price);
printerJobs.text(" ");
printerJobs.print('X' + data1.goodsList[i].quantity);
printerJobs.setSize(1, 1);
}
printerJobs.print(printerUtil.fillLine('-', 1, 32));
printerJobs.setAlign('lt').print('配送费:' + data1.deliveryFee);
if(data1.packageFee > 0){
printerJobs.print('打包费:' + data1.packageFee);
}
if(data1.userCoupon && data1.userCoupon.length >0){
printerJobs.print('优惠券:-' + data1.userCoupon[0].discountAmount);
}
if(data1.freeAmount > 0){
printerJobs.print('锦鲤免单:-' + data1.freeAmount);
}
printerJobs.print('商品金额:' + data1.goodsAmount);
printerJobs.print('合计金额:' + (data1.goodsAmount + data1.deliveryFee + data1.packageFee));
if(data1.mallRefundRecord != null){
printerJobs.print('应退金额:' + data1.totalAmount);
}else{
printerJobs.print('实付金额:' + data1.totalAmount);
}
printerJobs.setSize(2, 2).print('备注:' + data1.remark);
if(data1.mallRefundRecord != null){
printerJobs.setAlign('lt').print(
'退款原因:' + (data1.mallRefundRecord == null ? ' ' : data1.mallRefundRecord[0].reason)
);
}
printerJobs.setSize(1, 1).print(printerUtil.fillLine('-', 1, 32));
printerJobs.setAlign('lt').print('商品取到后,如有任何商品问题,请及时联系商家和平台,客服将为您服务,谢谢您的惠顾');
printerJobs.lineFeed(3);
let buffer = printerJobs.buffer();
this.sendPrint(buffer, onDone);
},
// 去除字符串中的 Emoji 表情
removeEmojis(str) {
if (!str) return '';
var emojiRegex =
/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;
return str.replace(emojiRegex, '');
},
formatTime(value) {
if (!value) return '';
if (value == '尽快送达') return '尽快送达';
const date = new Date(value);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
const second = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
},
delNode(data) {
let str;
if (typeof data === 'object' && data !== null) {
str = JSON.stringify(data);
} else if (typeof data === 'string') {
str = data;
} else {
str = String(data);
}
const result = str.replace(/[{}"]/g, '');
return result;
},
sendPrint(buffer, onDone) {
const maxChunk = 20;
const delay = 50;
isPrint = true;
const totalLength = buffer.byteLength;
let currentIndex = 0;
const srcView = new Uint8Array(buffer);
const sendNextChunk = () => {
if (currentIndex >= totalLength) {
isPrint = false;
if (typeof onDone === 'function') onDone();
return;
}
const end = Math.min(currentIndex + maxChunk, totalLength);
const chunkLength = end - currentIndex;
const valueToSend = new ArrayBuffer(chunkLength);
const dstView = new Uint8Array(valueToSend);
dstView.set(srcView.subarray(currentIndex, end));
bluetooth.writeBLECharacteristicValue(valueToSend).then(() => {
currentIndex = end;
setTimeout(sendNextChunk, delay);
}).catch((err) => {
isPrint = false;
if (typeof onDone === 'function') onDone(err);
});
};
sendNextChunk();
},
sendPrintData(buffer) {
bluetooth.writeBLECharacteristicValue(buffer).then(res => {});
},
startSearch(state) {
let that = this
bluetooth.openBluetoothAdapter().then(e => {
uni.startBluetoothDevicesDiscovery({
success: res => {
uni.onBluetoothDeviceFound(result => {
let arr = that.list;
let devices = [];
let list = result.devices;
for (let i = 0; i < list.length; ++i) {
if (list[i].name && list[i].name != "未知设备") {
let arrNew = arr.filter((item) => {
return item.deviceId == list[i].deviceId;
});
if (arrNew.length == 0) {
devices.push(list[i]);
}
that.list = arr.concat(devices);
});
},
fail: res => {
uni.hideLoading();
uni.showToast({
title: `搜索设备失败` + JSON.stringify(err)
})
if (uni.getStorageSync('bluetoothDeviceId') == list[i]
.deviceId) {
// that.bindViewTap(list[i].deviceId, state)
}
}
}
that.list = arr.concat(devices);
});
},
fail: res => {
uni.hideLoading();
uni.showToast({
title: `搜索设备失败` + JSON.stringify(err)
})
}).catch(e => {});
},
// 停止搜索
stopSearch() {
uni.hideLoading();
bluetooth.stopBluetoothDevicesDiscovery();
}
}
}
})
}).catch(e => {});
},
// 停止搜索
stopSearch() {
uni.hideLoading();
bluetooth.stopBluetoothDevicesDiscovery();
}
}

6
components/tab-bar/myCenter.vue

@ -109,9 +109,9 @@
},
methods: {
init(){
this.shopName = JSON.parse(uni.getStorageSync('area')).shop.shopName;
this.shopIcon = JSON.parse(uni.getStorageSync('area')).shop.shopIcon;
this.region = JSON.parse(uni.getStorageSync('area')).shop.region;
this.shopName = JSON.parse(uni.getStorageSync('area')).shopName;
this.shopIcon = JSON.parse(uni.getStorageSync('area')).shopIcon;
this.region = JSON.parse(uni.getStorageSync('area')).region;
// key
const { keys } = uni.getStorageInfoSync();
const data = {};

9
pages.json

@ -218,15 +218,6 @@
"bounce": "none"
}
}
},{
"path": "pages/shop/shopReturnOrder",
"style": {
"navigationBarTitleText": "退款页面",
"navigationStyle": "custom",
"app-plus": {
"bounce": "none"
}
}
},{
"path": "pages/shop/addType",
"style": {

17
pages/index/index.vue

@ -280,12 +280,17 @@
this.indexInit()
},
onLoad() {
if(uni.getStorageSync('peisongyuan')){
uni.reLaunch({
url: '../worker/index'
})
return
}
},
methods: {
indexInit() {
let that = this
this.shopConfig = JSON.parse(uni.getStorageSync('area')).shop || {}
this.shopConfig = JSON.parse(uni.getStorageSync('area')) || {}
uni.getSystemInfo({
success: function(info) {
@ -336,8 +341,8 @@
}, false, 'GET', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) {
this.shop = res.result
this.shop.shopIcon = JSON.parse(uni.getStorageSync('area')).shop.shopIcon
this.shop.shopName = JSON.parse(uni.getStorageSync('area')).shop.shopName
this.shop.shopIcon = JSON.parse(uni.getStorageSync('area')).shopIcon
this.shop.shopName = JSON.parse(uni.getStorageSync('area')).shopName
this.businessStatus = res.result.status
} else {
uni.showToast({
@ -352,10 +357,8 @@
uni.setStorageSync('shopId', item.shop.id)
uni.setStorageSync('shopMerchantType', item.shop.merchantType)
uni.setStorageSync('area', JSON.stringify(item))
console.log('1111111111111111',uni.getStorageSync('shopMerchantType'))
this.getBusinessStatus()
this.getData()
this.$refs.areaPopup.close()
},
//
@ -417,7 +420,7 @@
url = '/pages/shop/transferDeliveryOrderList'
break;
case 'tui':
url = '/pages/shop/shopReturnOrder?type=shop'
url = '/pages/shop/afterService?type=shop'
break;
case 'zd':
url = '/pages/shop/shopBill'

48
pages/login/login.vue

@ -58,7 +58,7 @@
<view class="popup-area-title">
<text>选择登录店铺</text>
</view>
<view class="popup-area-container" v-for="item in shopList" :key="item" @tap="checkShop(item)">
<view class="popup-area-container" v-for="(item,index) in shopList" :key="index" @tap="checkShop(item)">
<text style="display: inline-block">{{item.shopName}}</text>
</view>
</view>
@ -329,25 +329,25 @@
uni.getSystemInfo({
success: function (res1) {
that.NB.sendRequest('/auth/chooseShop', {
shopId: item.shop.id,
shopId: item.id,
deviceId:res1.deviceId
}, true, 'POST', 'application/x-www-form-urlencoded').then(res => {
if (res.code == 200) {
uni.setStorageSync('type',item.type)
uni.setStorageSync('warehouseKeeperFlag',item.warehouseKeeperFlag)
uni.setStorageSync('shopId',item.shop.id)
uni.setStorageSync('shopId',item.id)
uni.setStorageSync('shopName',item.shopName)
uni.setStorageSync('storeFlag',item.storeFlag)
uni.setStorageSync('shopIcon',res.result.shopIcon)
uni.setStorageSync('shopAddress',res.result.shopAddress)
uni.setStorageSync('shopRemark',res.result.remark)
uni.setStorageSync('shopScore',item.shop.shopScore)
uni.setStorageSync('shopMerchantType', item.shop.merchantType)
uni.setStorageSync('shopScore',item.shopScore)
uni.setStorageSync('shopMerchantType', item.merchantType)
uni.setStorageSync("shopOwnerPhone", item.shopOwnerPhone)
uni.setStorageSync('schoolShop',res.result.shop)
uni.setStorageSync('schoolShop',res.result.shop)
uni.setStorageSync('shopTakeaway',item.shopTakeaway)
uni.setStorageSync('attrId',item.shop.attrId)
uni.setStorageSync('attrId',item.attrId)
uni.setStorageSync('area',JSON.stringify(item))
uni.setStorageSync("isShop",true)
setTimeout(() => {
@ -412,17 +412,43 @@
that.NB.sendRequest(url, data, true, 'POST', 'application/x-www-form-urlencoded').then(res => {
if (res.code !== 200) return
uni.setStorageSync("hiver_token", res.result.accessToken)
if (res.result.accessToken) uni.setStorageSync('hiver_token', res.result.accessToken)
if (res.result.worker !== undefined) uni.setStorageSync('worker', res.result.worker)
uni.setStorageSync("wayValue", this.wayValue)
uni.setStorageSync("nickname", res.result.user.nickname)
uni.setStorageSync('username',this.mobile)
if (res.result.shopList.length > 1) {
this.shopList = res.result.shopList;
if (res.result.shop !== undefined) uni.setStorageSync('schoolShop', res.result.shop)
if (res.result.waimaiData !== undefined) uni.setStorageSync('waimaiData', res.result.waimaiData)
if (res.result.kuaidiData !== undefined) uni.setStorageSync('kuaidiData', res.result.kuaidiData)
if (res.result.user) {
uni.setStorageSync('nickname', res.result.user.nickname)
uni.setStorageSync('id', res.result.user.id)
uni.setStorageSync('unionid', res.result.user.unionid)
uni.setStorageSync('miniProgramOpenid', res.result.user.miniProgramOpenid)
uni.setStorageSync('officialAccountOpenid', res.result.user.officialAccountOpenid)
if (res.result.user.mobile) {
uni.setStorageSync('mobile', res.result.user.mobile)
}
}
// uni.setStorageSync('area',JSON.stringify(item))
this.shopList = res.result.shop;
let data = {
id:res.result.worker.region
}
uni.setStorageSync('area',JSON.stringify(data))
uni.setStorageSync('peisongyuan',this.peisongyuan)
if(this.peisongyuan){
uni.reLaunch({
url: '../worker/index'
})
return
}
console.log('111111111111111111111',res)
if (this.shopList.length > 1) {
this.toggle("center");
}else{
this.checkShop(res.result.shopList[0])
this.checkShop(this.shopList[0])
}
})

553
pages/shop/shopReturnOrder.vue

@ -1,553 +0,0 @@
<template>
<view class="page1">
<view class="title">
<view class="title-sreach">
<view class="back-btn" @tap="back">
<uni-icons type="left" size="28"></uni-icons>
</view>
<view class="title-name">
待退款/售后{{returnCount}}
</view>
</view>
</view>
<view class="content">
<!-- <view class="box1" style="display: flex;">
<view class="">
待退款/售后{{returnCount}}
</view>
</view> -->
<view class="box1" v-for="(item,index) in returnData" :key="index">
<view style="display: flex;height: 50rpx;border-bottom: 1px solid #eee;">
<view style="display: flex;">
{{'#' + item.mallOrder.numberCode}}
</view>
<view style="flex: 1;display: flex;padding-left: 20rpx;">
{{item.createTime | formatISOTime}}
<!-- <text>已退款</text> -->
</view>
<view>
{{item.status == 0?'待退款':item.status == 3?'待售后':""}}
</view>
</view>
<view style="height: 180rpx;padding-top: 20rpx;color: #777;">
<view style="height: 50rpx;line-height: 50rpx;font-size: 28rpx;">
<view>退款原因: <text style="font-weight: 700;color:#00231C;">{{item.refundTypeStatus == 1?'商家原因':item.refundTypeStatus == 2?'配送原因':item.refundTypeStatus == 3?'商家/配送都有原因(需要退配送费)':item.refundTypeStatus == 4?'平台退款':""}}</text></view>
<view>退款类型: <text style="font-weight: 700;color:#00231C;">{{item.refundType == 1?'退商品':item.refundType == 2?'退配送费':item.refundType == 3?'全额退款':""}}</text></view>
<view style="text-align: right;">退款金额: <text style="color:red;font-size: 34rpx;font-weight: 700;">{{item.refundAmount}}</text></view>
</view>
</view>
<view style="height: 80rpx;border-top: 1px solid #eee;display: flex;">
<view style="flex: 1;">
<view class="btn" @tap="orderDetailOpen(item)" style="display: inline-block;">
查看订单
</view>
</view>
<view class="btn" @tap="returnAmountAllow(item,0)" style="background: rgba(0, 35, 28, 1);color: rgba(166, 255, 234, 1);">
不同意
</view>
<view class="btn" @tap="returnAmountAllow(item,1)" style="margin-left: 10px;">
同意
</view>
</view>
</view>
<uni-popup ref="orderPopup" background-color="#fff">
<view class="popup-area-content" style="height: 1200rpx;overflow: scroll;">
<view class="popup-area-title">
<text>订单详情</text>
</view>
<view class="box1">
<view style="width: 100%;line-height: 70rpx;font-size: 28rpx;font-weight: 700;">
{{orderDetail.shopName}}
<img @tap="makeCall(orderDetail.shopPhone)"
src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/869a7af6a1c24bf3a0d523c4a18b55c6.png"
alt="" style="width: 60rpx;height: 60rpx;" />
</view>
<view v-for="(item1,index1) in goodsList" :key="index1" v-if="goodsList != null && goodsList.length > 0" style="display: flex;padding: 20rpx;background: #eee;border-radius: 20rpx;">
<view class="goods-img">
<img :src="item1.productPicture" alt="">
</view>
<view class="goods-content">
<view class="goods-name">
{{item1.productName}}
</view>
<view class="goods-content-center">
<view class="goods-deal1">
{{item1.specs}}
</view>
</view>
<view class="goods-content-bottom">
<view style="width: 50%;">
X{{item1.quantity}}
</view>
<view class="pintuan-left-price">
{{item1.price}}
</view>
</view>
</view>
</view>
<view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;" v-if="orderDetail.packageFee != null && orderDetail.packageFee > 0">
<view style="flex: 1;color: #777;font-weight: 700;">
打包费
</view>
<view style="color: #000;font-weight:700;">
{{orderDetail.packageFee}}
</view>
</view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;" v-if="orderDetail.deliveryType == 1">
<view style="flex: 1;color: #777;font-weight: 700;">
配送费
</view>
<view style="color: #000;font-weight:700;">
{{orderDetail.deliveryFee}}
</view>
</view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;">
<view style="flex: 1;color: #777;font-weight: 700;">
优惠券
</view>
<view style="color: #000;font-weight:700;">
-1 <uni-icons type="right" size="12"></uni-icons>
</view>
</view>
</view>
<view style="display: flex;height: 80rpx;line-height: 100rpx;border-top: 1px solid #eee;font-size: 32rpx;font-weight: 700;">
<view style="flex: 1;">
实付
</view>
<view class="">
{{orderDetail.totalAmount}}
</view>
</view>
</view>
<view class="box1">
<view>
<!-- <view style="height: 80rpx;line-height: 80rpx;display: flex;">
<view style="flex: 1;color: #777;font-weight: 700;">
收件地址
</view>
<view style="color: #000;font-weight: 700;">
北校区1号宿舍楼5楼512(0702)
</view>
</view> -->
<view style="height: 80rpx;line-height: 80rpx;display: flex;" v-if="orderDetail.numberCode != null">
<view style="flex: 1;color: #777;font-weight: 700;">
订单号
</view>
<view style="color: #000;font-weight: 700;">
{{orderDetail.numberCode}}
</view>
</view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;">
<view style="flex: 1;color: #777;font-weight: 700;">
下单时间
</view>
<view style="color: #000;font-weight: 700;">
{{orderDetail.createTime | formatISOTime}}
</view>
</view>
<view style="height: 80rpx;line-height: 80rpx;display: flex;" v-if="orderDetail.shopMakeTime != null">
<view style="flex: 1;color: #777;font-weight: 700;">
商家出餐时间
</view>
<view style="color: #000;font-weight: 700;">
{{orderDetail.shopMakeTime ? orderDetail.shopMakeTime : '' | formatISOTime}}
</view>
</view>
</view>
</view>
<view class="popup-area-container" v-for="(item,index) in productData" :key="index">
<text style="display: inline-block">{{item.productName}} {{item.specs}} * {{item.quantity}}</text>
</view>
</view>
</uni-popup>
<!-- 拼团详情弹窗 -->
<uni-popup ref="pintuanPopup" background-color="#fff">
<view class="guize-list">
<view v-for="(item,index) in tuanzhangOrder" :key="index">
<view style="height: 80rpx;line-height: 80rpx;font-size: 36rpx;font-weight: 700;">
订单-{{item.numberCode}}
</view>
<view class="">
<view class="dingdan">
<view style="display:flex">
<view style="width:300rpx;">
订单状态
</view>
<view class="pituan-text">
{{item.status == 0?'待支付':item.status == 2?'待配送员接单':(item.status == 3 && item.deliveryType == 1 && item.shopMakeTime == null) || (item.status == 3 && item.deliveryType == 2 && item.userRequireMake == 1)?'待出餐':(item.status == 3 && item.deliveryType == 1 && item.shopMakeTime != null)?'待取货':(item.status == 3 && item.deliveryType == 2)?'待消费':item.status == 4?'待送达':item.status == 5?'已完成':item.status == 7?'待同意退款':item.status == 8?'已退款':item.status == 6?'已取消':item.status == 11?'售后中':item.status == 12?'已售后':""}}
</view>
</view>
<view style="display:flex">
<view style="width:300rpx;">
订单号
</view>
<view class="pituan-text">
{{item.id}}
</view>
</view>
<view style="display:flex">
<view style="width:300rpx;">
订单时间
</view>
<view class="pituan-text">
{{item.createTime | formatISOTime}}
</view>
</view>
</view>
<view class="dingdan" v-for="(item1,index1) in item.goodsList" :key="index1">
<view class="pt-title">
商品信息
</view>
<view style="display: flex;font-weight: 700;">
<view style="flex:1">
商品名{{item1.productName}}
</view>
<view style="width:100rpx;">
X{{item1.quantity}}
</view>
<view style="width:220rpx;text-align: right;padding-right:20rpx;">
{{item1.price}}
</view>
</view>
</view>
<view class="dingdan">
<view style="text-align: right;padding-right: 20rpx;color: #777;">
餐盒费{{item.packageFee}} 配送费{{item.deliveryFee}}
</view>
<view style="text-align: right;padding-right: 20rpx;font-size: 28rpx;font-weight: 700;color: red;">
总计{{item.totalAmount}}
</view>
</view>
</view>
</view>
</view>
</uni-popup>
</view>
</view>
</template>
<script>
export default {
data() {
return {
searchCountForm:{
linkId:uni.getStorageSync('worker').workerId,
pageNum:1,
pageSize:100,
statusList:[0,3]
},
type:'worker',
returnFormData:{},
groupOrderIdList:[],
tuanzhangOrder:[],
goodsList:[],
orderDetail:{},
returnData:[],
returnCount:0
}
},
filters:{
formatISOTime(isoString) {
const date = new Date(isoString);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
},
onShow() {
this.searchCountForm.linkId = uni.getStorageSync('worker').workerId
},
onLoad(option) {
if(option.type){
this.type = option.type
}
this.getReturnCount()
},
methods: {
getGroupOrders(id){
this.NB.sendRequest("/mall/order/selectAllOrderByOrderId/"+id, {}, false, 'GET', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) {
this.tuanzhangOrder = res.result;
this.$refs.pintuanPopup.open('bottom')
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
uni.hideLoading()
}).catch((res) => {})
},
orderDetailOpen(item){
this.returnFormData.id = item.id;
this.returnFormData.linkId = item.linkId;
this.returnFormData.orderId = item.orderId;
this.returnFormData.deliveryType = item.mallOrder.deliveryType;
this.returnFormData.refundAmount = item.refundAmount;
this.returnFormData.refundType = item.refundType;
this.returnFormData.refundTypeStatus = item.refundTypeStatus;
this.orderDetail = item.mallOrder;
this.goodsList = item.items;
this.$refs.orderPopup.open();
},
makeCall(phone){
uni.makePhoneCall({
phoneNumber: phone
});
},
getReturnCount(){
let that = this
if(this.type == 'worker'){
this.searchCountForm.linkId = uni.getStorageSync('worker').workerId
}else{
this.searchCountForm.linkId = uni.getStorageSync('shopId')
}
this.NB.sendRequest("/mall/refund/page", this.searchCountForm, false, 'POST', 'application/json').then((res) => {
if (res.code == 200) {
that.returnCount = res.result.records.length;
that.returnData = res.result.records
that.$forceUpdate();
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
uni.hideLoading()
}).catch((res) => {})
},
returnAmountAllow(item,status){
let titleText = status == 1 ? '确定同意该申请吗?' : '确定拒绝该申请吗?';
//退
if(item.groupOrderIds != null && item.groupOrderIds != ''){
titleText += '该订单为面对面配送单,所有参团订单将同步处理';
for(let i = 0; i < this.returnData.length;i++){
if(item.groupOrderIds.indexOf(this.returnData[i].mallOrder.id) != -1){
//
this.groupOrderIdList.push(this.returnData[i]);
}
}
}else{
this.groupOrderIdList = []
}
// 2.
uni.showModal({
title: '提示',
content: titleText,
success: (res) => {
if (res.confirm) {
if(this.groupOrderIdList != [] && this.groupOrderIdList.length > 0){
for(let i = 0; i < this.groupOrderIdList.length;i++){
this.processReturn(this.groupOrderIdList[i], status);
}
}else{
this.processReturn(item, status);
}
}
}
});
},
processReturn(item,status){
let url = ''
//退
if(item.status == 0){
//
if(status == 0){
this.returnFormData.status = 2
}else{
this.returnFormData.status = 1
}
}else if(item.status == 3){
//
if(status == 0){
this.returnFormData.status = 5
}else{
this.returnFormData.status = 4
}
}
this.returnFormData.id = item.id;
this.returnFormData.linkId = item.linkId;
this.returnFormData.orderId = item.orderId;
this.returnFormData.deliveryType = item.mallOrder.deliveryType;
this.returnFormData.orderType = item.mallOrder.orderType;
this.returnFormData.refundAmount = item.refundAmount;
this.returnFormData.refundType = item.refundType;
this.returnFormData.refundTypeStatus = item.refundTypeStatus;
let that = this
this.NB.sendRequest("/mall/refund/allowOrReject", this.returnFormData, false, 'POST', 'application/json').then((res) => {
if (res.code == 200) {
uni.showToast({
title: res.message,
icon: 'none'
})
this.getReturnCount()
that.$forceUpdate();
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
uni.hideLoading()
}).catch((res) => {})
},
back() {
uni.navigateBack()
},
}
}
</script>
<style lang="scss">
page {
width: 100%;
height: 100%;
font-size: 24rpx;
background: #F5F8F5;
color: #00231C;
}
.page1 {
width: 100%;
height: 100%;
font-size: 24rpx;
position: relative;
}
.title {
background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/8bc15960c2dc40268e295d6dd23aecce.png') no-repeat;
width: 100%;
height: 20%;
}
.title-sreach {
width: 100%;
display: flex;
height: 200rpx;
position: relative;
}
.back-btn {
padding-top: 110rpx;
}
.title-name {
padding-top: 110rpx;
font-size: 36rpx;
font-weight: 700;
flex: 1;
text-align: center;
}
.content{
margin: -100rpx auto;
}
.box1 {
width: 95%;
margin: 20rpx auto;
background: #fff;
border-radius: 20rpx;
padding: 20rpx;
}
.btn{
background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
padding:0 20rpx;
height: 50rpx;
border-radius: 14rpx;
line-height: 50rpx;
text-align: center;
font-weight: 700;
margin-top: 20rpx;
}
.popup-area-title {
font-size: 36rpx;
font-weight: bold;
text-align: center;
position: relative;
}
.popup-area-content {
align-items: center;
justify-content: center;
padding: 30rpx;
width: 500rpx;
height: auto;
background-color: #fff;
}
.goods-img {
width: 160rpx;
height: 160rpx;
position: relative;
img {
width: 100%;
background-size: 100%;
height: 100%;
border-radius: 20rpx;
}
}
.pinzi{
margin: 20rpx 0;
background: linear-gradient(90deg, #FF4500, #FFA07A);
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
text-align: center;
border-radius: 10rpx;
color: #fff;
}
.goods-content {
flex: 1;
padding-left: 20rpx;
}
.goods-name {
font-size: 32rpx;
font-weight: 900;
}
.goods-content-center {
display: flex;
margin: 16rpx 0;
color: #777;
}
.guize-list {
width: 100%;
padding: 20rpx;
overflow: scroll;
background: #fff;
max-height: 1000rpx;
line-height: 25px;
}
.pt-title{
font-size: 28rpx;
font-weight: 700;
color: #777;
}
.dingdan{
border-top: 1px solid #eee;
}
.uni-popup__wrapper{
border-radius: 20rpx !important;
}
.pituan-text{
flex:1;
text-align:right;
padding-right:20rpx;
font-weight: 700;
}
</style>

4
pages/shop/transferDeliveryOrderList.vue

@ -69,9 +69,9 @@
this.totalPages = 1
this.list = []
this.loadStatus = 'more'
this.searchForm.shopId = JSON.parse(uni.getStorageSync('area')).shop.id
this.searchForm.shopId = JSON.parse(uni.getStorageSync('area')).id
const area = uni.getStorageSync('area')
this.searchForm.regionId = area ? JSON.parse(area).shop.regionId : ''
this.searchForm.regionId = area ? JSON.parse(area).regionId : ''
this.getList()
},
loadMore() {

785
pages/worker/index.vue

@ -204,7 +204,7 @@
<view class="delivery-list-wrap">
<view class="empty-delivery" v-if="deliveryItem">
<view class="empty-delivery" v-if="deliveryItem.length <= 0">
<view class="empty-delivery-icon">校园</view>
<view class="empty-delivery-title">暂时没有可抢订单</view>
<view class="empty-delivery-desc">可以切换分类或调整筛选条件新的校园订单会在这里出现</view>
@ -725,6 +725,7 @@
return {
isOnLine: 1,
bigImg: '',
adList:[],
zhipaiCheck: false,
tab1Checked: 'dating',
scrollTop: 0,
@ -732,17 +733,25 @@
isLoadingPage: false,
scrollViewHeight: 0,
isArea: false,
latitude: 39.909, //
longitude: 116.39742, //
latitude: 39.909,
longitude: 116.39742,
searchForm: {
status: 1,
hallOnly: true,
status: 0,
pageNum: 1,
pageSize: 10,
pageSize:10,
getAreaId: '',
putAreaId: '',
paths: ['home_top', 'home_center_left_top', 'home_center_left_bottom', 'home_center_right_top',
'home_center_right_bottom'
],
order: '',
returnOrderLast: 1,
regionId: '',
deliveryType: null,
workerId: uni.getStorageSync('worker') ? uni.getStorageSync('worker').workerId : ''
userId: uni.getStorageSync('id') || '',
deliveryType: 1,
waimaiData: [],
workerId: uni.getStorageSync('worker') ? uni.getStorageSync('worker').workerId : '',
kuaidiData: []
},
menuButtonInfo: {
top: 44
@ -825,7 +834,7 @@
}
},
onShow() {
this.runHomeInit()
this.indexInit()
if (this.pendingTabIndex !== null) {
const tabIndex = this.pendingTabIndex
const shouldShowDeliveryRuleConfirm = this.pendingDeliveryRuleConfirm && tabIndex == 1
@ -890,73 +899,32 @@
filters: {
formatHourMinute(value) {
if (!value) return '';
const date = new Date(value);
// (getDate)0
const day = String(date.getDate()).padStart(2, '0');
// (getHours)0
const hour = String(date.getHours()).padStart(2, '0');
// (getMinutes)0
const minute = String(date.getMinutes()).padStart(2, '0');
// --:
return `${hour}:${minute}`;
},
delNode(data) {
// 1.
let str;
if (typeof data === 'object' && data !== null) {
// JSON
str = JSON.stringify(data);
} else if (typeof data === 'string') {
str = data;
} else {
//
str = String(data);
}
// 2. { } "
const result = str.replace(/[{}"]/g, '');
return result;
},
delPlus(data){
if (data.endsWith("+")) {
data = data.slice(0, -1); //
data = data.slice(0, -1);
}
return data;
}
},
methods: {
init() {
if (!this.ensureLogin()) return
let worker = uni.getStorageSync('worker')
if (worker == '' || worker == undefined || worker == null) {
uni.showToast({
title: '您还没有注册兼职',
icon: 'none'
});
return
}
this.isOnLine = uni.getStorageSync('worker').isOnLine
this.zhipaiCheck = uni.getStorageSync('worker').getPushOrder == 1 ? true : false
if (uni.getStorageSync('area')) {
this.searchForm.regionId = JSON.parse(uni.getStorageSync('area')).id;
}
if (uni.getStorageSync('worker')) {
this.searchForm.workerId = uni.getStorageSync('worker').workerId
}
this.$forceUpdate()
this.loadWorkerRules()
this.getDelivery()
this.$nextTick(() => {
this.measureScrollView()
})
},
getPickupPictures(item) {
const pictures = item && item.getPictures
if (!pictures) return []
@ -976,22 +944,6 @@
}
return []
},
runHomeInit() {
//
this.indexInit()
this.$nextTick(() => {
this.refreshDaimaiStickyPosition()
})
},
refreshDaimaiStickyPosition() {
const query = uni.createSelectorQuery().in(this);
query.select('#menuList').boundingClientRect(rect => {
if (rect) {
this.menuListOffsetTop = rect.top + (this._scrollTopRaw || 0);
this.stickyTrigger = Math.max(360, this.menuListOffsetTop - this.navBarHeight - 46);
}
}).exec();
},
goMyCenter(){
uni.navigateTo({
url: '/pages/worker/partTimeJobCenter'
@ -1071,27 +1023,16 @@
&& Date.now() - Number(cacheItem.savedAt || 0) < HOME_AD_IMAGE_CACHE_TTL
&& this.isSavedFileExists(cacheItem.path))
},
//
getUserOrders() {
let that = this
this.NB.sendRequest("/mall/order/getOrdersByUserId/" + uni.getStorageSync('id'), {}, true, 'GET', 'application/x-www-form-urlencoded').then(res => {
if (res.code == 200) {
if (res.result != null) {
that.orderLists = res.result
that.$forceUpdate()
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
});
return
}
uni.hideLoading()
})
},
indexInit() {
let that = this
if (!this.ensureLogin()) return
this.isOnLine = uni.getStorageSync('worker').isOnLine
this.zhipaiCheck = uni.getStorageSync('worker').getPushOrder == 1 ? true : false
this.loadWorkerRules()
this.$nextTick(() => {
this.measureScrollView()
})
uni.getSystemInfo({
success: function(info) {
that.width = info.screenWidth * 2;
@ -1104,9 +1045,7 @@
that.searchForm.workerId = uni.getStorageSync('worker') ? uni.getStorageSync('worker').workerId : ''
//
// this.getUserLocation();
if(uni.getStorageSync('hiver_token')){
this.getUserOrders();
}
if (!uni.getStorageSync('area')) {
this.checkArea()
} else {
@ -1143,10 +1082,9 @@
}
this.searchForm.waimaiData = this.waimailistData;
this.searchForm.kuaidiData = [];
this.getDelivery();
this.getDaTing();
this.getShopArea();
}
// sticky offsetstatusBarHeight + 40px
const info = uni.getSystemInfoSync();
this.navBarHeight = info.statusBarHeight;
this.swipeOrderBaseWidth = info.windowWidth * 0.86;
@ -1307,7 +1245,7 @@
this.searchForm.order = ''
}
this.resetDeliveryQuery()
this.getDelivery();
this.getDaTing();
},
clearCheck() {
this.checkYongjin = false
@ -1317,7 +1255,7 @@
this.searchForm.putAreaId = ""
this.searchForm.order = ""
this.resetDeliveryQuery()
this.getDelivery()
this.getDaTing()
this.$forceUpdate()
},
resetDeliveryQuery() {
@ -1350,14 +1288,12 @@
if (!uni.getStorageSync('worker') && res.result != null) {
this.$refs.tishiPopup.open()
uni.setStorageSync('worker', res.result)
that.$refs.tabBar.indexWorkerCount ++
}else{
if(res.message == '接单成功'){
uni.showToast({
title: res.message,
icon: 'none'
});
that.$refs.tabBar.indexWorkerCount ++
}else{
uni.showToast({
title: res.message,
@ -1624,23 +1560,73 @@
}
this.searchForm.pageNum = 1
this.scrollToTop()
this.getDelivery()
this.getDaTing()
this.$forceUpdate();
},
shouldNotify(mustFinishTimeStr) {
// ISO 8601
const targetTime = new Date(mustFinishTimeStr);
//
if (isNaN(targetTime.getTime())) {
throw new Error('Invalid date format: ' + mustFinishTimeStr);
}
const currentTime = new Date();
const diffMs = targetTime - currentTime; //
// diffMs <= 0 100 < diffMs < 600000
const diffMs = targetTime - currentTime;
return diffMs <= 0 || diffMs < 10 * 60 * 1000;
},
getDaTing() {
let that = this
const requestVersion = that.deliveryQueryVersion
const requestPageNum = that.searchForm.pageNum
const requestForm = {
...that.searchForm,
waimaiData: [...(that.searchForm.waimaiData || [])],
kuaidiData: [...(that.searchForm.kuaidiData || [])]
}
that.waimaiCount = 0
that.kuaidiCount = 0
that.paotuiCount = 0
that.zhipaiCount = 0
that.adList = []
that.searchForm.userId = uni.getStorageSync('id') || that.searchForm.userId || ''
requestForm.userId = that.searchForm.userId
this.NB.sendRequest("/mall/delivery/page", requestForm, true, 'POST', 'application/json').then(res => {
if (requestVersion !== that.deliveryQueryVersion) return
that.loadStatus = 'nomore';
if (res.code == 200) {
const records = that.normalizeDeliveryRecords(res.result.records, requestPageNum)
if (requestPageNum == 1) {
that.deliveryItem = records;
} else {
that.deliveryItem = [...that.deliveryItem, ...records]
}
if (res.result.orderCount != null && res.result.orderCount.length > 0) {
for (let i = 0; i < res.result.orderCount.length; i++) {
if (res.result.orderCount[i].deliveryType == 1) {
that.waimaiCount = res.result.orderCount[i].orderCount
} else if (res.result.orderCount[i].deliveryType == 2) {
that.kuaidiCount = res.result.orderCount[i].orderCount
} else if (res.result.orderCount[i].deliveryType == 3) {
that.paotuiCount = res.result.orderCount[i].orderCount
}
}
}else{
that.waimaiCount = 0
that.kuaidiCount = 0
that.paotuiCount = 0
}
if (res.result.zhipaiCount != undefined && res.result.zhipaiCount != null) {
that.zhipaiCount = res.result.zhipaiCount
}
that.totalPages = res.result.pages; // pages =
that.$forceUpdate();
} else {
that.tui.toast(res.message);
return;
}
uni.hideLoading();
})
},
getDelivery() {
if (!this.ensureLogin()) return
let that = this
@ -1663,7 +1649,7 @@
that.pageData = that.deliveryItem
}
that.totalPages = res.result.pages; // pages =
that.totalPages = res.result.pages;
that.$forceUpdate();
} else {
uni.showToast({
@ -1708,7 +1694,7 @@
this.searchForm.waimaiData = [];
this.searchForm.kuaidiData = [];
}
this.getDelivery()
this.getDaTing()
this.$nextTick(() => {
this.scrollToDaimaiPanel()
})
@ -1784,7 +1770,7 @@
getPushOrder: this.zhipaiCheck ? 1 : 0
}, true, 'POST', 'application/x-www-form-urlencoded').then(res => {
if (res.code == 200) {
let worker = uni.getStorageSync('worker') || {}; //
let worker = uni.getStorageSync('worker') || {};
worker.getPushOrder = that.zhipaiCheck ? 1 : 0;
uni.setStorageSync('worker', worker);
uni.setStorageSync('waimaiData', that.waimaiData)
@ -1843,7 +1829,7 @@
})
},
checkArea() {
this.NB.sendRequest("/app/shopArea/getByParentId/0", {}, true, 'POST', 'application/x-www-form-urlencoded').then(res => {
this.NB.sendRequest("/app/shopArea/getByParentId/0", {}, true, 'get', 'application/x-www-form-urlencoded').then(res => {
if (res.code == 200) {
this.areaList = res.result
this.areaKeyword = ''
@ -2085,7 +2071,12 @@
}
this.searchForm.pageNum = 1
this.scrollToTop()
this.getDelivery()
if(type == 'dating'){
this.getDaTing()
}else{
this.getDelivery()
}
},
refreshCurrentTab() {
@ -2175,7 +2166,7 @@
id: worker.workerId
}, true, 'POST', 'application/x-www-form-urlencoded').then(res => {
if (res.code == 200) {
let worker = uni.getStorageSync('worker') || {}; //
let worker = uni.getStorageSync('worker') || {};
worker.isOnLine = value;
this.isOnLine = value
uni.setStorageSync('worker', worker);
@ -2193,6 +2184,584 @@
})
this.isArea = !this.isArea
this.$forceUpdate()
},
setTabBarVisible(visible) {
this.isTabBarVisible = visible
},
showDeliveryRuleEditedConfirm() {
this.$nextTick(() => {
setTimeout(() => {
if (this.$refs.deLiveryPage && this.$refs.deLiveryPage.showRuleEditedConfirm) {
this.$refs.deLiveryPage.showRuleEditedConfirm()
}
}, 300)
})
},
normalizeShareTargetPath(value) {
return normalizeShareTargetPath(value)
},
resolveShareTargetPath(value) {
let targetPath = String(value || '')
if (targetPath.indexOf('/pages/index/index') === 0 || targetPath.indexOf('pages/index/index') === 0) {
const queryIndex = targetPath.indexOf('?')
if (queryIndex !== -1) {
const query = targetPath.slice(queryIndex + 1).split('&')
for (let i = 0; i < query.length; i++) {
const pair = query[i].split('=')
if (pair[0] === 'targetPath') {
targetPath = pair.slice(1).join('=')
break
}
}
}
}
return this.normalizeShareTargetPath(targetPath)
},
openShareTargetIfNeeded() {
if (!this.pendingShareTargetPath) {
this.pendingShareTargetPath = this.resolveShareTargetPath(uni.getStorageSync('pendingShareTargetPath') || '')
if (this.pendingShareTargetPath) {
uni.setStorageSync('pendingShareTargetPath', this.pendingShareTargetPath)
}
}
if (!this.pendingShareTargetPath) return false
if (!uni.getStorageSync('area')) return true
const targetPath = this.pendingShareTargetPath
this.pendingShareTargetPath = ''
uni.removeStorageSync('pendingShareTargetPath')
uni.removeStorageSync('authPendingTargetPath')
this.$nextTick(() => {
setTimeout(() => {
uni.navigateTo({
url: targetPath,
fail: () => {
this.pendingShareTargetPath = targetPath
uni.setStorageSync('pendingShareTargetPath', targetPath)
uni.redirectTo({
url: targetPath,
success: () => {
uni.removeStorageSync('pendingShareTargetPath')
},
fail: () => {
uni.showToast({
title: '进入分享页面失败,请重试',
icon: 'none'
})
}
})
}
})
}, 300)
})
return true
},
refreshDaimaiStickyPosition() {
const query = uni.createSelectorQuery().in(this);
query.select('#menuList').boundingClientRect(rect => {
if (rect) {
this.menuListOffsetTop = rect.top + (this._scrollTopRaw || 0);
this.stickyTrigger = Math.max(360, this.menuListOffsetTop - this.navBarHeight - 46);
}
}).exec();
},
hasLogin() {
const token = uni.getStorageSync('hiver_token')
return !!(token && typeof token === 'string' && token.trim() && token !== 'null' && token !== 'undefined')
},
requireLogin(tabIndex = this.currentIndex) {
if (this.hasLogin()) return true
const redirectKey = 'login_redirect_' + Date.now()
const index = Number(tabIndex)
const redirectUrl = '/pages/index/index' + (!isNaN(index) && index > 0 ? '?tabIndex=' + index : '')
uni.setStorageSync(redirectKey, redirectUrl)
uni.navigateTo({
url: '/package2/login/login?redirect=' + redirectKey
})
return false
},
// isSwitching
_switchCategory(index) {
if (this.isSwitching) return;
this.isSwitching = true;
this.checkTab(index);
// 400ms200ms200ms
setTimeout(() => {
this.isSwitching = false;
}, 400);
},
productDetail(item) {
if (this._isSwipingOrderTap) {
this._isSwipingOrderTap = false
return
}
if (!item || item.deliveryType != 1) return
this.productData = item;
this.productGoodsList = Array.isArray(item.goodsList) ? item.goodsList : []
this.$refs.productPopup.open()
},
closeProductPopup() {
if (this.$refs.productPopup && this.$refs.productPopup.close) {
this.$refs.productPopup.close()
}
this.productData = {}
this.productGoodsList = []
},
getSwipeProgress(item, index) {
if (!item) return 0
if (this.swipeOrder.id === item.id && this.swipeOrder.index === index) {
return this.swipeOrder.progress
}
return 0
},
resetDeliveryQuery() {
this.deliveryQueryVersion++
this.searchForm.pageNum = 1
this.totalPages = 1
this.deliveryItem = []
this.resetSwipeOrder()
},
normalizeDeliveryRecords(records, pageNum) {
if (!Array.isArray(records)) return []
return records.filter(item => item && typeof item === 'object').map((item, index) => {
return {
...item,
deliveryKey: item.id !== undefined && item.id !== null ? String(item.id) : (pageNum + '-' + index)
}
})
},
shouldShowReceiverPhoneIcon(item) {
return !!(item && item.workerId)
},
parseDeliveryTime(value) {
if (!value) return NaN
if (typeof value === 'number') {
return String(value).length === 10 ? value * 1000 : value
}
const timeText = String(value).trim()
if (!timeText) return NaN
const nativeParsedTime = new Date(timeText).getTime()
if (!isNaN(nativeParsedTime)) return nativeParsedTime
const timeOnlyMatch = timeText.match(/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/)
if (timeOnlyMatch) {
const currentDate = new Date(this.deliveryNowTime || Date.now())
currentDate.setHours(Number(timeOnlyMatch[1]), Number(timeOnlyMatch[2]), Number(timeOnlyMatch[3] || 0), 0)
return currentDate.getTime()
}
const parsedTime = new Date(timeText.replace(/-/g, '/')).getTime()
return parsedTime
},
isNearMustFinishTime(item) {
if (!item || !item.mustFinishTime) return false
const mustFinishTime = this.parseDeliveryTime(item.mustFinishTime)
if (isNaN(mustFinishTime)) return false
return mustFinishTime - this.deliveryNowTime <= 10 * 60 * 1000
},
getMustFinishWarningText(item) {
const mustFinishTime = this.parseDeliveryTime(item && item.mustFinishTime)
if (!isNaN(mustFinishTime) && this.deliveryNowTime > mustFinishTime) {
return '已超过用户要求送达时间,为避免纠纷,建议和用户沟通是否继续接单配送'
}
return '已经临近用户要求送达时间,为避免纠纷,建议和用户沟通是否继续接单配送。'
},
startDeliveryTimeTimer() {
this.deliveryNowTime = Date.now()
if (this.deliveryTimer) return
this.deliveryTimer = setInterval(() => {
this.deliveryNowTime = Date.now()
}, 60 * 1000)
},
isSwipeOrderActive(item, index) {
if (!item) return false
return this.swipeOrder.id === item.id && this.swipeOrder.index === index && this.swipeOrder.progress > 0
},
//
startSwipeOrder(event, item, index) {
if (!item || item.id === undefined || item.id === null) return
if (!this.requireLogin(0)) return
const touch = event.touches && event.touches[0]
if (!touch) return
this._isSwipingOrderTap = false
this._swipeOrderProgress = 0
this._swipeOrderLastRenderTime = 0
this.swipeOrder = {
id: item.id,
index,
startX: touch.clientX,
startProgress: 0,
progress: 0,
progressStyle: 'transform: translate3d(0, 0, 0) scaleX(0); transition: none;',
thumbStyle: 'transform: translate3d(0, 0, 0); transition: none;',
trackWidth: this.swipeOrderBaseWidth || 0,
confirmed: false
}
this.$nextTick(() => {
uni.createSelectorQuery().in(this).select('#swipe-order-' + item.id).boundingClientRect((rect) => {
if (rect && this.swipeOrder.id === item.id && this.swipeOrder.index === index) {
this.swipeOrder.trackWidth = rect.width
}
}).exec()
})
},
moveSwipeOrder(event) {
const touch = event.touches && event.touches[0]
if (!touch || this.swipeOrder.id === '') return
const trackWidth = this.swipeOrder.trackWidth || this.swipeOrderBaseWidth || 1
const deltaX = Math.max(0, touch.clientX - this.swipeOrder.startX)
const progress = Math.min(100, Math.round(deltaX / (trackWidth * 0.72) * 100))
if (progress > 3) {
this._isSwipingOrderTap = true
}
this._swipeOrderProgress = progress
const now = Date.now()
const frameGap = this.swipeOrderFrameGap || 16
const progressStep = this.swipeOrderProgressStep || 1
if (now - (this._swipeOrderLastRenderTime || 0) < frameGap &&
Math.abs(progress - this.swipeOrder.progress) < progressStep &&
progress < 92) {
return
}
this._swipeOrderLastRenderTime = now
this.setSwipeOrderProgress(progress)
},
//
endSwipeOrder(item, index) {
if (!this.requireLogin(0)) {
this.resetSwipeOrder()
return
}
if (this.swipeOrder.id !== item.id || this.swipeOrder.index !== index) return
const progress = this._swipeOrderProgress !== undefined ? this._swipeOrderProgress : this.swipeOrder.progress
if (progress >= 92 && !this.swipeOrder.confirmed) {
this.swipeOrder.confirmed = true
this.setSwipeOrderProgress(100)
this.getOrder(item, index)
return
}
this.resetSwipeOrder()
},
resetSwipeOrder() {
this._swipeOrderProgress = 0
this._swipeOrderLastRenderTime = 0
clearTimeout(this._swipeOrderTapTimer)
this._swipeOrderTapTimer = setTimeout(() => {
this._isSwipingOrderTap = false
}, 300)
this.swipeOrder = {
id: '',
index: -1,
startX: 0,
startProgress: 0,
progress: 0,
progressStyle: 'transform: translate3d(0, 0, 0) scaleX(0); transition: none;',
thumbStyle: 'transform: translate3d(0, 0, 0); transition: none;',
trackWidth: 0,
confirmed: false
}
},
setSwipeOrderProgress(progress) {
if (this.swipeOrder.progress === progress) return
const trackWidth = this.swipeOrder.trackWidth || this.swipeOrderBaseWidth || 0
const thumbWidth = this.swipeOrderThumbWidth || 0
const thumbOffset = Math.max(0, trackWidth - thumbWidth) * progress / 100
this.swipeOrder.progress = progress
this.swipeOrder.progressStyle = 'transform: translate3d(0, 0, 0) scaleX(' + (progress / 100) + '); transition: none;'
this.swipeOrder.thumbStyle = 'transform: translate3d(' + thumbOffset + 'px, 0, 0); transition: none;'
},
normalizeAdImageUrl(url) {
if (!url) return ''
let normalized = String(url).trim()
while (normalized.endsWith(',')) {
normalized = normalized.slice(0, -1)
}
return normalized
},
getHomeAdImageCache() {
const cache = uni.getStorageSync(HOME_AD_IMAGE_CACHE_KEY)
return cache && typeof cache === 'object' ? cache : {}
},
saveHomeAdImageCache(cache) {
uni.setStorageSync(HOME_AD_IMAGE_CACHE_KEY, cache)
},
isSavedFileExists(filePath) {
if (!filePath || filePath.indexOf('__tmp__') !== -1) return false
try {
const fs = (uni.getFileSystemManager && uni.getFileSystemManager())
|| (typeof wx !== 'undefined' && wx.getFileSystemManager ? wx.getFileSystemManager() : null)
if (fs && fs.accessSync) {
fs.accessSync(filePath)
return true
}
} catch (e) {
return false
}
return true
},
isHomeAdImageCacheValid(cacheItem) {
return !!(cacheItem
&& Date.now() - Number(cacheItem.savedAt || 0) < HOME_AD_IMAGE_CACHE_TTL
&& this.isSavedFileExists(cacheItem.path))
},
cacheHomeMenuIcon(key, imageUrl) {
if (homeAdImageDownloading[imageUrl]) return
homeAdImageDownloading[imageUrl] = true
uni.downloadFile({
url: imageUrl,
success: (downloadRes) => {
if (downloadRes.statusCode !== 200 || !downloadRes.tempFilePath) {
this.homeMenuIconImages[key] = imageUrl
delete homeAdImageDownloading[imageUrl]
return
}
uni.saveFile({
tempFilePath: downloadRes.tempFilePath,
success: (saveRes) => {
const cache = this.getHomeAdImageCache()
const oldCacheItem = cache[imageUrl]
if (oldCacheItem && oldCacheItem.path && oldCacheItem.path !== saveRes.savedFilePath) {
uni.removeSavedFile({
filePath: oldCacheItem.path,
fail: () => {}
})
}
cache[imageUrl] = {
path: saveRes.savedFilePath,
savedAt: Date.now()
}
this.saveHomeAdImageCache(cache)
this.homeMenuIconImages[key] = saveRes.savedFilePath
},
fail: () => {
this.homeMenuIconImages[key] = imageUrl
},
complete: () => {
delete homeAdImageDownloading[imageUrl]
}
})
},
fail: () => {
this.homeMenuIconImages[key] = imageUrl
delete homeAdImageDownloading[imageUrl]
},
complete: (downloadRes) => {
if (!downloadRes || downloadRes.statusCode !== 200) {
this.homeMenuIconImages[key] = imageUrl
delete homeAdImageDownloading[imageUrl]
}
}
})
},
cacheHomeAdImage(imageUrl) {
if (homeAdImageDownloading[imageUrl]) return
homeAdImageDownloading[imageUrl] = true
uni.downloadFile({
url: imageUrl,
success: (downloadRes) => {
if (downloadRes.statusCode !== 200 || !downloadRes.tempFilePath) {
this.replaceAdImageWithCache(imageUrl, imageUrl)
delete homeAdImageDownloading[imageUrl]
return
}
uni.saveFile({
tempFilePath: downloadRes.tempFilePath,
success: (saveRes) => {
const cache = this.getHomeAdImageCache()
const oldCacheItem = cache[imageUrl]
if (oldCacheItem && oldCacheItem.path && oldCacheItem.path !== saveRes.savedFilePath) {
uni.removeSavedFile({
filePath: oldCacheItem.path,
fail: () => {}
})
}
cache[imageUrl] = {
path: saveRes.savedFilePath,
savedAt: Date.now()
}
this.saveHomeAdImageCache(cache)
this.replaceAdImageWithCache(imageUrl, saveRes.savedFilePath)
},
fail: () => {
this.replaceAdImageWithCache(imageUrl, imageUrl)
},
complete: () => {
delete homeAdImageDownloading[imageUrl]
}
})
},
fail: () => {
delete homeAdImageDownloading[imageUrl]
},
complete: (downloadRes) => {
if (!downloadRes || downloadRes.statusCode !== 200) {
this.replaceAdImageWithCache(imageUrl, imageUrl)
delete homeAdImageDownloading[imageUrl]
}
}
})
},
replaceAdImageWithCache(imageUrl, filePath) {
const replace = (list) => {
(list || []).forEach((item) => {
if (item.adImage === imageUrl) {
item.adDisplayImage = filePath
}
})
}
replace(this.mallAds)
replace(this.adList)
this.$forceUpdate()
},
pruneHomeAdImageCache(cache, activeUrls) {
const activeUrlMap = activeUrls.reduce((result, url) => {
result[url] = true
return result
}, {})
const now = Date.now()
Object.keys(cache).forEach((url) => {
const item = cache[url]
const isExpired = !this.isHomeAdImageCacheValid(item)
if (isExpired && !activeUrlMap[url]) {
item && item.path && uni.removeSavedFile({
filePath: item.path,
fail: () => {}
})
delete cache[url]
}
})
const urls = Object.keys(cache).sort((a, b) => Number(cache[a].savedAt || now) - Number(cache[b].savedAt || now))
while (urls.length > HOME_AD_IMAGE_CACHE_LIMIT) {
const url = urls.shift()
if (activeUrlMap[url]) {
urls.push(url)
if (urls.every(itemUrl => activeUrlMap[itemUrl])) break
continue
}
const item = cache[url]
item && item.path && uni.removeSavedFile({
filePath: item.path,
fail: () => {}
})
delete cache[url]
}
this.saveHomeAdImageCache(cache)
},
//广
goAdPage(item) {
if (!this.requireLogin(0)) return
uni.navigateTo({
url: item.linkUrl + item.linkParams
})
},
checkTab(index) {
for (let i = 0; i < this.menuList.length; i++) {
this.menuList[i].checked = (i === index);
}
//
this.searchForm.pageNum = 1;
this.pageNum = 1;
this.total = 1;
this.productItem = [];
// this.getProduct(this.menuList[index].id);
// nav-bar
// menuListOffsetTop - navBarHeight 使sticky
const target = this.menuListOffsetTop - this.navBarHeight;
uni.pageScrollTo({
scrollTop: target > 0 ? target : 0,
duration: 200
});
},
goSeckillGroup() {
uni.navigateTo({
url: '/package2/seckill/seckillGroup'
})
},
//
goDetail(type) {
let url = ''
switch (type) {
case '1':
url = '/package1/runErrand/runErrand'
break;
case '2':
url = '/package2/group/groupBuyList'
break;
case '3':
url = '/package2/group/studentStoreList'
break;
case '4':
url = '/package1/planet/index'
break;
case '5':
url = '/package1/ieBrowser/index'
break;
}
uni.navigateTo({
url: url
})
},
//
goOrderDetail(item) {
uni.navigateTo({
url: '/package1/order/orderDetail?id=' + item.id
});
},
scrollToDaimaiPanel() {
const query = uni.createSelectorQuery().in(this);
query.select('#menuList').boundingClientRect(rect => {
if (!rect) return;
const stickyTop = this.navBarHeight + 46;
const target = rect.top + (this._scrollTopRaw || 0) - stickyTop;
uni.pageScrollTo({
scrollTop: target > 0 ? target : 0,
duration: 260
});
}).exec();
},
//
makeCall(phone) {
uni.makePhoneCall({
phoneNumber: phone
});
},
//
checkAdd() {
this.isgetArea = !this.isgetArea
},
//
checkAdd1() {
this.isputArea = !this.isputArea
},
//tab
changeIndex(index) {
let that = this;
this.isTabBarVisible = true
this.lastIndex = this.currentIndex
if (index != 0) {
this.closeProductPopup()
}
if(index != 2){
this.currentIndex = index
}
switch (index) {
case 0:
this.runHomeInit()
break;
case 1:
that.$refs.deLiveryPage.init()
break;
case 2:
uni.navigateTo({
url: '/package1/tabbar/release'
})
break;
case 3:
that.$refs.postListPage.init()
break;
case 4:
that.$refs.myCenterPage.init()
break;
}
}
}
}

15
pages/worker/partTimeJobCenter.vue

@ -157,6 +157,14 @@
退款/售后记录
</view>
</view>
<view class="menu22" @tap="logOut">
<view class="menu33">
<image src="../../static/image/dingdan/dd0.png" alt="" />
</view>
<view class="menu44">
退出登录
</view>
</view>
</view>
</view>
</view>
@ -229,6 +237,13 @@
url: '/pages/worker/workerOrderList?today=1'
})
},
logOut() {
uni.clearStorage()
getApp().globalData.userinfo = ''
uni.reLaunch({
url: '../login/login'
})
},
goDetail(type, index) {
let url = ''
switch (type) {

Loading…
Cancel
Save