pocketlesson.js 2.8 KB
// pages/pocketlesson/pocketlesson.js

const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      'http://bronet.wangshuwen.com/kliuytyt@2x.png',
      'http://bronet.wangshuwen.com/kliuytyt@2x.png',
      'http://bronet.wangshuwen.com/kliuytyt@2x.png'
    ],
    indicatorDots: false,
    autoplay: false,
    interval: 2000,
    duration: 1000,
    currentSwiper: 0,

    homelist:'',
    state:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.showbtn()
  
  },

  //是否显示支付按钮、
  showbtn() {
    let that = this;
    var url = '/home/Welcome/paySwitch';
    var params = {


    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        state: res.state
      })



    }).catch((err) => {

    })

  },

  getindexlist(){
    let that = this;
    var url = '/home/Index/index';
    var params = {
      token: wx.getStorageSync('token'),
     
    }
    var header={
      'XX-Token': wx.getStorageSync('token'),
      'XX-Device-Type': 'wxapp'

    }
    app.post(url, params,header).then((res) => {
      console.log(res);

      this.setData({
        homelist:res,
        imgUrls:app.objToArry(res.slide)
      })



    }).catch((err) => {

    })
  },
  // 轮播图图片预览
  viewImg(e){
    let index = e.currentTarget.dataset.index;
    wx.previewImage({
      current: this.data.imgUrls[index],
      urls: this.data.imgUrls,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  //教学方案列表详情
  detail(e) {
    console.log(e)
    let id = e.currentTarget.dataset.id;
    let free=e.currentTarget.dataset.free;
    wx.navigateTo({
      url: '../teachplan/teachplanlistdetail/teachplanlistdetail?id='+id+'&free='+free,
    })
  },
  //搜索
  search(){
    wx.navigateTo({
      url: '../searchpage/searchpage',
    })
  },
  //查看更多
  seemore(){
    wx.navigateTo({
      url: '../teachplan/teachplanlist/teachplanlist',
    })
  },
  swiperChange: function (e) {
    this.setData({
      currentSwiper: e.detail.current
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getindexlist()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})