storeOrder.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const common_assets = require("../common/assets.js");
  4. const _sfc_main = {
  5. // mixins: [MescrollMixin],
  6. data() {
  7. return {
  8. searchKey: "",
  9. status: 0,
  10. orderStatus: [
  11. { name: "全部", value: "" },
  12. { name: "待付款", value: "0" },
  13. { name: "待发货", value: "1" },
  14. { name: "待收货", value: "2" },
  15. { name: "已完成", value: "3" }
  16. ],
  17. mescroll: null,
  18. // 上拉加载的配置
  19. upOption: {
  20. onScroll: true,
  21. use: true,
  22. // 是否启用上拉加载; 默认true
  23. page: {
  24. num: 0,
  25. // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  26. size: 10
  27. // 每页数据的数量,默认10
  28. },
  29. noMoreSize: 10,
  30. // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  31. empty: {
  32. icon: "/static/images/no_data.png",
  33. tip: "暂无数据"
  34. }
  35. },
  36. // 列表数据
  37. dataList: []
  38. };
  39. },
  40. onLoad(option) {
  41. this.status = option.status;
  42. var that = this;
  43. common_vendor.index.$on("refreshOrder", () => {
  44. that.mescroll.resetUpScroll();
  45. });
  46. },
  47. methods: {
  48. goSearch(e) {
  49. this.searchKey = e.detail.value;
  50. this.mescroll.resetUpScroll();
  51. },
  52. refund(item) {
  53. common_vendor.index.navigateTo({
  54. url: "./refundOrderProduct?orderId=" + item.id
  55. });
  56. },
  57. // tab切换
  58. orderStatusChange(item) {
  59. this.status = item.value;
  60. this.mescroll.resetUpScroll();
  61. },
  62. mescrollInit(mescroll) {
  63. this.mescroll = mescroll;
  64. },
  65. /*下拉刷新的回调 */
  66. downCallback(mescroll) {
  67. mescroll.resetUpScroll();
  68. },
  69. upCallback(page) {
  70. var that = this;
  71. var data = {
  72. keyword: this.searchKey,
  73. status: this.status,
  74. page: page.num,
  75. pageSize: page.size
  76. };
  77. getMyStoreOrderList(data).then((res) => {
  78. if (res.code == 200) {
  79. if (page.num == 1) {
  80. that.dataList = res.data.list;
  81. } else {
  82. that.dataList = that.dataList.concat(res.data.list);
  83. }
  84. that.mescroll.endBySize(res.data.list.length, res.data.total);
  85. } else {
  86. common_vendor.index.showToast({
  87. icon: "none",
  88. title: "请求失败"
  89. });
  90. that.dataList = null;
  91. that.mescroll.endErr();
  92. }
  93. });
  94. },
  95. // 查看订单详情
  96. showDetail(item) {
  97. console.log(item);
  98. common_vendor.index.navigateTo({
  99. url: "./storeOrderDetail?id=" + item.id
  100. });
  101. },
  102. cancel(item) {
  103. var that = this;
  104. common_vendor.index.showModal({
  105. title: "提示",
  106. content: "确定取消订单吗",
  107. success: function(res) {
  108. if (res.confirm) {
  109. var data = {
  110. orderId: item.id
  111. };
  112. cancelOrder(data).then((res2) => {
  113. if (res2.code == 200) {
  114. common_vendor.index.showToast({
  115. icon: "success",
  116. title: "操作成功"
  117. });
  118. that.mescroll.resetUpScroll();
  119. } else {
  120. common_vendor.index.showToast({
  121. icon: "none",
  122. title: res2.msg
  123. });
  124. }
  125. });
  126. } else if (res.cancel)
  127. ;
  128. }
  129. });
  130. },
  131. pay(item) {
  132. if (item.isPrescribe == 1 && item.prescribeId == null) {
  133. common_vendor.index.navigateTo({
  134. url: "/pages/shopping/prescribe?orderId=" + item.id
  135. });
  136. } else {
  137. common_vendor.index.navigateTo({
  138. url: "/pages/shopping/paymentOrder?orderId=" + item.id
  139. });
  140. }
  141. },
  142. // 查看物流
  143. showDelivery(item) {
  144. common_vendor.index.navigateTo({
  145. url: "./storeOrderDelivery?orderId=" + item.id
  146. });
  147. }
  148. }
  149. };
  150. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  151. return {
  152. a: common_vendor.f($data.orderStatus, (item, index, i0) => {
  153. return {
  154. a: common_vendor.t(item.name),
  155. b: $data.status == item.value,
  156. c: index,
  157. d: common_vendor.n($data.status == item.value ? "item active" : "item"),
  158. e: common_vendor.o(($event) => $options.orderStatusChange(item), index)
  159. };
  160. }),
  161. b: common_assets._imports_0$12,
  162. c: common_assets._imports_1,
  163. d: common_vendor.o((...args) => $options.goSearch && $options.goSearch(...args)),
  164. e: common_vendor.f($data.dataList, (item, index, i0) => {
  165. return common_vendor.e({
  166. a: common_vendor.t(item.storeName || ""),
  167. b: item.storeName,
  168. c: common_vendor.t(item.orderCode),
  169. d: common_vendor.t(_ctx.utils.getDictLabelName("storeOrderStatus", item.status)),
  170. e: common_vendor.o(($event) => $options.showDetail(item), index),
  171. f: item.isPackage != 1
  172. }, item.isPackage != 1 ? {
  173. g: common_vendor.f(item.items, (subItem, subIndex, i1) => {
  174. return common_vendor.e({
  175. a: JSON.parse(subItem.jsonInfo).image,
  176. b: subItem.isPrescribe == 1
  177. }, subItem.isPrescribe == 1 ? {} : {}, {
  178. c: common_vendor.t(JSON.parse(subItem.jsonInfo).productName),
  179. d: common_vendor.t(JSON.parse(subItem.jsonInfo).sku),
  180. e: common_vendor.t(JSON.parse(subItem.jsonInfo).price.toFixed(2)),
  181. f: common_vendor.t(JSON.parse(subItem.jsonInfo).num),
  182. g: common_vendor.o(($event) => $options.showDetail(item), subIndex),
  183. h: subIndex
  184. });
  185. })
  186. } : {}, {
  187. h: item.isPackage == 1 && item.packageJson != null
  188. }, item.isPackage == 1 && item.packageJson != null ? {
  189. i: JSON.parse(item.packageJson).imgUrl,
  190. j: common_vendor.t(JSON.parse(item.packageJson).title),
  191. k: common_vendor.t(JSON.parse(item.packageJson).descs),
  192. l: common_vendor.o(($event) => $options.showDetail(item), index)
  193. } : {}, {
  194. m: common_vendor.t(item.payPrice.toFixed(2)),
  195. n: item.status == 0
  196. }, item.status == 0 ? {
  197. o: common_vendor.o(($event) => $options.cancel(item), index)
  198. } : {}, {
  199. p: item.status == 0
  200. }, item.status == 0 ? {
  201. q: common_vendor.o(($event) => $options.pay(item), index)
  202. } : {}, {
  203. r: item.isAfterSales == 1
  204. }, item.isAfterSales == 1 ? {
  205. s: common_vendor.o(($event) => $options.refund(item), index)
  206. } : {}, {
  207. t: item.status >= 2 && item.deliveryId != null
  208. }, item.status >= 2 && item.deliveryId != null ? {
  209. v: common_vendor.o(($event) => $options.showDelivery(item), index)
  210. } : {}, {
  211. w: index
  212. });
  213. })
  214. };
  215. }
  216. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  217. wx.createPage(MiniProgramPage);