import { ApiModel } from '../../../../utils/api'; const _Http = new ApiModel(); const handleList = require("../../../../utils/processingData"); Page({ /** * 页面的初始数据 */ data: { statistics: [], //统计 productList: [], //列表 line: 0, //显示列表下标 active: 0, //tabs下标 statisticsData: {}, //统计数据 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { /* 获取数据统计总数 */ _Http.basic({ "accesstoken": wx.getStorageSync('userData').token, "classname": "customer.supplyanddemand.supplyanddemand", "method": "getsupplyanddemandtimes", "content": { "tenterprise_userid": wx.getStorageSync('userData').userid } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.data }) this.setData({ statistics: [{ title: '分享总数', number: res.data.fsharetimes }, { title: '电话总数', number: res.data.fphonetimes }, { title: '浏览总数', number: res.data.freadtimes }] }) }); /* 获取我的供需 */ _Http.basic({ "accesstoken": wx.getStorageSync('userData').token, "classname": "customer.supplyanddemand.supplyanddemand", "method": "query_mysupplyanddemandList", "content": { "getdatafromdbanyway": true, "pageNumber": 1, "pageSize": 20, "where": { "condition": '', "ftype": "", "fissupply": "0" } } }).then(res => { console.log(res) if (res.msg != "成功") return wx.showToast({ title: res.data, }) const data = handleList.getYTD(res.data); this.setData({ productList: data }) this.getsupplyanddemandLogTop10(0) }) }, toDetalis(e) { const { item } = e.currentTarget.dataset; wx.navigateTo({ url: './detalis?item=' + JSON.stringify(item) }) }, /* 列表下标改变 */ changeIndex(e) { const { line } = e.currentTarget.dataset, { index } = e.target.dataset; this.setData({ line, active: index - 0 }) this.getsupplyanddemandLogTop10(line) }, /* 获取十条数据 */ getsupplyanddemandLogTop10(index) { _Http.basic({ "accesstoken": wx.getStorageSync('userData').token, "classname": "customer.supplyanddemand.supplyanddemand", "method": "getsupplyanddemandLogTop10", "content": { "tsupplyanddemandid": this.data.productList[index].tsupplyanddemandid } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) for (let i in res.data) { let data = res.data[i]; if (data.length > 0) { for (let index = 0; index < data.length; index++) { data[index].createdate = data[index].createdate.slice(5, 16) } res.data[i] = data }; } this.setData({ statisticsData: res.data }) }) }, /* tabs改变 */ tabsOnChange(e) { this.setData({ active: e.detail.index }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })