confirmCreateOrder.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_order = require("../api/order.js");
  4. require("../common/request.js");
  5. const EvanSwitch = () => "../components/evan-switch/evan-switch.js";
  6. const popupBottom = () => "../components/px-popup-bottom/px-popup-bottom.js";
  7. const _sfc_main = {
  8. components: {
  9. EvanSwitch,
  10. popupBottom
  11. },
  12. data() {
  13. return {
  14. address: null,
  15. addressId: null,
  16. totalNum: null,
  17. orderKey: null,
  18. price: null,
  19. liveId: null,
  20. orderList: [],
  21. userInfo: null,
  22. userAddrLiat: [],
  23. temps: [],
  24. couponUserId: null,
  25. couponText: "\u8BF7\u9009\u62E9",
  26. couponsList: [],
  27. couponVisible: false,
  28. priceAll: {
  29. payPrice: 0,
  30. totalPostage: 0,
  31. usedIntegral: 0,
  32. totalPrice: 0
  33. },
  34. address: null,
  35. carts: [],
  36. checked: false,
  37. type: null,
  38. cartIds: null,
  39. confirmParam: []
  40. };
  41. },
  42. computed: {
  43. priceSum() {
  44. return this.price * this.totalNum;
  45. }
  46. },
  47. onLoad(options) {
  48. console.log("\u786E\u8BA4\u8BA2\u5355", options);
  49. this.orderKey = options.orderKey;
  50. this.liveId = options.liveId;
  51. this.productId = options.productId;
  52. this.totalNum = Number(options.totalNum);
  53. this.price = Number(options.price);
  54. },
  55. mounted() {
  56. common_vendor.index.$on("updateAddress", (e) => {
  57. this.address = e;
  58. this.addressId = e.addressId;
  59. });
  60. },
  61. beforeDestroy() {
  62. common_vendor.index.$off("updateAddress");
  63. },
  64. methods: {
  65. createLiveOrder() {
  66. let data = {
  67. liveId: this.liveId,
  68. orderKey: this.orderKey,
  69. userName: "\u6CA1\u540D\u5B57",
  70. userPhone: "1234568",
  71. userAddress: "\u968F\u4FBF\u4F4F",
  72. productId: this.productId,
  73. totalNum: this.totalNum
  74. };
  75. return api_order.createliveOrder(data).then((res) => {
  76. if (res.code == 200) {
  77. this.orderList = res.order;
  78. return res.order;
  79. } else {
  80. common_vendor.index.showToast({
  81. title: res.msg,
  82. icon: "none"
  83. });
  84. throw new Error(res.msg);
  85. }
  86. });
  87. },
  88. getWeixinOrderTemps: function() {
  89. getWeixinOrderTemps().then((res) => {
  90. if (res.code == 200) {
  91. this.temps = res.temp;
  92. }
  93. }, (rej) => {
  94. });
  95. },
  96. couponSelect(item) {
  97. this.couponText = "-\xA5" + item.couponPrice.toFixed(2);
  98. this.couponUserId = item.id;
  99. this.couponVisible = false;
  100. this.computed();
  101. },
  102. openCoupon() {
  103. let that = this;
  104. var data = {
  105. couponType: 2,
  106. useMinPrice: this.price.payPrice
  107. };
  108. getMyEnableCouponList(data).then((res) => {
  109. this.couponVisible = true;
  110. that.couponsList = res.data;
  111. });
  112. },
  113. integralChange(e) {
  114. this.form.useIntegral = e ? 1 : 0;
  115. this.computed();
  116. },
  117. async submitOrder() {
  118. try {
  119. if (this.orderKey == null) {
  120. common_vendor.index.showToast({
  121. icon: "none",
  122. title: "\u8BA2\u5355KEY\u4E0D\u5B58\u5728"
  123. });
  124. return;
  125. }
  126. if (this.address == null) {
  127. common_vendor.index.showToast({
  128. icon: "none",
  129. title: "\u6536\u8D27\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A"
  130. });
  131. return;
  132. }
  133. const orderList = await this.createLiveOrder();
  134. const orderListStr = encodeURIComponent(JSON.stringify(orderList));
  135. common_vendor.index.navigateTo({
  136. url: `/pages_shop/paymentOrder?orderList=${orderListStr}`
  137. });
  138. } catch (error) {
  139. console.error("\u8BA2\u5355\u521B\u5EFA\u5931\u8D25:", error);
  140. common_vendor.index.showToast({
  141. title: "\u63D0\u4EA4\u5931\u8D25",
  142. icon: "none"
  143. });
  144. }
  145. },
  146. openAddress() {
  147. common_vendor.index.navigateTo({
  148. url: "/pages_user/address"
  149. });
  150. }
  151. }
  152. };
  153. if (!Array) {
  154. const _component_popupBottom = common_vendor.resolveComponent("popupBottom");
  155. _component_popupBottom();
  156. }
  157. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  158. var _a, _b, _c;
  159. return common_vendor.e({
  160. a: $data.address == null
  161. }, $data.address == null ? {
  162. b: common_vendor.o(($event) => $options.openAddress())
  163. } : {}, {
  164. c: $data.address != null
  165. }, $data.address != null ? common_vendor.e({
  166. d: common_vendor.t($data.address.realName),
  167. e: $data.address.phone != null
  168. }, $data.address.phone != null ? {
  169. f: common_vendor.t(_ctx.$parsePhone($data.address.phone))
  170. } : {}, {
  171. g: common_vendor.t($data.address.province),
  172. h: common_vendor.t($data.address.city),
  173. i: common_vendor.t($data.address.district),
  174. j: common_vendor.t($data.address.detail),
  175. k: common_vendor.o(($event) => $options.openAddress())
  176. }) : {}, {
  177. l: common_vendor.f($data.carts, (shop, idx, i0) => {
  178. return common_vendor.e({
  179. a: shop.storeName && shop.storeName != "null"
  180. }, shop.storeName && shop.storeName != "null" ? {
  181. b: common_vendor.t(shop.storeName)
  182. } : {}, {
  183. c: common_vendor.f(shop.list, (item, index, i1) => {
  184. var _a2;
  185. return {
  186. a: item.productAttrImage ? item.productAttrImage : item.productImage,
  187. b: common_vendor.t(_ctx.utils.getDictLabelName("storeProductType", item.productType)),
  188. c: common_vendor.t(item.productName),
  189. d: common_vendor.t(item.productAttrName),
  190. e: common_vendor.t((_a2 = item.price) == null ? void 0 : _a2.toFixed(2)),
  191. f: common_vendor.t(item.cartNum),
  192. g: index
  193. };
  194. })
  195. }, $data.price && $data.price.length > 0 ? {
  196. d: common_vendor.t($data.price[idx].payPostage == null || $data.price[idx].payPostage == 0 ? "\u514D\u8FD0\u8D39" : $data.price[idx].payPostage.toFixed(2))
  197. } : {}, {
  198. e: shop.markinfo,
  199. f: common_vendor.o(($event) => shop.markinfo = $event.detail.value),
  200. g: idx
  201. });
  202. }),
  203. m: $data.price && $data.price.length > 0,
  204. n: common_vendor.t((_a = $data.price) == null ? void 0 : _a.toFixed(2)),
  205. o: common_vendor.t((_b = $options.priceSum) == null ? void 0 : _b.toFixed(2)),
  206. p: common_vendor.t((_c = $options.priceSum) == null ? void 0 : _c.toFixed(2)),
  207. q: common_vendor.o((...args) => $options.submitOrder && $options.submitOrder(...args)),
  208. r: $data.couponsList.length > 0
  209. }, $data.couponsList.length > 0 ? {
  210. s: common_vendor.f($data.couponsList, (item, index, i0) => {
  211. return common_vendor.e({
  212. a: item.status == 0
  213. }, item.status == 0 ? {} : {}, {
  214. b: item.status != 0
  215. }, item.status != 0 ? {} : {}, {
  216. c: common_vendor.t(item.couponPrice),
  217. d: common_vendor.t(item.useMinPrice),
  218. e: common_vendor.t(item.couponTitle),
  219. f: common_vendor.t(item.limitTime),
  220. g: common_vendor.o(($event) => $options.couponSelect(item)),
  221. h: index
  222. });
  223. })
  224. } : {}, {
  225. t: $data.couponsList.length == 0
  226. }, $data.couponsList.length == 0 ? {} : {}, {
  227. v: common_vendor.sr("popup", "bb501b1c-0"),
  228. w: common_vendor.p({
  229. visible: $data.couponVisible,
  230. title: " ",
  231. bgColor: "#f5f5f5",
  232. radius: "30",
  233. maxHeight: "60%"
  234. })
  235. });
  236. }
  237. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-bb501b1c"], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages_shop/confirmCreateOrder.vue"]]);
  238. wx.createPage(MiniProgramPage);