index.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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: 450,
  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. dataStr: '',
  154. })
  155. },
  156. submitSearch() {
  157. if (this.data.searchParams.storeId === undefined) {
  158. this.data.searchParams.storeId = ''
  159. }
  160. if (this.data.searchParams.storeName === undefined) {
  161. this.data.searchParams.storeName = ''
  162. }
  163. this.setData({
  164. selectH: 0,
  165. ["searchParams.pageNo"]: 1,
  166. pullUpOn: true,
  167. loadding: false,
  168. orderList: []
  169. })
  170. this.bindOrderList()
  171. },
  172. bindOrderList() {
  173. var that = this
  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. util.request(util.api.orderListPage, that.data.searchParams, "GET", false, true, app.globalData.token).then((res) => {
  181. if (res.code == 200) {
  182. if (res.result.records.length > 0) {
  183. if (that.data.orderList.length > 0) {
  184. let list = that.data.orderList
  185. var records = res.result.records
  186. records.forEach(record => {
  187. list.push(record)
  188. });
  189. that.setData({
  190. orderList: list
  191. })
  192. } else {
  193. that.setData({
  194. orderList: res.result.records
  195. })
  196. }
  197. } else {
  198. that.setData({
  199. loadding: false,
  200. pullUpOn: false
  201. })
  202. }
  203. }
  204. }).catch((res) => {})
  205. },
  206. bindStoreList() {
  207. var that = this
  208. util.request(util.api.storeList, that.searchParams, "GET", false, true, app.globalData.token).then((res) => {
  209. if (res.code == 200) {
  210. that.setData({
  211. storeList: res.result,
  212. ['searchParams.storeId']: res.result.id,
  213. ['searchParams.storeName']: res.result.storeName
  214. })
  215. }
  216. }).catch((res) => {})
  217. },
  218. searchOrder() {
  219. if (this.data.searchParams.storeId === undefined) {
  220. this.data.searchParams.storeId = ''
  221. }
  222. if (this.data.searchParams.storeName === undefined) {
  223. this.data.searchParams.storeName = ''
  224. }
  225. this.bindOrderList()
  226. },
  227. inputedit: function (e) {
  228. let _this = this;
  229. let dataset = e.currentTarget.dataset;
  230. let value = e.detail.value;
  231. let name = dataset.name;
  232. _this.data[name] = value;
  233. _this.setData({
  234. [name]: _this.data[name]
  235. });
  236. },
  237. toDetail(e) {
  238. const agentmoney = e.currentTarget.dataset.agentmoney?e.currentTarget.dataset.agentmoney:0
  239. const areaAgentMoney = e.currentTarget.dataset.areaagentmoney?e.currentTarget.dataset.areaagentmoney:0
  240. const storeCommission = e.currentTarget.dataset.storecommission?e.currentTarget.dataset.storecommission:0
  241. var url = '/pages/order/detail/index?orderSn=' + e.currentTarget.dataset.id + '&agentMoney=' + agentmoney + '&areaAgentMoney=' + areaAgentMoney + '&storeCommission=' + storeCommission
  242. wx.navigateTo({
  243. url: url
  244. })
  245. },
  246. })