From 00c6f473fcbc49597c23d8e23a95639e0f22177e Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Mon, 12 Apr 2021 10:31:37 +0800 Subject: [PATCH] no message --- api/saas.js | 2 + components/notify/index.wxml | 21 ++---- pages/index/index.js | 2 + pages/index/index.json | 3 +- pages/index/index.wxml | 5 +- pages/setting/paper-detial/index.js | 102 +++++++++++++++++++++++++- pages/setting/paper-detial/index.json | 9 ++- pages/setting/paper-detial/index.wxml | 20 +++++ pages/setting/paper/index.js | 19 +++-- pages/setting/paper/index.wxml | 6 +- 10 files changed, 159 insertions(+), 30 deletions(-) diff --git a/api/saas.js b/api/saas.js index a7c64f6..663f911 100644 --- a/api/saas.js +++ b/api/saas.js @@ -29,6 +29,7 @@ const createOrder = (params) => mPost(`/ztb-factory/factory-customer/save/order` const getFactoryOrderList = (params) => mGet(`/ztb-factory/factory/wechat-applet/get/order-list`, params, sconfig) const getFactoryOrderInfo = (id) => mGet(`/ztb-factory/factory/wechat-applet/get/order-detail/${id}`, null, sconfig) const getPaperList = (params) => mGet(`/ztb-factory/factory/get/all-product`, params, sconfig) +const getCategoryList = () => mGet(`/recycle-service/get/product-category-list`, null, sconfig) const getPaperPrice = (params) => mGet(`/ztb-factory/factory/get/product-price-list`, params, sconfig) const getPaperInfo = (id) => mGet(`/ztb-factory/factory/get/product-price/${id}`, null, sconfig) const savePaperPrice = (params) => mPost(`/ztb-factory/factory/save/product-price`, params, sconfig) @@ -61,6 +62,7 @@ export { paymentOrder, cancelOrder, getPaperPrice, + getCategoryList, getPaperInfo, savePaperPrice, editPaperPrice, diff --git a/components/notify/index.wxml b/components/notify/index.wxml index 5ef0d8c..58232ef 100644 --- a/components/notify/index.wxml +++ b/components/notify/index.wxml @@ -1,18 +1,7 @@ - - - + + + {{ message }} - + \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index bb3e939..b4cc0a6 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,4 +1,5 @@ // pages/administ/index.js +import Notify from '../../components/notify/notify' const event = require('../../utils/event') const app = getApp() @@ -38,6 +39,7 @@ Page({ onChange: function ({detail}) { this.setData({ tabIndex: detail }) this.onShow() + Notify({ type: 'primary', safeAreaInsetTop: true, message: '通知内容', }); }, stopTouchMove: function(e){ return false diff --git a/pages/index/index.json b/pages/index/index.json index 24945e7..5964b84 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -6,6 +6,7 @@ "message": "/pages/message/index/index", "workbench": "/pages/process/index/index", "home": "/pages/home/index/index", - "van-dialog": "/components/dialog/index" + "van-dialog": "/components/dialog/index", + "van-notify": "/components/notify/index" } } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 63c90cd..c77c4fe 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -15,4 +15,7 @@ - \ No newline at end of file + + + asdhjhjk + \ No newline at end of file diff --git a/pages/setting/paper-detial/index.js b/pages/setting/paper-detial/index.js index facad49..636db64 100644 --- a/pages/setting/paper-detial/index.js +++ b/pages/setting/paper-detial/index.js @@ -1,5 +1,6 @@ // pages/setting/paper-detial/index.js -import { getPaperInfo, savePaperPrice, editPaperPrice, delePaperPrice } from "../../../api/saas" +import Dialog from '../../../components/dialog/dialog' +import { getPaperInfo, getCategoryList, savePaperPrice, editPaperPrice, delePaperPrice } from "../../../api/saas" const event = require('../../../utils/event') const util = require('../../../utils/util') @@ -8,13 +9,108 @@ Page({ * 页面的初始数据 */ data: { - + paperList: null, + form: {}, + columns: [], + visible: false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + if(options.id){ + wx.showLoading({ title: '正在获取', mask: true }) + getCategoryList().then(result => { + this.data.paperList = result.data + this.data.columns = [] + for (let index = 0; index < this.data.paperList.length; index++) { + this.data.columns.push(this.data.paperList[index].categoryName) + } + this.setData({ columns: this.data.columns }) + }).catch(err => { + util.showToast(err) + }) + getPaperInfo(options.id).then(result => { + wx.hideLoading() + this.setData({ form: result.data }) + }).catch(err => { + wx.hideLoading() + util.showToast(err) + }) + } else { + wx.showLoading({ title: '正在获取', mask: true }) + getCategoryList().then(result => { + this.data.paperList = result.data + this.data.columns = [] + for (let index = 0; index < this.data.paperList.length; index++) { + this.data.columns.push(this.data.paperList[index].categoryName) + } + this.setData({ columns: this.data.columns }) + wx.hideLoading() + }).catch(err => { + wx.hideLoading() + util.showToast(err) + }) + } + }, + chooseMethod: function(e){ + this.setData({ visible: true }) + }, + onConfirm: function({detail}){ + var nowItem = this.data.paperList[detail.index] + this.data.form.categoryId = nowItem.categoryId + this.data.form.categoryName = nowItem.categoryName + this.setData({ visible: false, ['form.productName']: detail.value, ['form.categoryName']: detail.value }) + }, + onHide: function(){ + this.setData({ visible: false }) + }, + bindInput: function(e){ + this.data.form[e.currentTarget.id] = e.detail + }, + deleteForm: function(e){ + Dialog.confirm({ title: '温馨提示', message: '确定删除该纸品?' }).then(() => { + wx.showLoading({ title: '正在处理', mask: true }) + delePaperPrice(this.data.form.id).then(result => { + wx.hideLoading() + util.showBackToast('删除成功!') + event.emit('OrderMessage', { what: 201 }) + }).catch(err => { + wx.hideLoading() + util.showToast(err) + }) + }).catch(err => { + }) + }, + submitForm: function(e){ + if(util.isEmpty(this.data.form.categoryId)){ + util.showToast('请选择一个纸品名称') + return + } + if(util.isEmpty(this.data.form.defaultUnitPrice) || Number(this.data.form.defaultUnitPrice) <= 0){ + util.showToast('请输入纸品价格') + return + } + wx.showLoading({ title: '正在处理', mask: true }) + if(util.isEmpty(this.data.form.id)){ + savePaperPrice(this.data.form).then(result => { + wx.hideLoading() + util.showBackToast('添加成功!') + event.emit('OrderMessage', { what: 201 }) + }).catch(err => { + wx.hideLoading() + util.showToast(err) + }) + } else { + editPaperPrice(this.data.form).then(result => { + wx.hideLoading() + util.showBackToast('修改成功!') + event.emit('OrderMessage', { what: 202, detail: this.data.form }) + }).catch(err => { + wx.hideLoading() + util.showToast(err) + }) + } } }) \ No newline at end of file diff --git a/pages/setting/paper-detial/index.json b/pages/setting/paper-detial/index.json index 8835af0..896bc90 100644 --- a/pages/setting/paper-detial/index.json +++ b/pages/setting/paper-detial/index.json @@ -1,3 +1,10 @@ { - "usingComponents": {} + "usingComponents": { + "van-button": "/components/button/index", + "van-field": "/components/field/index", + "van-dialog": "/components/dialog/index", + "van-popup": "/components/popup/index", + "van-picker": "/components/picker/index", + "van-notice-bar": "/components/notice-bar/index" + } } \ No newline at end of file diff --git a/pages/setting/paper-detial/index.wxml b/pages/setting/paper-detial/index.wxml index fc28db8..66e1b54 100644 --- a/pages/setting/paper-detial/index.wxml +++ b/pages/setting/paper-detial/index.wxml @@ -2,3 +2,23 @@ 纸品详情 + + + + + + + + 删除 + + 保存 + + + + + + \ No newline at end of file diff --git a/pages/setting/paper/index.js b/pages/setting/paper/index.js index b9d6c93..4422659 100644 --- a/pages/setting/paper/index.js +++ b/pages/setting/paper/index.js @@ -16,7 +16,9 @@ Page({ form: { pageNum: 1, pageSize: 10 - } + }, + page: -1, + index: -1 }, // * 生命周期函数--监听页面加载 onLoad: function (options) { @@ -25,8 +27,10 @@ Page({ this.fetchOrderList() }, onEvent: function(message){ - if (message.what == 12) { + if (message.what == 201) { this.onRefreshList() + } else if (message.what == 202) { + this.setData({ [`orderList[${this.data.page}][${this.data.index}]`]: message.detail }) } }, onRefreshList: function () { @@ -34,7 +38,6 @@ Page({ return } this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) - this.data.lastTime = null this.fetchOrderList() }, //1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成 @@ -53,7 +56,11 @@ Page({ 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 - this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) + if(this.data.form.pageNum == 1){ + this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, top: 0, 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 }) } @@ -64,7 +71,9 @@ Page({ }, lookItem: function (e) { if(e.currentTarget.dataset.page >= 0){ - var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] + this.data.page = e.currentTarget.dataset.page + this.data.index = e.currentTarget.dataset.index + var item = this.data.orderList[this.data.page][ this.data.index] wx.navigateTo({ url: `/pages/setting/paper-detial/index?id=${item.id}` }) } else { wx.navigateTo({ url: `/pages/setting/paper-detial/index` }) diff --git a/pages/setting/paper/index.wxml b/pages/setting/paper/index.wxml index 44890d6..7bf951d 100644 --- a/pages/setting/paper/index.wxml +++ b/pages/setting/paper/index.wxml @@ -3,7 +3,7 @@ 纸品管理 - + @@ -14,8 +14,8 @@ - {{item.productName || ''}} - 单价范围(元/公斤):{{item.defaultUnitPrice}} - {{item.highestUnitPrice}} + {{item.productName || item.categoryName}} + 单价范围(元/公斤):{{item.defaultUnitPrice}} - {{item.highestUnitPrice}}