|
|
@@ -1,4 +1,15 @@
|
|
|
// pages/agent/index.js
|
|
|
+import {
|
|
|
+ saveAgent
|
|
|
+} from '../../services/index.js'
|
|
|
+import {
|
|
|
+ imgServerUrl
|
|
|
+} from '../../config/config.js'
|
|
|
+import {
|
|
|
+ showToast
|
|
|
+} from '../../utils/tips.js'
|
|
|
+
|
|
|
+const app = getApp();
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
@@ -7,8 +18,9 @@ Page({
|
|
|
data: {
|
|
|
name: '',
|
|
|
contact: '',
|
|
|
- sex: '',
|
|
|
- year: ''
|
|
|
+ year: '',
|
|
|
+ sex: ["请选择", "男", "女"],
|
|
|
+ sex_index: 0,
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -33,34 +45,6 @@ Page({
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 生命周期函数--监听页面隐藏
|
|
|
- */
|
|
|
- onHide: function() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
- */
|
|
|
- onUnload: function() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
- */
|
|
|
- onPullDownRefresh: function() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom: function() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
@@ -115,10 +99,14 @@ Page({
|
|
|
contact: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
- changeSex: function(e) {
|
|
|
- console.log("s", e.detail.value);
|
|
|
+ //改变性别
|
|
|
+ bindSexChange(e) {
|
|
|
+ console.log(e)
|
|
|
+ let {
|
|
|
+ value
|
|
|
+ } = e.detail
|
|
|
this.setData({
|
|
|
- sex: e.detail.value
|
|
|
+ sex_index: value
|
|
|
})
|
|
|
},
|
|
|
changeYear: function(e) {
|
|
|
@@ -130,10 +118,48 @@ Page({
|
|
|
submit() {
|
|
|
var name = this.data.name;
|
|
|
var contact = this.data.contact;
|
|
|
- var sex = this.data.sex;
|
|
|
+ var sex = this.data.sex_index;
|
|
|
var year = this.data.year;
|
|
|
if (!name) {
|
|
|
-
|
|
|
+ showToast("请填写姓名")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (contact == "" || contact.length !=11) {
|
|
|
+ showToast("请输入11位手机号")
|
|
|
+ return;
|
|
|
}
|
|
|
+ if (sex == 0) {
|
|
|
+ showToast("请选择性别")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!year) {
|
|
|
+ showToast("请填写年龄")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定提交吗?',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ let paramsObj = {
|
|
|
+ user_id: app.globalData.userId,
|
|
|
+ user_token: app.globalData.userToken,
|
|
|
+ name: name,
|
|
|
+ phone: contact,
|
|
|
+ gender: sex,
|
|
|
+ age: year
|
|
|
+ }
|
|
|
+ Object.assign(paramsObj);
|
|
|
+ saveAgent(paramsObj).then(data => {
|
|
|
+ showToast('提交成功', 'success')
|
|
|
+ setTimeout(function() {
|
|
|
+ wx.navigateBack();
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
+ } else if (res.cancel) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})
|