index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import {
  2. ApiModel
  3. } from '../../../../utils/api';
  4. const _Http = new ApiModel();
  5. const handleList = require("../../../../utils/processingData");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. statistics: [], //统计
  12. productList: [], //列表
  13. line: 0, //显示列表下标
  14. active: 0, //tabs下标
  15. statisticsData: {}, //统计数据
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. /* 获取数据统计总数 */
  22. _Http.basic({
  23. "accesstoken": wx.getStorageSync('userData').token,
  24. "classname": "customer.supplyanddemand.supplyanddemand",
  25. "method": "getsupplyanddemandtimes",
  26. "content": {
  27. "tenterprise_userid": wx.getStorageSync('userData').userid
  28. }
  29. }).then(res => {
  30. if (res.msg != '成功') return wx.showToast({
  31. title: res.data
  32. })
  33. this.setData({
  34. statistics: [{
  35. title: '分享总数',
  36. number: res.data.fsharetimes
  37. }, {
  38. title: '电话总数',
  39. number: res.data.fphonetimes
  40. }, {
  41. title: '浏览总数',
  42. number: res.data.freadtimes
  43. }]
  44. })
  45. });
  46. /* 获取我的供需 */
  47. _Http.basic({
  48. "accesstoken": wx.getStorageSync('userData').token,
  49. "classname": "customer.supplyanddemand.supplyanddemand",
  50. "method": "query_mysupplyanddemandList",
  51. "content": {
  52. "getdatafromdbanyway": true,
  53. "pageNumber": 1,
  54. "pageSize": 20,
  55. "where": {
  56. "condition": '',
  57. "ftype": "",
  58. "fissupply": "0"
  59. }
  60. }
  61. }).then(res => {
  62. console.log(res)
  63. if (res.msg != "成功") return wx.showToast({
  64. title: res.data,
  65. })
  66. const data = handleList.getYTD(res.data);
  67. this.setData({
  68. productList: data
  69. })
  70. this.getsupplyanddemandLogTop10(0)
  71. })
  72. },
  73. toDetalis(e) {
  74. const {
  75. item
  76. } = e.currentTarget.dataset;
  77. wx.navigateTo({
  78. url: './detalis?item=' + JSON.stringify(item)
  79. })
  80. },
  81. /* 列表下标改变 */
  82. changeIndex(e) {
  83. const {
  84. line
  85. } = e.currentTarget.dataset, {
  86. index
  87. } = e.target.dataset;
  88. this.setData({
  89. line,
  90. active: index - 0
  91. })
  92. this.getsupplyanddemandLogTop10(line)
  93. },
  94. /* 获取十条数据 */
  95. getsupplyanddemandLogTop10(index) {
  96. _Http.basic({
  97. "accesstoken": wx.getStorageSync('userData').token,
  98. "classname": "customer.supplyanddemand.supplyanddemand",
  99. "method": "getsupplyanddemandLogTop10",
  100. "content": {
  101. "tsupplyanddemandid": this.data.productList[index].tsupplyanddemandid
  102. }
  103. }).then(res => {
  104. if (res.msg != '成功') return wx.showToast({
  105. title: res.data,
  106. icon: "none"
  107. })
  108. for (let i in res.data) {
  109. let data = res.data[i];
  110. if (data.length > 0) {
  111. for (let index = 0; index < data.length; index++) {
  112. data[index].createdate = data[index].createdate.slice(5, 16)
  113. }
  114. res.data[i] = data
  115. };
  116. }
  117. this.setData({
  118. statisticsData: res.data
  119. })
  120. })
  121. },
  122. /* tabs改变 */
  123. tabsOnChange(e) {
  124. this.setData({
  125. active: e.detail.index
  126. })
  127. },
  128. /**
  129. * 生命周期函数--监听页面初次渲染完成
  130. */
  131. onReady() {
  132. },
  133. /**
  134. * 生命周期函数--监听页面显示
  135. */
  136. onShow() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面隐藏
  140. */
  141. onHide() {
  142. },
  143. /**
  144. * 生命周期函数--监听页面卸载
  145. */
  146. onUnload() {
  147. },
  148. /**
  149. * 页面相关事件处理函数--监听用户下拉动作
  150. */
  151. onPullDownRefresh() {
  152. },
  153. /**
  154. * 页面上拉触底事件的处理函数
  155. */
  156. onReachBottom() {
  157. },
  158. /**
  159. * 用户点击右上角分享
  160. */
  161. onShareAppMessage() {
  162. }
  163. })