You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

109 lines
2.6 KiB

import { mapState } from "vuex";
var app = getApp();
export const myMixin = {
data() {
return {
keyword: "",
event_rul: app.globalData.event_url,
field: "sort",
order: "desc",
shopProduct: [],
loading: false,
nomore: false,
nodata: false,
pagenum: 1,
}
},
computed: {
...mapState([
'opt'
])
},
mounted() {
this.keyword = this.opt.keyword;
console.log("keyword",this.opt.keyword)
this.getprolist(this.keyword);
},
methods: {
// 获取商品列表
getprolist(word, loadmore) {
const that = this;
that.loading = true;
that.nodata = false;
that.nomore = false;
if (!loadmore) {
that.pagenum = 1;
that.shopProduct = [];
}
app.post(
"ApiShop/getprolist",
{
pagenum: that.pagenum,
field: that.field,
keyword: word,
order: that.order,
bid: that.opt.bid,
},
function (res) {
console.log(res);
if (that.pagenum == 1) {
res.data.map((item) => {
if (item.id) {
item.proid = item.id;
}
that.shopProduct.push(item);
});
if (res.data.length == 0) {
that.nodata = true;
}
} else {
if (res.data.length == 0) {
that.nomore = true;
} else {
console.log("that.pagenum++++++----", that.pagenum);
res.data.map((item) => {
if (item.id) {
item.proid = item.id;
}
that.shopProduct = that.shopProduct.concat(item);
});
}
}
}
);
that.loading = false;
},
// 搜索
searchConfirm() {
this.getprolist(this.keyword);
},
// 价格升序降序切换
searchSelectNavList(n) {
this.searchNavListIndx = n;
if (this.searchNavListIndx == 3) {
this.order = this.order == "asc" ? "desc" : "asc";
}
},
// 切换 -商品
sortClick(e) {
this.field = e.currentTarget.dataset.field;
this.order = e.currentTarget.dataset.order;
// 每次切换之前先把商品列表清空
this.shopProduct = [];
this.getprolist(this.keyword);
},
// 滚动
getmorecomment() {
this.pagenum = this.pagenum + 1;
if (!this.nomore && !this.nodata) {
this.getprolist(this.keyword, true);
}
},
// 删除标签
delKeywordtex() {
this.keyword = "";
},
},
};