189 lines
5.9 KiB
JavaScript
189 lines
5.9 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const utils_enumUtils = require("../../utils/enumUtils.js");
|
|
const api_common = require("../../api/common.js");
|
|
const api_news = require("../../api/news.js");
|
|
const utils_index = require("../../utils/index.js");
|
|
const Header = () => "../../components/header.js";
|
|
const _sfc_main = {
|
|
components: { Header },
|
|
data() {
|
|
return {
|
|
titleList: utils_enumUtils.NEWS_TYPE,
|
|
swiperList: [],
|
|
currentNum: 0,
|
|
form: {
|
|
keywork: null,
|
|
type: 1,
|
|
page: 1,
|
|
pageSize: 15
|
|
},
|
|
inputCss: {
|
|
"height": "68rpx",
|
|
"background": "#FFFFFF",
|
|
"border-radius": "16rpx",
|
|
"border": "0rpx",
|
|
"padding": "0 0 0 16px"
|
|
},
|
|
newsList: [],
|
|
newsListTotal: 0,
|
|
loading: false
|
|
};
|
|
},
|
|
onLoad(option) {
|
|
this.getCarouselImage();
|
|
this.loadData();
|
|
},
|
|
methods: {
|
|
formatDate: utils_index.formatDate,
|
|
// 查询轮播图
|
|
async getCarouselImage() {
|
|
const params = {
|
|
pageUi: utils_enumUtils.APP_PAGE_TYPE.NEWS
|
|
};
|
|
const resp = await api_common.getCarouselImage(params);
|
|
if (resp && resp.bizcode === 100) {
|
|
const data = resp.data || [];
|
|
this.swiperList = data.length !== 0 ? data.map((obj) => obj.carouselImage) : [];
|
|
}
|
|
},
|
|
headerClick(item) {
|
|
this.form.type = item.key;
|
|
this.searchTap();
|
|
},
|
|
// 搜索
|
|
searchTap() {
|
|
this.newsList = [];
|
|
this.form.page = 1;
|
|
this.loadData();
|
|
},
|
|
// 加载数据的方法
|
|
async loadData() {
|
|
if (this.loading)
|
|
return;
|
|
this.loading = true;
|
|
try {
|
|
const newData = await this.fetchData(this.form.page, this.form.pageSize);
|
|
if (newData.entitys && newData.entitys.length !== 0) {
|
|
this.newsList = [...this.newsList, ...newData.entitys];
|
|
this.form.page++;
|
|
}
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/news/news.vue:147", "加载数据失败:", error);
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
// 模拟获取数据的方法,实际应用中应该替换为你的数据获取逻辑,例如从服务器获取数据
|
|
async fetchData(page, pageSize) {
|
|
const form = this.form;
|
|
const params = {
|
|
page,
|
|
pageSize,
|
|
type: form.type
|
|
};
|
|
if (form.keywork) {
|
|
params.keywork = form.keywork;
|
|
}
|
|
const data = await api_news.getNewsList(params);
|
|
if (data && data.bizcode === 100 && data.data) {
|
|
return data.data;
|
|
} else {
|
|
return [];
|
|
}
|
|
},
|
|
// 当滚动到底部时触发的方法
|
|
loadMore() {
|
|
this.loadData();
|
|
},
|
|
/**
|
|
* 跳转到详情
|
|
* @param {Object} item
|
|
*/
|
|
jumpInfo(item) {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/news_info/news_info?id=" + item.id
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _component_Header = common_vendor.resolveComponent("Header");
|
|
const _easycom_up_swiper2 = common_vendor.resolveComponent("up-swiper");
|
|
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
|
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
|
|
(_component_Header + _easycom_up_swiper2 + _easycom_up_input2 + _easycom_up_image2)();
|
|
}
|
|
const _easycom_up_swiper = () => "../../uni_modules/uview-plus/components/u-swiper/u-swiper.js";
|
|
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
|
|
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
|
|
if (!Math) {
|
|
(_easycom_up_swiper + _easycom_up_input + _easycom_up_image)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
leftTitle: "商学院",
|
|
["left-path-type"]: "switchTab",
|
|
["left-path"]: "/pages/mine/mine"
|
|
}),
|
|
b: common_vendor.f($data.titleList, (item, k0, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.value),
|
|
b: item.key,
|
|
c: common_vendor.n($data.form.type === item.key ? "heder_item_sel heder_item" : "heder_item"),
|
|
d: common_vendor.o(($event) => $options.headerClick(item), item.key)
|
|
};
|
|
}),
|
|
c: common_vendor.t($data.currentNum + 1),
|
|
d: common_vendor.t($data.swiperList.length),
|
|
e: common_vendor.o((e) => $data.currentNum = e.current),
|
|
f: common_vendor.p({
|
|
list: $data.swiperList,
|
|
height: "120",
|
|
radius: "10",
|
|
bgColor: "#ffffff00"
|
|
}),
|
|
g: common_vendor.o((...args) => $options.searchTap && $options.searchTap(...args)),
|
|
h: common_vendor.o(($event) => $data.form.keywork = $event),
|
|
i: common_vendor.p({
|
|
placeholder: "搜索关键字",
|
|
prefixIcon: "search",
|
|
prefixIconStyle: "font-size: 22px;color: #909399",
|
|
customStyle: $data.inputCss,
|
|
modelValue: $data.form.keywork
|
|
}),
|
|
j: $data.newsList && $data.newsList.length !== 0
|
|
}, $data.newsList && $data.newsList.length !== 0 ? {
|
|
k: common_vendor.f($data.newsList, (item, k0, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.title),
|
|
b: item.content,
|
|
c: common_vendor.t($options.formatDate(item.ctdate)),
|
|
d: "24bc9d41-3-" + i0,
|
|
e: common_vendor.t(item.browses),
|
|
f: item.id,
|
|
g: common_vendor.o(($event) => $options.jumpInfo(item), item.id)
|
|
};
|
|
}),
|
|
l: common_vendor.p({
|
|
src: "/static/login/show.png",
|
|
width: "20",
|
|
height: "20",
|
|
bgColor: "#f1f6ff00"
|
|
})
|
|
} : {
|
|
m: common_vendor.p({
|
|
src: "/static/common/not_order.png",
|
|
width: "80",
|
|
height: "80",
|
|
bgColor: "#f1f6ff00"
|
|
})
|
|
}, {
|
|
n: common_vendor.o((...args) => $options.loadMore && $options.loadMore(...args))
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-24bc9d41"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/news/news.js.map
|