list.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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. const sheep_api_trade_order = require("../../sheep/api/trade/order.js");
  6. require("../../sheep/url/index.js");
  7. require("../../sheep/store/index.js");
  8. require("../../sheep/store/app.js");
  9. require("../../sheep/api/promotion/diy.js");
  10. require("../../sheep/request/index.js");
  11. require("../../sheep/config/index.js");
  12. require("../../sheep/platform/index.js");
  13. require("../../sheep/platform/provider/wechat/index.js");
  14. require("../../sheep/platform/provider/wechat/miniProgram.js");
  15. require("../../sheep/api/member/auth.js");
  16. require("../../sheep/api/member/social.js");
  17. require("../../sheep/api/member/user.js");
  18. require("../../sheep/platform/provider/apple/index.js");
  19. require("../../sheep/platform/share.js");
  20. require("../../sheep/router/index.js");
  21. require("../../sheep/hooks/useModal.js");
  22. require("../../sheep/helper/index.js");
  23. require("../../sheep/helper/test.js");
  24. require("../../sheep/helper/digit.js");
  25. require("../../sheep/api/member/signin.js");
  26. require("../../sheep/helper/throttle.js");
  27. require("../../sheep/platform/pay.js");
  28. require("../../sheep/api/pay/order.js");
  29. require("../../sheep/store/user.js");
  30. require("../../sheep/store/cart.js");
  31. require("../../sheep/api/trade/cart.js");
  32. require("../../sheep/api/pay/wallet.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: "list",
  87. setup(__props) {
  88. const pagination = {
  89. list: [],
  90. current_page: 1,
  91. total: 1,
  92. last_page: 1
  93. };
  94. const state = common_vendor.reactive({
  95. currentTab: 0,
  96. // 选中的 tabMaps 下标
  97. pagination: {
  98. list: [],
  99. current_page: 1,
  100. total: 1,
  101. last_page: 1
  102. },
  103. loadStatus: ""
  104. });
  105. const tabMaps = common_vendor.reactive([
  106. {
  107. name: "全部",
  108. num: 0,
  109. isShow: false
  110. },
  111. {
  112. name: "待付款",
  113. value: 0,
  114. num: 0,
  115. isShow: true
  116. },
  117. {
  118. name: "待发货",
  119. value: 10,
  120. num: 0,
  121. isShow: true
  122. },
  123. {
  124. name: "待收货",
  125. value: 20,
  126. num: 0,
  127. isShow: true
  128. },
  129. {
  130. name: "待评价",
  131. value: 30,
  132. num: 0,
  133. isShow: true
  134. }
  135. ]);
  136. function onTabsChange(e) {
  137. if (state.currentTab === e.index) {
  138. return;
  139. }
  140. state.pagination.list = [];
  141. state.pagination.current_page = 1;
  142. state.pagination.total = 1;
  143. state.pagination.last_page = 1;
  144. state.currentTab = e.index;
  145. getOrderList();
  146. }
  147. function onOrderDetail(id) {
  148. sheep_index.sheep.$router.go("/pages/order/detail", {
  149. id
  150. });
  151. }
  152. function onOrderGroupon(order) {
  153. sheep_index.sheep.$router.go("/pages/activity/groupon/detail", {
  154. id: order.ext.groupon_id
  155. });
  156. }
  157. function onPay(id) {
  158. sheep_index.sheep.$router.go("/pages/pay/index", {
  159. id,
  160. openType: 2
  161. });
  162. }
  163. function onComment(id) {
  164. sheep_index.sheep.$router.go("/pages/goods/comment/add", {
  165. id
  166. });
  167. }
  168. async function onConfirm(order, ignore = false) {
  169. let isOpenBusinessView = true;
  170. common_vendor.index.showModal({
  171. title: "提示",
  172. content: "确认收货?",
  173. success: async function(res) {
  174. if (res.confirm) {
  175. if (sheep_index.sheep.$platform.name === "WechatMiniProgram" && !common_vendor.lodashExports.isEmpty(order.wechat_extra_data) && isOpenBusinessView && !ignore) {
  176. mpConfirm(order);
  177. return;
  178. }
  179. const {
  180. code
  181. } = await sheep_api_trade_order.OrderApi.receiveOrder(order.id);
  182. if (code === 0) {
  183. state.pagination = pagination;
  184. await getOrderList();
  185. }
  186. }
  187. }
  188. });
  189. }
  190. function mpConfirm(order) {
  191. if (!common_vendor.wx$1.openBusinessView) {
  192. sheep_index.sheep.$helper.toast(`请升级微信版本`);
  193. return;
  194. }
  195. common_vendor.wx$1.openBusinessView({
  196. businessType: "weappOrderConfirm",
  197. extraData: {
  198. merchant_id: "1481069012",
  199. merchant_trade_no: order.wechat_extra_data.merchant_trade_no,
  200. transaction_id: order.wechat_extra_data.transaction_id
  201. },
  202. success(response) {
  203. console.log("success:", response);
  204. if (response.errMsg === "openBusinessView:ok") {
  205. if (response.extraData.status === "success") {
  206. onConfirm(order, true);
  207. }
  208. }
  209. },
  210. fail(error) {
  211. console.log("error:", error);
  212. },
  213. complete(result) {
  214. console.log("result:", result);
  215. }
  216. });
  217. }
  218. async function onExpress(id) {
  219. sheep_index.sheep.$router.go("/pages/order/express/log", {
  220. id
  221. });
  222. }
  223. async function onCancel(orderId) {
  224. common_vendor.index.showModal({
  225. title: "提示",
  226. content: "确定要取消订单吗?",
  227. success: async function(res) {
  228. if (!res.confirm) {
  229. return;
  230. }
  231. const {
  232. code
  233. } = await sheep_api_trade_order.OrderApi.cancelOrder(orderId);
  234. if (code === 0) {
  235. let index = state.pagination.list.findIndex((order) => order.id === orderId);
  236. const orderInfo = state.pagination.list[index];
  237. orderInfo.status = 40;
  238. sheep_hooks_useGoods.handleOrderButtons(orderInfo);
  239. state.pagination = pagination;
  240. await getOrderList();
  241. }
  242. }
  243. });
  244. }
  245. function onDelete(orderId) {
  246. common_vendor.index.showModal({
  247. title: "提示",
  248. content: "确定要删除订单吗?",
  249. success: async function(res) {
  250. if (res.confirm) {
  251. const {
  252. code
  253. } = await sheep_api_trade_order.OrderApi.deleteOrder(orderId);
  254. if (code === 0) {
  255. let index = state.pagination.list.findIndex((order) => order.id === orderId);
  256. state.pagination.list.splice(index, 1);
  257. await getOrderList();
  258. }
  259. }
  260. }
  261. });
  262. }
  263. async function getOrderCount() {
  264. let { data } = await sheep_api_trade_order.OrderApi.getOrderCount();
  265. tabMaps[0].num = data.allCount;
  266. tabMaps[1].num = data.unpaidCount;
  267. tabMaps[2].num = data.undeliveredCount;
  268. tabMaps[3].num = data.deliveredCount;
  269. tabMaps[4].num = data.uncommentedCount;
  270. }
  271. async function getOrderList(page = 1, list_rows = 5) {
  272. state.loadStatus = "loading";
  273. let {
  274. code,
  275. data
  276. } = await sheep_api_trade_order.OrderApi.getOrderPage({
  277. pageNo: page,
  278. pageSize: list_rows,
  279. status: tabMaps[state.currentTab].value,
  280. commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
  281. });
  282. getOrderCount();
  283. if (code !== 0) {
  284. return;
  285. }
  286. let orderList = common_vendor._.concat(state.pagination.list, data.list);
  287. data.list.forEach((order) => sheep_hooks_useGoods.handleOrderButtons(order));
  288. state.pagination.list = orderList;
  289. state.pagination.total = data.total;
  290. state.pagination.last_page = Math.ceil(data.total / 5);
  291. if (state.pagination.current_page < state.pagination.last_page) {
  292. state.loadStatus = "more";
  293. } else {
  294. state.loadStatus = "noMore";
  295. }
  296. }
  297. common_vendor.onLoad(async (options) => {
  298. if (options.type) {
  299. state.currentTab = options.type;
  300. }
  301. await getOrderList();
  302. });
  303. common_vendor.onShow(async () => {
  304. if (state.loadStatus == "loading") {
  305. return;
  306. }
  307. state.pagination.list = [];
  308. state.pagination.current_page = 1;
  309. state.pagination.total = 1;
  310. state.pagination.last_page = 1;
  311. await getOrderList();
  312. });
  313. function loadMore() {
  314. if (state.loadStatus !== "noMore") {
  315. state.pagination.current_page += 1;
  316. getOrderList(state.pagination.current_page);
  317. }
  318. }
  319. common_vendor.onReachBottom(() => {
  320. loadMore();
  321. });
  322. common_vendor.onPullDownRefresh(() => {
  323. state.pagination.list = [];
  324. state.pagination.current_page = 1;
  325. state.pagination.total = 1;
  326. state.pagination.last_page = 1;
  327. getOrderList();
  328. setTimeout(function() {
  329. common_vendor.index.stopPullDownRefresh();
  330. }, 800);
  331. });
  332. return (_ctx, _cache) => {
  333. return common_vendor.e({
  334. a: common_vendor.o(onTabsChange),
  335. b: common_vendor.p({
  336. list: tabMaps,
  337. scrollable: false,
  338. current: state.currentTab,
  339. badge: true
  340. }),
  341. c: common_vendor.p({
  342. bgColor: "#fff"
  343. }),
  344. d: state.pagination.total === 0
  345. }, state.pagination.total === 0 ? {
  346. e: common_vendor.p({
  347. icon: "/static/order-empty.png",
  348. text: "暂无订单"
  349. })
  350. } : {}, {
  351. f: state.pagination.total > 0
  352. }, state.pagination.total > 0 ? {
  353. g: common_vendor.f(state.pagination.list, (order, index, i0) => {
  354. return common_vendor.e({
  355. a: common_vendor.t(order.no),
  356. b: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatOrderStatus)(order)),
  357. c: common_vendor.n(common_vendor.unref(sheep_hooks_useGoods.formatOrderColor)(order)),
  358. d: common_vendor.f(order.items, (item, k1, i1) => {
  359. return {
  360. a: "456ecf67-4-" + i0 + "-" + i1 + ",456ecf67-0",
  361. b: common_vendor.p({
  362. img: item.picUrl,
  363. title: item.spuName,
  364. skuText: item.properties.map((property) => property.valueName).join(" "),
  365. price: item.spuPayType === 2 ? item.highPrecisionPrice : item.price,
  366. num: item.count,
  367. virtualPirce: item.spuPayType === 2
  368. }),
  369. c: item.id
  370. };
  371. }),
  372. e: common_vendor.t(order.productCount),
  373. f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(order.payPrice)),
  374. g: order.buttons.includes("combination")
  375. }, order.buttons.includes("combination") ? {
  376. h: common_vendor.o(($event) => onOrderGroupon(order), order.id)
  377. } : {}, {
  378. i: order.buttons.length === 0
  379. }, order.buttons.length === 0 ? {
  380. j: common_vendor.o(($event) => onOrderDetail(order.id), order.id)
  381. } : {}, {
  382. k: order.buttons.includes("express")
  383. }, order.buttons.includes("express") ? {
  384. l: common_vendor.o(($event) => onExpress(order.id), order.id)
  385. } : {}, {
  386. m: order.buttons.includes("confirm")
  387. }, order.buttons.includes("confirm") ? {
  388. n: common_vendor.o(($event) => onConfirm(order), order.id)
  389. } : {}, {
  390. o: order.buttons.includes("cancel")
  391. }, order.buttons.includes("cancel") ? {
  392. p: common_vendor.o(($event) => onCancel(order.id), order.id)
  393. } : {}, {
  394. q: order.buttons.includes("comment")
  395. }, order.buttons.includes("comment") ? {
  396. r: common_vendor.o(($event) => onComment(order.id), order.id)
  397. } : {}, {
  398. s: order.buttons.includes("delete")
  399. }, order.buttons.includes("delete") ? {
  400. t: common_vendor.o(($event) => onDelete(order.id), order.id)
  401. } : {}, {
  402. v: order.buttons.includes("pay")
  403. }, order.buttons.includes("pay") ? {
  404. w: common_vendor.o(($event) => onPay(order.id), order.id)
  405. } : {}, {
  406. x: common_vendor.n(order.buttons.length > 3 ? "ss-row-between" : "ss-row-right"),
  407. y: order.id,
  408. z: common_vendor.o(($event) => onOrderDetail(order.id), order.id)
  409. });
  410. })
  411. } : {}, {
  412. h: state.pagination.total > 0
  413. }, state.pagination.total > 0 ? {
  414. i: common_vendor.o(_ctx.loadmore),
  415. j: common_vendor.p({
  416. status: state.loadStatus,
  417. ["content-text"]: {
  418. contentdown: "上拉加载更多"
  419. }
  420. })
  421. } : {}, {
  422. k: common_vendor.p({
  423. title: "我的订单"
  424. })
  425. });
  426. };
  427. }
  428. };
  429. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-456ecf67"], ["__file", "D:/zx/mall-front-app/pages/order/list.vue"]]);
  430. wx.createPage(MiniProgramPage);