From d88d0b938a3feb83171f3c08e32b080062540a84 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Mon, 22 Feb 2021 19:37:06 +0800 Subject: [PATCH] no message --- api/saas.js | 6 +- app.json | 2 + components/action-sheet/index.wxml | 61 ++++---------- components/tabbar/index.wxml | 2 +- pages/formate.wxs | 5 ++ pages/index/index.js | 15 +++- pages/index/index.wxml | 2 +- pages/process/index/index.js | 64 +++++++++++++-- pages/process/index/index.json | 3 +- pages/process/index/index.wxml | 19 +++-- pages/process/order-info/index.js | 1 - pages/process/order-list/index.js | 23 ++---- pages/process/payment-list/index.js | 114 ++++++++++++++++++++++++++ pages/process/payment-list/index.json | 11 +++ pages/process/payment-list/index.wxml | 41 +++++++++ pages/process/payment-list/index.wxss | 7 ++ pages/process/payment/index.js | 72 ++++++++++++++++ pages/process/payment/index.json | 9 ++ pages/process/payment/index.wxml | 50 +++++++++++ pages/process/payment/index.wxss | 10 +++ 20 files changed, 433 insertions(+), 84 deletions(-) create mode 100644 pages/process/payment-list/index.js create mode 100644 pages/process/payment-list/index.json create mode 100644 pages/process/payment-list/index.wxml create mode 100644 pages/process/payment-list/index.wxss create mode 100644 pages/process/payment/index.js create mode 100644 pages/process/payment/index.json create mode 100644 pages/process/payment/index.wxml create mode 100644 pages/process/payment/index.wxss diff --git a/api/saas.js b/api/saas.js index 4c0384b..48baa38 100644 --- a/api/saas.js +++ b/api/saas.js @@ -12,9 +12,11 @@ const sconfig = { const loginToken = (params) => mPost(`/recycle-user-center/authorize/get/product-line-token/by/login-token`, params, sconfig) const getUserInfo = () => mGet(`/recycle-user-center/user/get/user-info`, null, sconfig) const getBaseInfo = () => mGet(`/ztb-factory/get/self-enterprise-profile-detail`, null, sconfig) +const getStatisticsInfo = (params) => mGet(`/ztb-factory/get/my-workbench-statistics-info`, params, sconfig) const bindingAdmin = (params) => mPost(`/recycle-user-center/bind/factory-admin`, params, sconfig) const getOrderList = (params) => mGet(`/ztb-factory/factory-customer/get/order-list`, params, sconfig) const getReceiptList = (params) => mGet(`/ztb-factory/factory/get/order-receipt-proof-audit-list`, params, sconfig) +const getPeymentList = (params) => mGet(`/ztb-factory/get/order-pay-list`, params, sconfig) const getOrderInfo = (id) => mGet(`/ztb-factory/factory-customer/get/order-detail/${id}`, null, sconfig) const pricingOrder = (params) => mPost(`/ztb-factory/factory/submit/order-price`, params, sconfig) const cancelOrder = (id) => mPost(`/ztb-factory/factory/cancel/order/${id}`, null, sconfig) @@ -42,6 +44,7 @@ export { getFactoryOrderInfo, getOrderList, getReceiptList, + getPeymentList, getOrderInfo, createOrder, checkingOrder, @@ -55,5 +58,6 @@ export { deleteCustomer, getCustomerInfo, getPaperList, - repeatOrder + repeatOrder, + getStatisticsInfo } \ No newline at end of file diff --git a/app.json b/app.json index 9c80688..433fdf2 100644 --- a/app.json +++ b/app.json @@ -9,6 +9,8 @@ "pages/process/order-list/index", "pages/process/order-price/index", "pages/process/order-info/index", + "pages/process/payment-list/index", + "pages/process/payment/index", "pages/htmls/agreement/index", "pages/message/detail/index" ], diff --git a/components/action-sheet/index.wxml b/components/action-sheet/index.wxml index 7ed2819..51718be 100644 --- a/components/action-sheet/index.wxml +++ b/components/action-sheet/index.wxml @@ -1,67 +1,36 @@ - + {{ title }} - + {{ description }} - - + {{ cancelText }} - + \ No newline at end of file diff --git a/components/tabbar/index.wxml b/components/tabbar/index.wxml index 9239d21..df9a07b 100644 --- a/components/tabbar/index.wxml +++ b/components/tabbar/index.wxml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/pages/formate.wxs b/pages/formate.wxs index 1e03ef7..495409c 100644 --- a/pages/formate.wxs +++ b/pages/formate.wxs @@ -56,8 +56,13 @@ function formateAmount(amount) { return Number(amount).toFixed(2) } +function formateWeight(weight) { + return Number(weight).toFixed(3) +} + module.exports = { formateAmount: formateAmount, + formateWeight: formateWeight, formatTime: formatTime, formateDate: formateDate } \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index eefaeab..bb3e939 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,4 +1,5 @@ // pages/administ/index.js +const event = require('../../utils/event') const app = getApp() Page({ @@ -13,7 +14,8 @@ Page({ { index: 1, value: 'work', badge: 0, name: '工作台', blue: '/assets/image/tabbar/process-blue.png', gray: '/assets/image/tabbar/process-gray.png' }, { index: 2, value: 'home', badge: 0, name: '我的', blue: '/assets/image/tabbar/home-blue.png', gray: '/assets/image/tabbar/home-gray.png' } ], - tabIndex: 1 + tabIndex: 1, + visiable: true }, /************************************** 初始化流程 ********************************************/ onLoad: function (options) { @@ -23,7 +25,8 @@ Page({ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() }) - this.setData({fragment: (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100, safeBottom: app.globalData.safeBottom }) + event.on('TabMessage', this, this.onEvent) + this.setData({fragment: (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight), safeBottom: app.globalData.safeBottom }) }, /************************************** 生命周期函数--监听页面初次渲染完成 ********************************************/ onShow: function () { @@ -38,5 +41,13 @@ Page({ }, stopTouchMove: function(e){ return false + }, + onEvent: function (message) { + if (message.what == 99) { + this.setData({ visiable: message.visiable }) + } + }, + onUnload: function(){ + event.remove('TabMessage', this) } }) \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 14d3689..63c90cd 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -5,7 +5,7 @@ - + diff --git a/pages/process/index/index.js b/pages/process/index/index.js index a6adc1e..a43c65a 100644 --- a/pages/process/index/index.js +++ b/pages/process/index/index.js @@ -1,5 +1,5 @@ // pages/index/index.js -import { getUserInfo } from "../../../api/user" +import { getStatisticsInfo } from "../../../api/saas" const event = require('../../../utils/event') const app = getApp() @@ -19,8 +19,19 @@ Component({ { status: 2, badge: '', name: '过磅审核', icon: '/assets/image/icon_checking.png' }, { status: 3, badge: '', name: '待付款', icon: '/assets/image/icon_payment.png' }, { status: 4, badge: '', name: '已完成', icon: '/assets/image/icon_finish.png' }, - { status: 5, badge: '', name: '已关闭', icon: '/assets/image/icon_close.png' } - ] + // { status: 5, badge: '', name: '已关闭', icon: '/assets/image/icon_close.png' } + ], + show: false, + actions: [ + { name: '选项1' }, + { name: '选项2' }, + { name: '选项3' }, + ], + form: {}, + totalInfo: { + totalMoney: 0, + totalWeight: 0, + } }, lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 @@ -34,14 +45,53 @@ Component({ }, methods: { onRestart: function () { - + this.fetchStatisticsInfo() }, onEvent: function (message) { if (message.what == 888) { } }, - toOrderList: function (e) { - wx.navigateTo({ url: '/pages/process/order-list/index?status=' + e.currentTarget.dataset.status }) - } + orderList: function (e) { + if(e.currentTarget.dataset.status == 3){ + wx.navigateTo({ url: '/pages/process/payment-list/index?status=' + e.currentTarget.dataset.status }) + } else { + wx.navigateTo({ url: '/pages/process/order-list/index?status=' + e.currentTarget.dataset.status }) + } + }, + fetchStatisticsInfo: function(){ + getStatisticsInfo(this.data.form).then(result => { + if(Number(result.data.priceOrderNum) > 0){ + this.data.tabList[0].badge = Number(result.data.priceOrderNum) + } else { + this.data.tabList[0].badge = '' + } + if(Number(result.data.waitAuditOrderNum) > 0){ + this.data.tabList[1].badge = Number(result.data.waitAuditOrderNum) + } else { + this.data.tabList[1].badge = '' + } + if(Number(result.data.waitPayOrderNum) > 0){ + this.data.tabList[2].badge = Number(result.data.waitPayOrderNum) + } else { + this.data.tabList[2].badge = '' + } + this.setData({ tabList: this.data.tabList, totalInfo: result.data }) + }).catch(err => { + console.log(err) + }) + }, + showSheet: function(){ + // this.setData({ show: true }) + // event.emit('TabMessage', { what: 99, visiable: false }) + }, + onClose() { + this.setData({ show: false }) + setTimeout(function(){ + event.emit('TabMessage', { what: 99, visiable: true }) + }, 100) + }, + onSelect({detail}) { + console.log(detail) + }, } }) \ No newline at end of file diff --git a/pages/process/index/index.json b/pages/process/index/index.json index b869717..466d012 100644 --- a/pages/process/index/index.json +++ b/pages/process/index/index.json @@ -6,6 +6,7 @@ "van-cell": "/components/cell/index", "van-cell-group": "/components/cell-group/index", "van-info": "/components/info/index", - "van-icon": "/components/icon/index" + "van-icon": "/components/icon/index", + "van-action-sheet": "/components/action-sheet/index" } } \ No newline at end of file diff --git a/pages/process/index/index.wxml b/pages/process/index/index.wxml index 14569fd..4e30d4c 100644 --- a/pages/process/index/index.wxml +++ b/pages/process/index/index.wxml @@ -1,4 +1,5 @@ + 工作台 @@ -7,7 +8,7 @@ - {{userInfo.factoryName}} + {{userInfo.factoryName || userInfo.enterpriseName}} @@ -15,7 +16,7 @@ 收货统计 - + 今日 @@ -26,15 +27,15 @@ 收货重量 - 0.000吨 + {{formate.formateWeight(totalInfo.totalWeight)}}吨 查看收货详情 - + 收货金额 - 0.00 + {{formate.formateAmount(totalInfo.totalMoney)}} @@ -43,8 +44,8 @@ 收货订单 - - + + @@ -91,4 +92,6 @@ --> - \ No newline at end of file + + + \ No newline at end of file diff --git a/pages/process/order-info/index.js b/pages/process/order-info/index.js index ee20625..917cce7 100644 --- a/pages/process/order-info/index.js +++ b/pages/process/order-info/index.js @@ -33,7 +33,6 @@ Page({ wx.hideLoading() this.setData({ safeBottom: app.globalData.safeBottom }) util.showToast(err) - console.log(err) }) } }, diff --git a/pages/process/order-list/index.js b/pages/process/order-list/index.js index 159845b..c278217 100644 --- a/pages/process/order-list/index.js +++ b/pages/process/order-list/index.js @@ -1,6 +1,6 @@ // pages/process/order-list/index.js import Dialog from '../../../components/dialog/dialog' -import { getFactoryOrderList, cancelOrder, getReceiptList } from "../../../api/saas" +import { getFactoryOrderList, cancelOrder } from "../../../api/saas" const event = require('../../../utils/event') const util = require('../../../utils/util') const app = getApp() @@ -67,21 +67,12 @@ Page({ } else { this.setData({ requesting: true }) } - if(this.data.form.funcType == 3){ - getReceiptList(this.data.form).then(result => { - this.handResult(result) - }).catch(err => { - this.setData({ requesting: false, loading: false }) - util.showToast(err) - }) - } else { - getFactoryOrderList(this.data.form).then(result => { - this.handResult(result) - }).catch(err => { - this.setData({ requesting: false, loading: false }) - util.showToast(err) - }) - } + 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) { diff --git a/pages/process/payment-list/index.js b/pages/process/payment-list/index.js new file mode 100644 index 0000000..b4505d9 --- /dev/null +++ b/pages/process/payment-list/index.js @@ -0,0 +1,114 @@ +// pages/process/order-list/index.js +import { getPeymentList } from "../../../api/saas" +const event = require('../../../utils/event') +const util = require('../../../utils/util') +const app = getApp() + +Page({ + // * 页面的初始数据 + data: { + height: app.globalData.fragmentHeight, + loading: true, + requesting: false, + finished: false, + top: 0, + orderList: [], + form: { + status: 4, + funcType: 4, + pageNum: 1, + pageSize: 10 + }, + lastTime: null + }, + // * 生命周期函数--监听页面加载 + onLoad: function (options) { + event.on('OrderMessage', this, this.onEvent) + this.setData({ height: app.globalData.fragmentHeight }) + this.fetchOrderList() + }, + onEvent: function(message){ + if (message.what == 12) { + this.onRefreshList() + } + }, + onRefreshList: function () { + 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 }) + } + getPeymentList(this.data.form).then(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 }) + } + }).catch(err => { + this.setData({ requesting: false, loading: false }) + util.showToast(err) + }) + }, + lookItem: function (e) { + var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] + wx.navigateTo({ url: '/pages/process/payment/index?mobile=' + item.factoryCustomerMobile }) + }, + onUnload: function(){ + event.remove('OrderMessage', this) + } + +}) \ No newline at end of file diff --git a/pages/process/payment-list/index.json b/pages/process/payment-list/index.json new file mode 100644 index 0000000..8334ca8 --- /dev/null +++ b/pages/process/payment-list/index.json @@ -0,0 +1,11 @@ +{ + "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-cell": "/components/cell/index", + "van-divider": "/components/divider/index", + "van-loading": "/components/loading/index" + } +} \ No newline at end of file diff --git a/pages/process/payment-list/index.wxml b/pages/process/payment-list/index.wxml new file mode 100644 index 0000000..fab4b93 --- /dev/null +++ b/pages/process/payment-list/index.wxml @@ -0,0 +1,41 @@ + + + 待付款订单 + + + + + + + + + {{loading? '正在加载' : '暂无数据'}} + + + + + {{item.tipsTime}} + + + + + 客户名称:{{item.factoryCustomerName}} + ({{item.factoryCustomerMobile}}) + + 毛重:{{item.totalWeight}}KG + + + 待付款 + + + 已完成 + + + + + + + + {{finished?'到底啦~':'加载中...'}} + + \ No newline at end of file diff --git a/pages/process/payment-list/index.wxss b/pages/process/payment-list/index.wxss new file mode 100644 index 0000000..bc19567 --- /dev/null +++ b/pages/process/payment-list/index.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/process/payment/index.js b/pages/process/payment/index.js new file mode 100644 index 0000000..b31ede7 --- /dev/null +++ b/pages/process/payment/index.js @@ -0,0 +1,72 @@ +// pages/process/payment/index.js +import Dialog from '../../../components/dialog/dialog' +import { getPeymentList, repeatOrder } from "../../../api/saas" +const event = require('../../../utils/event') +const util = require('../../../utils/util') +const math = require('../../../utils/math') //导入模块 +const app = getApp() + +Page({ + /** + * 页面的初始数据 + */ + data: { + safeBottom: app.globalData.safeBottom, + form: { + status: 4, + pageNum: 1, + pageSize: 100 + }, + amount: 0, + orderList: null + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + if(options.mobile){ + this.data.form.mobile = options.mobile + } + wx.showLoading({ title: '正在获取', mask: true }) + getPeymentList(this.data.form).then(result => { + wx.hideLoading() + var amount = 0 + if (result.data && result.data.records.length) { + for (let index = 0; index < result.data.records.length; index++) { + amount = math.plus(amount, result.data.records[index].settlePrice) + } + this.setData({ safeBottom: app.globalData.safeBottom, orderList: result.data.records, amount }) + } else { + this.setData({ safeBottom: app.globalData.safeBottom }) + } + }).catch(err => { + wx.hideLoading() + this.setData({ safeBottom: app.globalData.safeBottom }) + util.showToast(err) + }) + }, + lookItem: function(e){ + var item = this.data.orderList[e.currentTarget.dataset.index] + item.checked = !item.checked + var amount = 0 + for (let index = 0; index < this.data.orderList.length; index++) { + if(!this.data.orderList[index].checked){ + amount = math.plus(amount, this.data.orderList[index].settlePrice) + } + } + this.setData({ ['orderList[' + e.currentTarget.dataset.index + '].checked']: item.checked, amount }) + }, + paymentOrder: function(){ + Dialog.confirm({ title: '温馨提示', message: '确定要付款吗?' }).then(() => { + wx.showLoading({ title: '正在获取', mask: true }) + repeatOrder(this.data.form.id).then(result => { + wx.hideLoading() + util.showBackToast('订单已经处理') + event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) + }).catch(err => { + wx.hideLoading() + util.showToast(err) + }) + }) + } +}) \ No newline at end of file diff --git a/pages/process/payment/index.json b/pages/process/payment/index.json new file mode 100644 index 0000000..e8b6f86 --- /dev/null +++ b/pages/process/payment/index.json @@ -0,0 +1,9 @@ +{ + "usingComponents": { + "van-cell": "/components/cell/index", + "van-button": "/components/button/index", + "van-checkbox": "/components/checkbox/index", + "van-image": "/components/image/index", + "van-dialog": "/components/dialog/index" + } +} \ No newline at end of file diff --git a/pages/process/payment/index.wxml b/pages/process/payment/index.wxml new file mode 100644 index 0000000..594c9f9 --- /dev/null +++ b/pages/process/payment/index.wxml @@ -0,0 +1,50 @@ + + + + 收货付款 + + + + 付款金额(元) + {{formate.formateAmount(amount)}} + + + + + + 付款备注 + + + + + + + + + + 订单列表 + (共3笔订单) + + + + + + + + {{item.factoryCustomerName}} {{item.factoryCustomerMobile}} + 2021年2月22日 + + + 废纸品类:{{item.productCategoryName}} + 金额:{{formate.formateAmount(item.settlePrice)}}元 + + + + + + + + 付款 + + + \ No newline at end of file diff --git a/pages/process/payment/index.wxss b/pages/process/payment/index.wxss new file mode 100644 index 0000000..9e1d849 --- /dev/null +++ b/pages/process/payment/index.wxss @@ -0,0 +1,10 @@ +/* pages/process/payment/index.wxss */ +.checkbox{ + padding-top: 6rpx; +} + +.lable{ + padding: 32rpx 32rpx 24rpx 32rpx; + margin-top:18rpx; + border-bottom:1rpx solid #eee +} \ No newline at end of file