Browse Source

个人设置接口

natasha 1 năm trước cách đây
mục cha
commit
9cda691e14

+ 5 - 0
src/icons/svg/information-fill.svg

@@ -0,0 +1,5 @@
+<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="information-fill">
+<path id="Vector" d="M6 11C3.23857 11 1 8.7614 1 6C1 3.23857 3.23857 1 6 1C8.7614 1 11 3.23857 11 6C11 8.7614 8.7614 11 6 11ZM5.5 5.5V8.5H6.5V5.5H5.5ZM5.5 3.5V4.5H6.5V3.5H5.5Z" fill="currentColor"/>
+</g>
+</svg>

+ 1 - 1
src/views/bookShelf/bookItem.vue

@@ -125,7 +125,7 @@
     <div class="main-center" v-if="info">
         <el-tabs type="card" style="margin-bottom:24px;">
             <el-tab-pane label="简介">
-                <div v-html="info.intro"></div>
+                <div v-html="info.intro||info.iss_note"></div>
             </el-tab-pane>
         </el-tabs>
         <el-tabs type="card">

+ 237 - 76
src/views/personalCenter/components/Setting.vue

@@ -49,12 +49,12 @@
                         <el-input v-model="infoForm.name" disabled placeholder="请输入用户名" maxlength="20"></el-input>
                     </el-form-item>
                     <el-form-item label="真实姓名" prop="realName">
-                        <el-input v-model="infoForm.realName" placeholder="请输入真实姓名" maxlength="20"></el-input>
+                        <el-input v-model="infoForm.realName" placeholder="请输入真实姓名" maxlength="20" @blur="handleTrim('infoForm','realName')"></el-input>
                     </el-form-item>
                     <el-form-item label="性别" prop="sex">
                         <el-radio-group v-model="infoForm.sex">
-                            <el-radio label="1">男</el-radio>
-                            <el-radio label="2">女</el-radio>
+                            <el-radio :label="1">男</el-radio>
+                            <el-radio :label="0">女</el-radio>
                         </el-radio-group>
                     </el-form-item>
                     <el-form-item label="所在省市" prop="selectedOptions">
@@ -66,22 +66,32 @@
                         </el-cascader>
                     </el-form-item>
                     <el-form-item label="备注" prop="desc">
-                        <el-input type="textarea" v-model="infoForm.desc" placeholder="请输入备注" maxlength="100" :rows="4" show-word-limit></el-input>
+                        <el-input type="textarea" v-model="infoForm.desc" placeholder="请输入备注" maxlength="100" :rows="4" show-word-limit @blur="handleTrim('infoForm','desc')"></el-input>
                     </el-form-item>
                     <el-form-item label="我的机构" prop="region">
-                        <el-select v-model="infoForm.region" placeholder="请选择机构" :disabled="regionFlag">
-                            <el-option label="请选择" value=""></el-option>
-                            <el-option label="区域一" value="shanghai"></el-option>
-                            <el-option label="区域二" value="beijing"></el-option>
+                        <el-select v-model="infoForm.region" placeholder="请选择机构" :disabled="personalInfo.is_manager==='true'">
+                            <el-option
+                                v-for="item in orgList"
+                                :key="item.id"
+                                :label="item.name"
+                                :value="item.id">
+                            </el-option>
                         </el-select>
-                        <el-button v-if="regionFlag" type="primary" size="small" class="btn" @click="regionFlag=!regionFlag">申请变更</el-button>
+                        <!--  -->
+                        <el-tag class="audit-status" v-if="personalInfo.audit_status===0">
+                            <svg-icon icon-class="information-fill"></svg-icon>审核中
+                        </el-tag>
+                        <el-tag class="audit-status audit-refused" v-if="personalInfo.audit_status===2">
+                            <i class="el-icon-error"></i>已拒绝
+                        </el-tag>
+                        <!-- <el-button v-if="regionFlag" type="primary" size="small" class="btn" @click="regionFlag=!regionFlag">申请变更</el-button>
                         <template v-else>
                             <el-button type="primary" @click="handleChangeOrg" size="small" class="btn">提交</el-button>
                             <el-button @click="handleorgCancel" size="small">取消</el-button>
-                        </template>
+                        </template> -->
                     </el-form-item>
                     <el-form-item>
-                        <el-button type="primary" @click="onSubmit('ruleForm')" size="small">保存</el-button>
+                        <el-button type="primary" @click="onSubmit('ruleForm')" size="small" :loading="submitLoading">保存</el-button>
                         <el-button @click="onCancel('ruleForm')" size="small">取消</el-button>
                     </el-form-item>
                 </el-form>
