123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- "use strict";
- const common_vendor = require("../common/vendor.js");
- const common_assets = require("../common/assets.js");
- const EvanSwitch = () => "../components/evan-switch/evan-switch.js";
- const popupBottom = () => "../components/px-popup-bottom/px-popup-bottom.js";
- const _sfc_main = {
- components: {
- EvanSwitch,
- popupBottom
- },
- data() {
- return {
- liveId: null,
- temps: [],
- totalMoney: 0,
- couponUserId: null,
- couponText: "请选择",
- couponsList: [],
- couponVisible: false,
- companyUserId: null,
- packageId: null,
- address: null,
- package: {},
- // checked: false,
- // type:null,
- // cartIds:null,
- form: {
- // useIntegral:0,
- orderKey: null,
- addressId: null,
- mark: null
- }
- };
- },
- onLoad(option) {
- },
- onShow() {
- },
- methods: {
- getWeixinTemps: function() {
- getWeixinTemps().then(
- (res) => {
- if (res.code == 200) {
- this.temps = res.temp;
- }
- },
- (rej) => {
- }
- );
- },
- couponSelect(item) {
- this.couponText = "-¥" + item.couponPrice.toFixed(2);
- this.couponUserId = item.id;
- this.couponVisible = false;
- this.computedPackageOrder();
- },
- openCoupon() {
- let that = this;
- var data = { packageCateId: this.package.cateId, couponType: 1, useMinPrice: this.totalMoney };
- getMyEnableCouponList(data).then((res) => {
- this.couponVisible = true;
- that.couponsList = res.data;
- });
- },
- confirmPackageOrder() {
- let data = { packageId: this.packageId, couponUserId: this.couponUserId };
- confirmPackageOrder(data).then(
- (res) => {
- if (res.code == 200) {
- this.form.orderKey = res.orderKey;
- this.address = res.address;
- this.package = res.package;
- if (res.address != null) {
- this.form.addressId = res.address.id;
- }
- this.totalMoney = res.totalMoney;
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- }
- },
- (rej) => {
- }
- );
- },
- computedPackageOrder() {
- let data = { packageId: this.packageId, couponUserId: this.couponUserId };
- computedPackageOrder(data).then(
- (res) => {
- if (res.code == 200) {
- this.totalMoney = res.totalMoney;
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- }
- },
- (rej) => {
- }
- );
- },
- // 提交订单
- submitOrder() {
- var that = this;
- if (this.form.orderKey == null) {
- common_vendor.index.showToast({
- icon: "none",
- title: "订单KEY不存在"
- });
- return;
- }
- if (this.form.addressId == null) {
- common_vendor.index.showToast({
- icon: "none",
- title: "收货地址不能为空"
- });
- return;
- }
- common_vendor.index.requestSubscribeMessage({
- tmplIds: this.temps,
- success(res) {
- that.createPackageOrder();
- },
- fail(res) {
- that.createPackageOrder();
- }
- });
- },
- createPackageOrder() {
- common_vendor.index.showLoading({
- title: "正在处理中..."
- });
- let data = { couponUserId: this.couponUserId, mark: this.form.mark, orderKey: this.form.orderKey, addressId: this.form.addressId, packageId: this.packageId, companyUserId: this.companyUserId };
- createPackageOrder(data).then(
- (res) => {
- common_vendor.index.hideLoading();
- if (res.code == 200) {
- if (res.order.isPrescribe == 1) {
- setTimeout(function() {
- common_vendor.index.redirectTo({
- url: "prescribe?orderId=" + res.order.id
- });
- }, 200);
- } else {
- setTimeout(function() {
- common_vendor.index.redirectTo({
- url: "./paymentOrder?orderId=" + res.order.id
- });
- }, 200);
- }
- return;
- } else {
- if (res.code == 501) {
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- setTimeout(function() {
- common_vendor.index.navigateBack({
- delta: 1
- });
- }, 200);
- return;
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- }
- }
- },
- (rej) => {
- }
- );
- },
- openAddress() {
- common_vendor.index.navigateTo({
- url: "/pages_user/user/address"
- });
- }
- }
- };
- if (!Array) {
- const _component_popupBottom = common_vendor.resolveComponent("popupBottom");
- _component_popupBottom();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: $data.address == null
- }, $data.address == null ? {
- b: common_assets._imports_0$11,
- c: common_vendor.o(($event) => $options.openAddress())
- } : {}, {
- d: $data.address != null
- }, $data.address != null ? common_vendor.e({
- e: common_vendor.t($data.address.realName),
- f: $data.address.phone != null
- }, $data.address.phone != null ? {
- g: common_vendor.t(_ctx.utils.parsePhone($data.address.phone))
- } : {}, {
- h: common_vendor.t($data.address.province),
- i: common_vendor.t($data.address.city),
- j: common_vendor.t($data.address.district),
- k: common_vendor.t($data.address.detail),
- l: common_assets._imports_0$11,
- m: common_vendor.o(($event) => $options.openAddress())
- }) : {}, {
- n: $data.package.imgUrl,
- o: common_vendor.t($data.package.title),
- p: common_vendor.t($data.package.descs),
- q: $data.package.payMoney != null
- }, $data.package.payMoney != null ? {
- r: common_vendor.t($data.package.payMoney.toFixed(2))
- } : {}, {
- s: $data.package.payMoney != null
- }, $data.package.payMoney != null ? {
- t: common_vendor.t($data.package.payMoney.toFixed(2))
- } : {}, {
- v: common_vendor.t($data.couponText),
- w: common_assets._imports_1$7,
- x: common_vendor.o(($event) => $options.openCoupon()),
- y: $data.form.mark,
- z: common_vendor.o(($event) => $data.form.mark = $event.detail.value),
- A: $data.totalMoney != null
- }, $data.totalMoney != null ? {
- B: common_vendor.t($data.totalMoney.toFixed(2))
- } : {}, {
- C: common_vendor.o((...args) => $options.submitOrder && $options.submitOrder(...args)),
- D: $data.couponsList.length > 0
- }, $data.couponsList.length > 0 ? {
- E: common_vendor.f($data.couponsList, (item, index, i0) => {
- return common_vendor.e({
- a: item.status == 0
- }, item.status == 0 ? {
- b: common_assets._imports_2$6
- } : {}, {
- c: item.status != 0
- }, item.status != 0 ? {
- d: common_assets._imports_3$2
- } : {}, {
- e: common_vendor.t(item.couponPrice),
- f: common_vendor.t(item.useMinPrice),
- g: common_vendor.t(item.couponTitle),
- h: common_vendor.t(item.limitTime),
- i: common_vendor.o(($event) => $options.couponSelect(item), index),
- j: index
- });
- })
- } : {}, {
- F: $data.couponsList.length == 0
- }, $data.couponsList.length == 0 ? {
- G: common_assets._imports_2$3
- } : {}, {
- H: common_vendor.sr("popup", "365fa217-0"),
- I: common_vendor.p({
- visible: $data.couponVisible,
- title: " ",
- bgColor: "#f5f5f5",
- radius: "30",
- maxHeight: "60%"
- })
- });
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-365fa217"]]);
- wx.createPage(MiniProgramPage);
|