6 changed files with 255 additions and 0 deletions
Split View
Diff Options
-
1app.json
-
3pages/home/index/index.js
-
170pages/process/agent-list/index.js
-
14pages/process/agent-list/index.json
-
60pages/process/agent-list/index.wxml
-
7pages/process/agent-list/index.wxss
@ -0,0 +1,170 @@ |
|||
// pages/process/order-list/index.js
|
|||
import Dialog from '../../../components/dialog/dialog' |
|||
import { getFactoryOrderList, cancelOrder } from "../../../api/saas" |
|||
const event = require('../../../utils/event') |
|||
const util = require('../../../utils/util') |
|||
const app = getApp() |
|||
|
|||
Page({ |
|||
// * 页面的初始数据
|
|||
data: { |
|||
height: app.globalData.fragmentHeight - 90, |
|||
tabIndex: 0, |
|||
tabList: [ |
|||
{id: 0, name: '全部', badge: 0, status: '' }, |
|||
{id: 1, name: '审核中', badge: 0, status: 1 }, |
|||
{id: 2, name: '审核未通过', badge: 0, status: 2 }, |
|||
{id: 4, name: '待付款', badge: 0, status: 4 }, |
|||
{id: 5, name: '已结算', badge: 0, status: 5 }, |
|||
// {id: 6, name: '已取消', badge: 0, status: 6 }
|
|||
], |
|||
loading: true, |
|||
requesting: false, |
|||
finished: false, |
|||
top: 0, |
|||
orderList: [], |
|||
form: { |
|||
funcType: 0, |
|||
pageNum: 1, |
|||
pageSize: 10 |
|||
}, |
|||
title: '全部', |
|||
lastTime: null |
|||
}, |
|||
// * 生命周期函数--监听页面加载
|
|||
onLoad: function (options) { |
|||
if(options.status){ |
|||
this.data.form.funcType = Number(options.status) |
|||
if(this.data.form.funcType == 1){ |
|||
this.data.title = '待定价订单' |
|||
} else if(this.data.form.funcType == 2){ |
|||
this.data.title = '过磅审核订单' |
|||
} else if(this.data.form.funcType == 3){ |
|||
this.data.title = '待付款订单' |
|||
} else if(this.data.form.funcType == 4){ |
|||
this.data.title = '已完成订单' |
|||
this.data.form.funcType = 6 |
|||
this.data.form.status = 5 |
|||
} else if(this.data.form.funcType == 5){ |
|||
this.data.title = '已关闭订单' |
|||
} |
|||
} |
|||
event.on('OrderMessage', this, this.onEvent) |
|||
this.setData({ height: app.globalData.fragmentHeight - 90, title: this.data.title }) |
|||
this.fetchOrderList() |
|||
}, |
|||
onEvent: function(message){ |
|||
if (message.what == 12) { |
|||
this.onRefreshList() |
|||
} |
|||
}, |
|||
onTabChange: function ({detail}) { |
|||
if (this.data.tabIndex == Number(detail.index)) { |
|||
return |
|||
} |
|||
this.setData({ tabIndex: detail.index, requesting: false }) |
|||
this.data.form.status = this.data.tabList[detail.index].status |
|||
this.onRefreshList() |
|||
}, |
|||
onRefreshList: function () { |
|||
if (this.data.requesting) { |
|||
return |
|||
} |
|||
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) |
|||
this.data.lastTime = null |
|||
this.fetchOrderList() |
|||
}, |
|||
//1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成
|
|||
fetchOrderList: function () { |
|||
if (this.data.requesting || this.data.finished) { |
|||
return |
|||
} |
|||
if (this.data.loading) { |
|||
this.data.requesting = true |
|||
} else { |
|||
this.setData({ requesting: true }) |
|||
} |
|||
getFactoryOrderList(this.data.form).then(result => { |
|||
this.handResult(result) |
|||
}).catch(err => { |
|||
this.setData({ requesting: false, loading: false }) |
|||
util.showToast(err) |
|||
}) |
|||
}, |
|||
handResult: function(result){ |
|||
if (result.data && result.data.records.length) { |
|||
var respList = result.data.records |
|||
// 对返回的消息列表进行处理,将同一天的消息显示在一起
|
|||
for (let i = 0; i < respList.length; i++) { |
|||
if (util.isEmpty(this.data.lastTime)) { |
|||
this.data.lastTime = respList[i].createTime |
|||
if (this.data.lastTime.length > 10) { |
|||
this.data.lastTime = this.data.lastTime.substring(0, 10) |
|||
} |
|||
respList[i].tipsTime = this.data.lastTime |
|||
} else { |
|||
var itemTime = respList[i].createTime |
|||
if (itemTime.length > 10) { |
|||
itemTime = itemTime.substring(0, 10) |
|||
} |
|||
if (this.data.lastTime !== itemTime) { |
|||
respList[i].tipsTime = itemTime |
|||
} |
|||
this.data.lastTime = itemTime |
|||
} |
|||
} |
|||
let nowList = `orderList[${this.data.orderList.length}]` |
|||
var num = this.data.form.pageNum |
|||
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|||
if(this.data.form.pageNum == 1){ |
|||
this.setData({ |
|||
[nowList]: respList, |
|||
['form.pageNum']: (num + 1), |
|||
top: 0, |
|||
finished, |
|||
requesting: false, |
|||
loading: false |
|||
}) |
|||
} else { |
|||
this.setData({ |
|||
[nowList]: respList, |
|||
['form.pageNum']: (num + 1), |
|||
finished, |
|||
requesting: false, |
|||
loading: false |
|||
}) |
|||
} |
|||
} else { |
|||
this.setData({ finished: true, requesting: false, loading: false }) |
|||
} |
|||
}, |
|||
cancelOrder: function(e){ |
|||
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => { |
|||
wx.showLoading({ title: '正在获取', mask: true }) |
|||
cancelOrder(e.currentTarget.dataset.id).then(result => { |
|||
wx.hideLoading() |
|||
util.showToast('订单已经删除') |
|||
this.onRefreshList() |
|||
}).catch(err => { |
|||
wx.hideLoading() |
|||
util.showToast(err) |
|||
}) |
|||
}) |
|||
}, |
|||
lookItem: function (e) { |
|||
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|||
if(item.status == 2 || item.status == 3 || item.status == 4 || item.status == 5){ |
|||
wx.navigateTo({ url: `/pages/process/order-info/index?id=${item.id}` }) |
|||
} |
|||
}, |
|||
priceOrder: function(e){ |
|||
wx.navigateTo({ url: '/pages/process/order-price/index?id=' + e.currentTarget.dataset.id }) |
|||
}, |
|||
checkOrder: function(e){ |
|||
wx.navigateTo({ url: '/pages/process/order-info/index?id=' + e.currentTarget.dataset.id }) |
|||
}, |
|||
onUnload: function(){ |
|||
event.remove('OrderMessage', this) |
|||
} |
|||
|
|||
}) |
|||
@ -0,0 +1,14 @@ |
|||
{ |
|||
"usingComponents": { |
|||
"refresh-view": "/components/refresher/index", |
|||
"van-button": "/components/button/index", |
|||
"van-index-bar": "/components/index-bar/index", |
|||
"van-index-anchor": "/components/index-anchor/index", |
|||
"van-tabs": "/components/tabs/index", |
|||
"van-tab": "/components/tab/index", |
|||
"van-cell": "/components/cell/index", |
|||
"van-divider": "/components/divider/index", |
|||
"van-loading": "/components/loading/index", |
|||
"van-dialog": "/components/dialog/index" |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
<!--pages/process/order-list/index.wxml--> |
|||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
|||
<view slot="content">{{title}}</view> |
|||
</cu-custom> |
|||
|
|||
<van-tabs sticky active="{{tabIndex}}" color="#008AFF" bind:change="onTabChange" line-height="2px" swipe-threshold="4"> |
|||
<van-tab wx:for="{{tabList}}" wx:key="index" title="{{item.name}}" title-style="color:{{tabIndex==index?'#008AFF':'#333333'}}"></van-tab> |
|||
</van-tabs> |
|||
|
|||
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchOrderList"> |
|||
<view class="list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}"> |
|||
<view style="margin-bottom:24px" wx:if="{{loading}}"> |
|||
<van-loading type="spinner" size="32" /> |
|||
</view> |
|||
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
|||
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view> |
|||
</view> |
|||
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> |
|||
<view class="bg-white" wx:for="{{pageItem}}" wx:key="index"> |
|||
<view style="background-color:#f3f3f3;" wx:if="{{item.tipsTime}}"> |
|||
<text class="text-sg" style="line-height:64rpx;padding-left:32rpx">{{item.tipsTime}}</text> |
|||
</view> |
|||
<view class="flex flex-justify item-content" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem"> |
|||
<view style="height: 88rpx"> |
|||
<view class="flex flex-center text-sg text-black"> |
|||
<text>客户名称:{{item.factoryCustomerName}}</text> |
|||
<text wx:if="{{item.status != 1 && item.factoryCustomerMobile}}">({{item.factoryCustomerMobile}})</text> |
|||
</view> |
|||
<view class="text-sm text-gray" style="margin-top:12rpx">毛重:{{item.totalWeight}}公斤</view> |
|||
</view> |
|||
<view class="flex flex-center" wx:if="{{item.status == 1}}" style="height: 88rpx"> |
|||
<van-button plain type="default" custom-style="height:64rpx;width:132rpx" data-id="{{item.id}}" |
|||
bind:click="cancelOrder">取消</van-button> |
|||
<van-button plain type="info" custom-style="margin-left:24rpx;height:64rpx;width:132rpx" data-id="{{item.id}}" |
|||
bind:click="priceOrder">定价</van-button> |
|||
</view> |
|||
<view class="flex flex-center" wx:if="{{item.status == 3}}" style="height: 88rpx"> |
|||
<van-button plain type="info" custom-style="height:64rpx;width:132rpx" data-id="{{item.id}}" |
|||
bind:click="checkOrder">审核</van-button> |
|||
</view> |
|||
<view class="flex flex-center" wx:elif="{{item.status ==2}}"> |
|||
<view class="text-df text-black">待过皮重</view> |
|||
</view> |
|||
<view class="flex flex-center" wx:elif="{{item.status == 4}}"> |
|||
<view class="text-df" style="color:#FA541C">待付款</view> |
|||
</view> |
|||
<view class="flex flex-center" wx:elif="{{item.status == 5}}"> |
|||
<view class="text-df" style="color:#028A00">已完成</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!--加载更多的UI--> |
|||
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx"> |
|||
<van-loading type="spinner" size="16" wx:if="{{!finished}}" /> |
|||
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
|||
</van-divider> |
|||
</refresh-view> |
|||
|
|||
<van-dialog id="van-dialog" /> |
|||
@ -0,0 +1,7 @@ |
|||
/* pages/process/order-list/index.wxss */ |
|||
.item-content{ |
|||
padding: 20rpx 32rpx 20rpx 0rpx; |
|||
border-bottom:1rpx solid #f3f3f3; |
|||
margin-left:32rpx; |
|||
align-items: flex-start; |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save