Commit 36dcc902 authored by 刘用法's avatar 刘用法

首页推荐订单

parent 8d78ae70
......@@ -33,7 +33,7 @@
<view>
<view v-if="showCountTime" class="bottom-left-view">
<view :class="['bottom-tag-view', {'timeout': timeout}]"><text>{{tagText}}</text></view>
<u-count-down :timestamp="timestamp" font-size="44"
<u-count-down :timestamp="timestamp" font-size="44" show-days
:color="timeout ? '#FA5A49' : '#FF930D'" @change="handleChange" ref="order-count-down"></u-count-down>
</view>
<view v-else-if="showTime">
......@@ -98,42 +98,12 @@
data() {
return {
timeout: false,
timestamp: 0,
timestamp: 0,
orderType: 0
};
},
computed: {
/*
orderStatus:
待接单 orderStatus<31 工单状态小于31
待预约 orderStatus == 31 and appointmentDatetime == null 工单状态等于30并且预约时间为空
待签到 orderStatus == 31 and appointmentDatetime is not null 工单状态等于30并且预约时间不为空
待完工 orderStatus >31 and orderStatus < 80 工单状态大于31 小于80
审核中 orderStatus ==85 or orderStatus == 87 工单状态 等于85 或者 等于有87
异常 orderStatus ==86 or orderStatus == 88 工单状态 等于86 或者 等于有88
已完工 orderStatus in(80,81,89,110) 工单状态 等于80 or 81 or 89 or 110
*/
orderText() { // 按钮文字
if (!this.orderType) {
if (this.orderData.orderStatus < 31) {
this.orderType = 0
} else if (this.orderData.orderStatus == 31) {
if (this.orderData.appointmentDatetime) {
return this.orderType = 2
} else {
this.orderType = 1
}
} else if (this.orderData.orderStatus > 31 && this.orderData.orderStatus < 80) {
this.orderType = 3
} else if (this.orderData.orderStatus == 85 && this.orderData.orderStatus == 87) {
this.orderType = 4
} else if (this.orderData.orderStatus == 86 && this.orderData.orderStatus == 88) {
this.orderType = 5
} else if ([80, 81, 89, 110].indexOf(this.orderData.orderStatus) != -1) {
this.orderType = 6
} else {
this.orderType = 0
}
}
return this.typeTexts[this.orderType]
},
buttonStyle() { // 按钮样式
......@@ -229,12 +199,43 @@
'exception': 5, // 异常单、
'finish': 6, //已完工
}
},
orderType() {
return this.types[this.type]
}
},
created() {
/*
orderStatus:
待接单 orderStatus<31 工单状态小于31
待预约 orderStatus == 31 and appointmentDatetime == null 工单状态等于30并且预约时间为空
待签到 orderStatus == 31 and appointmentDatetime is not null 工单状态等于30并且预约时间不为空
待完工 orderStatus >31 and orderStatus < 80 工单状态大于31 小于80
审核中 orderStatus ==85 or orderStatus == 87 工单状态 等于85 或者 等于有87
异常 orderStatus ==86 or orderStatus == 88 工单状态 等于86 或者 等于有88
已完工 orderStatus in(80,81,89,110) 工单状态 等于80 or 81 or 89 or 110
*/
if (!this.type) {
if (this.orderData.orderStatus < 31) {
this.orderType = 0
} else if (this.orderData.orderStatus == 31) {
if (this.orderData.appointmentDatetime) {
return this.orderType = 2
} else {
this.orderType = 1
}
} else if (this.orderData.orderStatus > 31 && this.orderData.orderStatus < 80) {
this.orderType = 3
} else if (this.orderData.orderStatus == 85 && this.orderData.orderStatus == 87) {
this.orderType = 4
} else if (this.orderData.orderStatus == 86 && this.orderData.orderStatus == 88) {
this.orderType = 5
} else if ([80, 81, 89, 110].indexOf(this.orderData.orderStatus) != -1) {
this.orderType = 6
} else {
this.orderType = 0
}
} else {
this.orderType = this.types[this.type]
}
this.timeout = this.orderData.currentOverTime < new Date().getTime()
this.timestamp = Math.round(Math.abs(this.orderData.currentOverTime - new Date().getTime()) / 1000)
},
......
......@@ -18,7 +18,7 @@
</view>
</view>
<!-- 订单推荐吸顶 -->
<u-sticky offset-top="60">
<u-sticky offset-top="0">
<view class="sticky">
<text>订单推荐</text>
</view>
......@@ -35,17 +35,24 @@
立即入驻
</u-button>
</view>
<view v-else-if="!needSettled && orderList.length > 0" class="order-item-view">
<view v-for="(item, index) in orderList" :key="index">
<OrderCell :orderData="item" type="waitAccept" :location="location" @click="handleClick(item.orderId)"
@action="handleAction(item.orderId)"> </OrderCell>
<template v-else>
<!-- 入驻成功之后无推荐订单 -->
<view v-if="orderList.length <= 0 && loadedOrder" class="no-order-view">
<NoOrder />
</view>
<u-loadmore :status="currentLoadStatus" bgColor="#f2f2f2"></u-loadmore>
</view>
<!-- 入驻成功之后无推荐订单 -->
<view v-else-if="!needSettled && orderList.length <= 0" class="no-order-view">
<NoOrder/>
</view>
<view v-else class="order-item-view">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom"
scroll-anchoring>
<view v-for="(item, index) in orderList" :key="index">
<OrderCell :orderData="item" type="waitAccept" :location="location"
@click="handleClick(item.orderId)" @action="handleAction(item.orderId)">
</OrderCell>
</view>
<u-loadmore :status="currentLoadStatus" bgColor="#F4F5F7"></u-loadmore>
</scroll-view>
</view>
</template>
</view>
</view>
<!-- </view> -->
......@@ -60,7 +67,7 @@
<script>
import util from "@/utils/util.js";
import TabBarPage from "@/components/tabBarList/index.vue"
import TabBarPage from "@/components/tabBarList/index.vue"
import NoOrder from "@/components/order/noOrder.vue"
const app = getApp();
import OrderCell from "@/components/order/index.vue";
......@@ -68,7 +75,7 @@
export default {
components: {
OrderCell,
TabBarPage,
TabBarPage,
NoOrder
},
data() {
......@@ -78,23 +85,22 @@
title: false,
title: "Hello",
loaded: false,
loadedOrder: false,
needSettled: true,
count: 0, // 推荐订单数量
messageList: [],
loadStatus: ["more", "loading", "noMore"],
currentLoadStatus: "loading",
orderList: [],
search: {
token: "",
pageNumber: 0,
pageSize: 10,
pageSize: 100,
},
bottomLoading: false
};
},
watch: {
vuex_token(val, oldVal) {
// 监听token变化,如果更新则重新加载页面数据
// 监听token变化,如果更新则重新加载页面数据
console.log('', val, oldVal)
val && this.initSettleInfo()
}
......@@ -120,23 +126,19 @@
},
shouyeyouImage() {
return process.uniEnv.qn_base_url + 'shouyeyou.png'
},
weiruzhuImage() {
return process.uniEnv.qn_base_url + 'weiruzhu.png'
},
weiruzhuImage() {
return process.uniEnv.qn_base_url + 'weiruzhu.png'
},
},
onLoad() {
this.getOrderCount()
onLoad() {
this.getOrderCount()
},
onShow() {
// 每次进入页面都刷新入驻状态
if (this.vuex_token) {
this.initSettleInfo();
}
// else {
// // 初始化订单数据
// this.loadOrderList();
// }
},
onPullDownRefresh() {
console.log('------下拉刷新------')
......@@ -146,17 +148,17 @@
methods: {
handleClick(orderId) { // 点击了cell
console.log('点击了cell')
console.log('点击了cell')
this.viewOderItem(orderId)
},
handleAction(orderId) { // 点击了按钮
console.log('点击了按钮')
this.viewOderItem(orderId)
},
viewOderItem(orderId) { // 跳转工单详情页面
uni.navigateTo({
url: 'pages/order/detail?id=' + orderId
})
},
viewOderItem(orderId) { // 跳转工单详情页面
uni.navigateTo({
url: 'pages/order/detail?id=' + orderId
})
},
async initSettleInfo() {
let self = this;
......@@ -165,13 +167,15 @@
if (result && result.record) {
vm.loaded = true;
vm.needSettled = result.needSettled;
vm.needSettled = false
vm.status = Number(result.record.status || '0');
// vm.status = 8
}
};
await app.getBaseInfo(self, callBack);
this.orderList = []
this.orderList = []
this.search.pageNumber = 0
// 加载消息列表
self.loadMessageList();
self.loadOrderList();
......@@ -193,14 +197,51 @@
},
loadOrderList() {
console.log('-----------准备加载推荐列表-----------')
this.search.pageNumber += 1
let self = this;
// 加载订单列表
self.search.token = self.vuex_token;
self.$u.api.listByRecommendOrder(self.search).then((res) => {
uni.stopPullDownRefresh() // 结束下拉刷新
self.loadedOrder = true
/*↓↓↓↓↓↓↓↓↓↓测试数据↓↓↓↓↓↓↓↓↓↓*/
// if (res.data.list) {
// if (res.data.list.length == 0 && res.data.total > 0) {
// res.data.total = 15
// res.data.list = [{
// orderServiceType: '安装', // 服务类型:安装、维修
// categoryName: '充电桩', // 品类:充电桩
// orderBusinessTypeText: '分配单', // 业务类型:分配单、订单池
// orderNumber: 'OR2021041809827', // 工单编号
// contactName: '郭小清', // 客户信息
// contactPhone: '13631612077', // 联系方式
// contactAddress: '湾街道荔枝花园D座125号', // 详细地址
// contactAddressLatitud: '116.3896', // 联系人地址经度
// contactAddressLongitud: '39.91917', // 联系人地址纬度
// orderStatus: 0, // 工单状态
// appointmentDatetime: '', // 预约时间
// currentWillOverTime: 10000, // 剩余时间
// currentOverTime: new Date().getTime() + 10000, // 超过时间点
// auditDatetime: '2021.04.19 12:45:09', // 审核时间
// submissionTime: '2021.04.19 16:24:48', // 提交时间
// auditResults: {}, // 审核结果
// orderBusinessType: 'R', // 业务类型 R 为抢单
// orderId: '1100000216'
// }]
// res.data.list = [...res.data.list, ...res.data.list, ...res.data.list, ...res.data
// .list,
// ...res.data.list, ...res.data.list, ...res.data.list, ...res.data.list, ...
// res
// .data.list, ...res.data.list
// ]
// }
// }
/*↑↑↑↑↑↑↑↑↑↑测试数据↑↑↑↑↑↑↑↑↑↑↑↑↑*/
if (res.code == 200) {
if (res.data && res.data.list && res.data.list.length > 0) {
self.orderList.push(...res.data.list);
self.currentLoadStatus = res.data.total > self.orderList.length ? 'loadmore' : 'nomore'
}
} else {
console.log(res.message, "初始化订单列表异常");
......@@ -211,27 +252,9 @@
this.triggered = "restore";
},
reachBottom() {
console.log("-----bottom will-----");
if (this.bottomLoading || this.currentLoadStatus == this.loadStatus[2]) {
return;
}
console.log("-----bottom did-----");
this.bottomLoading = true;
setTimeout(() => {
// 加载更多数据
// ...
this.orderList.push(...[{}, {}, {}, {}, {}, {}, {}, {}, {}, {}]);
// 加载完成
this.currentLoadStatus = false /*是否还有*/ ?
this.loadStatus[1] :
this.loadStatus[2];
this.$nextTick(function() {
this.bottomLoading = false;
});
}, 1000);
if (this.currentLoadStatus != 'loadmore') return
this.currentLoadStatus == 'loading'
this.loadOrderList()
},
// clickSwiper(index) {},
handleScroll() {
......@@ -276,29 +299,29 @@
});
}
},
// 获取订单数量
getOrderCount() {
var self = this; // 加载订单列表
self.$u.api.listOrderCount().then((res) => {
if (res.code == 200) {
console.log("===", res.data)
if (res.data) {
var count = 0
for (var i in res.data) {
count += res.data[i]
}
// 修改tab总数
uni.setTabBarBadge({
index: 1,
text: String(count)
})
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
// 获取订单数量
getOrderCount() {
var self = this; // 加载订单列表
self.$u.api.listOrderCount().then((res) => {
if (res.code == 200) {
console.log("===", res.data)
if (res.data) {
var count = 0
for (var i in res.data) {
count += res.data[i]
}
// 修改tab总数
uni.setTabBarBadge({
index: 1,
text: String(count)
})
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
},
};
</script>
......@@ -414,19 +437,20 @@
background-color: #ffffff;
border-radius: 12rpx;
min-height: 460rpx;
.tip-view-image {
width: 328rpx;
height: 200rpx;
margin-top: 30rpx;
.tip-view-image {
width: 328rpx;
height: 200rpx;
margin-top: 30rpx;
}
.tip-other {
font-size: 28rpx;
color: #333333;
margin-bottom: 20rpx;
}
.settle-button {
}
.settle-button {}
}
.order-item-view {
......
......@@ -194,6 +194,40 @@
var self = this;
self.$u.api.listOrder(param).then((res) => {
if (res.code == 200) {
/*↓↓↓↓↓↓↓↓↓↓测试数据↓↓↓↓↓↓↓↓↓↓*/
// res.data.type = self.orderType
// if (res.data.list) {
// if (res.data.list.length == 0 && res.data.total > 0) {
// res.data.total = 15
// res.data.list = [{
// orderServiceType: '安装', // 服务类型:安装、维修
// categoryName: '充电桩', // 品类:充电桩
// orderBusinessTypeText: '分配单', // 业务类型:分配单、订单池
// orderNumber: 'OR2021041809827', // 工单编号
// contactName: '郭小清', // 客户信息
// contactPhone: '13631612077', // 联系方式
// contactAddress: '湾街道荔枝花园D座125号', // 详细地址
// contactAddressLatitud: '116.3896', // 联系人地址经度
// contactAddressLongitud: '39.91917', // 联系人地址纬度
// orderStatus: 0, // 工单状态
// appointmentDatetime: '', // 预约时间
// currentWillOverTime: 10000, // 剩余时间
// currentOverTime: new Date().getTime() + 10000, // 超过时间点
// auditDatetime: '2021.04.19 12:45:09', // 审核时间
// submissionTime: '2021.04.19 16:24:48', // 提交时间
// auditResults: {}, // 审核结果
// orderBusinessType: 'R', // 业务类型 R 为抢单
// orderId: '1100000216'
// }]
// res.data.list = [...res.data.list, ...res.data.list, ...res.data.list, ...res.data
// .list,
// ...res.data.list, ...res.data.list, ...res.data.list, ...res.data.list, ...
// res
// .data.list, ...res.data.list
// ]
// }
// }
/*↑↑↑↑↑↑↑↑↑↑测试数据↑↑↑↑↑↑↑↑↑↑↑↑↑*/
// 后台需要返回type,防止数据返回延迟期间点击了其他的tab
if (res.data.type != self.orderType) return
self.triggered = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment