feat:初始提交uni-app项目

This commit is contained in:
2026-01-14 18:19:33 +08:00
commit 0dcbd340e6
515 changed files with 38560 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const api_apis = require("../../api/apis.js");
if (!Array) {
const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _easycom_uv_empty2 = common_vendor.resolveComponent("uv-empty");
const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
(_easycom_uni_search_bar2 + _easycom_uni_icons2 + _easycom_uv_empty2 + _easycom_uni_load_more2)();
}
const _easycom_uni_search_bar = () => "../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.js";
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_uv_empty = () => "../../uni_modules/uv-empty/components/uv-empty/uv-empty.js";
const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
if (!Math) {
(_easycom_uni_search_bar + _easycom_uni_icons + _easycom_uv_empty + _easycom_uni_load_more)();
}
const _sfc_main = {
__name: "search",
setup(__props) {
const queryParams = common_vendor.ref({
pageNum: 1,
pageSize: 12,
keyword: ""
});
const historySearch = common_vendor.ref(common_vendor.index.getStorageSync("historySearch") || []);
const recommendList = common_vendor.ref(["美女", "帅哥", "宠物", "卡通"]);
const noData = common_vendor.ref(false);
const noSearch = common_vendor.ref(false);
const classList = common_vendor.ref([]);
const onClear = () => {
initParams();
};
const clickTab = (value) => {
initParams(value);
onSearch();
};
const removeHistory = () => {
common_vendor.index.showModal({
title: "是否清空历史搜索",
success: (res) => {
if (res.confirm) {
common_vendor.index.removeStorageSync("historySearch");
historySearch.value = [];
}
}
});
};
const onSearch = () => {
common_vendor.index.showLoading();
historySearch.value = [.../* @__PURE__ */ new Set([queryParams.value.keyword, ...historySearch.value])].slice(0, 10);
common_vendor.index.setStorageSync("historySearch", historySearch.value);
initParams(queryParams.value.keyword);
searchData();
};
const searchData = async () => {
try {
let res = await api_apis.apiSearchData(queryParams.value);
classList.value = [...classList.value, ...res.data];
common_vendor.index.setStorageSync("storgClassList", classList.value);
if (queryParams.value.pageSize > res.data.length)
noData.value = true;
if (res.data.length == 0 && classList.value.length == 0)
noSearch.value = true;
} finally {
common_vendor.index.hideLoading();
}
};
const initParams = (value = "") => {
classList.value = [];
noData.value = false;
noSearch.value = false;
queryParams.value = {
pageNum: 1,
pageSize: 12,
// 如果有传入值就把这个值赋给keyword没有值的话就默认变成""
keyword: value || ""
};
};
common_vendor.onReachBottom(() => {
if (noData.value)
return;
queryParams.value.pageNum++;
searchData();
});
common_vendor.onUnload(() => {
common_vendor.index.removeStorageSync("storgClassList", classList.value);
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(onSearch),
b: common_vendor.o(onClear),
c: common_vendor.o(onClear),
d: common_vendor.o(($event) => queryParams.value.keyword = $event),
e: common_vendor.p({
focus: true,
placeholder: "搜索",
modelValue: queryParams.value.keyword
}),
f: !classList.value.length || noSearch.value
}, !classList.value.length || noSearch.value ? common_vendor.e({
g: historySearch.value.length
}, historySearch.value.length ? {
h: common_vendor.p({
type: "trash",
size: "25"
}),
i: common_vendor.o(removeHistory),
j: common_vendor.f(historySearch.value, (tab, k0, i0) => {
return {
a: common_vendor.t(tab),
b: tab,
c: common_vendor.o(($event) => clickTab(tab), tab)
};
})
} : {}, {
k: common_vendor.f(recommendList.value, (tab, k0, i0) => {
return {
a: common_vendor.t(tab),
b: tab,
c: common_vendor.o(($event) => clickTab(tab), tab)
};
})
}) : {}, {
l: noSearch.value
}, noSearch.value ? {
m: common_vendor.p({
mode: "search"
})
} : common_vendor.e({
n: common_vendor.f(classList.value, (item, k0, i0) => {
return {
a: item.smallPicurl,
b: `/pages/preview/preview?id=${item._id}`,
c: item._id
};
}),
o: noData.value || classList.value.length
}, noData.value || classList.value.length ? {
p: common_vendor.p({
status: noData.value ? "noMore" : "loading"
})
} : {}));
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c10c040c"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/search/search.js.map

View File

@@ -0,0 +1,9 @@
{
"navigationBarTitleText": "搜索",
"usingComponents": {
"uni-search-bar": "../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar",
"uni-icons": "../../uni_modules/uni-icons/components/uni-icons/uni-icons",
"uv-empty": "../../uni_modules/uv-empty/components/uv-empty/uv-empty",
"uni-load-more": "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more"
}
}

View File

@@ -0,0 +1 @@
<view class="searchLayout data-v-c10c040c"><view class="search data-v-c10c040c"><uni-search-bar wx:if="{{e}}" class="data-v-c10c040c" bindconfirm="{{a}}" bindcancel="{{b}}" bindclear="{{c}}" u-i="c10c040c-0" bind:__l="__l" bindupdateModelValue="{{d}}" u-p="{{e}}"></uni-search-bar></view><view wx:if="{{f}}" class="data-v-c10c040c"><view wx:if="{{g}}" class="history data-v-c10c040c"><view class="topTitle data-v-c10c040c"><view class="text data-v-c10c040c">最近搜索</view><view class="icon data-v-c10c040c" bindtap="{{i}}"><uni-icons wx:if="{{h}}" class="data-v-c10c040c" u-i="c10c040c-1" bind:__l="__l" u-p="{{h}}"></uni-icons></view></view><view class="tabs data-v-c10c040c"><view wx:for="{{j}}" wx:for-item="tab" wx:key="b" class="tab data-v-c10c040c" bindtap="{{tab.c}}">{{tab.a}}</view></view></view><view class="recommend data-v-c10c040c"><view class="topTitle data-v-c10c040c"><view class="text data-v-c10c040c">热门搜索</view></view><view class="tabs data-v-c10c040c"><view wx:for="{{k}}" wx:for-item="tab" wx:key="b" class="tab data-v-c10c040c" bindtap="{{tab.c}}">{{tab.a}}</view></view></view></view><view wx:if="{{l}}" class="noSearch data-v-c10c040c"><uv-empty wx:if="{{m}}" class="data-v-c10c040c" u-i="c10c040c-2" bind:__l="__l" u-p="{{m}}"></uv-empty></view><view wx:else class="data-v-c10c040c"><view class="list data-v-c10c040c"><navigator wx:for="{{n}}" wx:for-item="item" wx:key="c" url="{{item.b}}" class="item data-v-c10c040c"><image class="data-v-c10c040c" src="{{item.a}}" mode="aspectFill"></image></navigator></view><view wx:if="{{o}}" class="loadingLayout data-v-c10c040c"><uni-load-more wx:if="{{p}}" class="data-v-c10c040c" u-i="c10c040c-3" bind:__l="__l" u-p="{{p}}"/></view></view></view>

View File

@@ -0,0 +1,68 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.searchLayout .search.data-v-c10c040c {
padding: 0 10rpx;
}
.searchLayout .topTitle.data-v-c10c040c {
display: flex;
justify-content: space-between;
align-items: center;
}
.searchLayout .history.data-v-c10c040c {
padding: 30rpx;
}
.searchLayout .recommend.data-v-c10c040c {
padding: 30rpx;
}
.searchLayout .tabs.data-v-c10c040c {
display: flex;
align-items: center;
flex-wrap: wrap;
padding-top: 20rpx;
}
.searchLayout .tabs .tab.data-v-c10c040c {
background: #F4F4F4;
font-size: 28rpx;
color: #333;
padding: 10rpx 28rpx;
border-radius: 50rpx;
margin-right: 20rpx;
margin-top: 20rpx;
}
.searchLayout .list.data-v-c10c040c {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 5rpx;
padding: 20rpx 5rpx;
}
.searchLayout .list .item.data-v-c10c040c {
height: 440rpx;
}
.searchLayout .list .item image.data-v-c10c040c {
height: 100%;
width: 100%;
display: block;
}