邹能昇 3 mesi fa
parent
commit
aad7d3fed2

+ 1 - 1
config.js

@@ -1,5 +1,5 @@
 export default {
-    appid: "wx9e378ea72244da67",
+    appid: "wx4838c697d949a1e7",
     company: "qpFbRRSZrO",
     rootPage: "/nova-werun/pages/index/index",
     // 消息相关——JMessage

+ 12 - 0
nova-werun/pages/circle/send-circle/index.js

@@ -48,6 +48,7 @@ Page({
             contentpadding,
             contentHeight
         });
+        this.getUptoken()
     },
 
     /**
@@ -106,6 +107,17 @@ Page({
         });
         console.log(this.data.inputValue);
     },
+    async getUptoken() {
+        let res = await Parse.Cloud.run('qiniu_uptoken', {
+            company: company
+        })
+        this.setData({
+            uptokenURL: res.uptoken,
+            domain: res.domain,
+            uploadURL: res.zoneUrl
+        })
+        console.log(this.data.uptokenURL, this.data.domain, this.data.uploadURL);
+    },
     //获取图片数组
     picture(event) {
         console.log('event', event);

+ 264 - 18
nova-werun/pages/my/my-profile/index.js

@@ -22,10 +22,24 @@ Page({
                 name: '女',
             },
         ],
-        avatar:null,
-        sex:'男',
-        nickname:null,
+        avatar: null,
+        sex: '男',
+        nickname: null,
         height: null,
+        //  选择部门
+        mainActiveIndex: 0,
+        activeId: null,
+        items: [],
+        //显示遮罩层
+        show: false,
+        selectname: '',
+        selectobjectid: '',
+        upiobjectid: '',
+        // 图片
+        fileList: [],
+        uptokenURL: '',
+        domain: '',
+        uploadURL: '',
     },
 
     /**
@@ -41,7 +55,7 @@ Page({
         const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
 
         const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
-        const contentHeight = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
+        const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
         this.setData({
             statusBarHeight,
             screenHeight,
@@ -51,6 +65,9 @@ Page({
             contentpadding
         });
         this.getname()
+        this.getdep()
+        this.getDepartment()
+        this.getUptoken()
     },
 
     /**
@@ -105,7 +122,7 @@ Page({
     getHeight(e) {
         let height = e.detail.value;
         // 身高范围在 50 到 250 之间的正则表达式,允许浮点数
-        let a = /^(?:[5-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|250)(\.\d)?$/; 
+        let a = /^(?:[5-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|250)(\.\d)?$/;
         if (!height.match(a)) {
             wx.showToast({
                 icon: "none",
@@ -120,11 +137,11 @@ Page({
         }
     },
     //点击清空
-    clearHeight(){
+    clearHeight() {
         this.setData({
-            height:null
+            height: null
         })
-        console.log('清空',this.data.height);
+        console.log('清空', this.data.height);
     },
     //获取头像名称
     async getname() {
@@ -139,18 +156,46 @@ Page({
             User1List
         })
         this.setData({
-            avatar:User1List[0].avatar,
-            nickname:User1List[0].nickname,
-            sex:User1List[0].sex||'男',
+            avatar: User1List[0].avatar,
+            nickname: User1List[0].nickname,
+            sex: User1List[0].sex || '男',
         })
         console.log(this.data.User1List);
     },
+    //获取部门
+    async getdep() {
+        const currentUser = Parse.User.current();
+        let Userquery = new Parse.Query('Profile');
+        Userquery.equalTo('company', company);
+        Userquery.equalTo('user', currentUser.id);
+        // Userquery.equalTo('isCheck', true);
+        Userquery.notEqualTo('isDeleted', true)
+        Userquery.include('center');
+        let P2 = await Userquery.find();
+        let dep = P2.map(item => item.toJSON());
+        if (dep) {
+            if (dep[0].isCheck == true) {
+                this.setData({
+                    selectname: dep[0].center.name,
+                    selectobjectid: dep[0].center.objectId,
+                    upiobjectid: dep[0].department.objectId
+                })
+            } else {
+                wx.showToast({
+                    title: '您之前提交信息在审核当中',
+                    icon: 'none',
+                    duration: 2000
+                })
+            }
+        }
+        console.log('getdep', dep);
+    },
     onSelect(event) {
         let {
             name
         } = event.detail
         this.setData({
-            sex : name,
+            sex: name,
             show2: false
         })
         console.log(this.data.sex);
@@ -161,22 +206,223 @@ Page({
         })
     },
     //修改名字
-    changenickname(e){
+    changenickname(e) {
         this.setData({
-            nickname:e.detail
+            nickname: e.detail
         })
         console.log(this.data.nickname);
     },
     //上传信息
-    async setinfo(){
+    async setinfo() {
+        if (!this.data.nickname || !this.data.sex || !this.data.selectobjectid || !this.data.avatar) {
+            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('nickname',this.data.nickname)
-    }
+        user.set('sex', this.data.sex)
+        user.set('avatar', this.data.avatar)
+        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()
+                wx.showToast({
+                    title: '提交成功',
+                    icon: 'success',
+                    duration: 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());
+            try {
+                Profile.save()
+                console.log('部门保存成功');
+            } catch {
+                console.log('部门保存失败');
+            }
+        }
+
+    },
+    // 获取部门信息
+    async getDepartment() {
+        const currentUser = Parse.User.current();
+        let Userquery = new Parse.Query('Department');
+        Userquery.equalTo('company', company); // 假设 company 是你要查询的公司对象
+        Userquery.equalTo('isEnabled', true);
+        Userquery.notEqualTo('isDeleted', true);
+        Userquery.include('parent');
+
+        let P2 = await Userquery.find();
+        let Departmentlist = P2.map(item => item.toJSON());
+
+        // 创建一个以工会为键的对象,以便于匹配
+        const unionsMap = {};
+        console.log(Departmentlist);
+        // 遍历部门列表,构建工会映射
+        Departmentlist.forEach(department => {
+            //有工会的部门
+            if (department.parent && department.parent.objectId) {
+                const unionId = department.parent.objectId; //工会id
+
+                // 如果工会还没有在映射中,创建一个新的工会对象
+                if (!unionsMap[unionId]) {
+                    unionsMap[unionId] = {
+                        text: department.parent.name, // 工会名称
+                        objectId: department.parent.objectId,
+                        children: [] // 初始化子部门数组
+                    };
+                }
+                // 将部门添加到对应的工会子项中
+                unionsMap[unionId].children.push({
+                    text: department.name, // 部门名称
+                    id: department.objectId, // 部门 ID
+                    upid: department.parent.objectId
+                });
+            } else {
+                if (!unionsMap[department.objectId]) {
+                    unionsMap[department.objectId] = {
+                        text: department.name, // 工会名称
+                        objectId: department.objectId,
+                        children: [] // 初始化子部门数组
+                    };
+                }
+            }
+        });
+
+        // 将映射转换为数组
+        const result = Object.values(unionsMap);
+
+        console.log(result);
+        this.setData({
+            items: result
+        })
+    },
+    //点击工会
+    onClickNav({
+        detail = {}
+    }) {
+        this.setData({
+            mainActiveIndex: detail.index || 0,
+        });
+        console.log(detail);
+    },
+    //点击部门
+    onClickItem({
+        detail = {}
+    }) {
+        const activeId = this.data.activeId === detail.id ? null : detail.id;
+
+        this.setData({
+            activeId,
+            selectname: detail.text,
+            selectobjectid: detail.id,
+            upiobjectid: detail.upid
+        });
+        this.onClickHide()
+        console.log(detail);
+    },
+    //显示遮罩层
+    onClickShow() {
+        this.setData({
+            show: true
+        });
+    },
+    //关闭遮罩层
+    onClickHide() {
+        this.setData({
+            show: false
+        });
+    },
+    //返回上一页
+    goback() {
+        wx.navigateBack({
+            delta: 1 // 返回上一页
+        });
+    },
+    //删除头像
+    deleteavater() {
+        this.setData({
+            avatar: ''
+        })
+    },
+    async getUptoken() {
+        let res = await Parse.Cloud.run('qiniu_uptoken', {
+            company: company
+        })
+        this.setData({
+            uptokenURL: res.uptoken,
+            domain: res.domain,
+            uploadURL: res.zoneUrl
+        })
+        console.log(this.data.uptokenURL, this.data.domain, this.data.uploadURL);
+    },
+    //本地上传头像
+    picture(event) {
+        console.log('event', event);
+        let FileList = event.detail
+        let url = []
+        for (let i = 0; i < FileList.length; i++) {
+            url.push(FileList[i].url)
+        }
+        this.setData({
+            fileList: url
+        })
+        this.setData({
+            avatar:this.data.fileList[0]
+        })
+        console.log('图片', this.data.fileList);
+    },
 
 })

+ 3 - 1
nova-werun/pages/my/my-profile/index.json

@@ -1,6 +1,8 @@
 {
   "usingComponents": {
     "van-field": "@vant/weapp/field/index",
-    "van-action-sheet": "@vant/weapp/action-sheet/index"
+    "van-action-sheet": "@vant/weapp/action-sheet/index",
+    "van-tree-select": "@vant/weapp/tree-select/index",
+    "van-overlay": "@vant/weapp/overlay/index"
   }
 }

+ 27 - 4
nova-werun/pages/my/my-profile/index.less

@@ -18,14 +18,37 @@
                 border-radius: 50%;
             }
             .photo{
-                width: 60rpx;
-                height: 60rpx;
+                width: 40rpx;
+                height: 40rpx;
                 position: absolute;
-                right: -15rpx;
-                bottom: -18rpx;
+                right: -20rpx;
             }
         }
     }
+    .selectbox{
+        width: 100%;
+        height: 88rpx;
+        display: flex;
+        align-items: center;
+        padding-left: 16rpx;
+        padding-right: 32rpx;
+        padding-top: 20rpx;
+        padding-bottom: 20rpx;
+        .fuhao{
+            color:#E22525ed;
+            margin-right: 2rpx;
+        }
+        .selecttext{
+            width: 174rpx;
+            height: 48rpx;
+            font-size: 28rpx;
+            color: #646566;
+        }
+        .selectname{
+            font-size: 28rpx;
+            margin-left: 22rpx;
+        }
+    }
     .submitbox{
         width: 100%;
         height: 80rpx;

+ 27 - 7
nova-werun/pages/my/my-profile/index.wxml

@@ -3,17 +3,37 @@
 <view class="all" style="height: {{contentHeight}}rpx;">
     <view class="avatarbox">
         <view class="avatar-box">
-            <image class="avatar" src="{{avatar||'https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/63c55i022235020.png?imageView2/1/w/200/h/200'}}" mode="scaleToFill"></image>
-            <image class="photo" src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/95uip6030022742.png?imageView2/1/w/200/h/200"></image>
+            <image class="avatar" wx:if="{{avatar}}" src="{{avatar||'https://file-cloud.fmode.cn/qpFbRRSZrO/20241120/63c55i022235020.png?imageView2/1/w/200/h/200'}}" mode="scaleToFill"></image>
+            <image class="photo" wx:if="{{avatar}}" bindtap="deleteavater" src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241223/816ic1022338103.png?imageView2/1/w/200/h/200"></image>
+
+            <upload wx:if="{{!avatar}}" style="width: 50%;" bind:onChangeFile="picture" uploadURL="{{uploadURL}}" domain="{{domain}}" uptokenURL="{{uptokenURL}}" maxCount="1" />
         </view>
 
     </view>
-    <van-field value="{{ nickname }}" required clearable label="昵称" maxlength="8"  placeholder="请输入昵称" bind:change="changenickname" />
-    <van-field class="field" required model:value="{{ sex }}" readonly maxlength="1" label="性别"  bind:tap="showSelect" />
-    <van-field value="{{ height }}" required  clearable  label="身高" type="number"   placeholder="请输入身高" bind:blur="getHeight" bind:clear='clearHeight' />
-    <van-action-sheet show="{{ show2 }}"  actions="{{ actions }}" bind:select="onSelect" />
+    <van-field value="{{ nickname }}" required clearable label="昵称" maxlength="8" placeholder="请输入昵称" bind:change="changenickname" />
+    <van-field class="field" required model:value="{{ sex }}" readonly maxlength="1" label="性别" bind:tap="showSelect" />
+    <van-field value="{{ height }}" required clearable label="身高" type="number" placeholder="请输入身高" bind:blur="getHeight" bind:clear='clearHeight' />
+    <van-action-sheet show="{{ show2 }}" actions="{{ actions }}" bind:select="onSelect" />
+    <view class="selectbox" bindtap="onClickShow">
+        <view class="fuhao">*</view>
+        <view class="selecttext">部门</view>
+        <view class="selectname">{{selectname||'选择部门'}} ></view>
+    </view>
+
+    <van-overlay show="{{ show }}" >
+        <view class="wrapper" style="height: 100%;width: 100%; display: flex;align-items: flex-end;">
+            <view style="width: 100%;height: 300px;">
+                <van-tree-select items="{{ items }}" main-active-index="{{ mainActiveIndex }}" active-id="{{ activeId }}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
+            </view>
+
+        </view>
+    </van-overlay>
+
+
+
+
 
     <view class="submitbox">
-        <view class="submit">提交</view>
+        <view class="submit" bindtap="setinfo">提交</view>
     </view>
 </view>

+ 1 - 1
nova-werun/pages/my/my-profile/index.wxss

@@ -1 +1 @@
-.all{width:100vw}.all .avatarbox{width:100%;height:270rpx;background-color:#87ceeb;display:flex;justify-content:center;align-items:center}.all .avatarbox .avatar-box{width:150rpx;height:150rpx;position:relative}.all .avatarbox .avatar-box .avatar{width:150rpx;height:150rpx;border-radius:50%}.all .avatarbox .avatar-box .photo{width:60rpx;height:60rpx;position:absolute;right:-15rpx;bottom:-18rpx}.all .submitbox{width:100%;height:80rpx;display:flex;justify-content:center;align-items:center;margin-top:40rpx}.all .submitbox .submit{width:200rpx;height:80rpx;font-size:30rpx;color:white;background-color:#87ceeb;display:flex;justify-content:center;align-items:center;border-radius:40rpx}
+.all{width:100vw}.all .avatarbox{width:100%;height:270rpx;background-color:#87ceeb;display:flex;justify-content:center;align-items:center}.all .avatarbox .avatar-box{width:150rpx;height:150rpx;position:relative}.all .avatarbox .avatar-box .avatar{width:150rpx;height:150rpx;border-radius:50%}.all .avatarbox .avatar-box .photo{width:40rpx;height:40rpx;position:absolute;right:-20rpx}.all .selectbox{width:100%;height:88rpx;display:flex;align-items:center;padding-left:16rpx;padding-right:32rpx;padding-top:20rpx;padding-bottom:20rpx}.all .selectbox .fuhao{color:#E22525ed;margin-right:2rpx}.all .selectbox .selecttext{width:174rpx;height:48rpx;font-size:28rpx;color:#646566}.all .selectbox .selectname{font-size:28rpx;margin-left:22rpx}.all .submitbox{width:100%;height:80rpx;display:flex;justify-content:center;align-items:center;margin-top:40rpx}.all .submitbox .submit{width:200rpx;height:80rpx;font-size:30rpx;color:white;background-color:#87ceeb;display:flex;justify-content:center;align-items:center;border-radius:40rpx}

+ 1 - 1
project.config.json

@@ -49,7 +49,7 @@
     },
     "compileType": "miniprogram",
     "libVersion": "2.27.3",
-    "appid": "wx9e378ea72244da67",
+    "appid": "wx4838c697d949a1e7",
     "projectname": "nova-wapp",
     "cloudfunctionTemplateRoot": "",
     "editorSetting": {