detail.js 15 KB

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