235 lines
11 KiB
JavaScript
235 lines
11 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
if (!Array) {
|
|
const _easycom_uni_rate2 = common_vendor.resolveComponent("uni-rate");
|
|
const _easycom_uni_drawer2 = common_vendor.resolveComponent("uni-drawer");
|
|
(_easycom_uni_rate2 + _easycom_uni_drawer2)();
|
|
}
|
|
const _easycom_uni_rate = () => "../../uni_modules/uni-rate/components/uni-rate/uni-rate.js";
|
|
const _easycom_uni_drawer = () => "../../uni_modules/uni-drawer/components/uni-drawer/uni-drawer.js";
|
|
if (!Math) {
|
|
(sort + _easycom_uni_rate + Shopdetils + _easycom_uni_drawer)();
|
|
}
|
|
const sort = () => "./sort.js";
|
|
const Shopdetils = () => "./Shopdetails2.js";
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "merchant",
|
|
setup(__props) {
|
|
const currentIndex = common_vendor.ref(0);
|
|
const tabs = common_vendor.ref([
|
|
{ name: "点餐" },
|
|
{ name: "评价" },
|
|
{ name: "商家信息" }
|
|
]);
|
|
const switchTab = (index) => {
|
|
currentIndex.value = index;
|
|
};
|
|
const historyList = common_vendor.ref([
|
|
{
|
|
imgUrl: "https://img.zcool.cn/community/0105ec5b5ac3cba801206a35cf08a8.jpg@1280w_1l_2o_100sh.jpg",
|
|
title: "大表哥",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "刚才",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://ts1.cn.mm.bing.net/th/id/R-C.63e4b0a881283cbd46f07e77c2bbd491?rik=vWq%2fKkimZ5n2XQ&riu=http%3a%2f%2fseopic.699pic.com%2fphoto%2f50014%2f5917.jpg_wh1200.jpg&ehk=KCX2DzgqaiIJnMJZUyFc%2btT9ILzKGslHE8oaSAKORdE%3d&risl=&pid=ImgRaw&r=0",
|
|
title: "美食猎人",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "刚才",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://img.zcool.cn/community/0189d85c3c421aa80121fbb0284f6c.jpg@1280w_1l_2o_100sh.jpg",
|
|
title: "吃货小能手",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "刚才",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://ts1.cn.mm.bing.net/th/id/R-C.b3a7697d2793ba094a861d546c31190d?rik=NevOIW4XmkUuMA&riu=http%3a%2f%2fseopic.699pic.com%2fphoto%2f50069%2f5445.jpg_wh1200.jpg&ehk=wuLPicg%2b9wXz8QAwp%2fAVFBtJQ6loBUiVfQZu2bbZODA%3d&risl=&pid=ImgRaw&r=0",
|
|
title: "午夜觅食者",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "1分钟前",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://img.zcool.cn/community/0192885d01b363a801213ec27c862a.jpg@1280w_1l_2o_100sh.jpg",
|
|
title: "素食爱好者",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "40min",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://img.zcool.cn/community/018aab5cc14900a801214168fdffc2.jpg@1280w_1l_2o_100sh.jpg",
|
|
title: "加班狗",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "40min",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://ts1.cn.mm.bing.net/th/id/R-C.68978afc71576a94a1d50ef5016dbd9e?rik=cDDsy5SLmDvDHQ&riu=http%3a%2f%2fseopic.699pic.com%2fphoto%2f50075%2f0779.jpg_wh1200.jpg&ehk=FG4Hd5S711LYcuLBIcDagQyk4KhcH1oIfqyk1MWUOyg%3d&risl=&pid=ImgRaw&r=0",
|
|
title: "甜品达人",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "40min",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
},
|
|
{
|
|
imgUrl: "https://img95.699pic.com/photo/50093/6813.jpg_wh860.jpg",
|
|
title: "快餐侠",
|
|
sale: "8.0",
|
|
star: "4",
|
|
time: "40min",
|
|
message: "这次点的外卖真是超乎预期的好吃!【香辣鸡腿堡】外皮酥脆,鸡肉鲜嫩多汁,辣度适中,每一口都是满满的幸福感。【薯条】也是惊喜,又脆又香,完全没有油腻感。最棒的是配送员【小张】,准时送达,态度亲切,还特意提醒我餐品有点烫,小心食用。整体体验满分,下次还会再点!"
|
|
}
|
|
]);
|
|
const talk = () => {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/talk/talk"
|
|
});
|
|
};
|
|
common_vendor.ref(1);
|
|
const showRight = common_vendor.ref(null);
|
|
const showDrawer = () => {
|
|
if (showRight.value) {
|
|
showRight.value.open();
|
|
}
|
|
};
|
|
const isLiked = common_vendor.ref(false);
|
|
const likeImageSrc = common_vendor.ref("../../static/small/star.png");
|
|
const toggleLike = () => {
|
|
isLiked.value = !isLiked.value;
|
|
likeImageSrc.value = isLiked.value ? "../../static/small/star.png" : "../../static/small/starSelected.png";
|
|
console.log(isLiked.value ? "点赞成功" : "取消点赞成功");
|
|
};
|
|
const cartItems = common_vendor.ref([]);
|
|
const updateCart = (newCartItems) => {
|
|
cartItems.value = newCartItems;
|
|
console.log("更新后的购物车:", cartItems.value);
|
|
};
|
|
common_vendor.onMounted(() => {
|
|
cartItems.value = common_vendor.index.getStorageSync("cartItems") || [];
|
|
});
|
|
const deleteItem = (index) => {
|
|
cartItems.value.splice(index, 1);
|
|
};
|
|
const incrementQuantity = (index) => {
|
|
if (cartItems.value[index].quantity < 9) {
|
|
cartItems.value[index].quantity++;
|
|
}
|
|
};
|
|
const decrementQuantity = (index) => {
|
|
if (cartItems.value[index].quantity > 1) {
|
|
cartItems.value[index].quantity--;
|
|
}
|
|
};
|
|
const totalAmount = common_vendor.computed(() => {
|
|
return cartItems.value.reduce((total, item) => {
|
|
return total + item.dishesPrice * item.quantity;
|
|
}, 0);
|
|
});
|
|
const account = () => {
|
|
console.log("Total amount to pay:", totalAmount.value);
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/account/account?totalAmount=${encodeURIComponent(totalAmount.value.toString())}`
|
|
});
|
|
};
|
|
const merchantId = common_vendor.ref();
|
|
const getMerchantIdFromUrl = () => {
|
|
const pages = getCurrentPages();
|
|
const currentPage = pages[pages.length - 1];
|
|
console.log("Current page options:", currentPage.options);
|
|
if (currentPage && currentPage.options && currentPage.options.merchantId) {
|
|
merchantId.value = currentPage.options.merchantId;
|
|
console.log(`Merchant ID received: ${merchantId.value}`);
|
|
} else {
|
|
console.error("Could not retrieve merchantId from URL.");
|
|
}
|
|
};
|
|
common_vendor.onMounted(() => {
|
|
getMerchantIdFromUrl();
|
|
});
|
|
common_vendor.watch(merchantId, (newValue) => {
|
|
common_vendor.index.$emit("merchantIdChanged", newValue);
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.f(tabs.value, (tab, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(tab.name),
|
|
b: index,
|
|
c: currentIndex.value === index ? 1 : "",
|
|
d: common_vendor.o(($event) => switchTab(index))
|
|
};
|
|
}),
|
|
b: currentIndex.value === 0
|
|
}, currentIndex.value === 0 ? {
|
|
c: common_vendor.o(updateCart),
|
|
d: common_vendor.p({
|
|
["merchant-id"]: merchantId.value
|
|
})
|
|
} : {}, {
|
|
e: currentIndex.value === 1
|
|
}, currentIndex.value === 1 ? {
|
|
f: common_vendor.f(historyList.value, (item, index, i0) => {
|
|
return {
|
|
a: item.imgUrl,
|
|
b: common_vendor.t(item.title),
|
|
c: common_vendor.t(item.time),
|
|
d: common_vendor.t(item.sale),
|
|
e: "a7b7a9e4-1-" + i0,
|
|
f: common_vendor.p({
|
|
readonly: true,
|
|
value: item.star,
|
|
["active-color"]: "#13c2c2",
|
|
["is-fill"]: false,
|
|
color: "#13c2c2"
|
|
}),
|
|
g: common_vendor.t(item.message),
|
|
h: index
|
|
};
|
|
})
|
|
} : {}, {
|
|
g: currentIndex.value === 2
|
|
}, currentIndex.value === 2 ? {} : {}, {
|
|
h: likeImageSrc.value,
|
|
i: common_vendor.o(toggleLike),
|
|
j: common_vendor.o(talk),
|
|
k: common_vendor.o(($event) => showDrawer()),
|
|
l: common_vendor.f(cartItems.value, (item, index, i0) => {
|
|
return {
|
|
a: item.dishesImage,
|
|
b: common_vendor.o(($event) => deleteItem(index)),
|
|
c: common_vendor.t(item.dishesName),
|
|
d: common_vendor.t(item.dishesPrice),
|
|
e: common_vendor.o(($event) => decrementQuantity(index)),
|
|
f: common_vendor.t(item.quantity),
|
|
g: common_vendor.o(($event) => incrementQuantity(index)),
|
|
h: index
|
|
};
|
|
}),
|
|
m: common_vendor.t(common_vendor.unref(totalAmount)),
|
|
n: common_vendor.o(account),
|
|
o: () => ({
|
|
r: showRight,
|
|
k: "showRight"
|
|
}),
|
|
p: common_vendor.o(($event) => _ctx.change($event, "showRight")),
|
|
q: common_vendor.p({
|
|
mode: "left",
|
|
["mask-click"]: true
|
|
})
|
|
});
|
|
};
|
|
}
|
|
});
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/111111000000/uniapp04/pages/merchant/merchant.vue"]]);
|
|
my.createPage(MiniProgramPage);
|