acdr-ui/dist/dev/mp-weixin/modules/mall/activity/index.js
2024-10-01 09:15:35 +08:00

197 lines
7.1 KiB
JavaScript

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
const common_vendor = require("../../../common/vendor.js");
const modules_mall_sheep_index = require("../sheep/index.js");
const modules_mall_sheep_api_promotion_rewardActivity = require("../sheep/api/promotion/rewardActivity.js");
const modules_mall_sheep_hooks_useGoods = require("../sheep/hooks/useGoods.js");
const modules_mall_sheep_api_product_spu = require("../sheep/api/product/spu.js");
if (!Array) {
const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
const _easycom_s_goods_column2 = common_vendor.resolveComponent("s-goods-column");
const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
(_easycom_su_sticky2 + _easycom_s_goods_column2 + _easycom_uni_load_more2 + _easycom_s_layout2 + _component_layout_default_uni)();
}
const _easycom_su_sticky = () => "../sheep/ui/su-sticky/su-sticky.js";
const _easycom_s_goods_column = () => "../sheep/components/s-goods-column/s-goods-column.js";
const _easycom_uni_load_more = () => "../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
const _easycom_s_layout = () => "../sheep/components/s-layout/s-layout.js";
if (!Math) {
(_easycom_su_sticky + _easycom_s_goods_column + _easycom_uni_load_more + _easycom_s_layout)();
}
const _sfc_main = {
__name: "index",
setup(__props) {
const state = common_vendor.reactive({
activityId: 0,
// 获得编号
activityInfo: {},
// 获得信息
pagination: {
list: [],
total: 1,
pageNo: 1,
pageSize: 8
},
loadStatus: "",
leftGoodsList: [],
rightGoodsList: []
});
let count = 0;
let leftHeight = 0;
let rightHeight = 0;
function mountMasonry(height = 0, where = "left") {
if (!state.pagination.list[count])
return;
if (where === "left") {
leftHeight += height;
} else {
rightHeight += height;
}
if (leftHeight <= rightHeight) {
state.leftGoodsList.push(state.pagination.list[count]);
} else {
state.rightGoodsList.push(state.pagination.list[count]);
}
count++;
}
function getList() {
return __async(this, null, function* () {
const params = {};
if (state.activityInfo.productScope === 2) {
params.ids = state.activityInfo.productSpuIds.join(",");
} else if (state.activityInfo.productScope === 3) {
params.categoryIds = state.activityInfo.productSpuIds.join(",");
}
state.loadStatus = "loading";
const { code, data } = yield modules_mall_sheep_api_product_spu.SpuApi.getSpuPage(__spreadValues({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize
}, params));
if (code !== 0) {
return;
}
state.pagination.list = common_vendor.lodash.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
mountMasonry();
});
}
function getActivity(id) {
return __async(this, null, function* () {
const { code, data } = yield modules_mall_sheep_api_promotion_rewardActivity.RewardActivityApi.getRewardActivity(id);
if (code === 0) {
state.activityInfo = data;
}
});
}
function loadMore() {
if (state.loadStatus === "noMore") {
return;
}
state.pagination.pageNo++;
getList();
}
common_vendor.onReachBottom(() => {
loadMore();
});
common_vendor.onLoad((options) => __async(this, null, function* () {
state.activityId = options.activityId;
yield getActivity(state.activityId);
yield getList(state.activityId);
}));
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.f(state.activityInfo.rules, (item, k0, i0) => {
return {
a: common_vendor.t(common_vendor.unref(modules_mall_sheep_hooks_useGoods.formatRewardActivityRule)(state.activityInfo, item)),
b: item
};
}),
b: common_vendor.p({
bgColor: "#fff"
}),
c: common_vendor.f(state.leftGoodsList, (item, k0, i0) => {
return {
a: common_vendor.o(($event) => common_vendor.unref(modules_mall_sheep_index.sheep).$router.go("/modules/mall/goods/index", {
id: item.id
}), item.id),
b: common_vendor.o(($event) => mountMasonry($event, "left"), item.id),
c: "cb505c35-3-" + i0 + ",cb505c35-1",
d: common_vendor.p({
size: "md",
data: item
}),
e: item.id
};
}),
d: common_vendor.f(state.rightGoodsList, (item, k0, i0) => {
return {
a: common_vendor.o(($event) => common_vendor.unref(modules_mall_sheep_index.sheep).$router.go("/modules/mall/goods/index", {
id: item.id
}), item.id),
b: common_vendor.o(($event) => mountMasonry($event, "right"), item.id),
c: "cb505c35-4-" + i0 + ",cb505c35-1",
d: common_vendor.p({
size: "md",
data: item
}),
e: item.id
};
}),
e: state.pagination.total > 0
}, state.pagination.total > 0 ? {
f: common_vendor.o(loadMore),
g: common_vendor.p({
status: state.loadStatus,
["content-text"]: {
contentdown: "上拉加载更多"
}
})
} : {}, {
h: common_vendor.p({
title: state.activityInfo.title
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-cb505c35"]]);
wx.createPage(MiniProgramPage);