继续适配接口

This commit is contained in:
2025-03-27 19:41:34 +08:00
parent 7ac96fd807
commit 3257d586e0
4 changed files with 273 additions and 134 deletions

View File

@ -1,6 +1,10 @@
import request from './request';
export default {
deliveryTimeType:{immediate:'IMMEDIATE',scheduled:'SCHEDULED'},
deliveryTimeTypeKV:{
IMMEDIATE:'及时达',SCHEDULED:'定时达'
},
status:{
created:"CREATED",pending:"PENDING",
delivering:"DELIVERING",pickupReady:"PICKUP_READY",completed:"COMPLETED",
@ -10,8 +14,17 @@ export default {
CREATED:'待支付',PENDING:'待接单',DELIVERING:'待配送',PICKUP_READY:'待自提',
COMPLETED:'已完成',CANCELLED:'已取消',REFUNDING:'退款中',REFUNDED:'已退款'
},
product:{
typeKV:{
'SELF_OPERATED':'自营','MERCHANT':'商家'
}
},
list:(params)=>request.get('/api/merchant/order/merchant',params),
test:(data)=>request.post('/api/merchant',data)
accept:(order_id)=>request.put(`/api/merchant/order/${order_id}/accept`),
complete:(order_id)=>request.put(`/api/merchant/order/${order_id}/complete`),
summary:()=>request.get('/api/merchant/order/merchant/summary')
}

View File

@ -2,42 +2,190 @@ import orderApi from '../../../api/order';
import userApi from '../../../api/user';
Page({
/**
* 页面的初始数据
*/
data: {
orderCategory:['及时达','定时达'],
categoryIndex:0,
statusDic:{
[orderApi.deliveryTimeType.immediate]:[
{key:'PENDING',value:orderApi.statusKV['PENDING']},
{key:'DELIVERING',value:orderApi.statusKV['DELIVERING']},
{key:'COMPLETED',value:orderApi.statusKV['COMPLETED']}
],
[orderApi.deliveryTimeType.scheduled]:[
{key:'PICKUP_READY',value:orderApi.statusKV['PICKUP_READY']},
{key:'COMPLETED',value:orderApi.statusKV['COMPLETED']},
]
},
orderStatusList:[],
orderStatusIndex:0,
list:[{
status:'PENDING',
packages:[{},{}]
}],
list:[],
filterKey:'',
filtedList:[],
pager:{limit:10,loading:false,loadAll:false,pageIndex:0,refreshTrigger:false},
loadMoreText:'已经到底了',
orderStatus:orderApi.status,
genderKV:userApi.genderKV
genderKV:userApi.genderKV,
productTypeKV:orderApi.product.typeKV,
deliveryTimeType:orderApi.deliveryTimeType,
deliveryTimeTypeKV:orderApi.deliveryTimeTypeKV,
currentDeliveryTimeType:orderApi.deliveryTimeType.immediate,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// orderApi.test({
// community_id:1,
// "user_id":3,"category_id":2,"name":"一乐拉面","business_hours":"08:00 - 21:00","address":"四川省成都市双流区怡心街道天府滨河湾(3号门)","longitude":104.046831,"latitude":30.518607,"phone":"13438370499","brand_image_url":"https://dman-1311994147.cos.ap-chengdu.myqcloud.com/uploads/1/ecb77b5a2d4075f6ff320070ac55f81c085e54b0_1e8ba893-9966-436e-90a4-63361f1fdf79.jpg"
// })
orderApi.list();
this.loadList();
},
changeOrderCategory(event){
const index = event.currentTarget.dataset.index;
refreshList(){
this.data.pager.pageIndex = 0;
this.data.pager.loadAll = false;
this.setData({
categoryIndex:index
pager:this.data.pager
});
this.loadList();
},
loadList(){
if(this.data.pager.loading||this.data.pager.loadAll){
return;
}
this.setData({
"pager.loading":true
});
let status = this.data.statusDic[this.data.currentDeliveryTimeType][this.data.orderStatusIndex].key;
let params = {
skip:this.data.pager.pageIndex*this.data.pager.limit,
limit:this.data.pager.limit,
delivery_time_type:this.data.currentDeliveryTimeType,
status:status
}
if(this.needFilterList()){
//不分页 直接返回全部,供本地搜索
params.skip = 0;
params.limit = 1000;
}else{
this.setData({
loadMoreText:'已经到底了'
})
}
orderApi.list(params).then((data)=>{
if(this.data.pager.pageIndex==0){
this.data.list = data.items;
}else{
this.data.list = this.data.list.concat(data.items);
}
this.data.pager.loading = false;
this.data.pager.pageIndex++;
this.data.pager.refreshTrigger = false;
if(data.items.length<this.data.pager.limit){
this.data.pager.loadAll = true;
}
let needSetData = {
list:this.data.list,
pager:this.data.pager
}
this.setData(needSetData);
})
},
changeDeliveryTimeType(event){
const key = event.currentTarget.dataset.key;
this.setData({
currentDeliveryTimeType:key,
orderStatusIndex:0,
filterKey:''
})
this.refreshList();
},
changeStatus(event){
const index = event.currentTarget.dataset.index;
this.setData({
orderStatusIndex:index,
filterKey:''
})
this.refreshList();
},
makePhoneCall(event){
const phone = event.currentTarget.dataset.phone;
wx.makePhoneCall({
phoneNumber: phone,
})
},
needFilterList(){
let status = this.data.statusDic[this.data.currentDeliveryTimeType][this.data.orderStatusIndex].key;
return status==this.data.orderStatus.pending||
status==this.data.orderStatus.delivering||
status==this.data.orderStatus.pickupReady;
},
filterOrder(){
if(!this.needFilterList()){
return;
}
const value = this.data.filterKey;
let list = this.data.list.filter((item)=>{
const endNumber = item.address.phone.substr(item.address.phone.length-4,4);
console.log(endNumber);
return endNumber.indexOf(value)>-1;
});
let loadMoreText = '已经到底了';
if(value&&list.length==0){
loadMoreText = `暂无尾号 ${value} 的订单`
}
this.setData({
loadMoreText:loadMoreText,
filtedList:list
})
},
//接单
getOrder(event){
const item = event.currentTarget.dataset.item;
const index = event.currentTarget.dataset.index;
if(item.receiving)return;
this.setData({
[`list[${index}].receiving`]:true
})
orderApi.accept(item.order.order_id).then((data)=>{
wx.showToast({
icon:'success',
title: '接单成功',
})
this.refreshList();
})
},
//我已送达
receivedOrder(event){
const index = event.currentTarget.dataset.index;
const item = event.currentTarget.dataset.item;
orderApi.complete(item.order.order_id).then((data)=>{
wx.showToast({
icon:'success',
title: '取货成功',
})
this.refreshList();
}).catch(()=>{
this.setData({
[`list[${index}].receiving`]:false
})
})
},
openMap(event){
const item = event.currentTarget.dataset.item;
wx.openLocation({
name:`${item.address.name}${this.data.genderKV[item.address.gender]}${item.address.phone}`,
address:`${item.address.community_name}${item.address.address_detail}`,
latitude:item.address.latitude,
longitude:item.address.longitude,
})
},
emptyFun(){},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1,87 +1,91 @@
<nav-bar>
<view class="order-category active{{categoryIndex}}" slot="left">
<view class="item {{categoryIndex==index?'current':''}}" data-index="{{index}}"
bind:tap="changeOrderCategory" wx:for="{{orderCategory}}" wx:key="index">{{item}}</view>
<view class="custom-scroll-view">
<nav-bar>
<view class="order-category {{currentDeliveryTimeType}}" slot="left">
<view class="item {{deliveryTimeType==index?'current':''}}" data-key="{{index}}"
bind:tap="changeDeliveryTimeType" wx:for="{{deliveryTimeTypeKV}}" wx:key="index">{{item}}</view>
</view>
</nav-bar>
<view class="top-bar">
<view class="item {{orderStatusIndex==index?'current':''}}" bind:tap="changeStatus"
wx:for="{{statusDic[currentDeliveryTimeType]}}" wx:key="index" data-index="{{index}}">
{{item.value}}(0)
</view>
</view>
<view wx:if="{{statusDic[currentDeliveryTimeType][orderStatusIndex].key!=orderStatus.completed}}" class="search">
<input class="input" placeholder="手机尾号查询" bindinput="filterOrder"
model:value="{{filterKey}}"/>
<button class="button">搜索</button>
</view>
</nav-bar>
<view class="top-bar">
<view class="item">待接单(0)</view>
<view class="item">待配送(0)</view>
<view class="item">已送达(0)</view>
</view>
<view class="search">
<input class="input" placeholder="手机尾号查询"/>
<button class="button">搜索</button>
</view>
<list-view class="package-list main" bind:refresh="refreshList"
bind:loadMore="loadList" refresher-triggered="{{pager.refreshTrigger}}"
show-load-more="{{!(list.length==0&&pager.loadAll)}}"
loading="{{pager.loading}}" load-all="{{pager.loadAll}}">
<view wx:for="{{list}}" wx:key="index"
class="item {{item.status==orderStatus.unpaid||item.status==orderStatus.completed?'no-btns':''}} {{item.is_first_order?'is-new-order':''}} {{item.order_additional_fees.length>0?'has-markup':''}}">
<view bind:tap="navToOrderDetail" data-id="{{item.orderid}}" >
<view class="item-head">
<view class="tag">自营商品</view>
<view class="deliver-time">
剩余<label class="time">{{'59分钟'}}</label>(19:30前送达)
<list-view class="package-list main" bind:refresh="refreshList"
bind:loadMore="loadList" refresher-triggered="{{pager.refreshTrigger}}"
loadMoreText="{{loadMoreText}}"
loading="{{pager.loading}}" load-all="{{pager.loadAll}}">
<view wx:for="{{filterKey?filtedList:list}}" wx:key="index"
class="item {{item.order.status==orderStatus.completed?'no-btns':''}}">
<view bind:tap="navToOrderDetail" data-id="{{item.orderid}}" >
<view class="item-head">
<view class="tag">{{productTypeKV[item.product.operation_type]}}</view>
<view class="deliver-time">
剩余<label class="time">{{'59分钟'}}</label>(19:30前送达)
</view>
</view>
</view>
<view class="merchant">
<view class="name">
<view class="text">家庭私厨烤串【鲜货】</view>
<view class="count">x 1</view>
<view class="merchant">
<view class="name">
<view class="text">{{item.product.name}}</view>
<view class="count">x {{item.order.qty}}</view>
</view>
<view class="money">9.9</view>
</view>
<view class="money">9.9</view>
</view>
<view class="address">
<view class="title">佳兆业丽晶公馆3栋2单元2702</view>
<view class="sub-title">
<view>{{'仙人模斗'}}{{genderKV['MALE']}}{{'13438370499'}}</view>
<view class="make-phone-tap-area">
<view class="make-phone">
<view class="icon-phone"/>
<view class="address">
<view class="title">
{{item.address.community_name}}
{{item.address.address_detail}}
</view>
<view class="sub-title">
<view>
{{item.address.name}}{{genderKV[item.address.gender]}}{{item.address.phone}}
</view>
<view class="make-phone-tap-area" capture-catch:tap="makePhoneCall"
data-phone="{{item.address.phone}}">
<view class="make-phone">
<view class="icon-phone"/>
</view>
</view>
</view>
</view>
</view>
<view class="markup" wx:if="{{item.order_additional_fees.length>0}}">
<view class="mu-item" wx:for="{{item.order_additional_fees}}"
wx:for-item="mItem" wx:key="index">
【<label class="bold">{{markupStatusKV[mItem.result]}}</label>】加价金额:<label class="bold">{{mItem.additional_fee_amount}}元</label>
</view>
<view wx:if="{{item.order.status==orderStatus.pending||item.order.status==orderStatus.pickupReady}}" class="btns">
<button disabled="{{item.receiving}}" class="button more-btn" plain
capture-catch:tap="showMoreAS" data-item="{{item}}" data-index="{{index}}">
退单
</button>
<swipe-button class="swipe-button" loading="{{item.receiving}}" bind:done="getOrder"
data-item="{{item}}" data-index="{{index}}" button-text="我要接单"
button-loading-text="接单中..." capture-catch:tap="emptyFun"/>
</view>
<view class="btns" wx:if="{{item.order.status==orderStatus.delivering}}">
<button disabled="{{item.receiving}}" class="button more-btn" plain
capture-catch:tap="openMap" data-item="{{item}}" data-index="{{index}}">
导航
</button>
<swipe-button class="swipe-button" loading="{{item.receiving}}" bind:done="receivedOrder" canReleaseText="释放送达..."
data-item="{{item}}" data-index="{{index}}" button-text="我已送达"
button-loading-text="送达中..." capture-catch:tap="emptyFun"/>
</view>
<view class="btns" wx:if="{{item.status==orderStatus.delivering}}">
<!-- <button class="button concat-user-btn" capture-catch:tap="concatUser"
data-item="{{item}}">
<image class="icon" src="/assets/icon/phone.png"></image>
<label>联系用户</label>
</button> -->
<button disabled="{{item.receiving}}" class="button more-btn" plain
capture-catch:tap="showMoreAS" data-item="{{item}}" data-index="{{index}}">
<view class="icon"></view>
</button>
<button type="primary" class="confirm-send-btn"
capture-catch:tap="confirmSend" data-item="{{item}}">我已送达</button>
</view>
</view>
<view class="btns" wx:if="{{item.status==orderStatus.pending}}">
<button disabled="{{item.receiving}}" class="button more-btn" plain
capture-catch:tap="showMoreAS" data-item="{{item}}" data-index="{{index}}">
退单
</button>
<swipe-button class="swipe-button" loading="{{item.receiving}}" bind:done="getOrder"
data-item="{{item}}" data-index="{{index}}" button-text="我要接单"
button-loading-text="接单中..." capture-catch:tap="emptyFun"/>
</view>
<view class="btns" wx:if="{{item.status==orderStatus.received}}">
<button disabled="{{item.receiving}}" class="button more-btn" plain
capture-catch:tap="showMoreAS" data-item="{{item}}" data-index="{{index}}">
<view class="icon"></view>
</button>
<swipe-button class="swipe-button" loading="{{item.receiving}}" bind:done="receivedOrder"
data-item="{{item}}" data-index="{{index}}" button-text="我已取货"
button-loading-text="取货中..." capture-catch:tap="emptyFun"/>
</view>
<view class="btns" wx:if="{{item.status==orderStatus.delivering}}">
<!-- <button class="button concat-user-btn" capture-catch:tap="concatUser"
data-item="{{item}}">
<image class="icon" src="/assets/icon/phone.png"></image>
<label>联系用户</label>
</button> -->
<button disabled="{{item.receiving}}" class="button more-btn" plain
capture-catch:tap="showMoreAS" data-item="{{item}}" data-index="{{index}}">
<view class="icon"></view>
</button>
<button type="primary" class="confirm-send-btn"
capture-catch:tap="confirmSend" data-item="{{item}}">我已送达</button>
</view>
</view>
</list-view>
</list-view>
</view>

View File

@ -9,6 +9,7 @@
content: '';
position: absolute;
top:6rpx;bottom:6rpx;
left:6rpx;
width:140rpx;
background-color: #fff;
border-radius: 8rpx;
@ -16,10 +17,10 @@
/* transition-timing-function:cubic-bezier(0.215, 0.61, 0.355, 1); */
transition-timing-function:cubic-bezier(.26,.9,.31,.97);
}
.order-category.active0::before{
.order-category.IMMEDIATE::before{
right:auto;left:6rpx;
}
.order-category.active1::before{
.order-category.SCHEDULED::before{
left:126rpx;
}
.order-category .item{
@ -34,7 +35,7 @@
.top-bar{
display: flex;
justify-content: space-between;
justify-content: space-around;
padding:40rpx 0;
}
.top-bar .item{
@ -77,6 +78,10 @@
padding:20rpx;
position: relative;
}
.package-list .item:first-child{
margin-top:0;
background-color: red;
}
.package-list .item .item-head{
display: flex;
align-items: center;
@ -105,15 +110,9 @@
left:38.5rpx;top:160rpx;
bottom:250rpx;
}
.package-list .item.has-markup::before{
bottom:200rpx;
}
.package-list .item.no-btns::before{
bottom:100rpx;
}
.package-list .item.no-btns.has-markup::before{
bottom:50rpx;
}
.package-list .item .name{
font-size: 40rpx;
display: flex;
@ -153,8 +152,7 @@
}
.package-list .item .merchant::before,
.package-list .item .address::before,
.package-list .item .markup .mu-item::before{
.package-list .item .address::before{
position: absolute;
content: '商';
left:0;top:0;
@ -170,33 +168,6 @@
content: '送';
background-color: var(--main-color);
}
.package-list .item .markup{
font-size: 34rpx;
line-height: 40rpx;
padding-bottom:20rpx;
color: var(--main-font-color);
}
.package-list .item .markup .bold{
font-weight: 500;
}
.package-list .item .markup .mu-item{
padding-left:48rpx;
position: relative;
display: flex;
align-items: center;
margin-top:30rpx;
}
.package-list .item .markup .mu-item::before{
content: '加';
background-color:#ff0000;
}
/* .package-list .item .package .value{
flex:1;
display: flex;
flex-wrap: wrap;
gap: 16rpx;
} */
.package-list .item .address{
padding-left:64rpx;
@ -207,6 +178,9 @@
color:var(--main-font-color);
font-size: 40rpx;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.package-list .item .address .sub-title{
font-size: 32rpx;
@ -225,7 +199,7 @@
padding:10rpx;
font-size:24rpx;
}
.package-list .item.is-new-order .address .sub-title::before{
/* .package-list .item.is-new-order .address .sub-title::before{
content:'新';
background-color:#ff0000;
color:#fff;
@ -233,7 +207,7 @@
margin-right: 12rpx;
border-radius: 8rpx;
padding:6rpx 8rpx;
}
} */
.package-list .item .btns{
display: flex;