123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- // miniprogram/signup/signup.js
- const app = getApp();
- const utils = require("../../utils/http");
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- dialog: {
- type: Boolean,
- value: false
- },
- phone: {
- type: Number | String,
- value: "",
- observer: function (val) {
- this.setData({
- fPhone: val
- })
- }
- },
- cid: {
- type: Number|String,
- value: ""
- },
- type: {
- type: String,
- value: ""
- },
- agentid: {
- type: String|Number,
- value: ""
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- dialog: false,
- uloading: false,
- phone: '',
- fName: "",
- fPhone: "",
- fHouse: "",
- cid: "",
- type: "",
- agentid: ""
- },
- /**
- * 组件的方法列表
- */
- methods: {
- dothis() { },
- getinputName(e) {
- this.setData({
- fName: e.detail.value
- })
- },
- getinputPhone(e) {
- this.setData({
- fPhone: e.detail.value
- })
- },
- getinputArea(e) {
- this.setData({
- fHouse: e.detail.value
- })
- },
- submitFunc() {
- const that = this;
- if (!this.isPhoneNum(this.data.fPhone)) {
- wx.showToast({
- title: '手机号格式错误!',
- icon: "none"
- })
- return false;
- }
- this.setData({
- uloading: true
- })
- utils.$post({
- url: app.globalData.webUrl + 'client/index/add_customer',
- data: {
- name: that.data.fName,
- phone: that.data.fPhone,
- community_name: that.data.fHouse,
- agent_id: that.data.agentid
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- if (r.data.code == '0') {
- that.setData({
- uloading: false
- })
- wx.showToast({
- title: '报名成功',
- icon: "none",
- duration: 1000
- })
- }
- that.triggerEvent("close");
- }
- })
- },
- hideMaskFunc() {
- this.triggerEvent("close");
- },
- //手机号正则验证
- isPhoneNum: function (phone) {
- var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
- if (!myreg.test(phone)) {
- return false;
- }
- return true;
- },
- }
- })
|