// pages/index/index.js var app = getApp() Page({ /** * 页面的初始数据 */ data: { indicatorDors: true, autoplay: true, interval:4000, duration:500, activeCategoryId:0, zw:'', imgUrls: [ '../../images/ban11.jpg', '../../images/ban22.jpg' ], imgurl: app.data.resturl, utype:app.globalData.utype, keywords:'' }, tabClick: function(e){ this.setData({ activeCategoryId: e.currentTarget.id }) wx.showLoading({ title: '加载中', mask: true, success: ()=>{ this.getGoodsList(e.currentTarget.id) } }) // this.getGoodsList(e.currentTarget.id) }, getGoodsList: function(){ var that = this; let name = this.data.keywords; wx.request({ url: app.data.resturl + '/index.action', data: { name:name }, success:function(res){ that.setData({ goods: res.data.dlist }) setTimeout(()=>{ wx.hideLoading() },500) } }) }, tabDetails(e){ let kucun = e.currentTarget.dataset.kucun; let id = e.currentTarget.dataset.id; let cid = e.currentTarget.dataset.cid; console.log(kucun + " " + id + " " + cid); if (kucun <= 0) { wx.navigateTo({ url: '../../pages/tjlist/tjlist?cid=' + cid + "&id=" + id, }) }else{ wx.navigateTo({ url: '/pages/goods-details/index?id=' + e.currentTarget.dataset.id }) } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let zw = options.zw; if(zw==null){ zw = '201'; } app.globalData.zw = zw; }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this; that.getGoodsList(); }, goYuyue: function () { let uid = app.globalData.openid; if (uid == '') { wx.redirectTo({ url: '../../pages/login/login' }) return; } wx.navigateTo({ url: '../../pages/yuyue/yuyue' }) }, goGonggao: function () { wx.navigateTo({ url: '../../pages/gglist/gglist' }) }, goLiuyan: function () { let openid = app.globalData.openid; if (openid == '') { wx.redirectTo({ url: '../../pages/login/login', }) return; }; wx.navigateTo({ url: '../../pages/liuyan/liuyan' }) }, searchr: function () { this.getGoodsList(); }, keywordsInput: function (e) { let keywords = e.detail.value; this.setData({ keywords: keywords }); } })