search.js
4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
if (!Array) {
const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
_easycom_u_navbar2();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
if (!Math) {
(_easycom_u_navbar + search + shops)();
}
const search = () => "../../componets/searchBox.js";
const shops = () => "../../componets/shops.js";
const _sfc_main = {
setup(__props) {
let keyWord = common_vendor.ref("");
let historyrecord = common_vendor.ref([]);
let shopList = common_vendor.ref([]);
let searchRes = common_vendor.ref(false);
common_vendor.ref("");
common_vendor.ref(1);
common_vendor.ref(1);
common_vendor.onLoad(() => {
getRecords();
});
const serachHistroy = (item) => {
keyWord.value = item;
getSearchs(item);
};
const clearHistory = () => {
common_vendor.index.showModal({
title: "\u63D0\u793A",
content: "\u662F\u5426\u6E05\u7A7A\u5386\u53F2\u8BB0\u5F55",
success: function(res) {
if (res.confirm) {
getDelRecords();
common_vendor.index.showToast({ title: "\u6E05\u7A7A\u6210\u529F" });
common_vendor.index.removeStorage({
key: "searchRecords"
});
} else if (res.cancel) {
console.log("\u7528\u6237\u70B9\u51FB\u53D6\u6D88");
}
}
});
};
const doSearchs = (keyword) => {
if (keyword.trim() != "") {
getSearchs(keyword);
}
};
const input = (data) => {
searchRes.value = false;
shopList.value = [];
};
const getSearchs = async (keyWord2) => {
try {
const res = await api_index.getSearch(keyWord2);
shopList.value = res.goods.concat(res.tjgoods);
searchRes.value = shopList.value.length == 0 ? true : false;
getRecords();
console.log("getSearch", res);
} catch (err) {
console.log("getSearch", err);
}
};
const getRecords = async () => {
try {
const res = await api_index.getRecord();
historyrecord.value = res;
console.log("getRecord", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getRecord", err);
}
};
const getDelRecords = async () => {
try {
const res = await api_index.getDelRecord();
getRecords();
console.log("getDelRecord", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getDelRecord", err);
}
};
common_vendor.onReachBottom(() => {
if (this.page != this.lastPage) {
this.page = this.page + 1;
this.getSearch(1);
} else {
common_vendor.index.showToast({
title: "\u6682\u65E0\u66F4\u591A\u5546\u54C1~",
icon: "none"
});
}
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.p({
bgColor: "#F6F8FA",
title: "\u641C\u7D22",
placeholder: true,
autoBack: true
}),
b: common_vendor.o(doSearchs),
c: common_vendor.o(input),
d: common_vendor.p({
keyWord: common_vendor.unref(keyWord),
disabled: false
}),
e: !common_vendor.unref(shopList).length && !common_vendor.unref(searchRes)
}, !common_vendor.unref(shopList).length && !common_vendor.unref(searchRes) ? {
f: common_vendor.o(clearHistory),
g: common_vendor.f(common_vendor.unref(historyrecord), (item, index, i0) => {
return {
a: common_vendor.t(item),
b: index,
c: common_vendor.o(($event) => serachHistroy(item))
};
})
} : {}, {
h: _ctx.index,
i: common_vendor.p({
list: common_vendor.unref(shopList),
shopWidth: 344,
shopHeight: 344
}),
j: common_vendor.unref(searchRes)
}, common_vendor.unref(searchRes) ? {} : {});
};
}
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/index/search.vue"]]);
wx.createPage(MiniProgramPage);