完成订单、接单部分功能

This commit is contained in:
TOP糯米 2023-03-15 00:59:54 +08:00
parent 2125d4285b
commit e06be68d50
8 changed files with 164 additions and 174 deletions

View File

@ -1,11 +1,11 @@
<template>
<view class="component-get-action">
<block v-if="order.listType == 't1' || order.listType == 't3' || (order.listType == 't2' && order.orderType == 1)">
<block v-if="order.listType == 't1' || order.listType == 't3' || (order.listType == 't2' && order.orderType == 2)">
<view class="btn active" @click.stop="getOrder">
<text>立即抢单</text>
</view>
</block>
<block v-if="order.listType == 't2' && order.orderType == 2">
<block v-if="order.listType == 't2' && order.orderType == 1">
<view class="btn active" @click.stop="postPrice">
<text>立即报价</text>
</view>

View File

@ -48,7 +48,6 @@ export default {
name: "component-order-item",
data() {
return {
models: this.$models,
typeText: "",
typeTextBg: "",
};
@ -62,7 +61,8 @@ export default {
components: {},
created() {},
mounted() {
let [typeText, typeTextBg] = this.$models.order.getOrderTypeText(this.order.listType, this.order.orderType);
// console.log(this.order);
let [typeText, typeTextBg] = this.$models.order.orderTypeText(this.order.listType, this.order.orderType);
this.typeText = typeText;
this.typeTextBg = typeTextBg ? typeTextBg : "#8b9beb";
},

View File

@ -91,6 +91,25 @@ const apis = {
},
}
},
order: {
list: {
t1: {
url: "/user/workerorderc/myorderlist",
showLoading: true,
auth: true,
},
t2: {
url: "/user/workerorder/getmycarorder",
showLoading: true,
auth: true,
},
t3: {
url: "/user/workerorderc/myorderlist",
showLoading: true,
auth: true,
},
},
},
}
export default apis

View File

