diff --git a/pages/api/moment.js b/pages/api/moment.js index f9ccc68..c7e022e 100644 --- a/pages/api/moment.js +++ b/pages/api/moment.js @@ -34,7 +34,9 @@ const likeMoment = (params) => mPost(`/information-center/article-reply/like-or- const likeComment = (params) => mPost(`/information-center/article-reply/like-or-cancel/reply`, params, mconfig) // /article-reply/reply 评论 const commentMoment = (params) => mPost(`/information-center/article-reply/reply`, params, mconfig) -const getCategoryPrice = (params) => mGet(`/information-center/getPaperCategoryPrice`, params, mconfig) +const getCategoryPrice = (params) => mGet(`/information-center/getPaperCategoryPrice/new`, params, mconfig) +const getCategoryList = (params) => mGet(`/information-center/paper-index-category`, params, mconfig) + export { mconfig, @@ -50,5 +52,6 @@ export { likeMoment, likeComment, commentMoment, - getCategoryPrice + getCategoryPrice, + getCategoryList } \ No newline at end of file diff --git a/pages/api/ztb.js b/pages/api/ztb.js index 73be963..d777c25 100644 --- a/pages/api/ztb.js +++ b/pages/api/ztb.js @@ -136,6 +136,7 @@ const getPaperMillOfInformationList = (params) => mGet(`/recycle-service/get/pap const feedbackMillInformation = (params) => mPost(`/recycle-service/feedback/mill-information`, params, zconfig) + export { zconfig, loginToken, diff --git a/pages/mall/price-index/index.js b/pages/mall/price-index/index.js index d84be2d..f1bec4e 100644 --- a/pages/mall/price-index/index.js +++ b/pages/mall/price-index/index.js @@ -122,7 +122,8 @@ Page({ if(index == 0){ element.list.forEach(item => { categoriesList.push(item.data.substring(5)) - var price = math.times(item.unitPrice, 1000) + // var price = math.times(item.unitPrice, 1000) + var price = item.unitPrice if(min > price){ min = price } @@ -133,7 +134,7 @@ Page({ }) } else { element.list.forEach(item => { - var price = math.times(item.unitPrice, 1000) + var price = item.unitPrice if(min > price){ min = price } @@ -141,7 +142,7 @@ Page({ }) } var series = { - name: element.list[0].name, + name: element.name, data: dataList, format: function (val, name) { return val + '元/吨' diff --git a/pages/moment/paper/index.js b/pages/moment/paper/index.js new file mode 100644 index 0000000..cbcc76b --- /dev/null +++ b/pages/moment/paper/index.js @@ -0,0 +1,95 @@ +// pages/moment/paper/index.js +import { getCategoryList } from "../../api/moment" +const util = require('../../../utils/util') +const storage = require('../../../utils/storage') +const event = require('../../../utils/event.js') +const app = getApp() + +Page({ + /** + * 页面的初始数据 + */ + data: { + categoryList: [], + cateIds: null, + cateIdList: null + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + wx.showLoading({ + title: '加载中', + mask: true + }) + this.data.cateIds = storage.get('cateIdList' + app.globalData.userInfo.userId) + if(!util.isEmpty(this.data.cateIds)){ + this.data.cateIdList = this.data.cateIds.toString().split(',') + } + getCategoryList().then(result => { + //成功回调 + if(!util.isEmpty(this.data.cateIds)){ + for (let index = 0; index < result.data.records.length; index++) { + if(this.checkCategory(result.data.records[index].id)){ + result.data.records[index].checked = true + } + } + } + this.setData({categoryList: result.data.records}) + wx.hideLoading() + }).catch(err => { + //异常回调 + wx.hideLoading() + }) + }, + checkCategory: function(id){ + if(!this.data.cateIdList || !this.data.cateIdList.length){ + return false + } + for (let index = 0; index < this.data.cateIdList.length; index++) { + if(id == this.data.cateIdList[index]){ + return true + } + } + return false + }, + checkPaper: function(e) { + var index = e.target.dataset.index + var item = this.data.categoryList[index] + if(item.checked){ + this.setData({ ['categoryList[' + index + '].checked']: !item.checked}) + return + } + var sum = 0 + for (let i = 0; i < this.data.categoryList.length; i++) { + if(this.data.categoryList[i].checked){ + sum++ + } + } + if(sum >= 5){ + util.showToast('最多只能关注5个纸品') + return + } + this.setData({ ['categoryList[' + index + '].checked']: !item.checked}) + }, + onUnload: function(){ + var cateString = '' + for (let i = 0; i < this.data.categoryList.length; i++) { + if(this.data.categoryList[i].checked){ + if(util.isEmpty(cateString)){ + cateString = this.data.categoryList[i].id + } else { + cateString += ',' + this.data.categoryList[i].id + } + } + } + if(util.isEmpty(cateString) && util.isEmpty(this.data.cateIds)){ + return + } + if(cateString != this.data.cateIds){ + storage.put('cateIdList' + app.globalData.userInfo.userId, cateString) + event.emit('EventMessage', { what: 502, desc: 'CateChange' }) + } + } + +}) \ No newline at end of file diff --git a/pages/moment/paper/index.json b/pages/moment/paper/index.json new file mode 100644 index 0000000..1c10f0f --- /dev/null +++ b/pages/moment/paper/index.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "wux-cell-group": "/components/cell-group/index", + "wux-cell": "/components/cell/index" + } +} \ No newline at end of file diff --git a/pages/moment/paper/index.wxml b/pages/moment/paper/index.wxml new file mode 100644 index 0000000..72f704c --- /dev/null +++ b/pages/moment/paper/index.wxml @@ -0,0 +1,10 @@ + + + 纸品列表 + + + + + + + \ No newline at end of file diff --git a/pages/moment/paper/index.wxss b/pages/moment/paper/index.wxss new file mode 100644 index 0000000..c98d427 --- /dev/null +++ b/pages/moment/paper/index.wxss @@ -0,0 +1 @@ +/* pages/moment/paper/index.wxss */ \ No newline at end of file