order.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. dataStr: '',
  124. })
  125. },
  126. bindStoreList() {
  127. var that = this
  128. util.request(util.api.storeList, {}, "GET", false, true, app.globalData.token).then((res) => {
  129. if (res.code == 200) {
  130. that.setData({
  131. storeList: res.result
  132. })
  133. }
  134. }).catch((res) => {})
  135. },
  136. submitSearch(){
  137. this.setData({
  138. selectH: 0,
  139. ["searchParams.pageNo"]: 1,
  140. pullUpOn: true,
  141. loadding: false,
  142. orderList: []
  143. })
  144. this.bindProductOrderList()
  145. },
  146. bindProductOrderList(){
  147. var that = this
  148. util.request(util.api.productOrderListPage, that.data.searchParams, "GET", false, false, app.globalData.token).then((res) => {
  149. if (res.code == 200) {
  150. if (res.result.records.length > 0) {
  151. if (that.data.orderList.length > 0) {
  152. let list = that.data.orderList
  153. res.result.records.forEach((e)=>{
  154. list.push(e)
  155. })
  156. that.setData({
  157. orderList: list
  158. })
  159. }else{
  160. that.setData({
  161. orderList: res.result.records
  162. })
  163. }
  164. } else {
  165. that.setData({
  166. loadding: false,
  167. pullUpOn: false
  168. })
  169. }
  170. }
  171. }).catch((res) => {})
  172. },
  173. searchProductOrder(){
  174. if(this.data.searchParams.storeId === undefined){
  175. this.data.searchParams.storeId = ''
  176. }
  177. if(this.data.searchParams.storeName === undefined){
  178. this.data.searchParams.storeName = ''
  179. }
  180. this.bindProductOrderList()
  181. },
  182. inputedit: function (e) {
  183. let _this = this;
  184. let dataset = e.currentTarget.dataset;
  185. let value = e.detail.value;
  186. let name = dataset.name;
  187. _this.data[name] = value;
  188. _this.setData({
  189. [name]: _this.data[name]
  190. });
  191. },
  192. })