confirmPackageOrder.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. const EvanSwitch = () => "../components/evan-switch/evan-switch.js";
  4. const popupBottom = () => "../components/px-popup-bottom/px-popup-bottom.js";
  5. const _sfc_main = {
  6. components: {
  7. EvanSwitch,
  8. popupBottom
  9. },
  10. data() {
  11. return {
  12. liveId: null,
  13. temps: [],
  14. totalMoney: 0,
  15. couponUserId: null,
  16. couponText: "\u8BF7\u9009\u62E9",
  17. couponsList: [],
  18. couponVisible: false,
  19. companyUserId: null,
  20. packageId: null,
  21. address: null,
  22. package: {},
  23. form: {
  24. orderKey: null,
  25. addressId: null,
  26. mark: null
  27. }
  28. };
  29. },
  30. onLoad(option) {
  31. },
  32. onShow() {
  33. },
  34. methods: {
  35. getWeixinTemps: function() {
  36. getWeixinTemps().then((res) => {
  37. if (res.code == 200) {
  38. this.temps = res.temp;
  39. }
  40. }, (rej) => {
  41. });
  42. },
  43. couponSelect(item) {
  44. this.couponText = "-\xA5" + item.couponPrice.toFixed(2);
  45. this.couponUserId = item.id;
  46. this.couponVisible = false;
  47. this.computedPackageOrder();
  48. },
  49. openCoupon() {
  50. let that = this;
  51. var data = { packageCateId: this.package.cateId, couponType: 1, useMinPrice: this.totalMoney };
  52. getMyEnableCouponList(data).then((res) => {
  53. this.couponVisible = true;
  54. that.couponsList = res.data;
  55. });
  56. },
  57. confirmPackageOrder() {
  58. let data = { packageId: this.packageId, couponUserId: this.couponUserId };
  59. confirmPackageOrder(data).then((res) => {
  60. if (res.code == 200) {
  61. this.form.orderKey = res.orderKey;
  62. this.address = res.address;
  63. this.package = res.package;
  64. if (res.address != null) {
  65. this.form.addressId = res.address.id;
  66. }
  67. this.totalMoney = res.totalMoney;
  68. } else {
  69. common_vendor.index.showToast({
  70. icon: "none",
  71. title: res.msg
  72. });
  73. }
  74. }, (rej) => {
  75. });
  76. },
  77. computedPackageOrder() {
  78. let data = { packageId: this.packageId, couponUserId: this.couponUserId };
  79. computedPackageOrder(data).then((res) => {
  80. if (res.code == 200) {
  81. this.totalMoney = res.totalMoney;
  82. } else {
  83. common_vendor.index.showToast({
  84. icon: "none",
  85. title: res.msg
  86. });
  87. }
  88. }, (rej) => {
  89. });
  90. },
  91. submitOrder() {
  92. var that = this;
  93. if (this.form.orderKey == null) {
  94. common_vendor.index.showToast({
  95. icon: "none",
  96. title: "\u8BA2\u5355KEY\u4E0D\u5B58\u5728"
  97. });
  98. return;
  99. }
  100. if (this.form.addressId == null) {
  101. common_vendor.index.showToast({
  102. icon: "none",
  103. title: "\u6536\u8D27\u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A"
  104. });
  105. return;
  106. }
  107. common_vendor.index.requestSubscribeMessage({
  108. tmplIds: this.temps,
  109. success(res) {
  110. that.createPackageOrder();
  111. },
  112. fail(res) {
  113. that.createPackageOrder();
  114. }
  115. });
  116. },
  117. createPackageOrder() {
  118. common_vendor.index.showLoading({
  119. title: "\u6B63\u5728\u5904\u7406\u4E2D..."
  120. });
  121. let data = { couponUserId: this.couponUserId, mark: this.form.mark, orderKey: this.form.orderKey, addressId: this.form.addressId, packageId: this.packageId, companyUserId: this.companyUserId };
  122. createPackageOrder(data).then((res) => {
  123. common_vendor.index.hideLoading();
  124. if (res.code == 200) {
  125. if (res.order.isPrescribe == 1) {
  126. setTimeout(function() {
  127. common_vendor.index.redirectTo({
  128. url: "prescribe?orderId=" + res.order.id
  129. });
  130. }, 200);
  131. } else {
  132. setTimeout(function() {
  133. common_vendor.index.redirectTo({
  134. url: "./paymentOrder?orderId=" + res.order.id
  135. });
  136. }, 200);
  137. }
  138. return;
  139. } else {
  140. if (res.code == 501) {
  141. common_vendor.index.showToast({
  142. icon: "none",
  143. title: res.msg
  144. });
  145. setTimeout(function() {
  146. common_vendor.index.navigateBack({
  147. delta: 1
  148. });
  149. }, 200);
  150. return;
  151. } else {
  152. common_vendor.index.showToast({
  153. icon: "none",
  154. title: res.msg
  155. });
  156. }
  157. }
  158. }, (rej) => {
  159. });
  160. },
  161. openAddress() {
  162. common_vendor.index.navigateTo({
  163. url: "/pages_user/user/address"
  164. });
  165. }
  166. }
  167. };
  168. if (!Array) {
  169. const _component_popupBottom = common_vendor.resolveComponent("popupBottom");
  170. _component_popupBottom();
  171. }
  172. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  173. return common_vendor.e({
  174. a: $data.address == null
  175. }, $data.address == null ? {
  176. b: common_vendor.o(($event) => $options.openAddress())
  177. } : {}, {
  178. c: $data.address != null
  179. }, $data.address != null ? common_vendor.e({
  180. d: common_vendor.t($data.address.realName),
  181. e: $data.address.phone != null
  182. }, $data.address.phone != null ? {
  183. f: common_vendor.t(_ctx.utils.parsePhone($data.address.phone))
  184. } : {}, {
  185. g: common_vendor.t($data.address.province),
  186. h: common_vendor.t($data.address.city),
  187. i: common_vendor.t($data.address.district),
  188. j: common_vendor.t($data.address.detail),
  189. k: common_vendor.o(($event) => $options.openAddress())
  190. }) : {}, {
  191. l: $data.package.imgUrl,
  192. m: common_vendor.t($data.package.title),
  193. n: common_vendor.t($data.package.descs),
  194. o: $data.package.payMoney != null
  195. }, $data.package.payMoney != null ? {
  196. p: common_vendor.t($data.package.payMoney.toFixed(2))
  197. } : {}, {
  198. q: $data.package.payMoney != null
  199. }, $data.package.payMoney != null ? {
  200. r: common_vendor.t($data.package.payMoney.toFixed(2))
  201. } : {}, {
  202. s: common_vendor.t($data.couponText),
  203. t: common_vendor.o(($event) => $options.openCoupon()),
  204. v: $data.form.mark,
  205. w: common_vendor.o(($event) => $data.form.mark = $event.detail.value),
  206. x: $data.totalMoney != null
  207. }, $data.totalMoney != null ? {
  208. y: common_vendor.t($data.totalMoney.toFixed(2))
  209. } : {}, {
  210. z: common_vendor.o((...args) => $options.submitOrder && $options.submitOrder(...args)),
  211. A: $data.couponsList.length > 0
  212. }, $data.couponsList.length > 0 ? {
  213. B: common_vendor.f($data.couponsList, (item, index, i0) => {
  214. return common_vendor.e({
  215. a: item.status == 0
  216. }, item.status == 0 ? {} : {}, {
  217. b: item.status != 0
  218. }, item.status != 0 ? {} : {}, {
  219. c: common_vendor.t(item.couponPrice),
  220. d: common_vendor.t(item.useMinPrice),
  221. e: common_vendor.t(item.couponTitle),
  222. f: common_vendor.t(item.limitTime),
  223. g: common_vendor.o(($event) => $options.couponSelect(item)),
  224. h: index
  225. });
  226. })
  227. } : {}, {
  228. C: $data.couponsList.length == 0
  229. }, $data.couponsList.length == 0 ? {} : {}, {
  230. D: common_vendor.sr("popup", "6a46ad18-0"),
  231. E: common_vendor.p({
  232. visible: $data.couponVisible,
  233. title: " ",
  234. bgColor: "#f5f5f5",
  235. radius: "30",
  236. maxHeight: "60%"
  237. })
  238. });
  239. }
  240. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6a46ad18"], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages_shop/confirmPackageOrder.vue"]]);
  241. wx.createPage(MiniProgramPage);