orderList.js 7.3 KB

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