|
@@ -32,7 +32,8 @@ Page({
|
|
|
items: [],
|
|
|
//显示遮罩层
|
|
|
show: false,
|
|
|
- selectname: '',
|
|
|
+ selectname: '', //部门名字
|
|
|
+ departname: '', //工会名字
|
|
|
selectobjectid: '',
|
|
|
upiobjectid: '',
|
|
|
// 图片
|
|
@@ -40,6 +41,11 @@ Page({
|
|
|
uptokenURL: '',
|
|
|
domain: '',
|
|
|
uploadURL: '',
|
|
|
+ title: '',
|
|
|
+
|
|
|
+ //
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -64,6 +70,9 @@ Page({
|
|
|
contentHeight,
|
|
|
contentpadding
|
|
|
});
|
|
|
+ this.setData({
|
|
|
+ title: options.type
|
|
|
+ })
|
|
|
this.getname()
|
|
|
this.getdep()
|
|
|
this.getDepartment()
|
|
@@ -156,14 +165,14 @@ Page({
|
|
|
User1List
|
|
|
})
|
|
|
this.setData({
|
|
|
- avatar: User1List[0].avatar||'https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/95uip6030022742.png?imageView2/1/w/200/h/200',
|
|
|
- nickname: User1List[0].nickname||'微信用户',
|
|
|
+ avatar: User1List[0].avatar || 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/95uip6030022742.png?imageView2/1/w/200/h/200',
|
|
|
+ nickname: User1List[0].nickname || '微信用户',
|
|
|
sex: User1List[0].sex || '男',
|
|
|
-
|
|
|
+
|
|
|
})
|
|
|
- if(User1List[0].diyform){
|
|
|
+ if (User1List[0].diyform) {
|
|
|
this.setData({
|
|
|
- height:User1List[0].diyform.height
|
|
|
+ height: User1List[0].diyform.height
|
|
|
})
|
|
|
}
|
|
|
console.log(this.data.User1List);
|
|
@@ -177,11 +186,15 @@ Page({
|
|
|
// Userquery.equalTo('isCheck', true);
|
|
|
Userquery.notEqualTo('isDeleted', true)
|
|
|
Userquery.include('center');
|
|
|
+ Userquery.include('department');
|
|
|
let P2 = await Userquery.find();
|
|
|
let dep = P2.map(item => item.toJSON());
|
|
|
if (dep) {
|
|
|
if (dep[0].isCheck == true) {
|
|
|
this.setData({
|
|
|
+ name:dep[0].name,
|
|
|
+ phone:dep[0].mobile,
|
|
|
+ departname: dep[0].department.name,
|
|
|
selectname: dep[0].center.name,
|
|
|
selectobjectid: dep[0].center.objectId,
|
|
|
upiobjectid: dep[0].department.objectId
|
|
@@ -211,7 +224,7 @@ Page({
|
|
|
show2: true
|
|
|
})
|
|
|
},
|
|
|
- //修改名字
|
|
|
+ //修改昵称
|
|
|
changenickname(e) {
|
|
|
this.setData({
|
|
|
nickname: e.detail
|
|
@@ -220,98 +233,104 @@ Page({
|
|
|
},
|
|
|
//上传信息
|
|
|
async setinfo() {
|
|
|
- if (!this.data.nickname || !this.data.sex || !this.data.selectobjectid || !this.data.avatar||!this.data.height) {
|
|
|
- wx.showToast({
|
|
|
- title: '请输入相关内容',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- const currentUser = Parse.User.current();
|
|
|
- let Userquery = new Parse.Query('_User');
|
|
|
- Userquery.equalTo('company', company);
|
|
|
- Userquery.equalTo('objectId', currentUser.id);
|
|
|
- Userquery.notEqualTo('isDeleted', true)
|
|
|
- let user = await Userquery.first();
|
|
|
- user.set('sex', this.data.sex)
|
|
|
- user.set('avatar', this.data.avatar)
|
|
|
- let diyform = {
|
|
|
- height:this.data.height
|
|
|
- }
|
|
|
- user.set('diyform', diyform)
|
|
|
- user.set('nickname', this.data.nickname)
|
|
|
- try {
|
|
|
- user.save()
|
|
|
- console.log('昵称保存成功');
|
|
|
- } catch {
|
|
|
- console.log('保存失败');
|
|
|
- }
|
|
|
-
|
|
|
- let Profilerquery = new Parse.Query('Profile');
|
|
|
- Profilerquery.equalTo('company', company);
|
|
|
- Profilerquery.equalTo('user', currentUser.id);
|
|
|
- Profilerquery.notEqualTo('isDeleted', true)
|
|
|
- let Profile = await Profilerquery.first();
|
|
|
- //工会
|
|
|
- let Departmentquery = new Parse.Query('Department');
|
|
|
- Departmentquery.equalTo('company', company);
|
|
|
- Departmentquery.equalTo('objectId', this.data.upiobjectid);
|
|
|
- Departmentquery.notEqualTo('isDeleted', true)
|
|
|
- let Department = await Departmentquery.first();
|
|
|
- //部门
|
|
|
- let unionquery = new Parse.Query('Department');
|
|
|
- unionquery.equalTo('company', company);
|
|
|
- unionquery.equalTo('objectId', this.data.selectobjectid);
|
|
|
- unionquery.notEqualTo('isDeleted', true)
|
|
|
- let union = await unionquery.first();
|
|
|
-
|
|
|
- if (Profile) {
|
|
|
- Profile.set('department', Department.toPointer())
|
|
|
- Profile.set('center', union.toPointer())
|
|
|
- try {
|
|
|
- Profile.save()
|
|
|
+ if (this.data.title == '资料认证') {
|
|
|
+ if (!this.data.name || !this.data.sex || !this.data.selectobjectid || !this.data.height||!this.data.phone) {
|
|
|
wx.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
+ title: '请输入相关内容',
|
|
|
+ icon: 'none',
|
|
|
duration: 2000
|
|
|
})
|
|
|
- setTimeout(() => {
|
|
|
- this.goback()
|
|
|
- }, 2000);
|
|
|
- console.log('部门保存成功');
|
|
|
- } catch {
|
|
|
- console.log('部门保存失败');
|
|
|
+ return
|
|
|
}
|
|
|
- } else {
|
|
|
const currentUser = Parse.User.current();
|
|
|
let Userquery = new Parse.Query('_User');
|
|
|
Userquery.equalTo('company', company);
|
|
|
Userquery.equalTo('objectId', currentUser.id);
|
|
|
Userquery.notEqualTo('isDeleted', true)
|
|
|
- let P2 = await Userquery.first();
|
|
|
-
|
|
|
- let companyPointer = Parse.Object.extend('Company').createWithoutData(company);
|
|
|
- console.log(companyPointer);
|
|
|
- let Profile = new Parse.Object('Profile');
|
|
|
- Profile.set('company', companyPointer);
|
|
|
- Profile.set('isCheck', false);
|
|
|
- Profile.set('user', P2.toPointer());
|
|
|
- Profile.set('department', Department.toPointer());
|
|
|
- Profile.set('center', union.toPointer());
|
|
|
+ let user = await Userquery.first();
|
|
|
+ user.set('sex', this.data.sex)
|
|
|
+ // user.set('avatar', this.data.avatar)
|
|
|
+ let diyform = {
|
|
|
+ height: this.data.height
|
|
|
+ }
|
|
|
+ user.set('diyform', diyform)
|
|
|
+ // user.set('nickname', this.data.nickname)
|
|
|
try {
|
|
|
- Profile.save()
|
|
|
- wx.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- this.goback()
|
|
|
- }, 2000);
|
|
|
- console.log('部门保存成功');
|
|
|
+ user.save()
|
|
|
+ console.log('昵称保存成功');
|
|
|
} catch {
|
|
|
- console.log('部门保存失败');
|
|
|
+ console.log('保存失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ let Profilerquery = new Parse.Query('Profile');
|
|
|
+ Profilerquery.equalTo('company', company);
|
|
|
+ Profilerquery.equalTo('user', currentUser.id);
|
|
|
+ Profilerquery.notEqualTo('isDeleted', true)
|
|
|
+ let Profile = await Profilerquery.first();
|
|
|
+ //工会
|
|
|
+ let Departmentquery = new Parse.Query('Department');
|
|
|
+ Departmentquery.equalTo('company', company);
|
|
|
+ Departmentquery.equalTo('objectId', this.data.upiobjectid);
|
|
|
+ Departmentquery.notEqualTo('isDeleted', true)
|
|
|
+ let Department = await Departmentquery.first();
|
|
|
+ //部门
|
|
|
+ let unionquery = new Parse.Query('Department');
|
|
|
+ unionquery.equalTo('company', company);
|
|
|
+ unionquery.equalTo('objectId', this.data.selectobjectid);
|
|
|
+ unionquery.notEqualTo('isDeleted', true)
|
|
|
+ let union = await unionquery.first();
|
|
|
+
|
|
|
+ if (Profile) {
|
|
|
+ Profile.set('department', Department.toPointer())
|
|
|
+ Profile.set('center', union.toPointer())
|
|
|
+ Profile.set('name', this.data.name)
|
|
|
+ Profile.set('mobile', this.data.phone)
|
|
|
+ try {
|
|
|
+ Profile.save()
|
|
|
+ wx.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ this.goback()
|
|
|
+ }, 2000);
|
|
|
+ console.log('部门保存成功');
|
|
|
+ } catch {
|
|
|
+ console.log('部门保存失败');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ let Userquery = new Parse.Query('_User');
|
|
|
+ Userquery.equalTo('company', company);
|
|
|
+ Userquery.equalTo('objectId', currentUser.id);
|
|
|
+ Userquery.notEqualTo('isDeleted', true)
|
|
|
+ let P2 = await Userquery.first();
|
|
|
+
|
|
|
+ let companyPointer = Parse.Object.extend('Company').createWithoutData(company);
|
|
|
+ console.log(companyPointer);
|
|
|
+ let Profile = new Parse.Object('Profile');
|
|
|
+ Profile.set('company', companyPointer);
|
|
|
+ Profile.set('isCheck', false);
|
|
|
+ Profile.set('user', P2.toPointer());
|
|
|
+ Profile.set('department', Department.toPointer());
|
|
|
+ Profile.set('center', union.toPointer());
|
|
|
+ Profile.set('name', this.data.name)
|
|
|
+ Profile.set('mobile', this.data.phone)
|
|
|
+ try {
|
|
|
+ Profile.save()
|
|
|
+ wx.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ this.goback()
|
|
|
+ }, 2000);
|
|
|
+ console.log('部门保存成功');
|
|
|
+ } catch {
|
|
|
+ console.log('部门保存失败');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -369,6 +388,7 @@ Page({
|
|
|
this.setData({
|
|
|
items: result
|
|
|
})
|
|
|
+ console.log(this.data.items);
|
|
|
},
|
|
|
//点击工会
|
|
|
onClickNav({
|
|
@@ -384,7 +404,13 @@ Page({
|
|
|
detail = {}
|
|
|
}) {
|
|
|
const activeId = this.data.activeId === detail.id ? null : detail.id;
|
|
|
-
|
|
|
+ this.data.items.forEach((item) => {
|
|
|
+ if (item.objectId == detail.upid) {
|
|
|
+ this.setData({
|
|
|
+ departname: item.text
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
this.setData({
|
|
|
activeId,
|
|
|
selectname: detail.text,
|
|
@@ -441,9 +467,39 @@ Page({
|
|
|
fileList: url
|
|
|
})
|
|
|
this.setData({
|
|
|
- avatar:this.data.fileList[0]
|
|
|
+ avatar: this.data.fileList[0]
|
|
|
})
|
|
|
console.log('图片', this.data.fileList);
|
|
|
},
|
|
|
+ //修改姓名
|
|
|
+ changename(e) {
|
|
|
+ this.setData({
|
|
|
+ name: e.detail
|
|
|
+ })
|
|
|
+ console.log(this.data.name);
|
|
|
+ },
|
|
|
+ //修改电话
|
|
|
+ changephone(e) {
|
|
|
+ const mobileNumber = e.detail.value; // 假设手机号是通过 e.detail.value 传递的
|
|
|
+ console.log(mobileNumber);
|
|
|
+ // 正则表达式:匹配中国大陆手机号
|
|
|
+ const mobilePattern = /^1[3-9]\d{9}$/;
|
|
|
|
|
|
+ // 验证手机号格式
|
|
|
+ if (mobilePattern.test(mobileNumber)) {
|
|
|
+ this.setData({
|
|
|
+ phone: mobileNumber
|
|
|
+ })
|
|
|
+ console.log("手机号格式正确");
|
|
|
+ // 这里可以执行其他操作,比如保存手机号或进行下一步操作
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '手机号格式不正确',
|
|
|
+ icon: 'none',
|
|
|
+ })
|
|
|
+ console.log("手机号格式不正确");
|
|
|
+ // 这里可以提示用户手机号格式不正确
|
|
|
+ }
|
|
|
+ console.log(this.data.phone);
|
|
|
+ }
|
|
|
})
|