微信小程序发布试用版本

This commit is contained in:
zhonghua1
2026-01-31 21:10:40 +08:00
parent 4ebeec45bc
commit 80d6d46182
338 changed files with 5767 additions and 6091 deletions

View File

@@ -0,0 +1,338 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
const searchLogDbName = "opendb-search-log";
const mallGoodsDbName = "opendb-news-articles";
const associativeSearchField = "title";
const associativeField = "_id,title";
const localSearchListKey = "__local_search_history";
const arrUnique = (arr) => {
for (let i = arr.length - 1; i >= 0; i--) {
const curIndex = arr.indexOf(arr[i]);
const lastIndex = arr.lastIndexOf(arr[i]);
curIndex != lastIndex && arr.splice(lastIndex, 1);
}
return arr;
};
function debounce(fn, interval, isFirstAutoRun) {
var _self = fn;
var timer = null;
var first = true;
if (isFirstAutoRun) {
_self();
}
return function() {
var args = arguments;
var _me = this;
if (first) {
first = false;
_self.apply(_me, args);
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function() {
clearTimeout(timer);
timer = null;
_self.apply(_me, args);
}, interval || 200);
};
}
const _sfc_main = {
data() {
return {
mallGoodsDbName,
searchLogDbName,
statusBarHeight: "0px",
localSearchList: common_vendor.index.getStorageSync(localSearchListKey),
localSearchListDel: false,
netHotListIsHide: false,
searchText: "",
iconColor: "#999999",
associativeList: [],
keyBoardPopup: false,
hotWorld: "DCloud",
// 搜索热词,如果没有输入即回车,则搜索热词,但是不会加入搜索记录
focus: true,
// 是否自动聚焦
speechEngine: "iFly"
// 语音识别引擎 iFly 讯飞 baidu 百度
};
},
created() {
this.db = common_vendor.tr.database();
this.searchLogDb = this.db.collection(this.searchLogDbName);
this.mallGoodsDb = this.db.collection(this.mallGoodsDbName);
common_vendor.index.onKeyboardHeightChange((res) => {
this.keyBoardPopup = res.height !== 0;
});
this.searchText = getApp().globalData.searchText;
},
computed: {
associativeShow() {
return this.searchText && this.associativeList.length;
}
},
onLoad() {
},
methods: {
clear(res) {
common_vendor.index.__f__("log", "at pages-subpackage/list/search/search.nvue:172", "res: ", res);
},
confirm(res) {
this.search(res.value);
},
cancel(res) {
common_vendor.index.hideKeyboard();
this.searchText = "";
this.loadList();
},
search(value) {
if (!value && !this.hotWorld) {
return;
}
if (value) {
if (this.searchText !== value) {
this.searchText = value;
}
this.localSearchListManage(value);
this.searchLogDbAdd(value);
} else if (this.hotWorld) {
this.searchText = this.hotWorld;
}
common_vendor.index.hideKeyboard();
this.loadList(this.searchText);
},
localSearchListManage(word) {
let list = common_vendor.index.getStorageSync(localSearchListKey);
if (list.length) {
this.localSearchList.unshift(word);
arrUnique(this.localSearchList);
if (this.localSearchList.length > 10) {
this.localSearchList.pop();
}
} else {
this.localSearchList = [word];
}
common_vendor.index.setStorageSync(localSearchListKey, this.localSearchList);
},
LocalSearchListClear() {
common_vendor.index.showModal({
content: "确认清空搜索历史吗",
confirmText: "删除",
confirmColor: "red",
cancelColor: "#808080",
success: (res) => {
if (res.confirm) {
this.localSearchListDel = false;
this.localSearchList = [];
common_vendor.index.removeStorageSync(localSearchListKey);
}
}
});
},
LocalSearchlistItemClick(word, index) {
if (this.localSearchListDel) {
this.localSearchList.splice(index, 1);
common_vendor.index.setStorageSync(localSearchListKey, this.localSearchList);
if (!this.localSearchList.length) {
this.localSearchListDel = false;
}
return;
}
this.search(word);
},
searchHotRefresh() {
this.$refs.udb.refresh();
},
speech() {
},
searchLogDbAdd(value) {
this.getDeviceId().then((device_id) => {
this.searchLogDb.add({
// user_id: device_id,
device_id,
content: value,
create_date: Date.now()
});
});
},
getDeviceId() {
return new Promise((resolve, reject) => {
const uniId = common_vendor.index.getStorageSync("uni_id");
if (!uniId) {
resolve(common_vendor.index.getSystemInfoSync().system + "_" + Math.random().toString(36).substr(2));
} else {
resolve(uniId);
}
});
},
associativeClick(item) {
common_vendor.index.__f__("log", "at pages-subpackage/list/search/search.nvue:297", "associativeClick: ", item);
this.loadList(item.title);
},
loadList(text = "") {
getApp().globalData.searchText = text;
common_vendor.index.switchTab({
url: "/pages/list/list"
});
},
backPage() {
common_vendor.index.navigateBack();
}
},
watch: {
searchText: debounce(function(value) {
if (value) {
this.mallGoodsDb.where({
[associativeSearchField]: new RegExp(value, "gi")
}).field(associativeField).get().then((res) => {
this.associativeList = res.result.data;
});
} else {
this.associativeList.length = 0;
getApp().globalData.searchText = "";
}
}, 100)
}
};
if (!Array) {
const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _easycom_unicloud_db2 = common_vendor.resolveComponent("unicloud-db");
const _easycom_uni_list_item2 = common_vendor.resolveComponent("uni-list-item");
const _easycom_uni_list2 = common_vendor.resolveComponent("uni-list");
(_easycom_uni_search_bar2 + _easycom_uni_icons2 + _easycom_unicloud_db2 + _easycom_uni_list_item2 + _easycom_uni_list2)();
}
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_unicloud_db = () => "../../../node-modules/@dcloudio/uni-components/lib/unicloud-db/unicloud-db.js";
const _easycom_uni_list_item = () => "../../../uni_modules/uni-list/components/uni-list-item/uni-list-item.js";
const _easycom_uni_list = () => "../../../uni_modules/uni-list/components/uni-list/uni-list.js";
if (!Math) {
(_easycom_uni_search_bar + _easycom_uni_icons + _easycom_unicloud_db + _easycom_uni_list_item + _easycom_uni_list)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.sr("searchBar", "d9f44979-0"),
b: common_vendor.o($options.clear),
c: common_vendor.o($options.confirm),
d: common_vendor.o($options.cancel),
e: common_vendor.o(($event) => $data.searchText = $event),
f: common_vendor.p({
radius: "100",
focus: $data.focus,
placeholder: $data.hotWorld,
clearButton: "auto",
cancelButton: "always",
modelValue: $data.searchText
}),
g: $data.localSearchList.length
}, $data.localSearchList.length ? common_vendor.e({
h: !$data.localSearchListDel
}, !$data.localSearchListDel ? {
i: common_vendor.o(($event) => $data.localSearchListDel = true),
j: common_vendor.p({
color: $data.iconColor,
size: "18",
type: "trash"
})
} : {
k: common_vendor.o((...args) => $options.LocalSearchListClear && $options.LocalSearchListClear(...args)),
l: common_vendor.o(($event) => $data.localSearchListDel = false)
}, {
m: common_vendor.f($data.localSearchList, (word, index, i0) => {
return common_vendor.e({
a: common_vendor.t(word),
b: word
}, $data.localSearchListDel ? {
c: "d9f44979-2-" + i0,
d: common_vendor.p({
size: "12",
type: "closeempty"
})
} : {}, {
e: index,
f: common_vendor.o(($event) => $options.LocalSearchlistItemClick(word, index), index)
});
}),
n: $data.localSearchListDel
}) : {}, {
o: !$data.netHotListIsHide
}, !$data.netHotListIsHide ? {
p: common_vendor.o($options.searchHotRefresh),
q: common_vendor.p({
color: $data.iconColor,
size: "14",
type: "reload"
})
} : {}, {
r: common_vendor.o(($event) => $data.netHotListIsHide = !$data.netHotListIsHide),
s: common_vendor.p({
color: $data.iconColor,
size: "18",
type: $data.netHotListIsHide ? "eye-slash" : "eye"
}),
t: common_vendor.w(({
data,
loading,
error,
options
}, s0, i0) => {
return common_vendor.e({
a: loading && !$data.netHotListIsHide
}, loading && !$data.netHotListIsHide ? {} : common_vendor.e({
b: !$data.netHotListIsHide
}, !$data.netHotListIsHide ? common_vendor.e({
c: error
}, error ? {
d: common_vendor.t(error.message)
} : {
e: common_vendor.f(data, (word, index, i1) => {
return {
a: common_vendor.t(word.content),
b: index,
c: common_vendor.o(($event) => $options.search(word.content), index)
};
})
}) : {}), {
f: i0,
g: s0
});
}, {
name: "d",
path: "t",
vueId: "d9f44979-5"
}),
v: common_vendor.sr("udb", "d9f44979-5"),
w: common_vendor.p({
field: "content",
collection: "opendb-search-hot",
orderby: "create_date desc,count desc",
["page-data"]: "replace",
["page-size"]: 10
}),
x: $options.associativeShow
}, $options.associativeShow ? {
y: common_vendor.f($data.associativeList, (item, index, i0) => {
return {
a: item._id,
b: common_vendor.o(($event) => $options.associativeClick(item), item._id),
c: "d9f44979-7-" + i0 + ",d9f44979-6",
d: common_vendor.p({
ellipsis: 1,
title: item.name,
["show-extra-icon"]: true,
clickable: true,
["extra-icon"]: {
size: 18,
color: $data.iconColor,
type: "search"
}
})
};
})
} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-d9f44979"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages-subpackage/list/search/search.js.map