@@ -100,7 +110,7 @@
                     <label>绑定手机</label>
                     <div class="safe-items-right">
                         <p v-if="personalInfo.phone" class="hasContent">
-                            已绑定: {{personalInfo.phone}}
+                            已绑定: {{personalInfo.phone.substring(0,3)+'******'+personalInfo.phone.substring(9,11)}}
                         </p>
                         <p v-else class="noContent">
                         您暂未绑定手机,绑定手机可以有效的保护账号的安全。 
@@ -130,7 +140,7 @@
         </p>
         <el-form :model="passwordForm" :rules="rulesPassword" ref="passwordForm" label-width="100px" class="passwordForm">
             <el-form-item label="原始密码" prop="oldPwd">
-                <el-input v-model="passwordForm.oldPwd" :type="oldPwdFlag?'text':'password'" autocomplete="off" placeholder="请输入密码" maxlength="20">
+                <el-input v-model="passwordForm.oldPwd" :type="oldPwdFlag?'text':'password'" autocomplete="off" placeholder="请输入密码" maxlength="20" @blur="handleTrim('passwordForm','oldPwd')">
                     <i slot="suffix" class="el-icon-view show-icon" @click="changeIcon('oldPwdFlag')" v-if="oldPwdFlag"></i>
                     <i slot="suffix" class="show-icon" @click="changeIcon('oldPwdFlag')" v-else>
                         <svg-icon icon-class="eye-invisible"></svg-icon>
@@ -138,7 +148,7 @@
                 </el-input>
             </el-form-item>
             <el-form-item label="修改密码" prop="newPwd">
-                <el-input v-model="passwordForm.newPwd" :type="newPwdFlag?'text':'password'" autocomplete="off" placeholder="请输入密码" maxlength="20">
+                <el-input v-model="passwordForm.newPwd" :type="newPwdFlag?'text':'password'" autocomplete="off" placeholder="请输入密码" maxlength="20" @blur="handleTrim('passwordForm','newPwd')">
                     <i slot="suffix" class="el-icon-view show-icon" @click="changeIcon('newPwdFlag')" v-if="newPwdFlag"></i>
                     <i slot="suffix" class="show-icon" @click="changeIcon('newPwdFlag')" v-else>
                         <svg-icon icon-class="eye-invisible"></svg-icon>
@@ -146,7 +156,7 @@
                 </el-input>
             </el-form-item>
             <el-form-item label="再次输入" prop="confirmPwd">
-                <el-input v-model="passwordForm.confirmPwd" :type="comfirmPwdFlag?'text':'password'" autocomplete="off" placeholder="请输入密码" maxlength="20">
+                <el-input v-model="passwordForm.confirmPwd" :type="comfirmPwdFlag?'text':'password'" autocomplete="off" placeholder="请输入密码" maxlength="20" @blur="handleTrim('passwordForm','confirmPwd')">
                     <i slot="suffix" class="el-icon-view show-icon" @click="changeIcon('comfirmPwdFlag')" v-if="comfirmPwdFlag"></i>
                     <i slot="suffix" class="show-icon" @click="changeIcon('comfirmPwdFlag')" v-else>
                         <svg-icon icon-class="eye-invisible"></svg-icon>
@@ -154,7 +164,7 @@
                 </el-input>
             </el-form-item>
             <el-form-item>
-                <el-button type="primary" @click="onSubmitPassword('passwordForm')" size="small" :loading="true">保存</el-button>
+                <el-button type="primary" @click="onSubmitPassword('passwordForm')" size="small" :loading="passwordLoading">保存</el-button>
                 <el-button @click="onCancel('passwordForm')" size="small">取消</el-button>
             </el-form-item>
         </el-form>
@@ -165,32 +175,20 @@
             绑定手机
         </p>
         <el-form :model="phoneForm" :rules="rulesPhone" ref="phoneForm" label-width="100px" class="phoneForm">
