order.js 4.5 KB

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