index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. const utils = require('../../utils/util')
  2. const util = require('../../utils/util.js');
  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: "2019-01-01",
  21. // endTime: "2019-12-01",
  22. startTime: '',
  23. endTime: '',
  24. storeId:'',
  25. storeName:'',
  26. orderSn:'',
  27. },
  28. orderList:{
  29. status:'',
  30. },
  31. dataStr: '',
  32. storeList:{
  33. id:'',
  34. storeName:''
  35. },
  36. selectH: 0
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad: function (options) {
  42. // this.bindOrderList();
  43. this.bindStoreList();
  44. this.submitSearch();
  45. },
  46. /**
  47. * 生命周期函数--监听页面初次渲染完成
  48. */
  49. onReady: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面显示
  53. */
  54. onShow: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面隐藏
  58. */
  59. onHide: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面卸载
  63. */
  64. onUnload: function () {
  65. },
  66. /**
  67. * 页面相关事件处理函数--监听用户下拉动作
  68. */
  69. onPullDownRefresh: function () {
  70. this.setData({
  71. ["searchParams.pageNo"]: 1,
  72. pullUpOn: true,
  73. loadding: false,
  74. orderList: []
  75. })
  76. this.bindOrderList()
  77. setTimeout(() => {
  78. wx.stopPullDownRefresh()
  79. }, 300);
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. var that = this
  86. //只是测试效果,逻辑以实际数据为准
  87. this.setData({
  88. loadding: true,
  89. pullUpOn: true
  90. })
  91. this.setData({
  92. ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1
  93. })
  94. this.bindOrderList()
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage: function () {
  100. },
  101. timePickerShow: function () {
  102. this.setData({
  103. isPickerShow: true,
  104. isPickerRender: true,
  105. chartHide: true
  106. });
  107. },
  108. pickerHide: function () {
  109. this.setData({
  110. isPickerShow: false,
  111. chartHide: false
  112. });
  113. },
  114. setPickerTime: function (val) {
  115. console.log(val);
  116. let data = val.detail;
  117. let startTime = utils.formatDate(data.startTime)
  118. let endTime = utils.formatDate(data.endTime)
  119. this.setData({
  120. ["searchParams.startTime"]: data.startTime,
  121. ["searchParams.endTime"]: data.endTime,
  122. dataStr: startTime +" ~ "+ endTime
  123. });
  124. this.data.searchParams.startTime = data.startTime;
  125. this.data.searchParams.endTime = data.endTime;
  126. },
  127. bindStorePickerChange: function (e) {
  128. var item = this.data.storeList[e.detail.value]
  129. console.log(item)
  130. this.setData({
  131. ['searchParams.storeId']: item.id,
  132. ['searchParams.storeName']: item.storeName
  133. })
  134. this.data.searchParams.storeId = item.id;
  135. // this.data.searchParams.storeName
  136. },
  137. showSearchModel: function() {
  138. this.setData({
  139. selectH: 300,
  140. })
  141. },
  142. hideSearchModel: function() {
  143. this.setData({
  144. selectH: 0
  145. })
  146. },
  147. clearSearch(){
  148. this.setData({
  149. ['searchParams.storeName']: '',
  150. ['searchParams.storeId']: '',
  151. ['searchParams.startTime']: '',
  152. ['searchParams.endTime']: '',
  153. })
  154. },
  155. submitSearch(){
  156. if(this.data.searchParams.storeId === undefined){
  157. this.data.searchParams.storeId = ''
  158. }
  159. if(this.data.searchParams.storeName === undefined){
  160. this.data.searchParams.storeName = ''
  161. }
  162. this.setData({
  163. selectH: 0,
  164. ["searchParams.pageNo"]: 1,
  165. pullUpOn: true,
  166. loadding: false,
  167. orderList: []
  168. })
  169. this.bindOrderList()
  170. },
  171. bindOrderList(){
  172. var that = this
  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. util.request(util.api.orderListPage, that.data.searchParams, "GET", false, true,app.globalData.token).then((res)=>{
  180. if (res.code == 200) {
  181. if (res.result.records.length > 0) {
  182. if (that.data.orderList.length > 0) {
  183. let list = that.data.orderList
  184. var records = res.result.records
  185. records.forEach(record => {
  186. list.push(record)
  187. });
  188. that.setData({
  189. orderList: list
  190. })
  191. }else{
  192. that.setData({
  193. orderList: res.result.records
  194. })
  195. }
  196. } else {
  197. that.setData({
  198. loadding: false,
  199. pullUpOn: false
  200. })
  201. }
  202. }
  203. }).catch((res) => {})
  204. },
  205. bindStoreList(){
  206. var that = this
  207. util.request(util.api.storeList, that.searchParams, "GET", false, true,app.globalData.token).then((res)=>{
  208. if (res.code == 200) {
  209. that.setData({
  210. storeList: res.result,
  211. ['searchParams.storeId']: res.result.id,
  212. ['searchParams.storeName']: res.result.storeName
  213. })
  214. }
  215. }).catch((res) => {})
  216. },
  217. searchOrder(){
  218. if(this.data.searchParams.storeId === undefined){
  219. this.data.searchParams.storeId = ''
  220. }
  221. if(this.data.searchParams.storeName === undefined){
  222. this.data.searchParams.storeName = ''
  223. }
  224. this.bindOrderList()
  225. },
  226. inputedit: function (e) {
  227. let _this = this;
  228. let dataset = e.currentTarget.dataset;
  229. let value = e.detail.value;
  230. let name = dataset.name;
  231. _this.data[name] = value;
  232. _this.setData({
  233. [name]: _this.data[name]
  234. });
  235. },
  236. })