1.记录一下工作中容易遇到,但不容易发现的小问题(持续更新)

if (authenticationStatus == 0) {
          console.log('来了吗');
          wx.showModal({
            title: '提示',
            content: '您需要认证通过后才能使用此功能',
            confirmText: '去认证',
            success(res) {
              if (res.confirm) {
                wx.router.push({
                  name: 'IdSelect',
                  params: {}
                })
              } else if (res.cancel) {
                console.log('用户点击取消')
              }
            }
          })
          return true
        }

这样写是不能进入if条件里面的,因为当被判断的值为0时,会转化成null/undefind,返回false,所以要在判断语句上加上

if (authenticationStatus!=undefined || authenticationStatus!=null) {
        console.log('走没有');
        if (authenticationStatus == 0) {
          console.log('来了吗');
          wx.showModal({
            title: '提示',
            content: '您需要认证通过后才能使用此功能',
            confirmText: '去认证',
            success(res) {
              if (res.confirm) {
                wx.router.push({
                  name: 'IdSelect',
                  params: {}
                })
              } else if (res.cancel) {
                console.log('用户点击取消')
              }
            }
          })
          return true
        } else if (authenticationStatus == 1) {
          wx.showModal({
            title: '提示',
            content: '认证审批中,需要审批通过后才能使用此功能',
            showCancel: false,
          })
          return true
        }
}

2.工作中经常用到的标签多选

data里面数据定义

 tagArr: [{
                id: 1,
                title: '帮助很大',
                isCheck: false
            },
            {
                id: 2,
                title: '经验丰富',
                isCheck: false
            },
            {
                id: 3,
                title: '医术高超',
                isCheck: false
            },
            {
                id: 4,
                title: '耐心细致',
                isCheck: false
            },
            {
                id: 5,
                title: '热情亲切',
                isCheck: false
            },
            {
                id: 6,
                title: '接诊神速',
                isCheck: false
            },
        ],
   // 改变标签选中,未选中状态
    changeCheck(e) {
        console.log(e);
        let index = e.currentTarget.dataset.index;
        let item = this.data.tagArr[index];
        // let id = e.currentTarget.dataset.id;
        let idArr = []
        let tagArr = this.data.tagArr
        item.isCheck = !item.isCheck;
        tagArr.map(item => {
            if (item.isCheck) {
                idArr.push(item.id + ',' + item.title)
            }
        })

        this.setData({
            tagArr,
            idArr,
        });
        console.log(this.data.tagArr);
        console.log(this.data.idArr);
    },

3.微信小程序中 关羽小数点后的为数显示  .wxs文件

    function toFixedNum(value) {
       // var v = parseInt(value)
        var v = parseFloat(value) //强转浮点数,如果转成整数,小数点后的值会默认转换成0
        return v.toFixed(2)
    }

    module.exports = {
        toFixedNum: toFixedNum
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值