Browse Source

no message

feature/v1.2
xpz2018 5 years ago
parent
commit
00c6f473fc
10 changed files with 159 additions and 30 deletions
  1. 2
      api/saas.js
  2. 21
      components/notify/index.wxml
  3. 2
      pages/index/index.js
  4. 3
      pages/index/index.json
  5. 5
      pages/index/index.wxml
  6. 102
      pages/setting/paper-detial/index.js
  7. 9
      pages/setting/paper-detial/index.json
  8. 20
      pages/setting/paper-detial/index.wxml
  9. 19
      pages/setting/paper/index.js
  10. 6
      pages/setting/paper/index.wxml

2
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,

21
components/notify/index.wxml

@ -1,18 +1,7 @@
<van-transition
name="slide-down"
show="{{ show }}"
custom-class="van-notify__container"
custom-style="z-index: {{ zIndex }};"
bind:tap="onTap"
>
<view
class="van-notify van-notify--{{ type }}"
style="background:{{ background }};color:{{ color }};"
>
<view
wx:if="{{ safeAreaInsetTop }}"
style="height: {{ statusBarHeight }}px"
></view>
<van-transition name="slide-down" show="{{ show }}" custom-class="van-notify__container"
custom-style="z-index: {{ zIndex }};" bind:tap="onTap">
<view class="van-notify van-notify--{{ type }}" style="background:{{ background }};color:{{ color }};">
<view wx:if="{{ safeAreaInsetTop }}" style="height: {{ statusBarHeight }}px"></view>
<text>{{ message }}</text>
</view>
</van-transition>
</van-transition>

2
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

3
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"
}
}

5
pages/index/index.wxml

@ -15,4 +15,7 @@
</van-tabbar>
</view>
<van-dialog id="van-dialog" />
<van-dialog id="van-dialog" />
<van-notify id="van-notify">
<view>asdhjhjk</view>
</van-notify>

102
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)
})
}
}
})

9
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"
}
}

20
pages/setting/paper-detial/index.wxml

@ -2,3 +2,23 @@
<cu-custom bgColor="bg-white" isBack="{{true}}">
<view slot="content" style="color:black;font-size:18px">纸品详情</view>
</cu-custom>
<van-notice-bar color="#1989fa" background="#008AFF" left-icon="info-o" text="点击可以修改纸品信息" />
<van-field title-width="360rpx" required value="{{form.categoryName }}" readonly label="品类名称:" is-link
bindtap="chooseMethod" />
<van-field title-width="360rpx" id="productName" value="{{ form.productName || form.categoryName }}" label="品类别名:"
placeholder="请输入品类别名" bind:input="bindInput" />
<van-field title-width="360rpx" required id="defaultUnitPrice" value="{{ form.defaultUnitPrice }}" label="收货价格(元/公斤):"
placeholder="请输入收货价格" type="digit" bind:input="bindInput" />
<van-field title-width="360rpx" id="highestUnitPrice" value="{{ form.highestUnitPrice }}" label="最高收货价格(元/公斤):"
placeholder="请输入最高收货价格" type="digit" bind:input="bindInput" />
<view style="margin-top:48rpx;padding:48rpx 32rpx">
<van-button block type="danger" bind:click="deleteForm">删除</van-button>
<view style="height:36rpx"></view>
<van-button block type="info" bind:click="submitForm">保存</van-button>
</view>
<van-popup position="bottom" show="{{ visible }}" bind:close="onHide" z-index="29">
<van-picker show-toolbar title="选择纸品" columns="{{ columns }}" bind:cancel="onHide" bind:confirm="onConfirm" />
</van-popup>
<van-dialog id="van-dialog" />

19
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` })

6
pages/setting/paper/index.wxml

@ -3,7 +3,7 @@
<view slot="content" style="color:black;font-size:18px">纸品管理</view>
</cu-custom>
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" bind:scrolltolower="fetchOrderList">
<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" />
@ -14,8 +14,8 @@
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<van-cell center clickable is-link wx:for="{{pageItem}}" wx:key="index">
<view slot="title" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem">
<view class="text-sg text-bold">{{item.productName || ''}}</view>
<view class="text-sm text-gray" style="line-height: 24rpx">单价范围(元/公斤):{{item.defaultUnitPrice}} - {{item.highestUnitPrice}}</view>
<view class="text-sg text-bold">{{item.productName || item.categoryName}}</view>
<view class="text-sm text-gray" style="line-height: 28rpx">单价范围(元/公斤):{{item.defaultUnitPrice}} - {{item.highestUnitPrice}}</view>
</view>
</van-cell>
</view>

Loading…
Cancel
Save