index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. var et = endTime.split(" ");
  141. var entt = et[0]+" 23:59:59"
  142. this.setData({
  143. ["searchParams.startTime"]: data.startTime,
  144. ["searchParams.endTime"]: entt,
  145. dataStr: startTime +" ~ "+ endTime,
  146. ["searchParams.createTime_begin"]: data.startTime,
  147. ["searchParams.createTime_end"]: entt,
  148. ["searchParams.storeName"]: this.data.searchParams.storeName,
  149. list:[]
  150. });
  151. this.btnsearch();
  152. },
  153. btnsearch() {
  154. var that = this
  155. utils.request(utils.api.mgVmBillList, that.data.searchParams, "GET", true, false, app.globalData.token).then((res) => {
  156. if (res.code == 200) {
  157. console.log(res)
  158. that.setData({
  159. totalAmount: res.result.allMoney,
  160. })
  161. if (res.result.list.records.length > 0) {
  162. if (that.data.searchParams.pageNo > 1) {
  163. let list = that.data.list
  164. res.result.list.records.forEach((e)=>{
  165. list.push(e)
  166. })
  167. that.setData({
  168. list: list
  169. })
  170. }else{
  171. that.setData({
  172. list: res.result.list.records
  173. })
  174. }
  175. } else {
  176. that.setData({
  177. loadding: false,
  178. pullUpOn: false,
  179. ["searchParams.pageNo"]:that.data.searchParams.pageNo-1
  180. })
  181. }
  182. }
  183. }).catch((res) => {})
  184. },
  185. inputeditStoreName: function (e) {
  186. let _this = this;
  187. let value = e.detail.value;
  188. _this.setData({
  189. ["searchParams.storeName"]: value
  190. });
  191. },
  192. })