View File

@@ -0,0 +1,10 @@
{
"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",
"unicloud-db": "../../../node-modules/@dcloudio/uni-components/lib/unicloud-db/unicloud-db",
"uni-list-item": "../../../uni_modules/uni-list/components/uni-list-item/uni-list-item",
"uni-list": "../../../uni_modules/uni-list/components/uni-list/uni-list"
}
}

View File

@@ -0,0 +1 @@
<view class="container data-v-d9f44979"><view class="search-container data-v-d9f44979"><view class="search-container-bar data-v-d9f44979"><uni-search-bar wx:if="{{f}}" class="r data-v-d9f44979" u-r="searchBar" style="flex:1" bindclear="{{b}}" bindconfirm="{{c}}" bindcancel="{{d}}" u-i="d9f44979-0" bind:__l="__l" bindupdateModelValue="{{e}}" u-p="{{f}}"/></view></view><view class="search-body data-v-d9f44979"><view wx:if="{{g}}" class="word-container data-v-d9f44979"><view class="word-container_header data-v-d9f44979"><text class="word-container_header-text data-v-d9f44979">搜索历史</text><uni-icons wx:if="{{h}}" bindclick="{{i}}" class="search-icons data-v-d9f44979" style="padding-right:0" u-i="d9f44979-1" bind:__l="__l" u-p="{{j}}"></uni-icons><view wx:else class="flex-center flex-row data-v-d9f44979" style="font-weight:500;justify-content:space-between"><text class="data-v-d9f44979" style="font-size:22rpx;color:#666;padding-top:4rpx;padding-bottom:4rpx;padding-right:20rpx" bindtap="{{k}}">全部删除</text><text class="data-v-d9f44979" style="font-size:22rpx;color:#c0402b;padding-top:4rpx;padding-bottom:4rpx;padding-left:20rpx" bindtap="{{l}}">完成</text></view></view><view class="word-container_body data-v-d9f44979"><view wx:for="{{m}}" wx:for-item="word" wx:key="e" class="flex-center flex-row word-container_body-text data-v-d9f44979" bindtap="{{word.f}}"><text class="word-display data-v-d9f44979" key="{{word.b}}">{{word.a}}</text><uni-icons wx:if="{{n}}" class="data-v-d9f44979" u-i="{{word.c}}" bind:__l="__l" u-p="{{word.d}}"/></view></view></view><view class="word-container data-v-d9f44979"><view class="word-container_header data-v-d9f44979"><view class="flex-center flex-row data-v-d9f44979"><text class="word-container_header-text data-v-d9f44979">搜索发现</text><uni-icons wx:if="{{o}}" class="search-icons data-v-d9f44979" bindclick="{{p}}" u-i="d9f44979-3" bind:__l="__l" u-p="{{q}}"></uni-icons></view><uni-icons wx:if="{{s}}" class="search-icons data-v-d9f44979" style="padding-right:0" bindclick="{{r}}" u-i="d9f44979-4" bind:__l="__l" u-p="{{s}}"></uni-icons></view><unicloud-db wx:if="{{w}}" class="r data-v-d9f44979" u-s="{{['d']}}" u-r="udb" u-i="d9f44979-5" bind:__l="__l" u-p="{{w}}"><view wx:for="{{t}}" wx:for-item="v0" wx:key="f" slot="{{v0.g}}"><text wx:if="{{v0.a}}" class="word-container_body-info data-v-d9f44979">正在加载...</text><view wx:else class="word-container_body data-v-d9f44979"><block wx:if="{{v0.b}}"><text wx:if="{{v0.c}}" class="word-container_body-info data-v-d9f44979">{{v0.d}}</text><block wx:else><text wx:for="{{v0.e}}" wx:for-item="word" wx:key="b" class="word-container_body-text data-v-d9f44979" bindtap="{{word.c}}">{{word.a}}</text></block></block><view wx:else class="data-v-d9f44979" style="flex:1"><text class="word-container_body-info data-v-d9f44979">当前搜索发现已隐藏</text></view></view></view></unicloud-db></view></view><view wx:if="{{x}}" class="search-associative data-v-d9f44979"><uni-list class="data-v-d9f44979" u-s="{{['d']}}" u-i="d9f44979-6" bind:__l="__l"><uni-list-item wx:for="{{y}}" wx:for-item="item" wx:key="a" class="data-v-d9f44979" bindclick="{{item.b}}" u-i="{{item.c}}" bind:__l="__l" u-p="{{item.d}}"></uni-list-item></uni-list></view></view>

