index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. const utils = require('../../utils/util')
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. isPickerRender: false,
  9. isPickerShow: false,
  10. pickerConfig: {
  11. endDate: true,
  12. dateLimit: true,
  13. initStartTime: "2020-01-01",
  14. initEndTime: "2020-12-01",
  15. limitStartTime: "2015-01-01",
  16. limitEndTime: "2095-01-01",
  17. },
  18. searchParams: {
  19. startTime: "2019-01-01 ",
  20. endTime: "2019-12-01",
  21. pageNo: 1,
  22. pageSize: 10,
  23. createTime_begin:"",
  24. createTime_end:"",
  25. tradingStatus:1,
  26. storeName:""
  27. },
  28. dataStr: '',
  29. totalAmount:0,
  30. loadding: false,
  31. pullUpOn: true,
  32. list:[],
  33. values: {
  34. storeId: '',
  35. storeName: '',
  36. },
  37. storeList: [],
  38. },
  39. /**
  40. * 页面相关事件处理函数--监听用户下拉动作
  41. */
  42. onPullDownRefresh: function () {
  43. this.setData({
  44. ["searchParams.pageNo"]: 1,
  45. pullUpOn: true,
  46. loadding: false,
  47. list: []
  48. })
  49. this.btnsearch()
  50. setTimeout(() => {
  51. wx.stopPullDownRefresh()
  52. }, 300);
  53. },
  54. /**
  55. * 页面上拉触底事件的处理函数
  56. */
  57. onReachBottom: function () {
  58. //只是测试效果,逻辑以实际数据为准
  59. let that = this;
  60. this.setData({
  61. loadding: true,
  62. pullUpOn: true
  63. })
  64. this.setData({
  65. ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1
  66. })
  67. this.btnsearch()
  68. },
  69. /**
  70. * 生命周期函数--监听页面加载
  71. */
  72. onLoad: function (options) {
  73. this.bindStoreList()
  74. this.btnsearch();
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage: function () {
  100. },
  101. bindStorePickerChange: function (e) {
  102. var item = this.data.storeList[e.detail.value]
  103. this.setData({
  104. ['values.storeId']: item.id,
  105. ['values.storeName']: item.storeName,
  106. ['searchParams.storeId']: item.id,
  107. list:[]
  108. })
  109. this.btnsearch();
  110. },
  111. bindStoreList() {
  112. var that = this
  113. utils.request(utils.api.storeList, {}, "GET", false, true,app.globalData.token).then((res) => {
  114. if (res.code == 200) {
  115. that.setData({
  116. storeList: res.result
  117. })
  118. }
  119. }).catch((res) => {})
  120. },
  121. timePickerShow: function () {
  122. this.setData({
  123. isPickerShow: true,
  124. isPickerRender: true,
  125. chartHide: true
  126. });
  127. },
  128. pickerHide: function () {
  129. this.setData({
  130. isPickerShow: false,
  131. chartHide: false
  132. });
  133. },
  134. setPickerTime: function (val) {
  135. console.log(111111)
  136. console.log(this.data.searchParams.storeName)
  137. let data = val.detail;
  138. let startTime = utils.formatDate(data.startTime,'yyyy-MM-dd')
  139. let endTime = utils.formatDate(data.endTime,'yyyy-MM-dd')
  140. this.setData({
  141. ["searchParams.startTime"]: data.startTime,
  142. ["searchParams.endTime"]: data.endTime,
  143. dataStr: startTime +" ~ "+ endTime,
  144. ["searchParams.createTime_begin"]: data.startTime,
  145. ["searchParams.createTime_end"]: data.endTime,
  146. ["searchParams.storeName"]: this.data.searchParams.storeName,
  147. list:[]
  148. });
  149. this.btnsearch();
  150. },
  151. btnsearch() {
  152. var that = this
  153. utils.request(utils.api.mgVmBillList, that.data.searchParams, "GET", true, false, app.globalData.token).then((res) => {
  154. if (res.code == 200) {
  155. console.log(res)
  156. if (res.result.records.length > 0) {
  157. if (that.data.list.length > 0) {
  158. let list = that.data.list
  159. res.result.records.forEach((e)=>{
  160. list.push(e)
  161. })
  162. that.setData({
  163. list: list
  164. })
  165. }else{
  166. that.setData({
  167. list: res.result.records
  168. })
  169. }
  170. } else {
  171. that.setData({
  172. loadding: false,
  173. pullUpOn: false,
  174. ["searchParams.pageNo"]:that.data.searchParams.pageNo-1
  175. })
  176. }
  177. var allList = that.data.list;
  178. var allNumber = 0;
  179. for (let i = 0; i < allList.length; i++) {
  180. allNumber+=allList[i].number==null?0:allList[i].number;
  181. }
  182. that.setData({
  183. totalAmount: allNumber,
  184. })
  185. }
  186. }).catch((res) => {})
  187. },
  188. inputeditStoreName: function (e) {
  189. let _this = this;
  190. let value = e.detail.value;
  191. _this.setData({
  192. ["searchParams.storeName"]: value
  193. });
  194. },
  195. })