-            <el-form-item label="原手机号" prop="oldPhone">
-                <el-input v-model="phoneForm.oldPhone" autocomplete="off" placeholder="请输入完整手机号" maxlength="20">
-                    <template slot="prepend">+86</template>
-                </el-input>
-            </el-form-item>
-            <el-form-item label="验证码" prop="oldCode" class="code-box">
-                <el-input v-model="phoneForm.oldCode" autocomplete="off" placeholder="请输入验证码" class="code-input" maxlength="20">
-                </el-input>
-                <el-button type="primary" @click="sendCode('time','oldPhone','verificationCodeShow')" size="small" class="sendCode">
-                    {{ verificationCodeShow ? time+'s' : '发送验证码' }}
-                </el-button>
-            </el-form-item>
-            <el-form-item label="新手机号" prop="newPhone" style="margin-top:52px">
-                <el-input v-model="phoneForm.newPhone" autocomplete="off" placeholder="请输入完整手机号" maxlength="20">
+            <el-form-item label="新手机号" prop="newPhone">
+                <el-input v-model="phoneForm.newPhone" autocomplete="off" placeholder="请输入完整手机号" maxlength="20" @blur="handleTrim('phoneForm','newPhone')">
                     <template slot="prepend">+86</template>
                 </el-input>
             </el-form-item>
             <el-form-item label="验证码" prop="newCode" class="code-box">
-                <el-input v-model="phoneForm.newCode" autocomplete="off" placeholder="请输入验证码" class="code-input" maxlength="20">
+                <el-input v-model="phoneForm.newCode" autocomplete="off" placeholder="请输入验证码" class="code-input" maxlength="20" @blur="handleTrim('phoneForm','newCode')">
                 </el-input>
                 <el-button type="primary" @click="sendCode('times','newPhone','verificationCodesShow')" size="small" class="sendCode">
                     {{ verificationCodesShow ? times+'s' : '发送验证码' }}
                 </el-button>
             </el-form-item>
             <el-form-item>
-                <el-button type="primary" @click="onSubmitPhone('phoneForm')" size="small" :loading="true">保存</el-button>
+                <el-button type="primary" @click="onSubmitPhone('phoneForm')" size="small" :loading="passwordLoading">保存</el-button>
                 <el-button @click="onCancel('phoneForm')" size="small">取消</el-button>
             </el-form-item>
         </el-form>
@@ -202,18 +200,18 @@
         </p>
         <el-form :model="emailForm" :rules="rulesEmail" ref="emailForm" label-width="100px" class="emailForm">
             <el-form-item label="绑定邮箱" prop="email">
-                <el-input v-model="emailForm.email" autocomplete="off" placeholder="请输入邮箱地址" maxlength="100">
+                <el-input v-model="emailForm.email" autocomplete="off" placeholder="请输入邮箱地址" maxlength="100" @blur="handleTrim('emailForm','email')">
                 </el-input>
             </el-form-item>
             <el-form-item label="验证码" prop="code" class="code-box">
-                <el-input v-model="emailForm.code" autocomplete="off" placeholder="请输入验证码" class="code-input" maxlength="20">
+                <el-input v-model="emailForm.code" autocomplete="off" placeholder="请输入验证码" class="code-input" maxlength="20" @blur="handleTrim('emailForm','code')">
                 </el-input>
                 <el-button type="primary" @click="sendCode('timee','email','verificationCodeeShow','email')" size="small" class="sendCode">
-                    {{ verificationCodeeShow ? time+'s' : '发送验证码' }}
+                    {{ verificationCodeeShow ? timee+'s' : '发送验证码' }}
                 </el-button>
             </el-form-item>
             <el-form-item>
-                <el-button type="primary" @click="onSubmitPhone('emailForm')" size="small" :loading="true">保存</el-button>
+                <el-button type="primary" @click="onSubmitEmail('emailForm')" size="small" :loading="passwordLoading">保存</el-button>
                 <el-button @click="onCancel('emailForm')" size="small">取消</el-button>
             </el-form-item>
         </el-form>
@@ -287,9 +285,9 @@ export default {
         tabsIndex: 0,
         personalInfo: null,
         infoForm:{
-            name:'abc',
-            realName:'张平方',
-            sex:'1',
+            name: '',
+            realName:' ',
+            sex: 1,
             selectedOptions: [],
             desc:'',
             region:'',
@@ -371,6 +369,10 @@ export default {
             ]
         },
         loading: false,
+        orgList: [],
+        submitLoading: false,
+        passwordLoading: false,
+        timer: null
     }
   },
   //计算属性 类似于data概念
@@ -415,9 +417,30 @@ export default {
     onSubmit(formName){
         this.$refs[formName].validate((valid) => {
           if (valid) {
-            alert('submit!');
+            this.submitLoading = true
+            let MethodName = "/OrgServer/Client/PersonManager/UpdateMyBaseInfo";
+            let data = {
+                user_name: this.infoForm.name,
+                real_name: this.infoForm.realName,
+                sex: this.infoForm.sex,
+                city_id: this.infoForm.selectedOptions[1],
+                memo: this.infoForm.desc,
+                org_id: this.infoForm.region
+            }
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.submitLoading = false
+                if(res.status===1){
+                    this.getInfo()
+                    this.$message({
+                        message: '修改成功',
+                        type: 'success'
+                    })
+                }
+            }).catch((res) =>{
+                this.submitLoading = false
+            })
           } else {
-            console.log('error submit!!');
             return false;
           }
         });
@@ -447,9 +470,29 @@ export default {
     onSubmitPassword(formName){
         this.$refs[formName].validate((valid) => {
           if (valid) {
-            alert('submit!');
+            this.passwordLoading = true
+            let MethodName = "/OrgServer/Client/PersonManager/UpdateMyPassword";
+            let data = {
+                password_old: this.passwordForm.oldPwd,
+                password: this.passwordForm.newPwd
+            }
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.passwordLoading = false
+                if(res.status===1){
+                    this.$message({
+                        message: '修改成功',
+                        type: 'success'
+                    })
+                    this.handleSetting('passwordFlag')
+                    this.passwordForm.oldPwd = ''
+                    this.passwordForm.newPwd = ''
+                    this.passwordForm.confirmPwd = ''
+                }
+            }).catch((res) =>{
+                this.passwordLoading = false
+            })
           } else {
-            console.log('error submit!!');
             return false;
           }
         });
