//引入文本校验 import { TestVerify } from "../../utils/verify" const _Verify = new TestVerify() Page({ /** * 页面的初始数据 */ data: { brandName: "", //品牌名称 classify: "", //经营类目 contact: "", //联系人 telephone: "", //电话号 companyName: "", //公司名称 companyIntroduce: "", //公司介绍 companyAddress: "", //公司地址 userCode: "", //统一社会编码 fileList: "", //logo //必填项状态 是否红色字体 ErrRed: { brandNameErrRed:false,//品牌名 logoErrRed: false, //logo classifyErrRed: false,//经营类目 contactErrRed: false,//联系人 telephoneErrRed: false, //联系方式 }, telephoneErrTitle: "", //手机号错误提示 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /* 必填项,获得焦点更新状态 */ isInputFocus(e) { let data = this.data.ErrRed; data[e.currentTarget.dataset.name] = false; this.setData({ ErrRed: data }) }, /* 必填项,失去焦点更新状态 */ isInputBlur(e) { let data = this.data.ErrRed; data[e.currentTarget.dataset.name] = true; this.setData({ ErrRed: data }) }, //联系方式失去焦点校验 inputTelephoneBlur(e) { if (!_Verify.phoneNumber(this.data.telephone)) { let data = this.data.ErrRed; data[e.currentTarget.dataset.name] = true; this.setData({ telephoneErrTitle: "手机号格式错误", ErrRed: data }) return } this.setData({ telephoneErrTitle: "", }) }, afterRead(event) { console.log(event) // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 /* wx.uploadFile({ url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址 filePath: file.url, name: 'file', formData: { user: 'test' }, success(res) { // 上传完成需要更新 fileList const { fileList = [] } = this.data; fileList.push({ ...file, url: res.data }); this.setData({ fileList }); }, }); */ }, /* 完善设置商户信息 */ setUserMsg() { // _Verify.userName(this.data.brandName) // _Verify.phoneNumber(this.data.telephone) // console.log(_Verify.phoneNumber(this.data.telephone)) _Verify.required(this.data.classify) //经营类目 }, toHomePage() { wx.reLaunch({ url: '/pages/tabbarPage/Home/index' }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })