123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- const app = getApp()
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- const user = require('../../../utils/user.js');
- Page({
- data: {
- name:'',
- mobile:'',
- city:'',
- showPicker:false,
- columns:['上海市',
- '北京市',
- '深圳市',
- '南京市',
- '苏州市',
- '无锡市',
- '杭州市',
- '青岛市',
- '重庆市',
- '成都市',
- '广州市',],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
- },
- bindName(e){
- this.setData({
- name: e.detail.value
- });
- },
- bindMobile(e){
- this.setData({
- mobile: e.detail.value
- });
- },
- cityTap(){
- this.setData({
- showPicker:true,
- });
- },
- pickerCancel(){
- this.setData({
- showPicker:false,
- })
- },
- pickerConfirm(e){
- console.log(e);
-
- this.setData({
- city:e.detail.value,
- showPicker:false,
- });
-
-
- },
- onReachBottom() {
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
-
- },
-
- onHide: function () {
- },
- onUnload: function () {
- },
- submit(){
- if(this.data.name==''){
- wx.showToast({
- title: '请输入姓名',
- icon: 'none'
- });
- return false;
- }else if(this.data.mobile==''){
- wx.showToast({
- title: '请输入手机号码',
- icon: 'none'
- });
- return false;
- }else if (!/^1\d{10}$/.test(this.data.mobile)) {
- wx.showToast({
- title: '请输入正确的手机号码',
- icon: 'none'
- });
-
- return false;
- }else if(this.data.city==''){
- wx.showToast({
- title: '请选择城市',
- icon: 'none'
- });
- return false;
- }else{
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.inputSelf, {
- city: this.data.city,
- name: this.data.name,
- tel:this.data.mobile
- }, 'POST').then(res=> {
- wx.hideLoading();
- if (res.errno === 0) {
- wx.showToast({
- title: '提交成功'
- })
- }else{
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- }
- }).catch(err=>{
- wx.hideLoading();
- });
- }
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh:function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
-
- })
|