WeChat applet mobile phone number plus ****

Create utils.js page, write method

// 手机号加**
var toHide = function(array) {
  var phone = array.substring(0, 3) + '****' + array.substring(7);
  return phone;
}
module.exports.toHide = toHide;

 

Introduce and use in the required page, such as index.js page

var utils = require('../../utils/utils.js')


Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone:''
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     let phone = utils.toHide(JSON.stringify(wx.getStorageSync('phone')))
 
    this.setData({
    phone
     })
 
  },


}

 

Guess you like

Origin blog.csdn.net/asteriaV/article/details/110083002