"use strict";
|
const common_vendor = require("../../../common/vendor.js");
|
const common_util = require("../../../common/util.js");
|
const _sfc_main = {
|
data() {
|
return {
|
getNumData: common_util.getNumData,
|
mathf: common_util.mathf,
|
barList: [
|
{
|
id: 1,
|
name: "淘宝"
|
},
|
{
|
id: 2,
|
name: "京东"
|
},
|
{
|
id: 3,
|
name: "抖音"
|
},
|
{
|
id: 4,
|
name: "拼多多"
|
}
|
],
|
scrollInto: "",
|
TabCur: 1,
|
goodsList: [],
|
currentGoodsPage: 1,
|
loadingMore: true,
|
nomore: false,
|
inputValue: "",
|
showAssociate: false,
|
linkList: [],
|
nodata: false,
|
selectType: 0,
|
hasCoupon: false,
|
scrollTop: 0,
|
old: {
|
scrollTop: 0
|
},
|
hotSearchList: [],
|
hotSearchListAll: [],
|
isShowMore: false
|
};
|
},
|
onLoad(opt) {
|
this.GetHeightCommissionGoodList();
|
if (opt.keyWords) {
|
this.inputValue = opt.keyWords;
|
this.GetSearchGoodsList({
|
cur: 1,
|
keyWords: opt.keyWords
|
});
|
}
|
},
|
onShareAppMessage: function() {
|
return {
|
title: "淘券获取",
|
path: "/pages/index/index"
|
// promise
|
};
|
},
|
onShareTimeline() {
|
return {
|
title: "淘券获取",
|
query: "/pages/index/index"
|
};
|
},
|
methods: {
|
//搜索
|
GetSearchGoodsList(param) {
|
let me = this;
|
if (me.currentGoodsPage !== 1 && me.currentGoodsPage == param.cur) {
|
return;
|
}
|
me.showAssociate = false;
|
let url = "https://h.ushopvip.com/api/TkProduct/GetSearchGoodsList";
|
let params = {
|
pageNo: param.cur,
|
pageSize: 20,
|
hasCoupon: this.hasCoupon ? 1 : 0,
|
// type: null,
|
// pageId: null,
|
keyWords: param.keyWords,
|
// keyWords:'',
|
// tmall: null,
|
sort: param.type ?? 0
|
};
|
if (me.TabCur == 3) {
|
url = "https://h.ushopvip.com/api/TkTiktokProduct/GetSxSearchGoodsList";
|
} else if (me.TabCur == 2) {
|
url = "https://h.ushopvip.com/api/TkJdProduct/GetSearchGoodsList";
|
params = {
|
pageNo: param.cur,
|
pageSize: 20,
|
keyword: param.keyWords,
|
sortName: param.type == 1 ? "inOrderCount30Days" : "",
|
sort: "desc"
|
};
|
} else if (me.TabCur == 4) {
|
url = "https://h.ushopvip.com/api/TkPddProduct/GetPddSearchGoodsList";
|
}
|
common_vendor.index.request({
|
url,
|
method: "POST",
|
data: params,
|
success(res) {
|
var _a;
|
if ((_a = res.data) == null ? void 0 : _a.success) {
|
if (res.data.result.length < 20) {
|
me.nomore = true;
|
}
|
if (param.cur === 1) {
|
me.goodsList = res.data.result;
|
me.currentGoodsPage = param.cur;
|
me.loadingMore = true;
|
me.goTop();
|
} else {
|
let data = me.goodsList;
|
me.goodsList = data.concat(res.data.result);
|
me.currentGoodsPage = param.cur;
|
me.loadingMore = true;
|
}
|
} else {
|
if (param.cur === 1) {
|
me.goodsList = [];
|
me.nodata = true;
|
} else {
|
me.nomore = true;
|
}
|
}
|
},
|
fail(err) {
|
console.log("获取openid失败:", err);
|
}
|
});
|
},
|
GetSearchSuggestion(txt) {
|
let me = this;
|
common_vendor.index.request({
|
url: "https://h.ushopvip.com/api/TkProduct/GetSearchSuggestion",
|
method: "POST",
|
data: {
|
keyWords: txt
|
},
|
success(res) {
|
var _a;
|
if ((_a = res.data) == null ? void 0 : _a.success) {
|
let data = res.data.result.data;
|
data.forEach((i) => {
|
let d = i.kw.split(txt);
|
i.keywords = d;
|
});
|
me.linkList = data;
|
}
|
},
|
fail(err) {
|
console.log("获取openid失败:", err);
|
}
|
});
|
},
|
GetHeightCommissionGoodList() {
|
let me = this;
|
common_vendor.index.request({
|
url: "https://h.ushopvip.com/api/TkProduct/GetHotTop100",
|
method: "POST",
|
data: {
|
pageNo: 1,
|
pageSize: 10,
|
hasCoupon: true
|
},
|
success(res) {
|
var _a;
|
if ((_a = res.data) == null ? void 0 : _a.success) {
|
let data = res.data.result.hotWords;
|
me.hotSearchListAll = data;
|
me.hotSearchList = data.slice(0, 10);
|
}
|
},
|
fail(err) {
|
console.log("获取openid失败:", err);
|
}
|
});
|
},
|
loadMore() {
|
if (this.nomore) {
|
return;
|
}
|
this.loadingMore = false;
|
this.GetSearchGoodsList({
|
cur: this.currentGoodsPage + 1,
|
keyWords: this.inputValue,
|
type: this.selectType
|
});
|
},
|
scroll: function(e) {
|
console.log(e);
|
this.old.scrollTop = e.detail.scrollTop;
|
},
|
goTop: function(e) {
|
this.scrollTop = this.old.scrollTop;
|
this.$nextTick(function() {
|
this.scrollTop = 0;
|
});
|
},
|
TabClick(id) {
|
this.nomore = false;
|
this.selectType = 0;
|
this.nodata = false;
|
for (let i = 0; i < this.barList.length; ++i) {
|
if (id === this.barList[i].id) {
|
this.TabCur = this.barList[i].id;
|
this.scrollInto = this.barList[i].id;
|
if (this.inputValue) {
|
this.GetSearchGoodsList({
|
cur: 1,
|
keyWords: this.inputValue,
|
type: 0
|
});
|
}
|
}
|
}
|
},
|
gotogoodDetail(type, id, record) {
|
if (type == 1) {
|
common_vendor.index.navigateTo({
|
url: "/pages/goodDetail/index?id=" + id + "&type=" + this.TabCur + "&info=" + encodeURIComponent(JSON.stringify(record))
|
});
|
}
|
},
|
valueChange(val) {
|
this.inputValue = val.target.value;
|
this.showAssociate = true;
|
if (!val.target.value || val.target.value.replaceAll(" ", "") == "") {
|
this.linkList = [];
|
return;
|
}
|
this.GetSearchSuggestion(val.target.value);
|
},
|
onfocus() {
|
if (this.inputValue) {
|
this.showAssociate = true;
|
}
|
},
|
onblur() {
|
this.showAssociate = false;
|
},
|
clickSearch(txt) {
|
this.nomore = false;
|
this.nodata = false;
|
this.inputValue = txt == "" ? "女装" : txt;
|
this.GetSearchGoodsList({
|
cur: 1,
|
keyWords: txt == "" ? "女装" : txt,
|
type: this.selectType ?? 0
|
});
|
},
|
setSearchType(type) {
|
let t = this.selectType;
|
if (type < 5) {
|
t = type;
|
} else {
|
if (t < 5) {
|
t = 6;
|
} else if (t == 6) {
|
t = 5;
|
} else {
|
t = 0;
|
}
|
}
|
this.nomore = false;
|
this.nodata = false;
|
this.selectType = t;
|
this.GetSearchGoodsList({
|
cur: 1,
|
keyWords: this.inputValue,
|
type: t
|
});
|
},
|
radioClick() {
|
this.nomore = false;
|
this.nodata = false;
|
this.hasCoupon = !this.hasCoupon;
|
this.GetSearchGoodsList({
|
cur: 1,
|
keyWords: this.inputValue,
|
type: this.selectType
|
});
|
},
|
showMore() {
|
if (this.isShowMore) {
|
common_vendor.index.pageScrollTo({
|
scrollTop: 0
|
});
|
}
|
this.isShowMore = !this.isShowMore;
|
}
|
}
|
};
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
return common_vendor.e({
|
a: $data.inputValue,
|
b: common_vendor.o((...args) => $options.valueChange && $options.valueChange(...args)),
|
c: common_vendor.o((...args) => $options.onfocus && $options.onfocus(...args)),
|
d: common_vendor.o(($event) => $options.clickSearch($data.inputValue)),
|
e: common_vendor.o(($event) => $options.clickSearch($data.inputValue)),
|
f: $data.showAssociate
|
}, $data.showAssociate ? common_vendor.e({
|
g: $data.inputValue
|
}, $data.inputValue ? {
|
h: common_vendor.f($data.linkList, (item, index, i0) => {
|
return {
|
a: common_vendor.f(item.keywords, (item2, index2, i1) => {
|
return common_vendor.e({
|
a: item2
|
}, item2 ? {
|
b: common_vendor.t(item2)
|
} : {
|
c: common_vendor.t($data.inputValue)
|
}, {
|
d: item2
|
});
|
}),
|
b: common_vendor.o(($event) => $options.clickSearch(item.kw), item.kw),
|
c: item.kw
|
};
|
})
|
} : {}) : common_vendor.e({
|
i: common_vendor.f($data.barList, (item, index, i0) => {
|
return {
|
a: common_vendor.t(item.name),
|
b: "id" + item.id,
|
c: "key" + item.id,
|
d: index,
|
e: common_vendor.n(item.id == $data.TabCur ? "textlight" : "textan"),
|
f: index,
|
g: common_vendor.o(($event) => $options.TabClick(item.id), "key" + item.id)
|
};
|
}),
|
j: "id" + $data.scrollInto,
|
k: ($data.TabCur == 1 || $data.TabCur == 3) && $data.goodsList.length == 0
|
}, ($data.TabCur == 1 || $data.TabCur == 3) && $data.goodsList.length == 0 ? {
|
l: $data.TabCur == 1 ? "https://img.alicdn.com/imgextra/i2/751308485/O1CN01BB2oVT2CYBRnKHHsQ_!!751308485.png" : "https://img.alicdn.com/imgextra/i1/751308485/O1CN01mQQZ6X2CYBRqECkNj_!!751308485.png",
|
m: common_vendor.t($data.TabCur == 1 ? "淘宝" : "抖音")
|
} : {}, {
|
n: $data.TabCur == 1 && $data.goodsList.length == 0
|
}, $data.TabCur == 1 && $data.goodsList.length == 0 ? {
|
o: common_vendor.f($data.isShowMore ? $data.hotSearchListAll : $data.hotSearchList, (itemm, indexm, i0) => {
|
return {
|
a: common_vendor.t(indexm + 1),
|
b: common_vendor.n(indexm == 0 ? "hotsearch_num0" : indexm == 1 ? "hotsearch_num1" : indexm == 2 ? "hotsearch_num2" : indexm > 8 ? "hotsearch_num3" : indexm == 99 ? "hotsearch_num5" : "hotsearch_num4"),
|
c: common_vendor.t(itemm),
|
d: common_vendor.o(($event) => $options.clickSearch(itemm))
|
};
|
}),
|
p: common_vendor.t($data.isShowMore ? "收起更多" : "显示更多"),
|
q: common_vendor.o((...args) => $options.showMore && $options.showMore(...args))
|
} : {}, {
|
r: $data.goodsList.length > 0
|
}, $data.goodsList.length > 0 ? common_vendor.e({
|
s: common_vendor.n($data.selectType == 0 ? "searchTypeSelected" : ""),
|
t: common_vendor.o(($event) => $options.setSearchType(0)),
|
v: common_vendor.n($data.selectType == 1 ? "searchTypeSelected" : ""),
|
w: common_vendor.o(($event) => $options.setSearchType(1)),
|
x: $data.TabCur == 1
|
}, $data.TabCur == 1 ? {
|
y: common_vendor.n($data.selectType == 6 ? "activeup" : ""),
|
z: common_vendor.n($data.selectType == 5 ? "activedown" : ""),
|
A: common_vendor.o(($event) => $options.setSearchType(5)),
|
B: common_vendor.n($data.selectType == 5 || $data.selectType == 6 ? "searchTypeSelected" : "")
|
} : {}) : {}, {
|
C: $data.goodsList.length > 0 || $data.nodata
|
}, $data.goodsList.length > 0 || $data.nodata ? common_vendor.e({
|
D: common_vendor.f($data.goodsList, (item, index, i0) => {
|
return common_vendor.e({
|
a: item.mainPic,
|
b: item.shopType == 0 || item.shopType == 1
|
}, item.shopType == 0 || item.shopType == 1 ? {
|
c: item.shopType == 0 ? "https://img.alicdn.com/imgextra/i4/751308485/O1CN01ppfg8j2CYBRpPtb51_!!751308485.png" : "https://img.alicdn.com/imgextra/i4/751308485/O1CN01mKVp3U2CYBRzeHVcG_!!751308485.png"
|
} : {}, {
|
d: common_vendor.t(item.dtitle == "" ? item.desc : item.dtitle),
|
e: Number(item.actualPrice) && item.actualPrice !== item.originalPrice
|
}, Number(item.actualPrice) && item.actualPrice !== item.originalPrice ? {
|
f: common_vendor.t(item.actualPrice)
|
} : {
|
g: common_vendor.t(item.originalPrice)
|
}, {
|
h: item.couponPrice !== "0" && item.couponPrice || $data.mathf.subtract(Number(item.originalPrice), Number(item.actualPrice)) > 0 && item.actualPrice !== "0"
|
}, item.couponPrice !== "0" && item.couponPrice || $data.mathf.subtract(Number(item.originalPrice), Number(item.actualPrice)) > 0 && item.actualPrice !== "0" ? {
|
i: common_vendor.t(item.originalPrice ? $data.mathf.subtract(Number(item.originalPrice), Number(item.actualPrice)) : item.couponPrice)
|
} : {}, {
|
j: common_vendor.t(item.allsale ? item.allsale : Number(item.monthsale) == 0 || Number(item.monthSales) == 0 ? " 0 " : $data.getNumData(item.monthsale ?? item.monthSales) + "+"),
|
k: common_vendor.n(item.couponPrice !== "0" ? "goodCardDesc_bottomRighttext" : "goodCardDesc_bottomRighttext2"),
|
l: common_vendor.o(($event) => $options.gotogoodDetail(1, item.goodsId, item), item.goodsId),
|
m: item.goodsId
|
});
|
}),
|
E: !$data.nodata
|
}, !$data.nodata ? common_vendor.e({
|
F: $data.nomore
|
}, $data.nomore ? {} : $data.loadingMore && !$data.nomore ? {} : $data.loadingMore == false && !$data.nomore ? {} : {}, {
|
G: $data.loadingMore && !$data.nomore,
|
H: $data.loadingMore == false && !$data.nomore
|
}) : {}, {
|
I: common_vendor.o(($event) => $options.loadMore())
|
}) : {}));
|
}
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/OPProject/fx_h5_web/pages/index/search/index.vue"]]);
|
_sfc_main.__runtimeHooks = 6;
|
wx.createPage(MiniProgramPage);
|