orderList.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. var http = require('../../utils/http.js');
  2. var config = require('../../utils/config.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. statusObject: {
  9. 0: '待支付',
  10. 20: '订单已接单',
  11. 30: '订单待配送',
  12. 40: '订单配送中',
  13. 50: '订单取消待审核',
  14. 60: '订单已取消',
  15. 70: '订单已送达',
  16. 80: '订单已完成'
  17. },
  18. list: [],
  19. current: 1,
  20. pages: 0,
  21. sts: 9,//9是自定义的全部
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. console.log(options);
  28. if (options.sts) {
  29. this.setData({
  30. sts: options.sts
  31. });
  32. }
  33. this.loadOrderData(this.data.sts, 1);
  34. },
  35. /**
  36. * 生命周期函数--监听页面显示
  37. */
  38. onShow: function () {},
  39. /**
  40. * 加载订单数据
  41. */
  42. loadOrderData: function (sts, current) {
  43. var ths = this;
  44. wx.showLoading();
  45. let data = {
  46. current: current,
  47. size: 10,
  48. }
  49. if(sts!=9){
  50. data.status = sts
  51. }
  52. //加载订单列表
  53. var params = {
  54. url: "/p/myOrder/myOrder",
  55. method: "GET",
  56. data,
  57. callBack: function (res) {
  58. // console.log(res);
  59. let img=''
  60. res.records.forEach(orderItem => {
  61. orderItem.totalCounts = 0
  62. if (orderItem.returnMoneySts == null) {
  63. orderItem.returnMoneySts = 0
  64. }
  65. orderItem.orderItemDtos.forEach(prod => {
  66. img=prod.pic.split(',')
  67. prod.pic=img[0]
  68. orderItem.totalCounts += prod.prodCount
  69. })
  70. })
  71. var list = [];
  72. if (res.current == 1) {
  73. list = res.records;
  74. } else {
  75. list = ths.data.list;
  76. Array.prototype.push.apply(list, res.records);
  77. }
  78. ths.setData({
  79. list: list,
  80. pages: res.pages,
  81. current: res.current,
  82. });
  83. wx.hideLoading();
  84. }
  85. };
  86. http.request(params);
  87. },
  88. /**
  89. * 状态点击事件
  90. */
  91. onStsTap: function (e) {
  92. var sts = e.currentTarget.dataset.sts;
  93. this.setData({
  94. sts: sts
  95. });
  96. this.loadOrderData(sts, 1);
  97. },
  98. /**
  99. * 生命周期函数--监听页面初次渲染完成
  100. */
  101. onReady: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面卸载
  110. */
  111. onUnload: function () {
  112. },
  113. /**
  114. * 页面相关事件处理函数--监听用户下拉动作
  115. */
  116. onPullDownRefresh: function () {
  117. },
  118. /**
  119. * 页面上拉触底事件的处理函数
  120. */
  121. onReachBottom: function () {
  122. if (this.data.current < this.data.pages) {
  123. this.loadOrderData(this.data.sts, this.data.current + 1);
  124. }
  125. },
  126. /**
  127. * 用户点击右上角分享
  128. */
  129. onShareAppMessage: function () {
  130. },
  131. /**
  132. * 跳转店铺首页
  133. */
  134. toShopIndex: function (e) {
  135. wx.navigateTo({
  136. url: '/pages/shopPage/shopPage?shopId=' + e.currentTarget.dataset.shopid
  137. })
  138. },
  139. /**
  140. * 查看物流
  141. */
  142. toDeliveryPage: function (e) {
  143. let lat=e.currentTarget.dataset.lat
  144. let long=e.currentTarget.dataset.lon
  145. wx.navigateTo({
  146. url: '/pages/MaterialFlowInfo/MaterialFlowInfo?orderNumber=' + e.currentTarget.dataset.ordernum+'&lat='+lat+'&long='+long
  147. })
  148. },
  149. /**
  150. * 取消订单
  151. */
  152. onCancelOrder: function (e) {
  153. var ordernum = e.currentTarget.dataset.ordernum;
  154. var ths = this;
  155. wx.showModal({
  156. title: '',
  157. content: '要取消此订单?',
  158. confirmColor: "#3e62ad",
  159. cancelColor: "#3e62ad",
  160. cancelText: '否',
  161. confirmText: '是',
  162. success(res) {
  163. if (res.confirm) {
  164. wx.showLoading({
  165. mask: true
  166. });
  167. var params = {
  168. url: "/p/myOrder/cancel/" + ordernum,
  169. method: "PUT",
  170. data: {},
  171. callBack: function (res) {
  172. //console.log(res);
  173. ths.loadOrderData(ths.data.sts, 1);
  174. wx.hideLoading();
  175. }
  176. };
  177. http.request(params);
  178. } else if (res.cancel) {
  179. //console.log('用户点击取消')
  180. }
  181. }
  182. })
  183. },
  184. /**
  185. * 待发货取消订单
  186. * @param {*} e
  187. */
  188. onRefundOrder: function (e) {
  189. var params = {
  190. url: '/p/orderRefund/getIsDistribution',
  191. method: 'GET',
  192. data: {
  193. orderNumber: e.currentTarget.dataset.ordernum
  194. },
  195. callBack: res => {
  196. if (res == true) {
  197. wx.showToast({
  198. title: '商品已在配送中,无法取消',
  199. icon: 'none'
  200. })
  201. } else {
  202. wx.navigateTo({
  203. url: '/pages/order-detail/order-detail?orderNum=' + e.currentTarget.dataset.ordernum,
  204. })
  205. }
  206. }
  207. }
  208. http.request(params);
  209. },
  210. /**
  211. * 付款
  212. */
  213. onPayAgain: function (e) {
  214. wx.showLoading({
  215. mask: true
  216. });
  217. var orderType = e.currentTarget.dataset.ordertype;
  218. var params = {
  219. url: "/p/order/pay",
  220. method: "POST",
  221. data: {
  222. orderType: orderType ? orderType : 0,
  223. payType: 1,
  224. orderNumbers: e.currentTarget.dataset.ordernum
  225. },
  226. callBack: res => {
  227. //console.log(res);
  228. wx.hideLoading();
  229. wx.requestPayment({
  230. timeStamp: res.timeStamp,
  231. nonceStr: res.nonceStr,
  232. package: res.package,
  233. signType: res.signType,
  234. paySign: res.paySign,
  235. success: function () {
  236. wx.navigateTo({
  237. url: '/pages/pay-result/pay-result?sts=1&orderNumbers=' + e.currentTarget.dataset.ordernum,
  238. })
  239. },
  240. fail: function (err) {
  241. //console.log("支付失败");
  242. }
  243. })
  244. }
  245. };
  246. http.request(params);
  247. },
  248. /**
  249. * 查看订单详情
  250. */
  251. toOrderDetailPage: function (e) {
  252. wx.navigateTo({
  253. url: '/pages/order-detail/order-detail?orderNum=' + e.currentTarget.dataset.ordernum,
  254. })
  255. },
  256. /**
  257. * 确认收货
  258. */
  259. onConfirmReceive: function (e) {
  260. var ths = this;
  261. wx.showModal({
  262. title: '',
  263. content: '我已收到货?',
  264. confirmColor: "#FF941A",
  265. success(res) {
  266. if (res.confirm) {
  267. wx.showLoading({
  268. mask: true
  269. });
  270. var params = {
  271. url: "/p/myOrder/receipt/" + e.currentTarget.dataset.ordernum,
  272. method: "PUT",
  273. data: {},
  274. callBack: function (res) {
  275. //console.log(res);
  276. ths.loadOrderData(ths.data.sts, 1);
  277. wx.hideLoading();
  278. }
  279. };
  280. http.request(params);
  281. } else if (res.cancel) {
  282. //console.log('用户点击取消')
  283. }
  284. }
  285. })
  286. },
  287. //删除已完成||已取消的订单
  288. delOrderList: function (e) {
  289. var ths = this
  290. wx.showModal({
  291. title: '',
  292. content: '确定要删除此订单吗?',
  293. confirmColor: "#FF941A",
  294. success(res) {
  295. if (res.confirm) {
  296. var ordernum = e.currentTarget.dataset.ordernum;
  297. wx.showLoading();
  298. var params = {
  299. url: "/p/myOrder/" + ordernum,
  300. method: "DELETE",
  301. data: {},
  302. callBack: function (res) {
  303. ths.loadOrderData(ths.data.sts, 1);
  304. wx.hideLoading();
  305. }
  306. }
  307. http.request(params);
  308. } else if (res.cancel) {
  309. console.log('用户点击取消')
  310. }
  311. }
  312. })
  313. },
  314. /**
  315. * 跳转评价页面
  316. */
  317. onComment: function (e) {
  318. var info = e.currentTarget.dataset.info;
  319. wx.setStorageSync("orderItemInfo", info);
  320. wx.navigateTo({
  321. url: '/pages/prodComm/prodComm',
  322. })
  323. }
  324. })