Browse Source

feat: 删除个人信息页面中的修改信息部分

ChenYangfan 6 years ago
parent
commit
7c3479ef89
2 changed files with 96 additions and 92 deletions
  1. 3 0
      src/App.vue
  2. 93 92
      src/views/shared/Personal.vue

+ 3 - 0
src/App.vue

@@ -43,6 +43,7 @@ export default {
     }
     }
   },
   },
   created () {
   created () {
+    // 为每个请求添加Auth字段
     this.$axios.interceptors.request.use(config => {
     this.$axios.interceptors.request.use(config => {
       config.headers['Authorization'] = this.token
       config.headers['Authorization'] = this.token
       return config
       return config
@@ -59,6 +60,7 @@ export default {
       return Promise.reject(error)
       return Promise.reject(error)
     })
     })
 
 
+    // 页面权限鉴定
     this.$router.beforeEach((to, from, next) => {
     this.$router.beforeEach((to, from, next) => {
       if (to.matched.some(record => (record.meta.roles && !record.meta.roles.some(role => role === this.userInfo.role.toLowerCase())))) {
       if (to.matched.some(record => (record.meta.roles && !record.meta.roles.some(role => role === this.userInfo.role.toLowerCase())))) {
         this.$setInfoMessage('所前往的页面需要使用' + userTypeNaming[this.userInfo.role] + '身份登录')
         this.$setInfoMessage('所前往的页面需要使用' + userTypeNaming[this.userInfo.role] + '身份登录')
@@ -79,6 +81,7 @@ export default {
     })
     })
   },
   },
   mounted () {
   mounted () {
+    // 获取用户信息
     this.fetchUserInfo()
     this.fetchUserInfo()
   },
   },
   methods: {
   methods: {

+ 93 - 92
src/views/shared/Personal.vue

@@ -11,41 +11,41 @@
         <div>姓名:{{userInfo.name}}</div>
         <div>姓名:{{userInfo.name}}</div>
         <div>加入时间:{{momentFromNow(userInfo.createAt)}}</div>
         <div>加入时间:{{momentFromNow(userInfo.createAt)}}</div>
       </div>
       </div>
-      <div class="sub-title">
-        修改资料
-        <c-button :theme="showChangeProfile ? 'blue' : 'normal'" :left="8" text
-                  :icon="showChangeProfile ? 'unfold_less' : 'unfold_more'"
-                  @click="showChangeProfile = !showChangeProfile">
-          {{showChangeProfile ? '收起' : '展开'}}
-        </c-button>
-      </div>
-      <show-transition>
-        <div v-if="showChangeProfile">
-          <c-input :placeholder="'目前资料中的姓名:' + userInfo.name" class="mb-16" v-model="newName"></c-input>
-          <c-button theme="green" block class="mb-32" @click="handleModifyName" icon="check">确认修改姓名</c-button>
-        </div>
-      </show-transition>
-      <div class="sub-title">
-        修改密码
-        <c-button :theme="showChangePassword ? 'blue' : 'normal'" :left="8" text
-                  :icon="showChangePassword ? 'unfold_less' : 'unfold_more'"
-                  @click="showChangePassword = !showChangePassword">
-          {{showChangePassword ? '收起' : '展开'}}
-        </c-button>
-      </div>
-      <show-transition>
-        <div v-if="showChangePassword">
-          <div class="verified-code-wrapper">
-            <c-input placeholder="邮箱验证码" type="number" v-model="code"></c-input>
-            <c-button theme="blue" :no-click-warn="typeof emailButtonContent === typeof 0"
-                      @click="handleSendEmailCode">{{ emailButtonContent }}
-            </c-button>
-          </div>
-          <c-input placeholder="新密码" type="password" class="mb-16" v-model="password"></c-input>
-          <c-input placeholder="确认新密码" type="password" class="mb-16" v-model="passwordEnsure"></c-input>
-          <c-button block theme="orange" @click="handleModifyPassword" icon="check">确认修改密码</c-button>
-        </div>
-      </show-transition>
+      <!--      <div class="sub-title">-->
+      <!--        修改资料-->
+      <!--        <c-button :theme="showChangeProfile ? 'blue' : 'normal'" :left="8" text-->
+      <!--                  :icon="showChangeProfile ? 'unfold_less' : 'unfold_more'"-->
+      <!--                  @click="showChangeProfile = !showChangeProfile">-->
+      <!--          {{showChangeProfile ? '收起' : '展开'}}-->
+      <!--        </c-button>-->
+      <!--      </div>-->
+      <!--      <show-transition>-->
+      <!--        <div v-if="showChangeProfile">-->
+      <!--          <c-input :placeholder="'目前资料中的姓名:' + userInfo.name" class="mb-16" v-model="newName"></c-input>-->
+      <!--          <c-button theme="green" block class="mb-32" @click="handleModifyName" icon="check">确认修改姓名</c-button>-->
+      <!--        </div>-->
+      <!--      </show-transition>-->
+      <!--      <div class="sub-title">-->
+      <!--        修改密码-->
+      <!--        <c-button :theme="showChangePassword ? 'blue' : 'normal'" :left="8" text-->
+      <!--                  :icon="showChangePassword ? 'unfold_less' : 'unfold_more'"-->
+      <!--                  @click="showChangePassword = !showChangePassword">-->
+      <!--          {{showChangePassword ? '收起' : '展开'}}-->
+      <!--        </c-button>-->
+      <!--      </div>-->
+      <!--      <show-transition>-->
+      <!--        <div v-if="showChangePassword">-->
+      <!--          <div class="verified-code-wrapper">-->
+      <!--            <c-input placeholder="邮箱验证码" type="number" v-model="code"></c-input>-->
+      <!--            <c-button theme="blue" :no-click-warn="typeof emailButtonContent === typeof 0"-->
+      <!--                      @click="handleSendEmailCode">{{ emailButtonContent }}-->
+      <!--            </c-button>-->
+      <!--          </div>-->
+      <!--          <c-input placeholder="新密码" type="password" class="mb-16" v-model="password"></c-input>-->
+      <!--          <c-input placeholder="确认新密码" type="password" class="mb-16" v-model="passwordEnsure"></c-input>-->
+      <!--          <c-button block theme="orange" @click="handleModifyPassword" icon="check">确认修改密码</c-button>-->
+      <!--        </div>-->
+      <!--      </show-transition>-->
     </div>
     </div>
     <slide-in-different-transition>
     <slide-in-different-transition>
       <router-view/>
       <router-view/>
@@ -54,24 +54,25 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import CButton from '@/components/Basic/CButton'
-import CInput from '@/components/Basic/CInput'
-import { sendEmailCode } from '@/server/code'
-import { modifyUser, resetPasswordByEmail } from '@/server/user'
+// import CButton from '@/components/Basic/CButton'
+// import CInput from '@/components/Basic/CInput'
+// import { sendEmailCode } from '@/server/code'
+// import { modifyUser, resetPasswordByEmail } from '@/server/user'
 import { mapState } from 'vuex'
 import { mapState } from 'vuex'
 import CTag from '@/components/Basic/CTag'
 import CTag from '@/components/Basic/CTag'
 import SlideInDifferentTransition from '@/animations/SlideInDifferentTransition'
 import SlideInDifferentTransition from '@/animations/SlideInDifferentTransition'
-import ShowTransition from '@/animations/ShowTransition'
+// import ShowTransition from '@/animations/ShowTransition'
 import momentFromNow from '@/utils/moment-from-now'
 import momentFromNow from '@/utils/moment-from-now'
 import { userTypeNaming } from '@/enums/user-type'
 import { userTypeNaming } from '@/enums/user-type'
-import { SET_USER_INFO } from '@/store/types/main-types'
+// import { SET_USER_INFO } from '@/store/types/main-types'
 
 
 export default {
 export default {
   props: {
   props: {
     role: String,
     role: String,
     roleTagTheme: String
     roleTagTheme: String
   },
   },
-  components: { CTag, CInput, CButton, SlideInDifferentTransition, ShowTransition },
+  // components: { CTag, CInput, CButton, SlideInDifferentTransition, ShowTransition },
+  components: { CTag, SlideInDifferentTransition },
   data () {
   data () {
     return {
     return {
       emailButtonContent: '发送验证码',
       emailButtonContent: '发送验证码',
@@ -94,56 +95,56 @@ export default {
     }
     }
   },
   },
   methods: {
   methods: {
-    momentFromNow,
-    handleSendEmailCode () {
-      this.$setInfoMessage('正在尝试发送验证码')
-      if (this.email.match(/.+@.*(edu.cn)/)) {
-        this.setEmailCodeCd()
-        sendEmailCode({ email: this.email }).then(res => {
-          this.$setSuccessMessage('邮箱验证码发送成功')
-        }).catch(err => {
-          this.$setErrorMessage(err.response.data.msg)
-        })
-      } else {
-        this.$setErrorMessage('本邮箱不符合南京大学校邮格式')
-      }
-    },
-    setEmailCodeCd () {
-      this._emailCodeCdInterval && clearInterval(this._emailCodeCdInterval)
-      this.emailButtonContent = 60
-      this._emailCodeCdInterval = setInterval(() => {
-        this.emailButtonContent--
-        if (typeof this.emailButtonContent !== typeof 0 || this.emailButtonContent <= 0) {
-          clearInterval(this._emailCodeCdInterval)
-          this.emailButtonContent = '发送验证码'
-        }
-      }, 1000)
-    },
-    handleModifyPassword () {
-      if (!this.password || this.password !== this.passwordEnsure) {
-        this.$setInfoMessage('两次输入的密码不一致')
-        return
-      }
-
-      resetPasswordByEmail({ email: this.email, code: this.code, password: this.password }).then(res => {
-        this.$setSuccessMessage('密码修改成功')
-      }).catch(err => {
-        this.$setErrorMessage(err.response.data.msg)
-      })
-    },
-    handleModifyName () {
-      if (!this.newName) {
-        this.$setInfoMessage('输入的新用户名为空')
-        return
-      }
-
-      modifyUser({ name: this.newName, type: this.role }).then(res => {
-        this.$setSuccessMessage('修改用户名成功')
-        this.$store.commit(SET_USER_INFO, { userInfo: res })
-      }).catch(err => {
-        this.$setErrorMessage(err.response.data.msg)
-      })
-    }
+    momentFromNow
+    // handleSendEmailCode () {
+    //   this.$setInfoMessage('正在尝试发送验证码')
+    //   if (this.email.match(/.+@.*(edu.cn)/)) {
+    //     this.setEmailCodeCd()
+    //     sendEmailCode({ email: this.email }).then(res => {
+    //       this.$setSuccessMessage('邮箱验证码发送成功')
+    //     }).catch(err => {
+    //       this.$setErrorMessage(err.response.data.msg)
+    //     })
+    //   } else {
+    //     this.$setErrorMessage('本邮箱不符合南京大学校邮格式')
+    //   }
+    // },
+    // setEmailCodeCd () {
+    //   this._emailCodeCdInterval && clearInterval(this._emailCodeCdInterval)
+    //   this.emailButtonContent = 60
+    //   this._emailCodeCdInterval = setInterval(() => {
+    //     this.emailButtonContent--
+    //     if (typeof this.emailButtonContent !== typeof 0 || this.emailButtonContent <= 0) {
+    //       clearInterval(this._emailCodeCdInterval)
+    //       this.emailButtonContent = '发送验证码'
+    //     }
+    //   }, 1000)
+    // },
+    // handleModifyPassword () {
+    //   if (!this.password || this.password !== this.passwordEnsure) {
+    //     this.$setInfoMessage('两次输入的密码不一致')
+    //     return
+    //   }
+    //
+    //   resetPasswordByEmail({ email: this.email, code: this.code, password: this.password }).then(res => {
+    //     this.$setSuccessMessage('密码修改成功')
+    //   }).catch(err => {
+    //     this.$setErrorMessage(err.response.data.msg)
+    //   })
+    // },
+    // handleModifyName () {
+    //   if (!this.newName) {
+    //     this.$setInfoMessage('输入的新用户名为空')
+    //     return
+    //   }
+    //
+    //   modifyUser({ name: this.newName, type: this.role }).then(res => {
+    //     this.$setSuccessMessage('修改用户名成功')
+    //     this.$store.commit(SET_USER_INFO, { userInfo: res })
+    //   }).catch(err => {
+    //     this.$setErrorMessage(err.response.data.msg)
+    //   })
+    // }
   }
   }
 }
 }
 </script>
 </script>