@@ -458,9 +501,72 @@ export default {
     onSubmitPhone(formName){
         this.$refs[formName].validate((valid) => {
           if (valid) {
-            alert('submit!');
+            this.passwordLoading = true
+            let MethodName = "/OrgServer/Client/PersonManager/UpdateMyPhone";
+            let data = {
+                phone: this.phoneForm.newPhone,
+                dynamic_verification_code: this.phoneForm.newCode
+            }
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.passwordLoading = false
+                if(res.status===1){
+                    this.$message({
+                        message: '修改成功',
+                        type: 'success'
+                    })
+                    this.getInfo()
+                    this.handleSetting('phoneFlag')
+                    this.phoneForm.newPhone = ''
+                    this.phoneForm.newCode = ''
+                }
+            }).catch((res) =>{
+                clearInterval(this.timer);
+                this.timer = null;
+                this.times = 60;
+                this.timee = 60;
+                this.passwordLoading = false
+                this.verificationCodeeShow = false
+                this.verificationCodesShow = false
+            })
+          } else {
+            return false;
+          }
+        });
+    },
+    // 修改邮箱
+    onSubmitEmail(formName){
+        this.$refs[formName].validate((valid) => {
+          if (valid) {
+            this.passwordLoading = true
+            let MethodName = "/OrgServer/Client/PersonManager/UpdateMyEmail";
+            let data = {
+                dynamic_verification_code: this.emailForm.code,
+                email: this.emailForm.email
+            }
+            getLogin(MethodName, data)
+            .then((res) => {
+                this.passwordLoading = false
+                if(res.status===1){
+                    this.$message({
+                        message: '修改成功',
+                        type: 'success'
+                    })
+                    this.getInfo()
+                    this.handleSetting('emailFlag')
+                    this.emailForm.code = ''
+                    this.emailForm.email = ''
+                }
+            }).catch((res) =>{
+                this.passwordLoading = false
+                clearInterval(this.timer);
+                this.timer = null;
+                this.times = 60;
+                this.timee = 60;
+                this.verificationCodeeShow = false
+                this.verificationCodesShow = false
+            })
           } else {
-            console.log('error submit!!');
             return false;
           }
         });
@@ -471,7 +577,7 @@ export default {
         if(this_[time] != 60){
             return
         }
-        let timer;
+        this_.timer = null;
         // 修改手机号
         if(!obj){
             if (this_.phoneForm[phone]) {
@@ -482,27 +588,27 @@ export default {
                     return
                 }
                 this_[flag] = true;
-                timer = setInterval(() => {
+                this_.timer = setInterval(() => {
                     this_[time]--;
                     if (this_[time] == 0) {
                         this_[flag] = false;
-                        clearInterval(timer);
-                        timer = null;
+                        clearInterval(this_.timer);
+                        this_.timer = null;
                         this_[time] = 60;
                     }
                 }, 1000);
-                // let MethodName = "user_manager-SendVerificationCode";
-                // let data = {
-                // verification_type: 'EMAIL',
-                // phone_or_email: this_.loginForm.username,
-                // };
-                // getLogin(MethodName, data).then((res) => {
-                // }).catch(()=>{
-                //     this_[flag] = false;
-                //     clearInterval(timer);
-                //     timer = null;
-                //     this_[time] = 60;
-                // });
+                let MethodName = "/OrgServer/LoginControl/SendVerificationCode";
+                let data = {
+                    send_type: 'SMS',
+                    phone_or_email: this_.phoneForm[phone],
+                };
+                getLogin(MethodName, data).then((res) => {
+                }).catch(()=>{
+                    this_[flag] = false;
+                    clearInterval(this_.timer);
+                    this_.timer = null;
+                    this_[time] = 60;
+                });
             } else {
                 this_.$message.warning('请先输入手机号');
             }
@@ -516,27 +622,27 @@ export default {
                     return
                 }
                 this_[flag] = true;
-                timer = setInterval(() => {
+                this_.timer = setInterval(() => {
                     this_[time]--;
                     if (this_[time] == 0) {
                         this_[flag] = false;
-                        clearInterval(timer);
-                        timer = null;
+                        clearInterval(this_.timer);
+                        this_.timer = null;
                         this_[time] = 60;
                     }
                 }, 1000);
-                // let MethodName = "user_manager-SendVerificationCode";
-                // let data = {
-                // verification_type: 'EMAIL',
-                // phone_or_email: this_.loginForm.username,
-                // };
-                // getLogin(MethodName, data).then((res) => {
-                // }).catch(()=>{
-                //     this_[flag] = false;
-                //     clearInterval(timer);
-                //     timer = null;
-                //     this_[time] = 60;
-                // });
+                let MethodName = "/OrgServer/LoginControl/SendVerificationCode";
+                let data = {
+                    send_type: 'EMAIL',
+                    phone_or_email: this_.emailForm[phone],
+                };
+                getLogin(MethodName, data).then((res) => {
+                }).catch(()=>{
+                    this_[flag] = false;
+                    clearInterval(this_.timer);
+                    this_.timer = null;
+                    this_[time] = 60;
+                });
             } else {
                 this_.$message.warning('请先输入邮箱');
             }
@@ -552,6 +658,16 @@ export default {
             this.loading = false
             if(res.status===1){
                 this.personalInfo = res.person
+                this.infoForm = {
+                    name: this.personalInfo.user_name,
+                    realName: this.personalInfo.real_name,
+                    sex: this.personalInfo.sex,
+                    selectedOptions: this.personalInfo.province_id&&this.personalInfo.city_id?[this.personalInfo.province_id,this.personalInfo.city_id]:[],
+                    desc: this.personalInfo.memo,
+                    region: this.personalInfo.org_id,
+                    cover_image_list: [],
+                    cover_image_id: null,
+                }
                 this.$emit('changeTouxiang',this.personalInfo.image_url)
             }
         }).catch((res) =>{
@@ -571,9 +687,32 @@ export default {
         }).catch((res) =>{
         })
     },
+    // 查询列表
+    getOrgList(){
+        let MethodName = "/OrgServer/Client/OrgManager/GetOrgIndexList";
+        let data = {
+            name: '',
+            status: 1,
+            sn: ''
+        }
+        getLogin(MethodName, data)
+        .then((res) => {
+            if(res.status===1){
+                this.orgList = res.org_index_list
+            }
+        })
+        .catch(() => {
+            this.loading = false
+        });
+    },
+    // 去掉前后空格
+    handleTrim(form,fild){
+        this[form][fild] = this[form][fild].trim()
+    },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
+    this.getOrgList()
     this.getInfo()
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
@@ -865,5 +1004,27 @@ export default {
             width: 100% !important;
         }
     }
+    .audit-status{
+        border: none;
+        margin-left: 16px;
+        border-radius: 2px;
+        background:#E8F7FF;
+        padding: 1px 8px;
+        color: #3491FA;
+        font-size: 14px;
+        font-weight: 500;
+        line-height: 22px;
+        height: 24px;
+        .svg-icon{
+            margin-right: 4px;
+        }
+        &.audit-refused{
+            color: #F53F3F;
+            background: #FFECE8;
+            .el-icon-error{
+                margin-right: 4px;
+            }
+        }
+    }
 }
 </style>