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.
 
 
 
 

107 lines
2.5 KiB

import { mapState } from "vuex";
var app = getApp();
export const myMixin = {
data() {
return {
loading: false,
// 4. 商品 内容
shopProduct: [], // 店铺商品
field: "createtime",
order: "desc",
pagenum: 1,
loading: false,
nomore: false,
nodata: false,
searchVlaue: "",
navIndex: 3,
tops: 0,
hearHeights: 0,
};
},
props: {
hearHeight: {
type: String,
default: "0px",
},
},
computed: {
...mapState(['opt'])
},
mounted() {
this.getData();
},
methods: {
getData: function () {
const that = this;
that.loading = true;
that.getprolist();
},
getprolist(loadmore) {
const that = this;
that.loading = true;
that.nodata = false;
that.nomore = false;
if (!loadmore) {
that.pagenum = 1;
that.shopProduct = [];
}
app.post(
"/ApiShop/getprolist",
{
bid: that.opt.id,
pagenum: that.pagenum,
field: that.field,
order: that.order,
},
function (res) {
that.loading = false;
if (that.pagenum == 1) {
// console.log("that.pagenum-------", that.pagenum, res);
const newShopProduct = [];
res.data.map((item) => {
newShopProduct.push({
proid: item.id,
pic: item.pic,
name: item.name,
sales: item.sales,
sell_price: item.sell_price,
});
});
that.shopProduct = newShopProduct;
if (res.data.length == 0) {
that.nodata = true;
}
} else {
if (res.data.length == 0) {
that.nomore = true;
} else {
console.log("that.pagenum++++++----", that.pagenum);
const newShopProduct = [];
res.data.map((item) => {
newShopProduct.push({
proid: item.id,
pic: item.pic,
name: item.name,
sales: item.sales,
sell_price: item.sell_price,
});
});
that.shopProduct = that.shopProduct.concat(newShopProduct);
}
}
console.log(that.nomore, "打印nomore");
}
);
},
// 滚动
getmorecomment() {
this.pagenum = this.pagenum + 1;
if (!this.nomore && !this.nodata) {
this.getprolist(true);
}
},
},
};