purchase-let/unpackage/dist/dev/mp-weixin/pagesOrder/detail/detail.js

240 lines
8.5 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const api_order = require("../../api/order.js");
const api_user = require("../../api/user.js");
require("../../utils/request.js");
require("../../config/app.js");
require("../../store/user.js");
if (!Array) {
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
const _easycom_up_copy2 = common_vendor.resolveComponent("up-copy");
(_easycom_up_icon2 + _easycom_up_button2 + _easycom_up_image2 + _easycom_up_copy2)();
}
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
const _easycom_up_copy = () => "../../uni_modules/uview-plus/components/u-copy/u-copy.js";
if (!Math) {
(_easycom_up_icon + _easycom_up_button + _easycom_up_image + _easycom_up_copy + orderCanclePopup + addressPopup + modal)();
}
const addressPopup = () => "../../components/addressPopup.js";
const orderCanclePopup = () => "../../components/orderCanclePopup.js";
const modal = () => "../../components/modal.js";
const _sfc_main = {
__name: "detail",
setup(__props) {
const showCancel = common_vendor.ref(false);
const submitCancel = (e) => {
showCancel.value = false;
console.log(e);
common_vendor.index.showToast({
title: "取消成功",
icon: "none"
});
};
const datas = common_vendor.ref({});
const getDetails = () => {
api_order.orderDetailApi({
order_id: datas.value.id
}).then((res) => {
datas.value = res.data;
if (!res.data.paid) {
targetDate = new Date(res.data.create_time).getTime() + 30 * 60 * 1e3;
timer = setInterval(updateCountdown, 1e3);
updateCountdown();
}
});
};
const c_price = (price, index = 0) => {
price = price + "";
return price.split(".")[index] || (index ? "00" : "0");
};
const addressList = common_vendor.ref([]);
const getAddressList = () => {
api_user.addressListsApi().then((res) => {
addressList.value = res.data.lists;
addressList.value.forEach((item) => {
if (item.is_default) {
addressInfo.value = item;
}
});
if (addressList.value.length > 0) {
addressInfo.value = addressList.value[0];
}
});
};
getAddressList();
const showAddress = common_vendor.ref(false);
const addressInfo = common_vendor.ref({});
const changeAddress = (e) => {
addressInfo.value = e;
showAddress.value = false;
};
const rePay = () => {
api_order.rePaymentApi({
order_id: datas.value.id,
pay_type: 1
}).then((res) => {
console.log(res);
});
};
let targetDate = "";
let countDown = common_vendor.ref("");
let timer = null;
function updateCountdown() {
const now = (/* @__PURE__ */ new Date()).getTime();
const distance = targetDate - now;
if (distance < 0)
return clearInterval(timer);
const hours = Math.floor(distance % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60));
const minutes = Math.floor(distance % (1e3 * 60 * 60) / (1e3 * 60));
const seconds = Math.floor(distance % (1e3 * 60) / 1e3);
countDown.value = `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
if (distance < 0) {
console.log("倒计时结束");
countDown.value = "";
}
}
common_vendor.onLoad((option) => {
common_vendor.index.setNavigationBarTitle({
title: option.type == 0 ? "等待付款" : "订单详情"
});
if (option.id) {
datas.value.id = option.id;
getDetails();
}
});
common_vendor.onBackPress(() => {
clearInterval(timer);
console.log("清除");
});
return (_ctx, _cache) => {
return common_vendor.e({
a: datas.value.paid == 0 && common_vendor.unref(countDown)
}, datas.value.paid == 0 && common_vendor.unref(countDown) ? {
b: common_vendor.t(common_vendor.unref(countDown))
} : {}, {
c: common_vendor.p({
name: "account"
}),
d: common_vendor.t(addressInfo.value.real_name),
e: common_vendor.t(addressInfo.value.phone),
f: common_vendor.t(addressInfo.value.detail),
g: datas.value.paid == 0
}, datas.value.paid == 0 ? {
h: common_vendor.o(($event) => showAddress.value = true),
i: common_vendor.p({
size: "small",
shape: "circle",
color: "#f6f6f6",
customStyle: {
color: "#666666"
}
})
} : {}, {
j: common_vendor.f(datas.value.goods_list, (item, index, i0) => {
return {
a: "666b5ad0-2-" + i0,
b: common_vendor.p({
src: item.imgs,
width: "160rpx",
height: "160rpx"
}),
c: common_vendor.t(item.class_name),
d: common_vendor.t(item.sell),
e: common_vendor.t(item.goods_unit),
f: common_vendor.t(item.nums),
g: common_vendor.t(item.msg),
h: index
};
}),
k: datas.value.paid == 0
}, datas.value.paid == 0 ? common_vendor.e({
l: datas.value.goods_list
}, datas.value.goods_list ? {
m: common_vendor.t(datas.value.goods_list.length),
n: common_vendor.t(c_price(datas.value.total, 0)),
o: common_vendor.t(c_price(datas.value.total, 1))
} : {}, {
p: datas.value.total
}, datas.value.total ? {
q: common_vendor.t(c_price(datas.value.total, 0)),
r: common_vendor.t(c_price(datas.value.total, 1))
} : {}) : {}, {
s: datas.value.paid == 0
}, datas.value.paid == 0 ? common_vendor.e({
t: common_vendor.t(datas.value.number),
v: common_vendor.p({
content: datas.value.number
}),
w: common_vendor.t(datas.value.create_time),
x: datas.value.paid
}, datas.value.paid ? {} : {}) : common_vendor.e({
y: datas.value.goods_list
}, datas.value.goods_list ? {
z: common_vendor.t(c_price(datas.value.total, 0)),
A: common_vendor.t(c_price(datas.value.total, 1))
} : {}, {
B: common_vendor.t(datas.value.number),
C: common_vendor.p({
content: datas.value.number
}),
D: common_vendor.t(datas.value.pay_type == 3 ? "余额支付" : "微信支付"),
E: common_vendor.t(datas.value.create_time),
F: datas.value.paid
}, datas.value.paid ? {} : {}), {
G: datas.value.number
}, datas.value.number ? common_vendor.e({
H: !datas.value.paid
}, !datas.value.paid ? {
I: common_vendor.o(($event) => showCancel.value = true),
J: common_vendor.t(datas.value.total),
K: common_vendor.o(rePay),
L: common_vendor.p({
color: "#20B128",
shape: "circle"
})
} : common_vendor.e({
M: datas.value.status == 0 || datas.value.status == 1
}, datas.value.status == 0 || datas.value.status == 1 ? {
N: common_vendor.o(() => {
}),
O: common_vendor.p({
color: "#20B128",
shape: "circle"
})
} : {
P: common_vendor.o(() => {
}),
Q: common_vendor.p({
color: "#20B128",
shape: "circle"
})
})) : {}, {
R: common_vendor.o(($event) => showCancel.value = false),
S: common_vendor.o(submitCancel),
T: common_vendor.p({
show: showCancel.value
}),
U: addressList.value.length > 0
}, addressList.value.length > 0 ? {
V: common_vendor.o(($event) => showAddress.value = false),
W: common_vendor.o(changeAddress),
X: common_vendor.p({
show: showAddress.value,
list: addressList.value
})
} : {}, {
Y: common_vendor.p({
show: false,
content: "您还没有添加收货地址,请点击添加"
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/里海数字乡村/purchase-let/pagesOrder/detail/detail.vue"]]);
wx.createPage(MiniProgramPage);