confirmPackageOrder.js 7.8 KB

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