暑期实训13-7.26&27

1 下拉刷新、切换刷新

对首页添加了下拉刷新和切换刷新。增加了onShow方法和onPullDownRefresh方法。

onShow: function (options) {
    var _this = this;
    //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框

    wx.showLoading({
      title: '刷新中...',
    })
    setTimeout(function () {
      wx.hideLoading()
    }, 1000)
    _this.setData({
      curpage: 1,
      rb:true,//支持触底刷新
    });
    /**初始化list*/
    //判断app.js onLaunch是否执行完毕  是否得到token
    if (app.globalData.check) {
      console.log("登陆状态正常,开始加载页面")
      _this.getAjaxList(1);
    } else {
      console.log("重新登陆")
      app.checkLoginReadyCallback = res => {
        _this.getAjaxList(1);
      };
    }
  },
 */ //调用刷新时将执行的方法
  onPullDownRefresh: function () {
    //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
    wx.showLoading({
      title: '刷新中...',
    })
    setTimeout(function () {
      wx.hideLoading()
      }, 2000)
      this.setData({
        curpage:1,
        rb:true,//支持触底刷新
      });
      this.getAjaxList(1);
      wx.stopPullDownRefresh();
  }

2 活动描述

对活动的描述设置为一行,可通过点击获取更多描述内容。
这样可以使界面更加整齐,给用户较好的体验。
在这里插入图片描述

//activity.wxml
 <text bindtap="show_mp_act_desc"  data-desc="{{item.act_desc}}" wx:if="{{list}}" space="emsp" class="desc "> {{item.act_desc}}</text>
// ....
 <mp-half-screen-dialog show="{{show_mp_act_desc}}">
    <view slot="title">活动详情</view>
    <view slot="desc">{{mp_act_desc}}</view>
  </mp-half-screen-dialog>
//activity.wxss
.desc {
  font-size: 14px;
  font-weight: 350;
  margin-bottom: 10px;
  /* 超出部分隐藏 */
  overflow: hidden;
  /* 不换行 */
  white-space: nowrap;
  /* 添加... */
  text-overflow: ellipsis; 
}
//activity.js
data{
//....
  mp_act_desc:"",//活动描述
  show_mp_act_desc:false,//是否显示具体描述
}
//显示活动的描述信息
  show_mp_act_desc:function(e){
    this.setData({
      show_mp_act_desc:true,
      mp_act_desc:e.currentTarget.dataset.desc,
    })
  },

3 try catch / if

1.使用Storage时进行try catch包裹

try{
      var token = wx.getStorageSync('skey');
    }catch(error){
      console.log(error,'getStorageSync');
    };

2.在每次请求的success回调中,加一个if判断,原先回调的代码内容全部放入if内。
在这里插入图片描述

4 搜索成功提示

增加了一个搜索成功提示。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值