View File

@@ -0,0 +1,141 @@
@import "../../../nvue.wxss";
page {
height: 100%;
flex: 1;
}
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.status-bar.data-v-d9f44979 {
background-color: #fff;
}
.container.data-v-d9f44979 {
height: 100%;
flex: 1;
background-color: #f7f7f7;
}
.search-body.data-v-d9f44979 {
background-color: #fff;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
.flex-center.data-v-d9f44979 {
display: flex;
justify-content: center;
align-items: center;
}
.flex-row.data-v-d9f44979 {
display: flex;
flex-direction: row;
}
.uni-searchbar__box.data-v-d9f44979 {
border-width: 0;
}
.uni-input-placeholder.data-v-d9f44979 {
font-size: 28rpx;
}
.search-container.data-v-d9f44979 {
height: 52px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
background-color: #fff;
}
.search-container-bar.data-v-d9f44979 {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
}
.search-associative.data-v-d9f44979 {
overflow-y: auto;
position: absolute;
top: 52px;
left: 0;
right: 0;
bottom: 0;
background-color: #fff;
margin-top: 10rpx;
padding-left: 10rpx;
padding-right: 10rpx;
}
.search-icons.data-v-d9f44979 {
padding: 16rpx;
}
.word-display.data-v-d9f44979 {
font-size: 26rpx;
color: #666;
}
.word-container.data-v-d9f44979 {
padding: 20rpx;
}
.word-container_header.data-v-d9f44979 {
display: flex;
height: 72rpx;
line-height: 72rpx;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.word-container_header-text.data-v-d9f44979 {
color: #3e3e3e;
font-size: 30rpx;
font-weight: bold;
}
.word-container_body.data-v-d9f44979 {
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.word-container_body-text.data-v-d9f44979 {
display: flex;
font-size: 26rpx;
color: #666;
justify-content: center;
align-items: center;
background-color: #f6f6f6;
padding: 10rpx 20rpx;
margin: 20rpx 30rpx 0 0;
border-radius: 30rpx;
box-sizing: border-box;
text-align: center;
}
.word-container_body-info.data-v-d9f44979 {
display: block;
flex: 1;
text-align: center;
font-size: 26rpx;
color: #808080;
margin-top: 20rpx;
}