Compare commits
No commits in common. "0632e3672342e22fcfca863fc4b62bcb539ddaf5" and "1b7bbd66467fb4e8063ed4a487a76ba411ad4604" have entirely different histories.
0632e36723
...
1b7bbd6646
@ -8,9 +8,7 @@ import { GetShopBaseInfo } from "@/api/shop.js";
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
version: "",
|
version: "",
|
||||||
lastPlayTime: 0, // 记录最后一次播放语音的时间戳
|
|
||||||
playInterval: 20000 // 20秒的间隔限制
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
@ -32,26 +30,18 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState("user", ["uid", "userInfo"]),
|
...mapState("user", ["uid", "userInfo"]),
|
||||||
},
|
},
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
this.globalData.isAppActive = true;
|
this.globalData.isAppActive = true;
|
||||||
const globalConnName = 'globalSocket';
|
|
||||||
if (this.userInfo && Object.keys(this.userInfo).length > 0) {
|
|
||||||
// 检查指定的全局连接是否已连接,未连接则重建
|
|
||||||
if (!webSocketManager.isConnected(globalConnName)) {
|
|
||||||
this.connectSocket(this.userInfo); // 这里的connectSocket应该会创建名为globalConnName的连接
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 用户未登录时关闭所有全局连接
|
|
||||||
webSocketManager.closeAllGlobalConnections();
|
webSocketManager.closeAllGlobalConnections();
|
||||||
}
|
setTimeout(() => {
|
||||||
// 重新注册推送监听
|
if (this.userInfo && Object.keys(this.userInfo).length > 0) {
|
||||||
this.initPushListener();
|
this.connectSocket(this.userInfo);
|
||||||
},
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
onHide: function () {
|
onHide: function () {
|
||||||
this.globalData.isAppActive = false;
|
this.globalData.isAppActive = false;
|
||||||
// webSocketManager.closeAllGlobalConnections();
|
webSocketManager.closeAllGlobalConnections();
|
||||||
},
|
},
|
||||||
globalData: {
|
globalData: {
|
||||||
isAppActive: false,
|
isAppActive: false,
|
||||||
@ -79,39 +69,6 @@ onShow: function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 新增推送监听初始化方法
|
|
||||||
initPushListener() {
|
|
||||||
const _self = this;
|
|
||||||
// 先移除旧监听再添加新监听,避免重复注册
|
|
||||||
uni.offPushMessage();
|
|
||||||
uni.onPushMessage(async (res) => {
|
|
||||||
console.log("收到推送消息:", res);
|
|
||||||
|
|
||||||
// 检查用户登录状态,未登录直接返回
|
|
||||||
if (!_self.userInfo || Object.keys(_self.userInfo).length === 0) {
|
|
||||||
console.log("用户未登录,忽略推送");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.data) {
|
|
||||||
if (!_self.globalData.isAppActive) {
|
|
||||||
if (res.type == "click") {
|
|
||||||
_self.handlePushClick(res.data.payload);
|
|
||||||
} else {
|
|
||||||
let shopRes = await GetShopBaseInfo();
|
|
||||||
if (shopRes.data.ringtone_is_enable === 1) {
|
|
||||||
_self.handlePushSound(res.data);
|
|
||||||
uni.setStorageSync("pendingPushData", res.data);
|
|
||||||
uni.createPushMessage(res.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log("应用已打开,直接处理消息");
|
|
||||||
_self.$store.dispatch("push/setPush", res.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async initAppOrderPush() {
|
async initAppOrderPush() {
|
||||||
uni.getPushClientId({
|
uni.getPushClientId({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -192,12 +149,6 @@ onShow: function () {
|
|||||||
async handlePushSound(pushData) {
|
async handlePushSound(pushData) {
|
||||||
console.log(pushData.payload);
|
console.log(pushData.payload);
|
||||||
try {
|
try {
|
||||||
const currentTime = Date.now();
|
|
||||||
// 检查是否在10秒内已经播放过语音
|
|
||||||
if (currentTime - this.lastPlayTime < this.playInterval) {
|
|
||||||
console.log("10秒内已播放过语音,本次不播放");
|
|
||||||
return; // 10秒内不重复播放
|
|
||||||
}
|
|
||||||
// 获取category决定使用哪种声音
|
// 获取category决定使用哪种声音
|
||||||
const category = pushData.payload.category;
|
const category = pushData.payload.category;
|
||||||
var AUDIO = uni.createInnerAudioContext();
|
var AUDIO = uni.createInnerAudioContext();
|
||||||
@ -218,7 +169,7 @@ onShow: function () {
|
|||||||
AUDIO.play();
|
AUDIO.play();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.lastPlayTime = currentTime; // 更新最后播放时间戳
|
|
||||||
// 处理播放错误
|
// 处理播放错误
|
||||||
AUDIO.onError((res) => {
|
AUDIO.onError((res) => {
|
||||||
console.error("播放声音失败:", res);
|
console.error("播放声音失败:", res);
|
||||||
|
|||||||
@ -164,24 +164,6 @@ export function GetExpediteSFOrder(params) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//商家自行发货
|
|
||||||
export function SelDelivery(params) {
|
|
||||||
return http({
|
|
||||||
url: "/shop/sf-express/selDelivery",
|
|
||||||
method: "post",
|
|
||||||
params,
|
|
||||||
baseURL: config.apiMobile,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//订单完成
|
|
||||||
export function SelFinishDelivery(params) {
|
|
||||||
return http({
|
|
||||||
url: "/shop/sf-express/selFinishOrder",
|
|
||||||
method: "post",
|
|
||||||
params,
|
|
||||||
baseURL: config.apiMobile,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 拣货完成
|
* 拣货完成
|
||||||
* @author Seven
|
* @author Seven
|
||||||
|
|||||||
@ -10,17 +10,12 @@
|
|||||||
<view class="name">{{ orderItem.sf_order_info.operator_name }}</view>
|
<view class="name">{{ orderItem.sf_order_info.operator_name }}</view>
|
||||||
<view class="btn_call" @click="handerExpedite">催快递</view>
|
<view class="btn_call" @click="handerExpedite">催快递</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item time" v-if="orderItem.booking_state==1">
|
<view class="item time">
|
||||||
立即送达/{{
|
立即送达/{{
|
||||||
$u.timeFormat(orderItem.arrival_time, "mm-dd hh:MM")
|
$u.timeFormat(orderItem.arrival_time, "mm-dd hh:MM")
|
||||||
}}前送达
|
}}前送达
|
||||||
</view>
|
</view>
|
||||||
<view class="item time" v-if="orderItem.booking_state==2">
|
<u-icon
|
||||||
预订单/{{
|
|
||||||
$u.timeFormat(orderItem.booking_begin_time, "mm-dd hh:MM")
|
|
||||||
}}前送达
|
|
||||||
</view>
|
|
||||||
<u-icon
|
|
||||||
v-if="currOrderItem.sf_order_info.feed && !isErrorOrder"
|
v-if="currOrderItem.sf_order_info.feed && !isErrorOrder"
|
||||||
class="icon"
|
class="icon"
|
||||||
name="arrow-right"
|
name="arrow-right"
|
||||||
@ -65,7 +60,7 @@
|
|||||||
<view class="box"></view>
|
<view class="box"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="order_picking_box" v-if="!isErrorOrder">
|
<view class="order_picking_box" v-if="!isErrorOrder">
|
||||||
<view class="order_picking_text" v-if="orderItem.booking_state==1">
|
<view class="order_picking_text">
|
||||||
拣货中:
|
拣货中:
|
||||||
<text>{{ getRemainingTime(orderItem.arrival_time) }}</text>
|
<text>{{ getRemainingTime(orderItem.arrival_time) }}</text>
|
||||||
</view>
|
</view>
|
||||||
@ -225,17 +220,11 @@
|
|||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="body"
|
class="body"
|
||||||
v-if="orderItem.is_deny_return==2"
|
v-if="orderItem.is_deny_return"
|
||||||
>
|
>
|
||||||
<view v-if="orderItem.operate_flag==0&&isErrorOrder"class="btn btn_cancel" @click="handerSelDelivery" >
|
<view class="btn btn_cancel" @click="handerShowCancelOrder" >
|
||||||
自行发货
|
取消订单
|
||||||
</view>
|
</view>
|
||||||
<view v-if="orderItem.operate_flag==1&&isErrorOrder"class="btn btn_cancel" @click="handerFinishOrder" >
|
|
||||||
订单完成
|
|
||||||
</view>
|
|
||||||
<view class="btn btn_cancel" @click="handerShowCancelOrder" >
|
|
||||||
取消订单
|
|
||||||
</view>
|
|
||||||
<view class="btn btn_refund" @click="handerShowPartOrderRefund" >
|
<view class="btn btn_refund" @click="handerShowPartOrderRefund" >
|
||||||
部分退款
|
部分退款
|
||||||
</view>
|
</view>
|
||||||
@ -482,8 +471,6 @@ import {
|
|||||||
GetExpediteSFOrder,
|
GetExpediteSFOrder,
|
||||||
GetInitiativeOrderRefund,
|
GetInitiativeOrderRefund,
|
||||||
GetOrderPicking,
|
GetOrderPicking,
|
||||||
SelDelivery,
|
|
||||||
SelFinishDelivery
|
|
||||||
} from "@/api/order";
|
} from "@/api/order";
|
||||||
|
|
||||||
import { makePhoneCall } from "@/utils/callPhone";
|
import { makePhoneCall } from "@/utils/callPhone";
|
||||||
@ -679,26 +666,6 @@ export default {
|
|||||||
this.orderItemIndex
|
this.orderItemIndex
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async handerSelDelivery(){
|
|
||||||
let params = {
|
|
||||||
order_id: this.orderItem.order_id,
|
|
||||||
};
|
|
||||||
let res=await SelDelivery(params);
|
|
||||||
if(res&&res.status==200){
|
|
||||||
uni.$u.toast("处理完成");
|
|
||||||
this.$emit('refreshOrderList');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async handerFinishOrder(){
|
|
||||||
let params = {
|
|
||||||
order_id: this.orderItem.order_id,
|
|
||||||
};
|
|
||||||
let res=await SelFinishDelivery(params);
|
|
||||||
if(res&&res.status==200){
|
|
||||||
uni.$u.toast("处理完成");
|
|
||||||
this.$emit('refreshOrderList');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
makePhone(phone) {
|
makePhone(phone) {
|
||||||
console.log(makePhoneCall);
|
console.log(makePhoneCall);
|
||||||
|
|
||||||
|
|||||||
@ -188,7 +188,6 @@
|
|||||||
:isErrorOrder="true"
|
:isErrorOrder="true"
|
||||||
@cancelOrder="handerCancelOrder"
|
@cancelOrder="handerCancelOrder"
|
||||||
@showRefundOrderInfo="handerShowRefundOrderInfo"
|
@showRefundOrderInfo="handerShowRefundOrderInfo"
|
||||||
@refreshOrderList="handleRefresh"
|
|
||||||
></OrderItem>
|
></OrderItem>
|
||||||
<view
|
<view
|
||||||
class="no-data"
|
class="no-data"
|
||||||
|
|||||||
@ -182,18 +182,6 @@ class WebSocketManager {
|
|||||||
this.connections = {};
|
this.connections = {};
|
||||||
this.globalConnections = [];
|
this.globalConnections = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增:判断指定名称的连接是否处于连接状态
|
|
||||||
isConnected(connectionName) {
|
|
||||||
// 获取指定名称的连接实例
|
|
||||||
const connection = this.connections[connectionName];
|
|
||||||
if (!connection) return false;
|
|
||||||
|
|
||||||
// 检查连接状态:WebsocketUtil的is_open_socket为true,且socketTask的readyState为1(连接中)
|
|
||||||
return connection.is_open_socket &&
|
|
||||||
connection.socketTask &&
|
|
||||||
connection.socketTask.readyState === 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出单例实例
|
// 导出单例实例
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user