otherlist.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  4. const sheep_index = require("../../sheep/index.js");
  5. require("../../sheep/url/index.js");
  6. require("../../sheep/store/index.js");
  7. require("../../sheep/store/app.js");
  8. require("../../sheep/api/promotion/diy.js");
  9. require("../../sheep/request/index.js");
  10. require("../../sheep/config/index.js");
  11. require("../../sheep/platform/index.js");
  12. require("../../sheep/platform/provider/wechat/index.js");
  13. require("../../sheep/platform/provider/wechat/miniProgram.js");
  14. require("../../sheep/api/member/auth.js");
  15. require("../../sheep/api/member/social.js");
  16. require("../../sheep/api/member/user.js");
  17. require("../../sheep/platform/provider/apple/index.js");
  18. require("../../sheep/platform/share.js");
  19. require("../../sheep/router/index.js");
  20. require("../../sheep/hooks/useModal.js");
  21. require("../../sheep/helper/index.js");
  22. require("../../sheep/helper/test.js");
  23. require("../../sheep/helper/digit.js");
  24. require("../../sheep/api/member/signin.js");
  25. require("../../sheep/helper/throttle.js");
  26. require("../../sheep/platform/pay.js");
  27. require("../../sheep/api/pay/order.js");
  28. require("../../sheep/store/user.js");
  29. require("../../sheep/store/cart.js");
  30. require("../../sheep/api/trade/cart.js");
  31. require("../../sheep/api/pay/wallet.js");
  32. require("../../sheep/api/trade/order.js");
  33. require("../../sheep/api/promotion/coupon.js");
  34. require("../../sheep/store/sys.js");
  35. require("../../sheep/store/modal.js");
  36. require("../../sheep/util/index.js");
  37. require("../../sheep/api/index.js");
  38. require("../../sheep/api/distri/score.js");
  39. require("../../sheep/api/distri/share.js");
  40. require("../../sheep/api/distri/team.js");
  41. require("../../sheep/api/infra/file.js");
  42. require("../../sheep/api/member/address.js");
  43. require("../../sheep/api/member/point.js");
  44. require("../../sheep/api/migration/app.js");
  45. require("../../sheep/api/migration/chat.js");
  46. require("../../sheep/api/migration/index.js");
  47. require("../../sheep/api/migration/third.js");
  48. require("../../sheep/api/pay/channel.js");
  49. require("../../sheep/api/product/category.js");
  50. require("../../sheep/api/product/comment.js");
  51. require("../../sheep/api/product/favorite.js");
  52. require("../../sheep/api/product/history.js");
  53. require("../../sheep/api/product/spu.js");
  54. require("../../sheep/api/promotion/activity.js");
  55. require("../../sheep/api/promotion/article.js");
  56. require("../../sheep/api/promotion/bargain.js");
  57. require("../../sheep/api/promotion/combination.js");
  58. require("../../sheep/api/promotion/rewardActivity.js");
  59. require("../../sheep/api/promotion/seckill.js");
  60. require("../../sheep/api/system/area.js");
  61. require("../../sheep/api/system/voice.js");
  62. require("../../sheep/api/trade/afterSale.js");
  63. require("../../sheep/api/trade/brokerage.js");
  64. require("../../sheep/api/trade/config.js");
  65. require("../../sheep/api/trade/delivery.js");
  66. require("../../sheep/config/zIndex.js");
  67. if (!Array) {
  68. const _easycom_su_tabs2 = common_vendor.resolveComponent("su-tabs");
  69. const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  70. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  71. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  72. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  73. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  74. (_easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_s_empty2 + _easycom_s_goods_item2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  75. }
  76. const _easycom_su_tabs = () => "../../sheep/ui/su-tabs/su-tabs.js";
  77. const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
  78. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  79. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  80. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  81. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  82. if (!Math) {
  83. (_easycom_su_tabs + _easycom_su_sticky + _easycom_s_empty + _easycom_s_goods_item + _easycom_uni_load_more + _easycom_s_layout)();
  84. }
  85. const _sfc_main = {
  86. __name: "otherlist",
  87. setup(__props) {
  88. const tradeManaged = common_vendor.computed(() => sheep_index.sheep.$store("app").has_wechat_trade_managed);
  89. const pagination = {
  90. data: [],
  91. current_page: 1,
  92. total: 1,
  93. last_page: 1
  94. };
  95. const state = common_vendor.reactive({
  96. currentTab: 0,
  97. pagination: {
  98. data: [],
  99. current_page: 1,
  100. total: 1,
  101. last_page: 1
  102. },
  103. loadStatus: "",
  104. deleteOrderId: 0,
  105. error: 0
  106. });
  107. const tabMaps = [
  108. {
  109. name: "全部",
  110. value: "all"
  111. },
  112. {
  113. name: "待付款",
  114. value: "unpaid"
  115. },
  116. {
  117. name: "待发货",
  118. value: "nosend"
  119. },
  120. {
  121. name: "待收货",
  122. value: "noget"
  123. },
  124. {
  125. name: "待评价",
  126. value: "nocomment"
  127. }
  128. ];
  129. function onTabsChange(e) {
  130. if (state.currentTab === e.index)
  131. return;
  132. state.pagination = pagination;
  133. state.currentTab = e.index;
  134. getOrderList();
  135. }
  136. function onOrderDetail(orderSN) {
  137. sheep_index.sheep.$router.go("/pages/order/detail", {
  138. orderSN
  139. });
  140. }
  141. function onOrderGroupon(order) {
  142. sheep_index.sheep.$router.go("/pages/activity/groupon/detail", {
  143. id: order.ext.groupon_id
  144. });
  145. }
  146. function onOrderInvoice(invoiceId) {
  147. sheep_index.sheep.$router.go("/pages/order/invoice", {
  148. invoiceId
  149. });
  150. }
  151. function onPay(orderSN) {
  152. sheep_index.sheep.$router.go("/pages/pay/index", {
  153. orderSN
  154. });
  155. }
  156. function onComment(orderSN) {
  157. sheep_index.sheep.$router.go("/pages/goods/comment/add", {
  158. orderSN
  159. });
  160. }
  161. async function onConfirm(order, ignore = false) {
  162. if (sheep_index.sheep.$platform.name === "WechatMiniProgram" && !common_vendor.lodashExports.isEmpty(order.wechat_extra_data) && tradeManaged.value === 1 && !ignore) {
  163. mpConfirm(order);
  164. return;
  165. }
  166. const { error } = await sheep_index.sheep.$api.order.confirm(order.id);
  167. if (error === 0) {
  168. state.pagination = pagination;
  169. getOrderList();
  170. }
  171. }
  172. function mpConfirm(order) {
  173. if (!common_vendor.wx$1.openBusinessView) {
  174. sheep_index.sheep.$helper.toast(`请升级微信版本`);
  175. return;
  176. }
  177. common_vendor.wx$1.openBusinessView({
  178. businessType: "weappOrderConfirm",
  179. extraData: {
  180. merchant_trade_no: order.wechat_extra_data.merchant_trade_no,
  181. transaction_id: order.wechat_extra_data.transaction_id
  182. },
  183. success(response) {
  184. console.log("success:", response);
  185. if (response.errMsg === "openBusinessView:ok") {
  186. if (response.extraData.status === "success") {
  187. onConfirm(order, true);
  188. }
  189. }
  190. },
  191. fail(error) {
  192. console.log("error:", error);
  193. },
  194. complete(result) {
  195. console.log("result:", result);
  196. }
  197. });
  198. }
  199. async function onExpress(orderId) {
  200. sheep_index.sheep.$router.go("/pages/order/express/list", {
  201. orderId
  202. });
  203. }
  204. async function onCancel(orderId) {
  205. common_vendor.index.showModal({
  206. title: "提示",
  207. content: "确定要取消订单吗?",
  208. success: async function(res) {
  209. if (res.confirm) {
  210. const { error, data } = await sheep_index.sheep.$api.order.cancel(orderId);
  211. if (error === 0) {
  212. let index = state.pagination.data.findIndex((order) => order.id === orderId);
  213. state.pagination.data[index] = data;
  214. }
  215. }
  216. }
  217. });
  218. }
  219. function onDelete(orderId) {
  220. common_vendor.index.showModal({
  221. title: "提示",
  222. content: "确定要删除订单吗?",
  223. success: async function(res) {
  224. if (res.confirm) {
  225. const { error, data } = await sheep_index.sheep.$api.order.delete(orderId);
  226. if (error === 0) {
  227. let index = state.pagination.data.findIndex((order) => order.id === orderId);
  228. state.pagination.data.splice(index, 1);
  229. }
  230. }
  231. }
  232. });
  233. }
  234. async function onRefund(orderId) {
  235. common_vendor.index.showModal({
  236. title: "提示",
  237. content: "确定要申请退款吗?",
  238. success: async function(res) {
  239. if (res.confirm) {
  240. sheep_index.sheep.$platform.useProvider("wechat").subscribeMessage("order_refund");
  241. const { error, data } = await sheep_index.sheep.$api.order.applyRefund(orderId);
  242. if (error === 0) {
  243. let index = state.pagination.data.findIndex((order) => order.id === orderId);
  244. state.pagination.data[index] = data;
  245. }
  246. }
  247. }
  248. });
  249. }
  250. async function getOrderList(page = 1, list_rows = 5) {
  251. state.loadStatus = "loading";
  252. let res = await sheep_index.sheep.$api.order.list({
  253. type: tabMaps[state.currentTab].value,
  254. list_rows,
  255. page
  256. });
  257. state.error = res.error;
  258. if (res.error === 0) {
  259. let orderList = common_vendor._.concat(state.pagination.data, res.data.data);
  260. state.pagination = {
  261. ...res.data,
  262. data: orderList
  263. };
  264. if (state.pagination.current_page < state.pagination.last_page) {
  265. state.loadStatus = "more";
  266. } else {
  267. state.loadStatus = "noMore";
  268. }
  269. }
  270. }
  271. common_vendor.onLoad(async (options) => {
  272. if (options.type) {
  273. state.currentTab = options.type;
  274. }
  275. getOrderList();
  276. });
  277. function loadmore() {
  278. if (state.loadStatus !== "noMore") {
  279. getOrderList(state.pagination.current_page + 1);
  280. }
  281. }
  282. common_vendor.onReachBottom(() => {
  283. loadmore();
  284. });
  285. common_vendor.onPullDownRefresh(() => {
  286. state.pagination = pagination;
  287. getOrderList();
  288. setTimeout(function() {
  289. common_vendor.index.stopPullDownRefresh();
  290. }, 800);
  291. });
  292. return (_ctx, _cache) => {
  293. return common_vendor.e({
  294. a: common_vendor.o(onTabsChange),
  295. b: common_vendor.p({
  296. list: tabMaps,
  297. scrollable: false,
  298. current: state.currentTab
  299. }),
  300. c: common_vendor.p({
  301. bgColor: "#fff"
  302. }),
  303. d: state.pagination.total === 0
  304. }, state.pagination.total === 0 ? {
  305. e: common_vendor.p({
  306. icon: "/static/order-empty.png",
  307. text: "暂无订单"
  308. })
  309. } : {}, {
  310. f: state.pagination.total > 0
  311. }, state.pagination.total > 0 ? {
  312. g: common_vendor.f(state.pagination.data, (order, k0, i0) => {
  313. return common_vendor.e({
  314. a: common_vendor.t(order.order_sn),
  315. b: common_vendor.t(order.status_text),
  316. c: common_vendor.n(common_vendor.unref(sheep_hooks_useGoods.formatOrderColor)(order.status_code)),
  317. d: common_vendor.f(order.items, (item, k1, i1) => {
  318. return common_vendor.e({
  319. a: item.btns.includes("aftersale")
  320. }, item.btns.includes("aftersale") ? {
  321. b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/apply", {
  322. item: JSON.stringify(item)
  323. }), item.id)
  324. } : {}, {
  325. c: item.btns.includes("re_aftersale")
  326. }, item.btns.includes("re_aftersale") ? {
  327. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/apply", {
  328. item: JSON.stringify(item)
  329. }), item.id)
  330. } : {}, {
  331. e: item.btns.includes("aftersale_info")
  332. }, item.btns.includes("aftersale_info") ? {
  333. f: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/detail", {
  334. id: item.ext.aftersale_id
  335. }), item.id)
  336. } : {}, {
  337. g: item.btns.includes("buy_again")
  338. }, item.btns.includes("buy_again") ? {
  339. h: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  340. id: item.goods_id
  341. }), item.id)
  342. } : {}, {
  343. i: "ad14ec43-4-" + i0 + "-" + i1 + ",ad14ec43-0",
  344. j: common_vendor.p({
  345. img: item.goods_image,
  346. title: item.goods_title,
  347. skuText: item.goods_sku_text,
  348. price: item.goods_price,
  349. score: order.score_amount,
  350. num: item.goods_num
  351. }),
  352. k: item.id
  353. });
  354. }),
  355. e: order.total_discount_fee > 0
  356. }, order.total_discount_fee > 0 ? {
  357. f: common_vendor.t(order.total_discount_fee)
  358. } : {}, {
  359. g: common_vendor.t(order.dispatch_amount),
  360. h: common_vendor.t(order.order_amount),
  361. i: order.score_amount
  362. }, order.score_amount ? {} : {}, {
  363. j: order.score_amount
  364. }, order.score_amount ? {
  365. k: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/score1.svg"),
  366. l: common_vendor.t(order.score_amount)
  367. } : {}, {
  368. m: order.btns.includes("groupon")
  369. }, order.btns.includes("groupon") ? {
  370. n: common_vendor.t(order.status_code === "groupon_ing" ? "邀请拼团" : "拼团详情"),
  371. o: common_vendor.o(($event) => onOrderGroupon(order), order.id)
  372. } : {}, {
  373. p: order.btns.includes("invoice")
  374. }, order.btns.includes("invoice") ? {
  375. q: common_vendor.o(($event) => {
  376. var _a;
  377. return onOrderInvoice((_a = order.invoice) == null ? void 0 : _a.id);
  378. }, order.id)
  379. } : {}, {
  380. r: order.btns.length === 0
  381. }, order.btns.length === 0 ? {
  382. s: common_vendor.o(($event) => onOrderDetail(order.order_sn), order.id)
  383. } : {}, {
  384. t: order.btns.includes("confirm")
  385. }, order.btns.includes("confirm") ? {
  386. v: common_vendor.o(($event) => onConfirm(order), order.id)
  387. } : {}, {
  388. w: order.btns.includes("express")
  389. }, order.btns.includes("express") ? {
  390. x: common_vendor.o(($event) => onExpress(order.id), order.id)
  391. } : {}, {
  392. y: order.btns.includes("apply_refund")
  393. }, order.btns.includes("apply_refund") ? {
  394. z: common_vendor.o(($event) => onRefund(order.id), order.id)
  395. } : {}, {
  396. A: order.btns.includes("re_apply_refund")
  397. }, order.btns.includes("re_apply_refund") ? {
  398. B: common_vendor.o(($event) => onRefund(order.id), order.id)
  399. } : {}, {
  400. C: order.btns.includes("cancel")
  401. }, order.btns.includes("cancel") ? {
  402. D: common_vendor.o(($event) => onCancel(order.id), order.id)
  403. } : {}, {
  404. E: order.btns.includes("comment")
  405. }, order.btns.includes("comment") ? {
  406. F: common_vendor.o(($event) => onComment(order.order_sn), order.id)
  407. } : {}, {
  408. G: order.btns.includes("delete")
  409. }, order.btns.includes("delete") ? {
  410. H: common_vendor.o(($event) => onDelete(order.id), order.id)
  411. } : {}, {
  412. I: order.btns.includes("pay")
  413. }, order.btns.includes("pay") ? {
  414. J: common_vendor.o(($event) => onPay(order.order_sn), order.id)
  415. } : {}, {
  416. K: common_vendor.n(order.btns.length > 3 ? "ss-row-between" : "ss-row-right"),
  417. L: order.id,
  418. M: common_vendor.o(($event) => onOrderDetail(order.order_sn), order.id)
  419. });
  420. })
  421. } : {}, {
  422. h: state.pagination.total > 0
  423. }, state.pagination.total > 0 ? {
  424. i: common_vendor.o(loadmore),
  425. j: common_vendor.p({
  426. status: state.loadStatus,
  427. ["content-text"]: {
  428. contentdown: "上拉加载更多"
  429. }
  430. })
  431. } : {}, {
  432. k: common_vendor.p({
  433. title: "我的订单"
  434. })
  435. });
  436. };
  437. }
  438. };
  439. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ad14ec43"], ["__file", "D:/zx/mall-front-app/pages/order/otherlist.vue"]]);
  440. wx.createPage(MiniProgramPage);