goodtail.js 2.8 KB
// pages/shop/goodtail/goodtail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      {
        url: '../../../img/chairfour.png',
        color: '#E7D3A8',
        colorname:'卡其色',
        idx:0
      },
      {
        url: '../../../img/chairfour.png',
        color: '#D4D4D4',
        colorname: '灰色',
        idx: 1
      },
      {
        url: '../../../img/chairfour.png',
        color: '#15276D',
        colorname: '深蓝',
        idx: 2
      }
      
    ],
    indicatorDots: false,
    autoplay: false,
    interval: 2000,
    duration: 1000,
    currentSwiper: 0,

    // 字轮播
    currentSwipername:0,
    goodnum:1,
    buywrap:false,
    number:2,
    type:'',
    canshu:true
  },

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

  },
  shopintro(){
    this.setData({
      canshu:!this.data.canshu
    })
  },
  //进入首页
  goindex(){
    console.log(9090)
    wx.switchTab({
   
      url: "/pages/homeindex/homeindex",
    })
    
  },
  swiperChange: function (e) {
    console.log(e)
    this.setData({
      currentSwiper: e.detail.current,
      currentSwipername:e.detail.current
    })
  },

  //加入购物车
  addcar(){
    console.log(99)
    this.setData({
      buywrap:true,
      type:1
    })
  },
  //立即购买
  buynow(){
      // wx.navigateTo({
      //   url: '/pages/ordercontainer/sureorderone/sureorderone',
      // })

    this.setData({
      buywrap: true,
      type: 2
    })

  },
  sure(){
    if(this.data.type==1){
      this.setData({
        buywrap:false
      })
    }else{
      wx.navigateTo({
        //url:"/pages/ordercontainer/shopsureorder/shopsureorder"
       url: '/pages/ordercontainer/sureorderone/sureorderone',
      })
    }
  },
  //购物车增加
  add(){
    let newgoodnum=this.data.goodnum;
    newgoodnum++;
    this.setData({
      goodnum:newgoodnum
    })
  },
  hidebuywrap(){
      this.setData({
        buywrap:false
      })
  },

  reduce(){
    let newgoodnum = this.data.goodnum;
    if(newgoodnum<=1){
      this.setData({
        goodnum: 1
      })
    }else{
      newgoodnum=newgoodnum-1;
      this.setData({
        goodnum: newgoodnum
      })
    }
   
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})