微信小程序缓存用户密码及轮播

122 阅读1分钟

1.缓存用户及密码:

wxml内容:

用户名:<input class="input-sty" placeholder="请输入您的账户" bindinput="bindKeyInput"/>

密码:<input class="input-sty" placeholder="请输入您的密码" bindinput="bindKeyInput2" type="password"/>

<button bindtap="dl" size="mini" type="primary" plain="">登录

js内容;

// pages/shuoye/shouye.js

Page({

    /**

     * 页面的初始数据

     */

    data: {

    },

    bindKeyInput:function(e){

        console.log(e)

        let {detail:{value}} = e;

        this.setData({

            inputVal:value

        })

\

        },

    bindKeyInput2:function(a){

        console.log(a)

        let {detail:{value}} = a;

        this.setData({

            inputVal1:value

        })

\

        },

    dl:function(res){

        wx.setStorageSync('username', this.data.inputVal),

        wx.setStorageSync('password', this.data.inputVal1),

        wx.navigateTo({

          url: '/pages/lunbo/lunbo',

        })

\

    },

    /**

     * 生命周期函数--监听页面加载

     */

    onLoad: function (options) {

    },

    /**

     * 生命周期函数--监听页面初次渲染完成

     */

    onReady: function () {

    },

    /**

     * 生命周期函数--监听页面显示

     */

    onShow: function () {

    },

    /**

     * 生命周期函数--监听页面隐藏

     */

    onHide: function () {

    },

    /**

     * 生命周期函数--监听页面卸载

     */

    onUnload: function () {

    },

    /**

     * 页面相关事件处理函数--监听用户下拉动作

     */

    onPullDownRefresh: function () {

    },

    /**

     * 页面上拉触底事件的处理函数

     */

    onReachBottom: function () {

    },

    /**

     * 用户点击右上角分享

     */

    onShareAppMessage: function () {

    }

})

wxss内容:

/* pages/shuoye/shouye.wxss */

.input-sty{

    border: 1px solid #000;

    margin: 5px;

    padding: 5px;

}

效果图:

\

2.轮播:

wxml内容:

<swiper indicator-dots="{{indicatorDots}}"

  autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}} " bindchange="bindchangeTag">

  <block wx:for="{{imgUrls}}">

    

      <image src="{{item}}" class="slide-image"/>

    

  

<button bindtap="changeIndicatorDots"> 是否显示面板指示点 

<button bindtap="changeAutoplay"> 是否自动切换 

<slider bindchange="intervalChange" show-value min="1000" max="2000"/> 自动切换时间间隔

<slider bindchange="durationChange" show-value min="1800" max="10000"/> 滑动动画时长

JS内容:

Page({

    data: {

      imgUrls: [

        'img0.baidu.com/it/u=328866…',

        'img0.baidu.com/it/u=379385…',

        'img1.baidu.com/it/u=235607…',

        'img1.baidu.com/it/u=270638…'

      ],

      indicatorDots: true,

      autoplay: true,

      interval: 1000,

      duration: 1800

    },

    //是否显示面板指示点

    changeIndicatorDots: function(e) {

      this.setData({

        indicatorDots: !this.data.indicatorDots

      })

    },

    //是否自动切换

    changeAutoplay: function(e) {

      this.setData({

        autoplay: !this.data.autoplay

      })

    },

    //自动切换时间间隔

    intervalChange: function(e) {

      this.setData({

        // e.detail.value获取slider的值

        interval: e.detail.value

      })

    },

    //滑动动画时长

    durationChange: function(e) {

      this.setData({

        duration: e.detail.value

      })

    },

    //当页面改变是会触发

    bindchangeTag:function(e){

      console.log("bindchangeTag...")

    }, 

    onLoad:function(options){

      // 页面初始化 options为页面跳转所带来的参数

    },

    onReady:function(){

      // 页面渲染完成

    },

    onShow:function(){

      // 页面显示

    },

    onHide:function(){

      // 页面隐藏

    },

    onUnload:function(){

      // 页面关闭

    }

  })

wxss内容:

/* pages/lunbo/lunbo.wxss */

.slide-image{

    width: 100%;

    height: 160px;

}