| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- const app = getApp();
- Page({
- data: {
- region: ['省', '市', '区'],
- companyInfo: {},
- mobileClick: false,
- emailClick: false,
- codeBtnTxt: "发送验证码",
- codeBtnEmailTxt:'发送验证码'
- },
- onLoad(options) {
- this.setData({
- companyInfo: options.info ? JSON.parse(options.info) : {},
- isCreateOrEdit:options.info ? true : false,
- })
- },
- RegionChange: function (e) {
- this.setData({
- region: e.detail.value
- })
- },
- setMobile(e) {
- this.setData({
- mobile: e.detail.value
- })
- },
- setEmail(e) {
- this.setData({
- email: e.detail.value
- })
- },
- sendCodeMobile(e) {
- //验证手机号
- var myreg = /^[1][0-9]{10}$/;
- if (!myreg.test(this.data.mobile)) {
- app.showToptip(this, "worning", "手机号输入有误")
- return;
- }
- var that = this;
- wx.showLoading({
- title: '发送中...',
- mask: true
- })
- app.requestP({
- url: "/sms/getSmsCodeByMobile",
- needToken: false,
- contentType: ' application/json',
- data: {
- mobile: that.data.mobile,
- }
- }).then((res) => {
- app.showToptip(that, "success", "发送成功")
- that.data.lastSendTime = Date.now()
- that.setData({
- mobileClick: false
- })
- //定时器触发倒计时,
- var times = 60
- var i = setInterval(function () {
- times--
- if (times == 0) {
- that.setData({
- mobileClick: true,
- codeBtnTxt: "获取验证码",
- })
- clearInterval(i)
- } else {
- that.setData({
- codeBtnTxt: "重新获取" + times + "S",
- })
- }
- }, 1000)
- }).catch(function (r) {
- app.showToptip(that, "error", r.data.msg)
- })
- },
- sendCodeEmail() {
- //验证手机号
- // var myreg = /^[1][0-9]{10}$/;
- // if (!myreg.test(this.data.email)) {
- // app.showToptip(this, "worning", "手机号输入有误")
- // return;
- // }
- var that = this;
- wx.showLoading({
- title: '发送中...',
- mask: true
- })
- app.requestP({
- url: "/sms/getEmailGetAuthCode",
- needToken: false,
- contentType: ' application/json',
- data: {
- email: that.data.email,
- }
- }).then((res) => {
- app.showToptip(that, "success", "发送成功")
- that.data.lastSendTime = Date.now()
- that.setData({
- emailClick: false
- })
- //定时器触发倒计时,
- var times = 60
- var i = setInterval(function () {
- times--
- if (times == 0) {
- that.setData({
- emailClick: true,
- codeBtnEmailTxt: "获取验证码",
- })
- clearInterval(i)
- } else {
- that.setData({
- codeBtnEmailTxt: "重新获取" + times + "S",
- })
- }
- }, 1000)
- }).catch(function (r) {
- app.showToptip(that, "error", r.data.msg)
- })
- },
- formSubmit(e){
- var that = this;
- var value = e.detail.value;
- const {companyName,managerName,managerPhone,phoneCode,managerEmail,emailCode,address} = value;
- if(companyName&&managerName&&managerEmail&&managerPhone&&phoneCode&&emailCode&&address){
- app.requestP({
- url:that.data.isCreateOrEdit ?'/company/editCompany' :'/company/createCompany',
- method:'post',
- contentType:'application/json',
- data:{
- name:companyName,
- managerName,
- managerPhone,
- phoneCode,
- managerEmail,
- emailCode,
- address
- }
- }).then(res=>{
- app.showToptip(that,'success',res.data.msg);
- wx.navigateBack({
- delta: 1,
- })
- }).catch(err=>{
- app.showToptip(that,'error',err.data.msg);
- })
- }else{
- app.showToptip(that,'error','企业信息不能为空');
- }
- },
- })
|