detail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.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/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/promotion/coupon.js");
  33. require("../../sheep/store/sys.js");
  34. require("../../sheep/store/modal.js");
  35. require("../../sheep/config/zIndex.js");
  36. require("../../sheep/util/index.js");
  37. if (!Array) {
  38. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  39. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  40. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  41. (_easycom_s_goods_item2 + _easycom_su_fixed2 + _easycom_s_layout2)();
  42. }
  43. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  44. const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";
  45. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  46. if (!Math) {
  47. (_easycom_s_goods_item + _easycom_su_fixed + _easycom_s_layout)();
  48. }
  49. const _sfc_main = {
  50. __name: "detail",
  51. setup(__props) {
  52. common_vendor.useCssVars((_ctx) => ({
  53. "7295e610": common_vendor.unref(headerBg)
  54. }));
  55. const statusBarHeight = sheep_index.sheep.$platform.device.statusBarHeight * 2;
  56. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/order/order_bg.png");
  57. const state = common_vendor.reactive({
  58. orderInfo: {},
  59. merchantTradeNo: "",
  60. // 商户订单号
  61. comeinType: ""
  62. // 进入订单详情的来源类型
  63. });
  64. const onCopy = () => {
  65. sheep_index.sheep.$helper.copyText(state.orderInfo.sn);
  66. };
  67. function onPay(payOrderId) {
  68. sheep_index.sheep.$router.go("/pages/pay/index", {
  69. id: payOrderId
  70. });
  71. }
  72. function onGoodsDetail(id) {
  73. sheep_index.sheep.$router.go("/pages/goods/index", {
  74. id
  75. });
  76. }
  77. async function onCancel(orderId) {
  78. common_vendor.index.showModal({
  79. title: "提示",
  80. content: "确定要取消订单吗?",
  81. success: async function(res) {
  82. if (!res.confirm) {
  83. return;
  84. }
  85. const { code } = await sheep_api_trade_order.OrderApi.cancelOrder(orderId);
  86. if (code === 0) {
  87. await getOrderDetail(orderId);
  88. }
  89. }
  90. });
  91. }
  92. async function onExpress(id) {
  93. sheep_index.sheep.$router.go("/pages/order/express/log", {
  94. id
  95. });
  96. }
  97. async function onConfirm(orderId, ignore = false) {
  98. let isOpenBusinessView = true;
  99. if (sheep_index.sheep.$platform.name === "WechatMiniProgram" && !common_vendor.lodashExports.isEmpty(state.orderInfo.wechat_extra_data) && isOpenBusinessView && !ignore) {
  100. mpConfirm(orderId);
  101. return;
  102. }
  103. const { code } = await sheep_api_trade_order.OrderApi.receiveOrder(orderId);
  104. if (code === 0) {
  105. await getOrderDetail(orderId);
  106. }
  107. }
  108. function mpConfirm(orderId) {
  109. if (!common_vendor.wx$1.openBusinessView) {
  110. sheep_index.sheep.$helper.toast(`请升级微信版本`);
  111. return;
  112. }
  113. common_vendor.wx$1.openBusinessView({
  114. businessType: "weappOrderConfirm",
  115. extraData: {
  116. merchant_trade_no: state.orderInfo.wechat_extra_data.merchant_trade_no,
  117. transaction_id: state.orderInfo.wechat_extra_data.transaction_id
  118. },
  119. success(response) {
  120. console.log("success:", response);
  121. if (response.errMsg === "openBusinessView:ok") {
  122. if (response.extraData.status === "success") {
  123. onConfirm(orderId, true);
  124. }
  125. }
  126. },
  127. fail(error) {
  128. console.log("error:", error);
  129. },
  130. complete(result) {
  131. console.log("result:", result);
  132. }
  133. });
  134. }
  135. function onComment(id) {
  136. sheep_index.sheep.$router.go("/pages/goods/comment/add", {
  137. id
  138. });
  139. }
  140. async function getOrderDetail(id) {
  141. let res;
  142. if (state.comeinType === "wechat") {
  143. res = await sheep_api_trade_order.OrderApi.getOrder(id, {
  144. merchant_trade_no: state.merchantTradeNo
  145. });
  146. } else {
  147. res = await sheep_api_trade_order.OrderApi.getOrder(id);
  148. }
  149. if (res.code === 0) {
  150. state.orderInfo = res.data;
  151. sheep_hooks_useGoods.handleOrderButtons(state.orderInfo);
  152. } else {
  153. sheep_index.sheep.$router.back();
  154. }
  155. }
  156. common_vendor.onLoad(async (options) => {
  157. let id = 0;
  158. if (options.id) {
  159. id = options.id;
  160. }
  161. state.comeinType = options.comein_type;
  162. if (state.comeinType === "wechat") {
  163. state.merchantTradeNo = options.merchant_trade_no;
  164. }
  165. await getOrderDetail(id);
  166. });
  167. return (_ctx, _cache) => {
  168. var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
  169. return common_vendor.e({
  170. a: state.orderInfo.status_code == "unpaid" || state.orderInfo.status === 10 || // 待发货
  171. state.orderInfo.status_code == "nocomment"
  172. }, state.orderInfo.status_code == "unpaid" || state.orderInfo.status === 10 || state.orderInfo.status_code == "nocomment" ? {
  173. b: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/order/order_loading.png")
  174. } : {}, {
  175. c: state.orderInfo.status_code == "completed" || state.orderInfo.status_code == "refund_agree"
  176. }, state.orderInfo.status_code == "completed" || state.orderInfo.status_code == "refund_agree" ? {
  177. d: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/order/order_success.png")
  178. } : {}, {
  179. e: state.orderInfo.status_code == "cancel" || state.orderInfo.status_code == "closed"
  180. }, state.orderInfo.status_code == "cancel" || state.orderInfo.status_code == "closed" ? {
  181. f: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/order/order_close.png")
  182. } : {}, {
  183. g: state.orderInfo.status_code == "noget"
  184. }, state.orderInfo.status_code == "noget" ? {
  185. h: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/order/order_express.png")
  186. } : {}, {
  187. i: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatOrderStatus)(state.orderInfo)),
  188. j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatOrderStatusDescription)(state.orderInfo)),
  189. k: common_vendor.s({
  190. marginTop: "-" + Number(statusBarHeight + 88) + "rpx",
  191. paddingTop: Number(statusBarHeight + 88) + "rpx"
  192. }),
  193. l: state.orderInfo.receiverAreaId > 0
  194. }, state.orderInfo.receiverAreaId > 0 ? {
  195. m: common_vendor.t(state.orderInfo.receiverName),
  196. n: common_vendor.t(state.orderInfo.receiverMobile),
  197. o: common_vendor.t(state.orderInfo.receiverAreaName),
  198. p: common_vendor.t(state.orderInfo.receiverDetailAddress)
  199. } : {}, {
  200. q: common_vendor.f(state.orderInfo.items, (item, k0, i0) => {
  201. return common_vendor.e({
  202. a: [10, 20, 30].includes(state.orderInfo.status) && item.afterSaleStatus === 0
  203. }, [10, 20, 30].includes(state.orderInfo.status) && item.afterSaleStatus === 0 ? {
  204. b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/apply", {
  205. orderId: state.orderInfo.id,
  206. itemId: item.id
  207. }), item.goods_id)
  208. } : {}, {
  209. c: item.afterSaleStatus === 10
  210. }, item.afterSaleStatus === 10 ? {
  211. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/detail", {
  212. id: item.afterSaleId
  213. }), item.goods_id)
  214. } : {}, {
  215. e: item.afterSaleStatus === 20
  216. }, item.afterSaleStatus === 20 ? {
  217. f: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/detail", {
  218. id: item.afterSaleId
  219. }), item.goods_id)
  220. } : {}, {
  221. g: item.status_text
  222. }, item.status_text ? {
  223. h: common_vendor.t(item.status_text)
  224. } : {}, {
  225. i: common_vendor.o(($event) => onGoodsDetail(item.skuId), item.goods_id),
  226. j: "6b23c96c-1-" + i0 + ",6b23c96c-0",
  227. k: common_vendor.p({
  228. img: item.picUrl,
  229. title: item.spuName,
  230. skuText: item.properties.map((property) => property.valueName).join(" "),
  231. price: item.price,
  232. num: item.count
  233. }),
  234. l: item.goods_id
  235. });
  236. }),
  237. r: common_vendor.s({
  238. marginTop: state.orderInfo.receiverAreaId > 0 ? "0" : "-40rpx"
  239. }),
  240. s: common_vendor.t(state.orderInfo.no),
  241. t: common_vendor.o(onCopy),
  242. v: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(state.orderInfo.createTime, "yyyy-mm-dd hh:MM:ss")),
  243. w: state.orderInfo.payTime
  244. }, state.orderInfo.payTime ? {
  245. x: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(state.orderInfo.payTime, "yyyy-mm-dd hh:MM:ss"))
  246. } : {}, {
  247. y: common_vendor.t(state.orderInfo.payChannelName || "-"),
  248. z: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.totalPrice)),
  249. A: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.deliveryPrice)),
  250. B: state.orderInfo.discountPrice > 0
  251. }, state.orderInfo.discountPrice > 0 ? {
  252. C: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.discountPrice))
  253. } : {}, {
  254. D: common_vendor.t(state.orderInfo.payStatus ? "已付款" : "需付款"),
  255. E: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.payPrice)),
  256. F: state.orderInfo.refundPrice > 0
  257. }, state.orderInfo.refundPrice > 0 ? {
  258. G: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.refundPrice))
  259. } : {}, {
  260. H: (_a = state.orderInfo.buttons) == null ? void 0 : _a.length
  261. }, ((_b = state.orderInfo.buttons) == null ? void 0 : _b.length) ? common_vendor.e({
  262. I: (_c = state.orderInfo.buttons) == null ? void 0 : _c.includes("cancel")
  263. }, ((_d = state.orderInfo.buttons) == null ? void 0 : _d.includes("cancel")) ? {
  264. J: common_vendor.o(($event) => onCancel(state.orderInfo.id))
  265. } : {}, {
  266. K: (_e = state.orderInfo.buttons) == null ? void 0 : _e.includes("pay")
  267. }, ((_f = state.orderInfo.buttons) == null ? void 0 : _f.includes("pay")) ? {
  268. L: common_vendor.o(($event) => onPay(state.orderInfo.payOrderId))
  269. } : {}, {
  270. M: (_g = state.orderInfo.buttons) == null ? void 0 : _g.includes("combination")
  271. }, ((_h = state.orderInfo.buttons) == null ? void 0 : _h.includes("combination")) ? {
  272. N: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/activity/groupon/detail", {
  273. id: state.orderInfo.ext.groupon_id
  274. }))
  275. } : {}, {
  276. O: (_i = state.orderInfo.buttons) == null ? void 0 : _i.includes("express")
  277. }, ((_j = state.orderInfo.buttons) == null ? void 0 : _j.includes("express")) ? {
  278. P: common_vendor.o(($event) => onExpress(state.orderInfo.id))
  279. } : {}, {
  280. Q: (_k = state.orderInfo.buttons) == null ? void 0 : _k.includes("confirm")
  281. }, ((_l = state.orderInfo.buttons) == null ? void 0 : _l.includes("confirm")) ? {
  282. R: common_vendor.o(($event) => onConfirm(state.orderInfo.id))
  283. } : {}, {
  284. S: (_m = state.orderInfo.buttons) == null ? void 0 : _m.includes("comment")
  285. }, ((_n = state.orderInfo.buttons) == null ? void 0 : _n.includes("comment")) ? {
  286. T: common_vendor.o(($event) => onComment(state.orderInfo.id))
  287. } : {}, {
  288. U: common_vendor.p({
  289. bottom: true,
  290. placeholder: true,
  291. bg: "bg-white"
  292. })
  293. }) : {}, {
  294. V: common_vendor.s(_ctx.__cssVars()),
  295. W: common_vendor.p({
  296. title: "订单详情",
  297. navbar: "inner"
  298. })
  299. });
  300. };
  301. }
  302. };
  303. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6b23c96c"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/order/detail.vue"]]);
  304. wx.createPage(MiniProgramPage);