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
}