Files
AGuestSaas/pages/ticket/goods/goods.js
2020-12-28 09:16:11 +08:00

121 lines
2.7 KiB
JavaScript

/*
* 手太欠
* 企获客商城
*/
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
user_coupon_id : '', //券id
title : '', //搜索关键字标题
dataArr : [],
page : {}, //分页信息
lodingStats : false, //加载状态
ordertype : '', //排序类型 price为价格 sell为销量
orderasc : '', //排序方式 asc为正序 desc为倒序
total_page : '',
current : '',
nomore :false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
user_coupon_id: options.user_coupon_id,
})
this.goosInfo()
},
goosInfo() {
if (wx.getStorageSync("token") == "") {
wx.navigateTo({
url: '/pages/login/login'
})
return
}
let orderasc = this.data.orderasc,
ordertype = this.data.ordertype
wx.$api.mall.couponsGoods({
user_coupon_id : this.data.user_coupon_id,
title : this.data.title || '',
page : this.data.page || '',
orderasc : orderasc,
ordertype : ordertype,
}).then(res => {
this.setData({
dataArr : res.data,
total_page: res.page.total_page,
current : res.page.current,
})
})
},
confirmTap(event) {
let searchvalue = event.detail.value
this.setData({
title: searchvalue
})
// 拉取商品列表数据
this.goosInfo();
},
/**
* 综合推荐
*/
emptyTap() {
this.setData({
orderasc : '',
ordertype : ''
})
// 拉取商品列表数据
this.goosInfo();
},
/**
* 销量排序
*/
orderTap(e) {
let type = e.currentTarget.dataset.type
this.setData({
ordertype: type,
})
if (this.data.orderasc == 'asc') {
this.setData({
orderasc: 'desc',
})
} else {
this.setData({
orderasc: 'asc',
})
}
// 拉取商品列表数据
this.goosInfo();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let total_page = this.data.total_page;
let current = parseInt(this.data.current) + 1;
this.setData({
page: current
})
if (current > total_page) {
this.setData({
nomore: true
})
} else {
this.goosInfo();
}
}
})