Files
frontend-app/unpackage/dist/dev/mp-weixin/pages/home/home.js
T
2025-05-10 18:17:24 +08:00

444 lines
14 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const api_product = require("../../api/product.js");
const api_common = require("../../api/common.js");
const utils_enumUtils = require("../../utils/enumUtils.js");
const choiceness = () => "../../components/choiceness/choiceness.js";
const CustomTabBar = () => "../../components/custom-tab-bar.js";
const _sfc_main = {
components: { choiceness, CustomTabBar },
data() {
return {
swiperList: [
"/static/home/banner01.png",
"/static/home/banner04.png"
],
currentNum: 0,
sortList: [],
languageShow: false,
// 语言选项
languageList: [
{
name: "中文",
key: "CN"
},
{
name: "英文",
key: "EN"
}
],
currentLanguage: {},
yxProduct: [],
// 好物优选列表
faddishProduct: [],
// 爆款专区
hotList: [
{
id: 1,
name: "中文中文中文中文中文",
url: "/static/common/product_def.png",
price: 99
},
{
id: 2,
name: "中文中文中文中文",
url: "/static/common/product_def.png",
price: 99
},
{
id: 3,
name: "中文中文中文中文中文",
url: "/static/common/product_def.png",
price: 99
},
{
id: 4,
name: "中文中文中文中文中文",
url: "/static/common/product_def.png",
price: 99
}
],
// 热门
productLoading: false,
openShow: false,
platformType: null,
// 当前设备信息
bannerShow: false,
// 是否需要強制更新app
type: "",
// 设备类型 android:2, ios:1
updateApkObj: {},
// 后台数据
bannerPercentageShow: false,
// 是否显示进度条
bannerPercentage: 0
// 进度条
};
},
onShow() {
common_vendor.index.getStorageSync("platform");
common_vendor.index.getStorageSync("versionUpdateTime");
this.getSortList();
this.querySearchList(utils_enumUtils.SEARCH_TYPE.SOMETHING);
this.querySearchList(utils_enumUtils.SEARCH_TYPE.EXPLOSIVE);
},
mounted() {
},
methods: {
checkUpdate() {
common_vendor.index.getStorageSync("version");
common_vendor.index.getStorageSync("versionCode");
},
// 安装
goUpdate(updateApkObj, platformType) {
const self = this;
if (platformType == "ANDROID") {
var dtask = plus.downloader.createDownload(updateApkObj.downloadUrl, {}, function(d, status) {
if (status == 200) {
plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename), { force: true }, function(resp) {
common_vendor.index.setStorageSync("versionUpdateTime", common_vendor.dayjs().valueOf());
plus.runtime.restart();
}, function(error) {
common_vendor.index.__f__("log", "at pages/home/home.vue:319", "error", error);
common_vendor.index.showToast({
title: error.message,
mask: false,
duration: 1500
});
});
} else {
self.bannerPercentageShow = false;
common_vendor.index.showToast({
title: "更新失败",
mask: false,
duration: 1500
});
}
});
try {
dtask.start();
let prg = 0;
this.bannerPercentageShow = true;
dtask.addEventListener("statechanged", function(task, status) {
switch (task.state) {
case 1:
break;
case 2:
break;
case 3:
prg = parseInt(parseFloat(task.downloadedSize) / parseFloat(task.totalSize) * 100);
self.bannerPercentage = prg;
break;
case 4:
plus.nativeUI.closeWaiting();
self.bannerShow = false;
break;
}
});
} catch (err) {
common_vendor.index.__f__("log", "at pages/home/home.vue:357", "更新失败-03err", err);
plus.nativeUI.closeWaiting();
common_vendor.index.showToast({
title: "更新失败-03",
mask: false,
duration: 1500
});
}
} else if (platformType == "IOS") {
plus.runtime.openURL(updateApkObj.downloadUrl);
}
},
jumpTurntable() {
common_vendor.index.navigateTo({
url: "/pages/turntable/turntable?backPath=home"
});
},
jumpPrdference() {
common_vendor.index.navigateTo({
url: "/pages/preference/preference"
});
},
jumpWelcome() {
common_vendor.index.navigateTo({
url: "/pages/welcome/welcome"
});
},
jumpSearch() {
common_vendor.index.navigateTo({
url: "/pages/search/search"
});
},
/**
* 查询商品列表
*/
async querySearchList(type) {
this.productLoading = true;
const params = {
type,
page: 1,
pageSize: type === utils_enumUtils.SEARCH_TYPE.SOMETHING ? 4 : 3
};
const resp = await api_product.searchList(params);
if (resp && resp.bizcode === 100) {
if (type === utils_enumUtils.SEARCH_TYPE.SOMETHING) {
this.yxProduct = resp.data;
} else if (type === utils_enumUtils.SEARCH_TYPE.EXPLOSIVE) {
this.faddishProduct = resp.data;
}
}
this.productLoading = false;
},
/**
* 查询分类列表
*/
async getSortList() {
const resp = await api_common.getCascadeCategory({ parentId: 0 });
if (resp && resp.bizcode === 100) {
this.sortList = resp.data.slice(0, 10);
}
},
// 跳转到分类栏目
jumpSort(item) {
common_vendor.index.setStorageSync("sortId", item.id);
common_vendor.index.switchTab({
// 首页
url: "/pages/sort/sort"
});
},
// 跳转到商品详情
jumpInfo(item) {
common_vendor.index.navigateTo({
url: "/pages/productInfo/productInfo?id=" + item.id
});
}
}
};
if (!Array) {
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
const _easycom_up_swiper2 = common_vendor.resolveComponent("up-swiper");
const _easycom_up_loading_icon2 = common_vendor.resolveComponent("up-loading-icon");
const _easycom_choiceness2 = common_vendor.resolveComponent("choiceness");
const _easycom_up_modal2 = common_vendor.resolveComponent("up-modal");
const _component_CustomTabBar = common_vendor.resolveComponent("CustomTabBar");
const _easycom_up_action_sheet2 = common_vendor.resolveComponent("up-action-sheet");
const _easycom_up_line_progress2 = common_vendor.resolveComponent("up-line-progress");
const _easycom_up_overlay2 = common_vendor.resolveComponent("up-overlay");
(_easycom_up_image2 + _easycom_up_swiper2 + _easycom_up_loading_icon2 + _easycom_choiceness2 + _easycom_up_modal2 + _component_CustomTabBar + _easycom_up_action_sheet2 + _easycom_up_line_progress2 + _easycom_up_overlay2)();
}
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
const _easycom_up_swiper = () => "../../uni_modules/uview-plus/components/u-swiper/u-swiper.js";
const _easycom_up_loading_icon = () => "../../uni_modules/uview-plus/components/u-loading-icon/u-loading-icon.js";
const _easycom_choiceness = () => "../../components/choiceness/choiceness.js";
const _easycom_up_modal = () => "../../uni_modules/uview-plus/components/u-modal/u-modal.js";
const _easycom_up_action_sheet = () => "../../uni_modules/uview-plus/components/u-action-sheet/u-action-sheet.js";
const _easycom_up_line_progress = () => "../../uni_modules/uview-plus/components/u-line-progress/u-line-progress.js";
const _easycom_up_overlay = () => "../../uni_modules/uview-plus/components/u-overlay/u-overlay.js";
if (!Math) {
(_easycom_up_image + _easycom_up_swiper + _easycom_up_loading_icon + _easycom_choiceness + _easycom_up_modal + _easycom_up_action_sheet + _easycom_up_line_progress + _easycom_up_overlay)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.p({
src: "/static/home/logo.png",
width: "86",
height: "30",
bgColor: "#f1f6ff00"
}),
b: common_vendor.p({
src: "/static/home/search.png",
width: "18",
height: "18",
bgColor: "#f1f6ff00"
}),
c: common_vendor.o((...args) => $options.jumpSearch && $options.jumpSearch(...args)),
d: common_vendor.t($data.currentNum + 1),
e: common_vendor.t($data.swiperList.length),
f: common_vendor.o((e) => $data.currentNum = e.current),
g: common_vendor.p({
list: $data.swiperList,
height: "120",
radius: "10",
bgColor: "#ffffff00"
}),
h: $data.sortList && $data.sortList.length !== 0
}, $data.sortList && $data.sortList.length !== 0 ? {
i: common_vendor.f($data.sortList, (item, k0, i0) => {
return {
a: "07e72d3c-3-" + i0,
b: common_vendor.p({
src: item.icon,
width: "40",
height: "32",
bgColor: "#f1f6ff00"
}),
c: common_vendor.t(item.name),
d: item.id,
e: common_vendor.o(($event) => $options.jumpSort(item), item.id)
};
})
} : {
j: common_vendor.p({
src: "/static/common/not_order.png",
width: "80",
height: "80",
bgColor: "#f1f6ff00"
})
}, {
k: $data.faddishProduct && $data.faddishProduct.length !== 0
}, $data.faddishProduct && $data.faddishProduct.length !== 0 ? {
l: common_vendor.p({
src: "/static/home/youxuan.png",
width: "10",
height: "10",
bgColor: "#f1f6ff00"
}),
m: common_vendor.p({
src: "/static/common/right_y_st2.png",
width: "12",
height: "12",
bgColor: "#f1f6ff00"
}),
n: common_vendor.o((...args) => $options.jumpWelcome && $options.jumpWelcome(...args)),
o: common_vendor.p({
show: $data.productLoading
}),
p: common_vendor.f($data.faddishProduct, (item, k0, i0) => {
return {
a: "07e72d3c-8-" + i0,
b: common_vendor.p({
src: item.url,
width: "100%",
height: "130",
bgColor: "#f1f6ff00",
shape: "square",
radius: "15"
}),
c: common_vendor.t(item.title),
d: common_vendor.t(item.adPrice),
e: item.id,
f: common_vendor.o(($event) => $options.jumpInfo(item), item.id)
};
}),
q: common_vendor.n($data.faddishProduct && $data.faddishProduct.length > 2 ? "product_item2" : "product_item"),
r: common_vendor.n($data.faddishProduct && $data.faddishProduct.length > 2 ? "product_content product_content2" : "product_content")
} : {}, {
s: common_vendor.p({
src: "/static/home/min_card_jfdh.png",
width: "60",
height: "14",
bgColor: "#f1f6ff00"
}),
t: common_vendor.p({
src: "/static/common/right_y.png",
width: "10",
height: "10",
bgColor: "#f1f6ff00"
}),
v: common_vendor.p({
src: "/static/home/min_card_jfdh_2.png",
width: "66",
height: "46",
bgColor: "#f1f6ff00"
}),
w: common_vendor.o((...args) => $options.jumpPrdference && $options.jumpPrdference(...args)),
x: common_vendor.p({
src: "/static/home/min_card_hbcj.png",
width: "60",
height: "14",
bgColor: "#f1f6ff00"
}),
y: common_vendor.p({
src: "/static/common/right_y.png",
width: "10",
height: "10",
bgColor: "#f1f6ff00"
}),
z: common_vendor.p({
src: "/static/home/min_card_hbcj_2.png",
width: "66",
height: "46",
bgColor: "#f1f6ff00"
}),
A: common_vendor.o((...args) => $options.jumpTurntable && $options.jumpTurntable(...args)),
B: $data.yxProduct && $data.yxProduct.length !== 0
}, $data.yxProduct && $data.yxProduct.length !== 0 ? {
C: common_vendor.p({
src: "/static/common/right.png",
width: "12",
height: "12",
bgColor: "#f1f6ff00"
}),
D: common_vendor.p({
show: $data.productLoading
}),
E: common_vendor.f($data.yxProduct, (item, k0, i0) => {
return {
a: "07e72d3c-17-" + i0,
b: common_vendor.p({
src: item.url,
width: "100%",
height: "80",
bgColor: "#f1f6ff00",
shape: "square",
radius: "10"
}),
c: item.id
};
}),
F: common_vendor.n($data.yxProduct && $data.yxProduct.length < 4 ? "product_item_yx product_item_yx2" : "product_item_yx"),
G: common_vendor.n($data.yxProduct && $data.yxProduct.length > 3 ? "product_content_yx product_content2" : "product_content_yx"),
H: common_vendor.o((...args) => $options.jumpPrdference && $options.jumpPrdference(...args))
} : {}, {
I: common_vendor.p({
src: "/static/common/close.png",
width: "20",
height: "20",
bgColor: "#f1f6ff00"
}),
J: common_vendor.o(($event) => {
$data.openShow = false;
}),
K: common_vendor.o(($event) => {
$data.openShow = false;
}),
L: common_vendor.p({
show: $data.openShow,
showConfirmButton: false
}),
M: common_vendor.p({
tabIndex: 0
}),
N: common_vendor.o(($event) => $data.languageShow = false),
O: common_vendor.p({
actions: $data.languageList,
show: $data.languageShow,
cancelText: "取消"
}),
P: common_vendor.t($data.updateApkObj.versionCode || 100),
Q: common_vendor.t($data.updateApkObj.content),
R: !$data.bannerPercentageShow
}, !$data.bannerPercentageShow ? common_vendor.e({
S: common_vendor.o(($event) => $options.goUpdate($data.updateApkObj, $data.platformType)),
T: !$data.updateApkObj.isForce
}, !$data.updateApkObj.isForce ? {
U: common_vendor.o(($event) => {
$data.bannerShow = false;
})
} : {}) : {
V: common_vendor.p({
percentage: $data.bannerPercentage,
activeColor: "#FF7C41"
}),
W: common_vendor.t($data.bannerPercentage)
}, {
X: common_vendor.o(() => {
}),
Y: common_vendor.p({
show: $data.bannerShow
})
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-07e72d3c"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/home/home.js.map