@ -1,88 +1,45 @@
import Vue from "vue"
let prototype = Vue.prototype;
export default {
type: {
NORMAL: 1,
WORKER_PRICE: 2,
CUSTOM_PRICE: 3,
},
state: {
// 订单关闭
ORDER_CLOSE: -2,
// 未支付
NO_PAY: -1,
// 等待师傅报价
NO_PRICE: 0,
// 等待您选择师傅
NO_SELECT_WORKER: 1,
// 等待师傅上门
NO_SERVICE: 2,
// 完成订单
NO_APPRAISE: 3,
// 服务完结
ALL_FINISH: 4,
// 已申请退款
APPLY_REFUND: 6,
// 已退款
REFUNDED: 7,
// 无法退款
CAN_NOT_REFUND: 8,
},
getOrderTypeText(listType, orderType) {
orderTypeText(listType, orderType) {
switch (listType) {
case "t1": return ["购买服务", "#3ABCF6"];
case "t2":
if (orderType == 1) {
if (orderType == 2) {
return ["一口价", "#3ABCF6"];
}
return ["报价"];
case "t3": return ["货运", "#628BE7"];
}
},
getOrderStateTextColor(state) {
switch (state) {
case this.state.NO_PAY:
return '#000000';
case this.state.NO_PRICE:
return '#000000';
case this.state.NO_SELECT_WORKER:
return '#000000';
case this.state.NO_SERVICE:
return '#000000';
case this.state.NO_APPRAISE:
return '#000000';
case this.state.ALL_FINISH:
return '#000000';
case this.state.APPLY_REFUND:
return '#000000';
case this.state.REFUNDED:
return '#000000';
case this.state.CAN_NOT_REFUND:
return '#000000';
default:
return '#ff0000';
}
},
getOrderStateText(state) {
switch (state) {
case this.state.NO_PAY:
return '待支付';
case this.state.NO_PRICE:
return '等待师傅报价';
case this.state.NO_SELECT_WORKER:
return '等待您选择师傅';
case this.state.NO_SERVICE:
return '等待师傅上门';
case this.state.NO_APPRAISE:
return '完成订单';
case this.state.ALL_FINISH:
return '服务完结';
case this.state.APPLY_REFUND:
return '已提交申请';
case this.state.REFUNDED:
return '已退款';
case this.state.CAN_NOT_REFUND:
return '未通过';
default:
return '未知状态';
}
/**
* 获取列表
*/
getList(options) {
return new Promise((resolve, reject) => {
prototype.$request(options.request).then(response => {
if (response.code == 1) {
let list = [];
response.data.forEach(item => {
list.push({
listType: options.listType,
id: item.id,
orderId: item.order,
username: "用户名称",
cate: "待返数据",
content: item.desc,
createTime: item.time,
serviceTime: item.times,
orderType: item.types,
state: item.status,
price: item.money,
});
});
return resolve(list);
}
return reject(response.msg);
}).catch(e => { });
});
}
}

View File

@ -27,7 +27,8 @@
{
"path": "pages/order/order",
"style": {
"navigationBarTitleText": "订单"
"navigationBarTitleText": "订单",
"enablePullDownRefresh": true
}
},
{

View File

@ -20,7 +20,7 @@
</view>
</view>
</view>
<block v-if="listType == 't1'">
<block v-if="listType == 't1' || listType == 't2'">
<view class="detail-section">
<view class="section-title">需求信息</view>
<view class="section-content">
@ -104,9 +104,11 @@
</view>
</view>
</block>
<view class="detail-section">
<text class="price-box">¥ {{ utils.formatNumber(order.price, 2) }}</text>
</view>
<block v-if="listType == 't1' || (listType == 't2' && order.orderType == 2)">
<view class="detail-section">
<text class="price-box">¥ {{ utils.formatNumber(order.price, 2) }}</text>
</view>
</block>
</view>
<view class="common-bottom-components" :style="{ bottom: pageConfig.safeAreaInsets.bottom + 'px' }">
<view class="service" @click="utils.serviceActions()">
@ -258,6 +260,28 @@ export default {
mobile: response.address.mobil,
},
};
} else if (this.listType == "t2") {
this.order = {
listType: this.listType,
id: response.id,
orderId: response.order,
username: "用户名称",
cate: "待返数据",
content: response.desc,
createTime: response.time,
serviceTime: response.times,
orderType: response.types,
state: response.status,
price: response.money,
orderId: response.order,
images: response.img,
address: {
address: response.address.address,
detail: response.address.doorplate,
name: response.address.name,
mobile: response.address.mobil,
},
};
} else if (this.listType == "t3") {
this.order = {
listType: this.listType,
@ -273,7 +297,7 @@ export default {
price: response.money,
};
}
let [typeText, typeTextBg] = this.$models.order.getOrderTypeText(this.listType, this.order.orderType);
let [typeText, typeTextBg] = this.$models.order.orderTypeText(this.listType, this.order.orderType);
this.typeText = typeText;
this.typeTextBg = typeTextBg ? typeTextBg : "#8b9beb";
});

View File

@ -23,7 +23,15 @@
<view class="order-item-box" v-for="(v, k) in item.list" :key="k" @click.stop="toDetail(v.id)">
<order-item :order="v">
<view class="order-action">
<view class="price">¥ 306.00</view>
<view
v-if="
v.listType == 't1' ||
v.listType == 't3' ||
(v.listType == 't2' && v.orderType == 2)
"
class="price"
>¥ {{ v.price }}</view
>
<get-action
:order="v"
@postPrice="postPrice(v.id)"
@ -96,10 +104,10 @@ export default {
OrderItem,
GetPostPrice,
},
onLoad() {
this.switchTab(0);
onLoad() {},
onShow() {
this.switchTab(this.tabIndex);
},
onShow() {},
onReady() {},
onReachBottom() {
this.loadData();
@ -242,6 +250,8 @@ export default {
white-space: nowrap;
box-sizing: border-box;
padding: 5rpx 0;
display: flex;
justify-content: center;
.cate-item {
display: inline-block;
height: 86rpx;

View File

@ -28,7 +28,7 @@
</view>
</view>
<view class="order-group">
<swiper :current="tabIndex" :style="{ height: tabHeight + 'px' }" @change="changeTab">
<swiper :current="tabIndex" :style="{ height: tabHeight + 'px' }" @change="switchTab($event.detail.current)">
<swiper-item v-for="(item, index) in tabList" :key="index">
<view :class="['tab' + index]">
<view class="order-item-box" v-for="(v, k) in item.list" :key="k" @click.stop="toDetail(v.id)">
@ -68,78 +68,24 @@ export default {
tabHeight: 0,
tabList: [
{
id: 1,
name: "报价",
list: [
{
id: 1,
orderId: "xxgfdkgn1223",
cate: "家具安装",
content: "我想要安装一个书柜,需要上墙啊啊啊啊",
createTime: "2022-10-18 10:56:34",
serviceTime: "2022-10-18 10:56:34",
orderType: 1,
state: 1,
price: 306,
username: "李先生",
},
{
id: 2,
orderId: "xxgfdkgn1223",
cate: "家具安装",
content: "我想要安装一个书柜,需要上墙啊啊啊啊",
createTime: "2022-10-18 10:56:34",
serviceTime: "2022-10-18 10:56:34",
orderType: 1,
state: 1,
price: 306,
username: "李先生",
},
{
id: 3,
orderId: "xxgfdkgn1223",
cate: "家具安装",
content: "我想要安装一个书柜,需要上墙啊啊啊啊",
createTime: "2022-10-18 10:56:34",
serviceTime: "2022-10-18 10:56:34",
orderType: 1,
state: 1,
price: 306,
username: "李先生",
},
],
},
{
id: 2,
name: "待预约",
list: [
{
id: 2,
orderId: "xxgfdkgn1223",
cate: "家具安装",
content: "我想要安装一个书柜,需要上墙啊啊啊啊",
createTime: "2022-10-18 10:56:34",
serviceTime: "2022-10-18 10:56:34",
orderType: 2,
state: 1,
price: 306,
username: "李先生",
},
],
},
{
id: 3,
name: "服务中",
listType: "t1",
name: "购买订单",
more: true,
page: 1,
list: [],
},
{
id: 4,
name: "完工/关闭",
listType: "t2",
name: "报/议价订单",
more: true,
page: 1,
list: [],
},
{
id: 5,
name: "退款",
listType: "t3",
name: "货运订单",
more: true,
page: 1,
list: [],
},
],
@ -154,28 +100,26 @@ export default {
LoadMore,
OrderConfirmPrice,
},
onLoad() {
this.$nextTick(() => {
this.setTabHeight();
});
onLoad() {},
onShow() {
this.switchTab(this.tabIndex);
},
onShow() {},
onReady() {},
onReachBottom() {},
onPullDownRefresh() {},
onReachBottom() {
this.loadData();
},
onPullDownRefresh() {
this.switchTab(this.tabIndex);
uni.stopPullDownRefresh();
},
methods: {
switchTab(index) {
this.tabIndex = index;
this.$nextTick(() => {
this.setTabHeight();
});
uni.pageScrollTo({
scrollTop: 0,
duration: 100,
});
},
changeTab(e) {
this.switchTab(e.detail.current);
let currentTab = this.tabList[index];
currentTab.page = 1;
currentTab.more = true;
currentTab.list = [];
this.loadData();
},
setTabHeight() {
let query = uni.createSelectorQuery().in(this);
@ -190,6 +134,39 @@ export default {
this.$store.commit("order/setConfirmId", id);
this.showConfirmModal = true;
},
/**
* 加载数据
*/
loadData() {
let currentTab = this.tabList[this.tabIndex];
return new Promise((resolve, reject) => {
if (!currentTab.more) {
return;
}
this.$models.order
.getList({
request: {
api: "order.list." + currentTab.listType,
data: {
page: currentTab.page,
status: currentTab.status,
},
},
listType: currentTab.listType,
})
.then((list) => {
if (list.length == 0) {
currentTab.more = false;
} else {
currentTab.page++;
currentTab.list = currentTab.list.concat(list);
}
this.$nextTick(() => {
this.setTabHeight();
});
});
});
},
toDetail(id) {
this.$utils.toPage("/pages/order/detail?type=detail&id=" + id);
},
@ -241,6 +218,8 @@ export default {
white-space: nowrap;
box-sizing: border-box;
padding: 5rpx 0;
display: flex;
justify-content: center;
.cate-item {
display: inline-block;
height: 86rpx;