123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- "use strict";
- var common_vendor = require("../common/vendor.js");
- var api_common = require("../api/common.js");
- var api_userAddress = require("../api/userAddress.js");
- var api_user = require("../api/user.js");
- var api_package = require("../api/package.js");
- var api_packageOrder = require("../api/packageOrder.js");
- require("../common/request.js");
- const _sfc_main = {
- data() {
- return {
- giftPrice: 0,
- payTypes: [],
- addressId: null,
- wxPay: true,
- address: null,
- orderId: null,
- order: null,
- items: null,
- payType: "1",
- couponText: "\u8BF7\u9009\u62E9\u4F18\u60E0\u5238",
- userCouponId: 0,
- coupons: [],
- couponShow: false,
- payMoney: 0,
- discountMoney: 0,
- payRemain: 0,
- payDelivery: 0,
- payPrice: 0,
- gifts: []
- };
- },
- onLoad(option) {
- this.orderId = option.orderId;
- var that = this;
- common_vendor.index.$on("updateAddress", (e) => {
- that.addressId = e.addressId;
- that.address = e;
- that.address.address = e.province + e.city + e.district + e.detail;
- });
- this.getAddressByDefault();
- },
- onShow() {
- this.getPackageOrderById();
- this.getPackageById();
- this.getConfigByKey();
- },
- methods: {
- getAddressByDefault() {
- api_userAddress.getAddressByDefault().then((res) => {
- if (res.code == 200) {
- if (res.data != null) {
- this.addressId = res.data.addressId;
- this.address = res.data;
- this.address.address = res.data.province + res.data.city + res.data.district + res.data.detail;
- }
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- }
- }, (rej) => {
- });
- },
- getConfigByKey() {
- var data = { key: "his.package" };
- api_common.getConfigByKey(data).then((res) => {
- if (res.code == 200) {
- this.giftPrice = JSON.parse(res.data).giftPrice;
- console.log(this.giftPrice);
- }
- }, (rej) => {
- });
- },
- checkPayType(payType) {
- var flag = false;
- this.payTypes.forEach(function(value, index, array) {
- if (value.toString() == payType.toString()) {
- flag = true;
- }
- });
- return flag;
- },
- payTypeChange(e) {
- console.log(e.detail.value);
- this.payType = e.detail.value;
- this.compute();
- },
- couponSelect(item) {
- this.couponShow = false;
- this.userCouponId = item.id;
- console.log(item);
- this.couponText = item.price + "\u5143\u4F18\u60E0\u5238";
- this.compute();
- },
- open() {
- },
- close() {
- this.couponShow = false;
- },
- openCoupon() {
- this.couponShow = true;
- },
- delCoupon() {
- this.userCouponId = 0;
- this.couponText = "\u8BF7\u9009\u62E9\u4F18\u60E0\u5238";
- this.compute();
- },
- compute() {
- var data = {
- payType: this.payType,
- orderId: this.orderId,
- userCouponId: this.userCouponId,
- companyId: this.companyId,
- companyUserId: this.companyUserId
- };
- console.log(data);
- api_packageOrder.compute(data).then((res) => {
- if (res.code == 200) {
- this.payPrice = res.moneys.payPrice.toFixed(2);
- this.payMoney = res.moneys.payMoney.toFixed(2);
- this.discountMoney = res.moneys.discountMoney.toFixed(2);
- this.payDelivery = res.moneys.payDelivery.toFixed(2);
- this.payRemain = res.moneys.payRemain.toFixed(2);
- this.gifts = res.moneys.gifts;
- } else {
- this.payType = 1;
- this.compute();
- this.userCouponId = 0;
- this.couponText = "\u8BF7\u9009\u62E9\u4F18\u60E0\u5238";
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- }
- }, (err) => {
- });
- },
- getMyEnableCouponList() {
- var data = {};
- if (this.package.isShow == 0) {
- data.couponType = 5;
- data.cateId = this.package.privateType;
- } else if (this.package.isShow == 1) {
- data.couponType = 6;
- data.cateId = this.package.diseaseType;
- }
- api_user.getMyEnableCouponList(data).then((res) => {
- if (res.code == 200) {
- this.coupons = res.data;
- }
- }, (err) => {
- });
- },
- getPackageOrderById() {
- var data = { orderId: this.orderId };
- console.log(data);
- api_packageOrder.getPackageOrderById(data).then((res) => {
- if (res.code == 200) {
- this.order = res.order;
- this.compute();
- this.getPackageById(this.order.packageId);
- }
- }, (rej) => {
- });
- },
- getPackageById(packageId) {
- var data = { packageId };
- api_package.getPackageById(data).then((res) => {
- if (res.code == 200) {
- this.package = res.data;
- this.payTypes = res.data.payType.split(",");
- console.log(this.payTypes);
- this.getMyEnableCouponList();
- }
- }, (rej) => {
- });
- },
- openAddress() {
- common_vendor.index.navigateTo({
- url: "/pages_user/address"
- });
- },
- payOrder() {
- var data = {
- payType: this.payType,
- userCouponId: this.userCouponId,
- addressId: this.addressId,
- remark: this.order.remark,
- orderId: this.order.orderId
- };
- common_vendor.index.showLoading();
- api_packageOrder.pay(data).then((res) => {
- if (res.code == 200) {
- common_vendor.index.redirectTo({
- url: "./packagePayment?orderId=" + this.orderId
- });
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: res.msg
- });
- }
- }, (rej) => {
- });
- }
- }
- };
- if (!Array) {
- const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
- _easycom_u_popup2();
- }
- const _easycom_u_popup = () => "../uni_modules/uview-plus/components/u-popup/u-popup.js";
- if (!Math) {
- _easycom_u_popup();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: $data.address == null
- }, $data.address == null ? {
- b: common_vendor.o(($event) => $options.openAddress())
- } : {}, {
- c: $data.address != null
- }, $data.address != null ? common_vendor.e({
- d: common_vendor.t($data.address.realName),
- e: $data.address.phone != null
- }, $data.address.phone != null ? {
- f: common_vendor.t($data.address.phone)
- } : {}, {
- g: common_vendor.t($data.address.address),
- h: common_vendor.o(($event) => $options.openAddress())
- }) : {}, {
- i: common_vendor.t($data.payPrice),
- j: $data.order != null && ($data.order.userCouponId == null || $data.order.userCouponId == 0)
- }, $data.order != null && ($data.order.userCouponId == null || $data.order.userCouponId == 0) ? common_vendor.e({
- k: common_vendor.t($data.couponText),
- l: $data.userCouponId != 0
- }, $data.userCouponId != 0 ? {
- m: common_vendor.o(($event) => $options.delCoupon())
- } : {}, {
- n: common_vendor.o(($event) => $options.openCoupon())
- }) : {}, {
- o: common_vendor.t($data.discountMoney),
- p: common_vendor.t($data.payMoney),
- q: common_vendor.t($data.payRemain),
- r: common_vendor.t($data.payDelivery),
- s: $options.checkPayType("1")
- }, $options.checkPayType("1") ? {
- t: $data.payType == "1"
- } : {}, {
- v: $options.checkPayType("2")
- }, $options.checkPayType("2") ? {
- w: $data.payType == "2"
- } : {}, {
- x: $options.checkPayType("3")
- }, $options.checkPayType("3") ? {
- y: $data.payType == "3"
- } : {}, {
- z: common_vendor.o((...args) => $options.payTypeChange && $options.payTypeChange(...args)),
- A: $data.gifts.length > 0
- }, $data.gifts.length > 0 ? {
- B: common_vendor.f($data.gifts, (product, k0, i0) => {
- return {
- a: product.image,
- b: common_vendor.t(product.productName),
- c: common_vendor.t(product.sku),
- d: common_vendor.t(product.price.toFixed(2)),
- e: common_vendor.t(product.count)
- };
- })
- } : {}, {
- C: $data.order != null
- }, $data.order != null ? {
- D: $data.order.remark,
- E: common_vendor.o(($event) => $data.order.remark = $event.detail.value)
- } : {}, {
- F: $data.coupons.length > 0
- }, $data.coupons.length > 0 ? {
- G: common_vendor.f($data.coupons, (item, k0, i0) => {
- return common_vendor.e({
- a: item.status == 0
- }, item.status == 0 ? {} : {}, {
- b: item.status != 0
- }, item.status != 0 ? {} : {}, {
- c: common_vendor.t(item.price.toFixed(2)),
- d: common_vendor.t(item.minPrice.toFixed(2)),
- e: common_vendor.t(item.title),
- f: item.status == 0 || item.status == 2
- }, item.status == 0 || item.status == 2 ? {
- g: common_vendor.t(item.limitTime)
- } : {}, {
- h: item.status == 1
- }, item.status == 1 ? {
- i: common_vendor.t(item.useTime)
- } : {}, {
- j: item.status == 1
- }, item.status == 1 ? {} : {}, {
- k: item.status == 2
- }, item.status == 2 ? {} : {}, {
- l: item.status == 0
- }, item.status == 0 ? {} : {}, {
- m: common_vendor.o(($event) => $options.couponSelect(item))
- });
- })
- } : {}, {
- H: $data.coupons.length == 0
- }, $data.coupons.length == 0 ? {} : {}, {
- I: common_vendor.o($options.close),
- J: common_vendor.o($options.open),
- K: common_vendor.p({
- closeable: true,
- show: $data.couponShow,
- round: 10,
- mode: "bottom"
- }),
- L: $data.order != null
- }, $data.order != null ? {
- M: common_vendor.t($data.payMoney),
- N: common_vendor.o(($event) => $options.payOrder())
- } : {});
- }
- var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_order/packageOrderPay.vue"]]);
- wx.createPage(MiniProgramPage);
|