123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- let app = getApp();
- let host = app.globalData.servsers;
- Page({
-
- data: {
- host:host,
- isSelect: "1",
- dataStateArray: [
- {
- state: '1',
- label: "营销礼赠",
- },
- {
- state: '2',
- label: "商务送礼",
- },
- {
- state: '3',
- label: "员工/福利",
- }
- ],
- filterArray: [
-
-
-
-
- ],
- requestState:true,
- filterStatic: false,
- isNew: true,
- isMin: true,
- goodsList:[],
- page:1,
- limit:20,
- maxPrice:null,
- minPrice:null,
- priceSort: null,
- timeSort: null,
- requestState:true,
- loginStatic: false,
- },
-
- onLoad: function (options) {
-
- },
-
- onReady: function () {
- },
-
- onShow: function () {
- let that = this;
- that.getGiftNavTab(that)
- that.setData({
- goodsList:[],
- page:1,
- })
- if (wx.getStorageSync('channelIdObj').channelId) {
- that.setData({
- loginStatic: true,
- })
- }
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- let that = this;
- if (that.data.requestState){
- that.setData({
- page:that.data.page + 1
- })
- that.getGiftList(that)
- }
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- },
- tab(e){
- let that = this;
- that.setData({
- isSelect: e.currentTarget.dataset.id,
- goodsList:[],
- page:1,
- requestState: true,
- })
- that.getGiftList(that)
- },
- timeSortTap(){
- let that = this;
- that.setData({
- timeSort: that.data.timeSort === null ? 'asc' : that.data.timeSort === 'asc' ? 'desc' : 'asc',
- goodsList: [],
- page: 1,
- requestState: true,
- })
- that.getGiftList(that)
- },
- priceSortTap() {
- let that = this;
- that.setData({
- priceSort: that.data.priceSort === null ? 'asc' : that.data.priceSort === 'asc' ? 'desc' : 'asc',
- goodsList: [],
- page: 1,
- requestState: true,
- })
- that.getGiftList(that)
- },
- priceMaxMinTap(){
- let that = this;
- that.setData({
- filterStatic: true
- })
- },
- close(){
- let that = this;
- that.setData({
- filterStatic: false
- })
- },
- blurPriceMin(e){
-
- let that = this;
- that.setData({
- minPrice: e.detail.value,
- page: 1,
- requestState:true,
- goodsList: [],
- })
- that.getGiftList(that)
- },
- blurPriceMax(e){
- let that = this;
- that.setData({
- maxPrice:e.detail.value,
- page:1,
- requestState: true,
- goodsList:[],
- })
- that.getGiftList(that)
- },
- getGiftNavTab(that){
- wx.request({
- url: host + '/classifyapi/classifyTwoAll',
- method: 'get',
- data: {
- classifyHigher:'3060'
- },
- success(res){
- console.log(res,"res")
- that.setData({
- dataStateArray:res.data.rows,
- isSelect:res.data.rows[0].id
- })
- that.getGiftList(that)
- }
- })
- },
- getGiftList(that){
- let data = {
- channelId: 5,
- classId: that.data.isSelect,
- limit: that.data.limit,
- offset: that.data.page,
- channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
- }
- if (that.data.priceSort) {
- data.priceSort = that.data.priceSort
- }
- if (that.data.timeSort) {
- data.timeSort = that.data.timeSort
- }
- if (that.data.maxPrice){
- data.maxPrice = that.data.maxPrice
- }
- if (that.data.minPrice) {
- data.minPrice = that.data.minPrice
- }
- wx.request({
- url: host +'/commodityapi/queryCommodityByClass',
- method:'get',
- data:data,
- success(res){
- let dataArray = that.data.goodsList;
- res.data.rows.forEach(el=>{
- el.logo = el.commodity_logo.split(",")
- })
- dataArray.push(...res.data.rows)
- that.setData({
- goodsList: dataArray,
- requestState: res.data.rows.length == that.data.limit
- })
- }
- })
- },
- toGoodsDetail(e){
- let that = this, id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/buy/buy?com_id='+id,
- })
- }
- })
|