| xqd
@@ -13,7 +13,8 @@ Page({
|
|
|
roles: [],
|
|
|
roleIndex: -1,
|
|
|
name: '',
|
|
|
- remark: ''
|
|
|
+ remark: '',
|
|
|
+ phone: ''
|
|
|
},
|
|
|
|
|
|
/**
|
| xqd
@@ -23,7 +24,7 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
- onInputChange: function(e) {
|
|
|
+ onInputChange: function (e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
var val = e.detail.value
|
|
|
this.setData({
|
| xqd
@@ -32,41 +33,81 @@ Page({
|
|
|
},
|
|
|
|
|
|
updatePhoneNumber(e) {
|
|
|
- if(e.detail.errMsg == 'errMsg') {
|
|
|
- http({
|
|
|
- url: 'auth/parsePhone',
|
|
|
- data: e.detail,
|
|
|
- success: function(res) {
|
|
|
- util.success('手机号获取成功')
|
|
|
+ var that = this
|
|
|
+ if (e.detail.errMsg == 'getPhoneNumber:ok') {
|
|
|
+ wx.checkSession({
|
|
|
+ success: () => {
|
|
|
+ var data = Object.assign({}, e.detail, {
|
|
|
+ session_key: wx.getStorageSync('session_key')
|
|
|
+ })
|
|
|
+ console.log(data)
|
|
|
+ that.parsePhone(data)
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ wx.login({
|
|
|
+ success: function(res) {
|
|
|
+ var data = Object.assign({}, e.detail, {
|
|
|
+ code: res.code
|
|
|
+ })
|
|
|
+ console.log(data)
|
|
|
+ that.parsePhone(data)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- getUserInfo: function(e) {
|
|
|
+ parsePhone(data) {
|
|
|
+ var that = this
|
|
|
+ http({
|
|
|
+ url: 'parsePhone',
|
|
|
+ data: data,
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res)
|
|
|
+ if(res.code == 0 && res.data.phoneNumber) {
|
|
|
+ that.setData({
|
|
|
+ phone: res.data.phoneNumber
|
|
|
+ })
|
|
|
+ if(res.data.session_key) {
|
|
|
+ wx.setStorageSync('session_key', res.data.session_key)
|
|
|
+ }
|
|
|
+ util.success('手机号获取成功')
|
|
|
+ } else {
|
|
|
+ util.error('发生错误')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getUserInfo: function (e) {
|
|
|
var that = this;
|
|
|
- util.wechatLogin(e, false, function(res) {
|
|
|
+ util.wechatLogin(e, false, function (res) {
|
|
|
that.submit()
|
|
|
}, true)
|
|
|
},
|
|
|
|
|
|
- submit: function() {
|
|
|
- if(!this.data.name) {
|
|
|
+ submit: function () {
|
|
|
+ if (!this.data.name) {
|
|
|
util.error('真实姓名必填')
|
|
|
return false;
|
|
|
}
|
|
|
- if(!this.data.projectIndex < 0) {
|
|
|
+ if (!this.data.projectIndex < 0) {
|
|
|
util.error('所属项目必填')
|
|
|
return false;
|
|
|
}
|
|
|
- if(!this.data.roleIndex < 0) {
|
|
|
+ if (!this.data.roleIndex < 0) {
|
|
|
util.error('申请角色不能为空')
|
|
|
return false;
|
|
|
}
|
|
|
- if(this.data.remark.length < 10) {
|
|
|
+ if (this.data.remark.length < 10) {
|
|
|
util.error('备注需10个字以上')
|
|
|
return false;
|
|
|
}
|
|
|
+ if(!this.data.phone) {
|
|
|
+ util.error('手机号不能为空')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
var project = this.data.projects[this.data.projectIndex]
|
|
|
var role = this.data.roles[this.data.roleIndex]
|
|
|
http({
|
| xqd
@@ -75,15 +116,16 @@ Page({
|
|
|
name: this.data.name,
|
|
|
project_id: project ? project.id : '',
|
|
|
project_role_id: role ? role.id : '',
|
|
|
- remark: this.data.remark
|
|
|
+ remark: this.data.remark,
|
|
|
+ phone: this.data.phone
|
|
|
},
|
|
|
- success: function(res) {
|
|
|
+ success: function (res) {
|
|
|
util.success('操作成功')
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- bindPickerChange: function(e) {
|
|
|
+ bindPickerChange: function (e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
this.setData({
|
|
|
[name]: e.detail.value
|
| xqd
@@ -102,7 +144,9 @@ Page({
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
api.getByName(this, 'projects/getAll', 'projects')
|
|
|
- api.getByName(this, 'project-roles/getAll', 'roles', {'limit': true})
|
|
|
+ api.getByName(this, 'project-roles/getAll', 'roles', {
|
|
|
+ 'limit': true
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|