detail.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. const sheep_hooks_useModal = require("../../sheep/hooks/useModal.js");
  7. require("../../sheep/api/index.js");
  8. require("../../sheep/api/distri/score.js");
  9. require("../../sheep/request/index.js");
  10. require("../../sheep/config/index.js");
  11. require("../../sheep/store/index.js");
  12. require("../../sheep/store/app.js");
  13. require("../../sheep/api/promotion/diy.js");
  14. require("../../sheep/platform/index.js");
  15. require("../../sheep/platform/provider/wechat/index.js");
  16. require("../../sheep/platform/provider/wechat/miniProgram.js");
  17. require("../../sheep/api/member/auth.js");
  18. require("../../sheep/api/member/social.js");
  19. require("../../sheep/api/member/user.js");
  20. require("../../sheep/platform/provider/apple/index.js");
  21. require("../../sheep/platform/share.js");
  22. require("../../sheep/router/index.js");
  23. require("../../sheep/helper/throttle.js");
  24. require("../../sheep/url/index.js");
  25. require("../../sheep/platform/pay.js");
  26. require("../../sheep/helper/index.js");
  27. require("../../sheep/helper/test.js");
  28. require("../../sheep/helper/digit.js");
  29. require("../../sheep/api/pay/order.js");
  30. require("../../sheep/store/user.js");
  31. require("../../sheep/store/cart.js");
  32. require("../../sheep/api/trade/cart.js");
  33. require("../../sheep/api/pay/wallet.js");
  34. require("../../sheep/api/promotion/coupon.js");
  35. require("../../sheep/store/sys.js");
  36. require("../../sheep/store/modal.js");
  37. require("../../sheep/api/distri/share.js");
  38. require("../../sheep/api/distri/team.js");
  39. require("../../sheep/api/infra/file.js");
  40. require("../../sheep/api/member/address.js");
  41. require("../../sheep/api/member/point.js");
  42. require("../../sheep/api/member/signin.js");
  43. require("../../sheep/api/migration/app.js");
  44. require("../../sheep/api/migration/chat.js");
  45. require("../../sheep/api/migration/index.js");
  46. require("../../sheep/api/migration/third.js");
  47. require("../../sheep/api/pay/channel.js");
  48. require("../../sheep/api/product/category.js");
  49. require("../../sheep/api/product/comment.js");
  50. require("../../sheep/api/product/favorite.js");
  51. require("../../sheep/api/product/history.js");
  52. require("../../sheep/api/product/spu.js");
  53. require("../../sheep/api/promotion/activity.js");
  54. require("../../sheep/api/promotion/article.js");
  55. require("../../sheep/api/promotion/bargain.js");
  56. require("../../sheep/api/promotion/combination.js");
  57. require("../../sheep/api/promotion/rewardActivity.js");
  58. require("../../sheep/api/promotion/seckill.js");
  59. require("../../sheep/api/system/area.js");
  60. require("../../sheep/api/system/voice.js");
  61. require("../../sheep/api/trade/afterSale.js");
  62. require("../../sheep/api/trade/brokerage.js");
  63. require("../../sheep/api/trade/config.js");
  64. require("../../sheep/api/trade/delivery.js");
  65. require("../../sheep/config/zIndex.js");
  66. require("../../sheep/util/index.js");
  67. if (!Array) {
  68. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  69. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  70. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  71. (_easycom_s_goods_item2 + _easycom_su_fixed2 + _easycom_s_layout2)();
  72. }
  73. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  74. const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";
  75. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  76. if (!Math) {
  77. (_easycom_s_goods_item + _easycom_su_fixed + _easycom_s_layout)();
  78. }
  79. const _sfc_main = {
  80. __name: "detail",
  81. setup(__props) {
  82. common_vendor.useCssVars((_ctx) => ({
  83. "7295e610": common_vendor.unref(headerBg)
  84. }));
  85. sheep_index.sheep.$store("user").userInfo;
  86. const statusBarHeight = sheep_index.sheep.$platform.device.statusBarHeight * 2;
  87. const headerBg = sheep_index.sheep.$url.css("/static/images/order_bg.png");
  88. const state = common_vendor.reactive({
  89. orderInfo: {},
  90. merchantTradeNo: "",
  91. // 商户订单号
  92. comeinType: ""
  93. // 进入订单详情的来源类型
  94. });
  95. const onCopy = () => {
  96. sheep_index.sheep.$helper.copyText(state.orderInfo.no);
  97. };
  98. function onPay(id) {
  99. sheep_index.sheep.$router.go("/pages/pay/index", {
  100. id,
  101. openType: 2
  102. });
  103. }
  104. function onGoodsDetail(id) {
  105. sheep_index.sheep.$router.go("/pages/goods/index", {
  106. id
  107. });
  108. }
  109. async function onCancel(orderId) {
  110. common_vendor.index.showModal({
  111. title: "提示",
  112. content: "确定要取消订单吗?",
  113. success: async function(res) {
  114. if (!res.confirm) {
  115. return;
  116. }
  117. const {
  118. code
  119. } = await sheep_api_trade_order.OrderApi.cancelOrder(orderId);
  120. if (code === 0) {
  121. await getOrderDetail(orderId);
  122. }
  123. }
  124. });
  125. }
  126. async function onExpress(id) {
  127. sheep_index.sheep.$router.go("/pages/order/express/log", {
  128. id
  129. });
  130. }
  131. async function onConfirm(orderId, ignore = false) {
  132. let isOpenBusinessView = true;
  133. common_vendor.index.showModal({
  134. title: "提示",
  135. content: "确认收货?",
  136. success: async function(res) {
  137. if (res.confirm) {
  138. if (sheep_index.sheep.$platform.name === "WechatMiniProgram" && !common_vendor.lodashExports.isEmpty(state.orderInfo.wechat_extra_data) && isOpenBusinessView && !ignore) {
  139. mpConfirm(orderId);
  140. return;
  141. }
  142. const {
  143. code
  144. } = await sheep_api_trade_order.OrderApi.receiveOrder(orderId);
  145. if (code === 0) {
  146. await getOrderDetail(orderId);
  147. }
  148. }
  149. }
  150. });
  151. }
  152. function mpConfirm(orderId) {
  153. if (!common_vendor.wx$1.openBusinessView) {
  154. sheep_index.sheep.$helper.toast(`请升级微信版本`);
  155. return;
  156. }
  157. common_vendor.wx$1.openBusinessView({
  158. businessType: "weappOrderConfirm",
  159. extraData: {
  160. merchant_trade_no: state.orderInfo.wechat_extra_data.merchant_trade_no,
  161. transaction_id: state.orderInfo.wechat_extra_data.transaction_id
  162. },
  163. success(response) {
  164. console.log("success:", response);
  165. if (response.errMsg === "openBusinessView:ok") {
  166. if (response.extraData.status === "success") {
  167. onConfirm(orderId, true);
  168. }
  169. }
  170. },
  171. fail(error) {
  172. console.log("error:", error);
  173. },
  174. complete(result) {
  175. console.log("result:", result);
  176. }
  177. });
  178. }
  179. function onComment(id) {
  180. sheep_index.sheep.$router.go("/pages/goods/comment/add", {
  181. id
  182. });
  183. }
  184. async function getOrderDetail(id) {
  185. let res;
  186. if (state.comeinType === "wechat") {
  187. res = await sheep_api_trade_order.OrderApi.getOrder(id, {
  188. merchant_trade_no: state.merchantTradeNo
  189. });
  190. } else {
  191. res = await sheep_api_trade_order.OrderApi.getOrder(id);
  192. }
  193. if (res.code === 0) {
  194. state.orderInfo = res.data;
  195. sheep_hooks_useGoods.handleOrderButtons(state.orderInfo);
  196. } else {
  197. sheep_index.sheep.$router.back();
  198. }
  199. }
  200. const isLogin = common_vendor.computed(() => sheep_index.sheep.$store("user").isLogin);
  201. common_vendor.watch(
  202. () => isLogin.value,
  203. (newVal) => {
  204. if (newVal) {
  205. window.location.reload();
  206. }
  207. },
  208. {
  209. deep: true
  210. // 深度监听
  211. }
  212. );
  213. common_vendor.onLoad(async (options) => {
  214. if (!isLogin.value) {
  215. sheep_hooks_useModal.showAuthModal();
  216. sheep_index.sheep.$helper.toast("您尚未登录,请登录:" + options.username + "后再试", 3e3);
  217. } else {
  218. if (options.username) {
  219. console.log(JSON.parse(common_vendor.index.getStorageSync("user-store")).userInfo.username);
  220. if (options.username != JSON.parse(common_vendor.index.getStorageSync("user-store")).userInfo.username) {
  221. sheep_index.sheep.$helper.toast(
  222. "您当前登录的账号是" + JSON.parse(common_vendor.index.getStorageSync("user-store")).userInfo.username + ",请切换到" + options.username + "后再试",
  223. 3e3
  224. );
  225. }
  226. }
  227. }
  228. let id = 0;
  229. if (options.id) {
  230. id = options.id;
  231. }
  232. state.comeinType = options.comein_type;
  233. if (state.comeinType === "wechat") {
  234. state.merchantTradeNo = options.merchant_trade_no;
  235. }
  236. await getOrderDetail(id);
  237. });
  238. return (_ctx, _cache) => {
  239. var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
  240. return common_vendor.e({
  241. a: state.orderInfo.status_code == "unpaid" || state.orderInfo.status === 10 || // 待发货
  242. state.orderInfo.status_code == "nocomment"
  243. }, state.orderInfo.status_code == "unpaid" || state.orderInfo.status === 10 || state.orderInfo.status_code == "nocomment" ? {
  244. b: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order_loading.png")
  245. } : {}, {
  246. c: state.orderInfo.status_code == "completed" || state.orderInfo.status_code == "refund_agree"
  247. }, state.orderInfo.status_code == "completed" || state.orderInfo.status_code == "refund_agree" ? {
  248. d: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order_success.png")
  249. } : {}, {
  250. e: state.orderInfo.status_code == "cancel" || state.orderInfo.status_code == "closed"
  251. }, state.orderInfo.status_code == "cancel" || state.orderInfo.status_code == "closed" ? {
  252. f: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order_close.png")
  253. } : {}, {
  254. g: state.orderInfo.status_code == "noget"
  255. }, state.orderInfo.status_code == "noget" ? {
  256. h: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order_express.png")
  257. } : {}, {
  258. i: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatOrderStatus)(state.orderInfo)),
  259. j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatOrderStatusDescription)(state.orderInfo)),
  260. k: common_vendor.s({
  261. marginTop: "-" + Number(statusBarHeight + 88) + "rpx",
  262. paddingTop: Number(statusBarHeight + 88) + "rpx"
  263. }),
  264. l: state.orderInfo.receiverAreaId > 0
  265. }, state.orderInfo.receiverAreaId > 0 ? {
  266. m: common_vendor.t(state.orderInfo.receiverName),
  267. n: common_vendor.t(state.orderInfo.receiverMobile),
  268. o: common_vendor.t(state.orderInfo.receiverAreaName),
  269. p: common_vendor.t(state.orderInfo.receiverDetailAddress)
  270. } : {}, {
  271. q: common_vendor.f(state.orderInfo.items, (item, k0, i0) => {
  272. return common_vendor.e({
  273. a: [10, 20, 30].includes(state.orderInfo.status) && item.afterSaleStatus === 0
  274. }, [10, 20, 30].includes(state.orderInfo.status) && item.afterSaleStatus === 0 ? {
  275. b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/apply", {
  276. orderId: state.orderInfo.id,
  277. itemId: item.id
  278. }), item.goods_id)
  279. } : {}, {
  280. c: item.afterSaleStatus === 10
  281. }, item.afterSaleStatus === 10 ? {
  282. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/detail", {
  283. id: item.afterSaleId
  284. }), item.goods_id)
  285. } : {}, {
  286. e: item.afterSaleStatus === 20
  287. }, item.afterSaleStatus === 20 ? {
  288. f: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/aftersale/detail", {
  289. id: item.afterSaleId
  290. }), item.goods_id)
  291. } : {}, {
  292. g: item.status_text
  293. }, item.status_text ? {
  294. h: common_vendor.t(item.status_text)
  295. } : {}, {
  296. i: common_vendor.o(($event) => onGoodsDetail(item.spuId), item.goods_id),
  297. j: "6b23c96c-1-" + i0 + ",6b23c96c-0",
  298. k: common_vendor.p({
  299. img: item.picUrl,
  300. title: item.spuName,
  301. skuText: item.properties.map((property) => property.valueName).join(" "),
  302. price: item.spuPayType === 2 ? item.highPrecisionPrice : item.price,
  303. num: item.count,
  304. virtualPirce: item.spuPayType === 2
  305. }),
  306. l: item.goods_id
  307. });
  308. }),
  309. r: common_vendor.s({
  310. marginTop: state.orderInfo.receiverAreaId > 0 ? "0" : "-40rpx"
  311. }),
  312. s: common_vendor.t(state.orderInfo.no),
  313. t: common_vendor.o(onCopy),
  314. v: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.points2point)(state.orderInfo.payIntegral)),
  315. w: common_vendor.t(state.orderInfo.userRemark || "无"),
  316. x: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(state.orderInfo.createTime, "yyyy-mm-dd hh:MM:ss")),
  317. y: state.orderInfo.payTime
  318. }, state.orderInfo.payTime ? {
  319. z: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(state.orderInfo.payTime, "yyyy-mm-dd hh:MM:ss"))
  320. } : {}, {
  321. A: common_vendor.t(state.orderInfo.payChannelName || "-"),
  322. B: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.totalPrice)),
  323. C: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.deliveryPrice)),
  324. D: state.orderInfo.discountPrice > 0
  325. }, state.orderInfo.discountPrice > 0 ? {
  326. E: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.discountPrice))
  327. } : {}, {
  328. F: common_vendor.t(state.orderInfo.payStatus ? "已付款" : "需付款"),
  329. G: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.payPrice)),
  330. H: state.orderInfo.refundPrice > 0
  331. }, state.orderInfo.refundPrice > 0 ? {
  332. I: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.refundPrice))
  333. } : {}, {
  334. J: (_a = state.orderInfo.buttons) == null ? void 0 : _a.length
  335. }, ((_b = state.orderInfo.buttons) == null ? void 0 : _b.length) ? common_vendor.e({
  336. K: (_c = state.orderInfo.buttons) == null ? void 0 : _c.includes("cancel")
  337. }, ((_d = state.orderInfo.buttons) == null ? void 0 : _d.includes("cancel")) ? {
  338. L: common_vendor.o(($event) => onCancel(state.orderInfo.id))
  339. } : {}, {
  340. M: (_e = state.orderInfo.buttons) == null ? void 0 : _e.includes("pay")
  341. }, ((_f = state.orderInfo.buttons) == null ? void 0 : _f.includes("pay")) ? {
  342. N: common_vendor.o(($event) => onPay(state.orderInfo.id))
  343. } : {}, {
  344. O: (_g = state.orderInfo.buttons) == null ? void 0 : _g.includes("combination")
  345. }, ((_h = state.orderInfo.buttons) == null ? void 0 : _h.includes("combination")) ? {
  346. P: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/activity/groupon/detail", {
  347. id: state.orderInfo.ext.groupon_id
  348. }))
  349. } : {}, {
  350. Q: (_i = state.orderInfo.buttons) == null ? void 0 : _i.includes("express")
  351. }, ((_j = state.orderInfo.buttons) == null ? void 0 : _j.includes("express")) ? {
  352. R: common_vendor.o(($event) => onExpress(state.orderInfo.id))
  353. } : {}, {
  354. S: (_k = state.orderInfo.buttons) == null ? void 0 : _k.includes("confirm")
  355. }, ((_l = state.orderInfo.buttons) == null ? void 0 : _l.includes("confirm")) ? {
  356. T: common_vendor.o(($event) => onConfirm(state.orderInfo.id))
  357. } : {}, {
  358. U: (_m = state.orderInfo.buttons) == null ? void 0 : _m.includes("comment")
  359. }, ((_n = state.orderInfo.buttons) == null ? void 0 : _n.includes("comment")) ? {
  360. V: common_vendor.o(($event) => onComment(state.orderInfo.id))
  361. } : {}, {
  362. W: common_vendor.p({
  363. bottom: true,
  364. placeholder: true,
  365. bg: "bg-white"
  366. })
  367. }) : {}, {
  368. X: common_vendor.s(_ctx.__cssVars()),
  369. Y: common_vendor.p({
  370. title: "订单详情",
  371. navbar: "inner"
  372. })
  373. });
  374. };
  375. }
  376. };
  377. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6b23c96c"], ["__file", "D:/zx/mall-front-app/pages/order/detail.vue"]]);
  378. wx.createPage(MiniProgramPage);