123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- const app = getApp();
- Page({
-
- data: {
- nickname: '',
- photo: '',
- sex: '',
- age: '',
- height: '',
- province: '',
- city: '',
- area: '',
- education: '',
- marry: '',
- income: '',
- occupation: '',
- openid:'',
- wx_id:'',
- user: '',
- password: '',
- code: '',
- codeid: '',
- text: '获取验证码',
- currentTime: 61,
- phone: '',
- disabled: false,
- color: '',
-
-
- },
-
- onLoad: function (options) {
- var that = this
-
- var _openid = 0;
- try {
- var value = wx.getStorageSync('openid')
- if (value) {
- _openid = value
- that.setData({
- openid: _openid
- })
- }
- console.log(_openid);
- } catch (e) {
-
- }
-
- var _wx_id = 0;
- try {
- var value = wx.getStorageSync('wx_id')
- if (value) {
- _wx_id = value
- that.setData({
- wx_id: _wx_id
- })
- }
- console.log(_wx_id);
- } catch (e) {
-
- }
-
- that.setData({
- nickname: that.options.nickname,
- photo: that.options.photo,
- sex: that.options.sex,
- age: that.options.age,
- height: that.options.height,
- province: that.options.province,
- city: that.options.city,
- area: that.options.area,
- education: that.options.education,
- marry: that.options.marry,
- income: that.options.income,
- occupation: that.options.occupation,
- });
- },
-
- Telephone: function (e) {
- var user = e.detail.value;
- console.log(user);
- this.setData({
- user: user
- });
- },
- password: function (e) {
- var password = e.detail.value;
- console.log(password);
- this.setData({
- password: password
- });
- },
-
- getCode: function (e) {
- var code = e.detail.value;
- console.log(code);
- this.setData({
- code: code
- });
- },
-
- complete: function (e) {
- console.log(this)
- let user = this.data.user;
- let password = this.data.password;
- let code = this.data.code;
- var complete = null;
- if (user == ''){
- complete ='请输入手机号码';
- } else if (user.trim().length != 11 || ! /^1[23456789]\d{9}$/.test(user)) {
- complete = '手机号码格式不对';
- } else if (password==''){
- complete = '请设置密码';
- }
- else if (code == ''){
- complete = '请输入验证码';
- } else if (code.trim().length != 4 || ! /^[0-9]\d{3}$/.test(code)) {
- complete = '验证码4位数';
- }else{
- var _this = this
- console.log(this.data.nickname)
- let income_url = 'public/signup';
- let income_data = {
- nickname: this.data.nickname,
- photo: this.data.photo,
- sex: this.data.sex,
- age: this.data.age,
- height: this.data.height,
- province: this.data.province,
- city: this.data.city,
- area: this.data.area,
- education: this.data.education,
- marry: this.data.marry,
- income: this.data.income,
-
- user: this.data.user,
- password: this.data.password,
- openid: this.data.openid,
- wx_id: this.data.wx_id,
- occupation: this.data.occupation,
- code: this.data.code,
- codeid: this.data.codeid,
- };
- app.postRequest(income_url, income_data,function (res) {
-
- if(res.code==201){
- console.log(res.msg);
- wx.showModal({
- title: '提示',
- content: res.msg,
- showCancel: false,
- })
- wx.uploadFile({
- url: app.globalData.url+ 'public/photo',
- filePath: income_data.photo,
- name: 'photo',
- formData: {
- 'uid': res.data.uid
- },
- success: function (res) {
-
- }, fail: function (d) {
-
- }
- })
- wx.navigateTo({
- url: '/pages/Landpage/Land/Land'
- })
- } else if (res.code == 301){
- wx.showModal({
- title: '提示',
- content: res.msg,
- showCancel: false,
- })
- }
- })
- }
- if (complete != null) {
- wx.showModal({
- title: '提示',
- content: complete,
- showCancel: false,
- })
- return;
- };
- },
-
- getVerificationCode(res) {
- var that = this
- var phone = that.data.user;
- var currentTime = that.data.currentTime
- var warn = null;
- if (phone == '') {
- warn = "号码不能为空";
- } else if (phone.trim().length != 11 || ! /^1[23456789]\d{9}$/.test(phone)) {
-
- warn = "手机号格式不正确";
- } else {
-
-
- let code_url = 'public/verificationcode';
- let code_data = {
- mobile:this.data.user,
- type: 1,
- source: 1,
- };
- app.postRequest(code_url, code_data, function (res) {
- if (res.code == 201) {
-
- that.setData({
- codeid: res.data.id,
- disabled: true,
- color: '#ccc',
- })
-
-
- wx.showToast({
- title: '短信验证码已发送',
- icon: 'none',
- duration: 2000
- });
-
- var interval = setInterval(function () {
- currentTime--;
- that.setData({
- text: "重新发送(" + currentTime + 's)',
- })
-
- if (currentTime <= 0) {
- clearInterval(interval)
- that.setData({
- text: '重新发送',
- currentTime: 61,
- disabled: false,
- color: '#FF9BCA'
- })
- }
- }, 1000);
- return;
- }
- var _qrcode = res.data.mobile[0]
- getApp().Tips(_qrcode);
- })
-
-
- };
-
- if (warn != null) {
- wx.showModal({
- title: '填写手机号码',
- content: warn,
- showCancel: false,
- })
- that.setData({
- disabled: false,
- color: '#FF9BCA'
- })
- return;
- };
- },
- })
|