// 放在utils或者自己建一个文件
var toHide = function(array) {
var phone = array.substring(0, 3) + '****' + array.substring(7);
return phone;
}
module.exports.toHide = toHide;
在js里边引用以及使用
// 引用手机号为*号
var utils = require('../../utils/phone.js')
//使用
res.data.result.phone = utils.toHide (res.data.result.phone)
that.setData({
areaCode:res.data.result.areaCode,
phone:res.data.result.phone
})
在wxml中
<view>验证码讲发送到 +{{areaCode}} {{phone}}</view>