123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- // 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
- });
-
- }
- })
|