Преглед изворни кода

update:消息通知设置

damon227 пре 11 месеци
родитељ
комит
3ae4104544
2 измењених фајлова са 104 додато и 1 уклоњено
  1. 91 0
      src/views/main-navbar-notify-type.vue
  2. 13 1
      src/views/main-navbar.vue

+ 91 - 0
src/views/main-navbar-notify-type.vue

@@ -0,0 +1,91 @@
+<template>
+  <el-dialog
+    title="消息通知设置"
+    :visible.sync="visible"
+    :append-to-body="true">
+    <el-form :model="dataForm" ref="dataForm"  label-width="0px">
+      <el-form-item label="">
+        <el-checkbox-group v-model="checkTypes">
+            <el-checkbox :disabled="item.value == 'system'" :label="item.value"  :key="item.value" v-for="item in types">{{item.name}}</el-checkbox>
+        </el-checkbox-group>
+      </el-form-item>
+     
+    </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 { getMyInfo } from '@/api/my'
+  import { clearLoginInfo } from '@/utils'
+  export default {
+    data () {
+      return {
+        visible: false,
+        dataForm: {},
+        userInfo:{},
+        types: [{
+					value: 'system',
+					name: '系统消息',
+					disabled: true
+				}, {
+					value: 'message',
+					name: '短信消息'
+				}, {
+					value: 'weChat',
+					name: '微信消息'
+				}],
+        checkTypes:['system']
+      }
+    },
+    computed: {
+    },
+    methods: {
+      // 初始化
+      init () {
+        this.visible = true
+        // 获取用户信息
+        getMyInfo().then(({data}) => {
+          if (data && data.code === '200' && data.data) {
+            this.userInfo = data.data
+            if(this.userInfo.userEntity.notifyType){
+            this.checkTypes = this.userInfo.userEntity.notifyType.split(",")
+            }
+          }
+        })
+      },
+      // 表单提交
+      dataFormSubmit () {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            this.$http({
+              url: this.$http.adornUrl('/biz-service/personal/notifyType/save'),
+              method: 'post',
+              data: this.$http.adornData({
+                'notifyType': this.checkTypes.join(","),
+                'userId': ''
+              })
+            }).then(({data}) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.visible = false
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+          }
+        })
+      }
+    }
+  }
+</script>
+

+ 13 - 1
src/views/main-navbar.vue

@@ -47,6 +47,7 @@
               <img src="~@/assets/img/avatar.png" :alt="userName">{{ userName }}
             </span>
             <el-dropdown-menu slot="dropdown">
+              <el-dropdown-item @click.native="notifyTypeHandle()">消息通知设置</el-dropdown-item>
               <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>
               <el-dropdown-item @click.native="updateSignHandle()">修改个人签名</el-dropdown-item>
               <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
@@ -55,6 +56,7 @@
         </el-menu-item>
       </el-menu>
     </div>
+    <notify-type v-if="notifyTypeVisible" ref="notifyType"></notify-type>
     <!-- 弹窗, 修改密码 -->
     <update-password v-if="updatePasswordVisible" ref="updatePassowrd"></update-password>
     <update-user-sign v-if="updateUserSignVisible" ref="updateUserSign"></update-user-sign>
@@ -64,6 +66,7 @@
 </template>
 
 <script>
+  import NotifyType from './main-navbar-notify-type'
   import UpdatePassword from './main-navbar-update-password'
   import UpdateUserSign from './main-navbar-update-sign'
   import Msg from './common/msg'
@@ -74,6 +77,7 @@
 export default {
     data () {
       return {
+        notifyTypeVisible: false,
         updatePasswordVisible: false,
         updateUserSignVisible: false,
         cnt: 0,
@@ -85,7 +89,8 @@ export default {
       PreviewComponent,
       UpdatePassword,
       UpdateUserSign,
-      Msg
+      Msg,
+      NotifyType
     },
     computed: {
       navbarLayoutType: {
@@ -107,6 +112,13 @@ export default {
       }
     },
     methods: {
+      //消息设置
+      notifyTypeHandle(){
+        this.notifyTypeVisible = true
+        this.$nextTick(() => {
+          this.$refs.notifyType.init()
+        })
+      },
       // 修改密码
       updatePasswordHandle () {
         this.updatePasswordVisible = true