index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //引入文本校验
  2. import {
  3. TestVerify
  4. } from "../../utils/verify"
  5. const _Verify = new TestVerify()
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. brandName: "", //品牌名称
  12. classify: "", //经营类目
  13. contact: "", //联系人
  14. telephone: "", //电话号
  15. companyName: "", //公司名称
  16. companyIntroduce: "", //公司介绍
  17. companyAddress: "", //公司地址
  18. userCode: "", //统一社会编码
  19. fileList: "", //logo
  20. //必填项状态 是否红色字体
  21. ErrRed: {
  22. brandNameErrRed:false,//品牌名
  23. logoErrRed: false, //logo
  24. classifyErrRed: false,//经营类目
  25. contactErrRed: false,//联系人
  26. telephoneErrRed: false, //联系方式
  27. },
  28. telephoneErrTitle: "", //手机号错误提示
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. },
  35. /* 必填项,获得焦点更新状态 */
  36. isInputFocus(e) {
  37. let data = this.data.ErrRed;
  38. data[e.currentTarget.dataset.name] = false;
  39. this.setData({
  40. ErrRed: data
  41. })
  42. },
  43. /* 必填项,失去焦点更新状态 */
  44. isInputBlur(e) {
  45. let data = this.data.ErrRed;
  46. data[e.currentTarget.dataset.name] = true;
  47. this.setData({
  48. ErrRed: data
  49. })
  50. },
  51. //联系方式失去焦点校验
  52. inputTelephoneBlur(e) {
  53. if (!_Verify.phoneNumber(this.data.telephone)) {
  54. let data = this.data.ErrRed;
  55. data[e.currentTarget.dataset.name] = true;
  56. this.setData({
  57. telephoneErrTitle: "手机号格式错误",
  58. ErrRed: data
  59. })
  60. return
  61. }
  62. this.setData({
  63. telephoneErrTitle: "",
  64. })
  65. },
  66. afterRead(event) {
  67. console.log(event)
  68. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  69. /* wx.uploadFile({
  70. url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址
  71. filePath: file.url,
  72. name: 'file',
  73. formData: {
  74. user: 'test'
  75. },
  76. success(res) {
  77. // 上传完成需要更新 fileList
  78. const {
  79. fileList = []
  80. } = this.data;
  81. fileList.push({
  82. ...file,
  83. url: res.data
  84. });
  85. this.setData({
  86. fileList
  87. });
  88. },
  89. }); */
  90. },
  91. /* 完善设置商户信息 */
  92. setUserMsg() {
  93. // _Verify.userName(this.data.brandName)
  94. // _Verify.phoneNumber(this.data.telephone)
  95. // console.log(_Verify.phoneNumber(this.data.telephone))
  96. _Verify.required(this.data.classify) //经营类目
  97. },
  98. toHomePage() {
  99. wx.reLaunch({
  100. url: '/pages/tabbarPage/Home/index'
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面初次渲染完成
  105. */
  106. onReady: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面显示
  110. */
  111. onShow: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面隐藏
  115. */
  116. onHide: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面卸载
  120. */
  121. onUnload: function () {
  122. },
  123. /**
  124. * 页面相关事件处理函数--监听用户下拉动作
  125. */
  126. onPullDownRefresh: function () {
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function () {
  132. },
  133. /**
  134. * 用户点击右上角分享
  135. */
  136. onShareAppMessage: function () {
  137. }
  138. })