index.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. var et = endTime.split(" ");
  120. var entt = et[0]+" 23:59:59"
  121. this.setData({
  122. ["searchParams.startTime"]: data.startTime,
  123. ["searchParams.endTime"]: data.entt,
  124. dataStr: startTime + " ~ " + entt
  125. });
  126. this.data.searchParams.startTime = data.startTime;
  127. this.data.searchParams.entt = data.entt;
  128. },
  129. bindStorePickerChange: function (e) {
  130. var item = this.data.storeList[e.detail.value]
  131. console.log(item)
  132. this.setData({
  133. ['searchParams.storeId']: item.id,
  134. ['searchParams.storeName']: item.storeName
  135. })
  136. this.data.searchParams.storeId = item.id;
  137. // this.data.searchParams.storeName
  138. },
  139. showSearchModel: function () {
  140. this.setData({
  141. selectH: 450,
  142. })
  143. },
  144. hideSearchModel: function () {
  145. this.setData({
  146. selectH: 0
  147. })
  148. },
  149. clearSearch() {
  150. this.setData({
  151. ['searchParams.storeName']: '',
  152. ['searchParams.storeId']: '',
  153. ['searchParams.startTime']: '',
  154. ['searchParams.endTime']: '',
  155. dataStr: '',
  156. })
  157. },
  158. submitSearch() {
  159. if (this.data.searchParams.storeId === undefined) {
  160. this.data.searchParams.storeId = ''
  161. }
  162. if (this.data.searchParams.storeName === undefined) {
  163. this.data.searchParams.storeName = ''
  164. }
  165. this.setData({
  166. selectH: 0,
  167. ["searchParams.pageNo"]: 1,
  168. pullUpOn: true,
  169. loadding: false,
  170. orderList: []
  171. })
  172. this.bindOrderList()
  173. },
  174. bindOrderList() {
  175. var that = this
  176. if (this.data.searchParams.storeId === undefined) {
  177. this.data.searchParams.storeId = ''
  178. }
  179. if (this.data.searchParams.storeName === undefined) {
  180. this.data.searchParams.storeName = ''
  181. }
  182. util.request(util.api.orderListPage, that.data.searchParams, "GET", false, true, app.globalData.token).then((res) => {
  183. if (res.code == 200) {
  184. if (res.result.records.length > 0) {
  185. if (that.data.orderList.length > 0) {
  186. let list = that.data.orderList
  187. var records = res.result.records
  188. records.forEach(record => {
  189. list.push(record)
  190. });
  191. that.setData({
  192. orderList: list
  193. })
  194. } else {
  195. that.setData({
  196. orderList: res.result.records
  197. })
  198. }
  199. } else {
  200. that.setData({
  201. loadding: false,
  202. pullUpOn: false
  203. })
  204. }
  205. }
  206. }).catch((res) => {})
  207. },
  208. bindStoreList() {
  209. var that = this
  210. util.request(util.api.storeList, that.searchParams, "GET", false, true, app.globalData.token).then((res) => {
  211. if (res.code == 200) {
  212. that.setData({
  213. storeList: res.result,
  214. ['searchParams.storeId']: res.result.id,
  215. ['searchParams.storeName']: res.result.storeName
  216. })
  217. }
  218. }).catch((res) => {})
  219. },
  220. searchOrder() {
  221. if (this.data.searchParams.storeId === undefined) {
  222. this.data.searchParams.storeId = ''
  223. }
  224. if (this.data.searchParams.storeName === undefined) {
  225. this.data.searchParams.storeName = ''
  226. }
  227. this.bindOrderList()
  228. },
  229. inputedit: function (e) {
  230. let _this = this;
  231. let dataset = e.currentTarget.dataset;
  232. let value = e.detail.value;
  233. let name = dataset.name;
  234. _this.data[name] = value;
  235. _this.setData({
  236. [name]: _this.data[name]
  237. });
  238. },
  239. toDetail(e) {
  240. const agentmoney = e.currentTarget.dataset.agentmoney?e.currentTarget.dataset.agentmoney:0
  241. const areaAgentMoney = e.currentTarget.dataset.areaagentmoney?e.currentTarget.dataset.areaagentmoney:0
  242. const storeCommission = e.currentTarget.dataset.storecommission?e.currentTarget.dataset.storecommission:0
  243. var url = '/pages/order/detail/index?orderSn=' + e.currentTarget.dataset.id + '&agentMoney=' + agentmoney + '&areaAgentMoney=' + areaAgentMoney + '&storeCommission=' + storeCommission
  244. wx.navigateTo({
  245. url: url
  246. })
  247. },
  248. })