Sfoglia il codice sorgente

新增功能:用户签名

chrislee 1 anno fa
parent
commit
094be4028c
1 ha cambiato i file con 95 aggiunte e 0 eliminazioni
  1. 95 0
      src/views/main-navbar-update-sign.vue

+ 95 - 0
src/views/main-navbar-update-sign.vue

@@ -0,0 +1,95 @@
+<template>
+  <el-dialog
+    title="修改个人签名"
+    :visible.sync="visible"
+    :append-to-body="true">
+    <el-form :model="dataForm" :rules="dataRule" ref="dataForm"  label-width="80px">
+      <upload-component :title="'个人签名'" :accept="'*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
+    </el-form>
+    <span slot="footer">
+      <el-button @click="visible = false">取消</el-button>
+      <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+  import { clearLoginInfo } from '@/utils'
+  import { getMyInfo } from '@/api/my'
+  import UploadComponent from './modules/common/upload-component'
+  export default {
+    components: {
+      UploadComponent
+    },
+    data () {
+      return {
+        visible: false,
+        fileList: [],
+        dataForm: {},
+        dataRule: {
+        }
+      }
+    },
+    computed: {
+      userName: {
+        get () { return this.$store.state.user.name }
+      },
+      mainTabs: {
+        get () { return this.$store.state.common.mainTabs },
+        set (val) { this.$store.commit('common/updateMainTabs', val) }
+      }
+    },
+    methods: {
+      // 初始化
+      init () {
+        // 获取用户信息
+        getMyInfo().then(({data}) => {
+          if (data && data.code === '200' && data.data) {
+            this.dataForm = data.data
+          }
+        })
+        this.visible = true
+        this.$nextTick(() => {
+          this.$refs['dataForm'].resetFields()
+        })
+      },
+      // 表单提交
+      dataFormSubmit () {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            this.$http({
+              url: this.$http.adornUrl('/biz-service/user/password'),
+              method: 'post',
+              data: this.$http.adornData({
+                'password': this.dataForm.password,
+                'newPassword': this.dataForm.newPassword
+              })
+            }).then(({data}) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.visible = false
+                    this.$nextTick(() => {
+                      this.mainTabs = []
+                      clearLoginInfo()
+                      this.$router.replace({ name: 'login' })
+                    })
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+          }
+        })
+      },
+      uploadSuccess (fileList) {
+        this.fileList = fileList
+      }
+    }
+  }
+</script>
+