Эх сурвалжийг харах

feat:未登录聊天,图片文件上传拦截处理

zhangsiya 1 жил өмнө
parent
commit
fac51697d8

+ 14 - 3
src/components/action-list/index.vue

@@ -12,6 +12,7 @@
       >
         <el-upload
           v-if="item.type == 'image'"
+          :disabled="disabled"
           action="#"
           accept=".jpg,.png,.svg,.jpeg,.gif,.bmp"
           :file-list="imageList"
@@ -21,10 +22,11 @@
           :before-upload="beforeUploadImage"
           slot="reference"
         >
-          <span class="action-img image"></span>
+          <span class="action-img image"  @click="checkLogin"></span>
         </el-upload>
         <el-upload
           v-else-if="item.type == 'attach'"
+          :disabled="disabled"
           action="#"
           accept=".pdf,.word,.docx,.ppt,.pptx"
           :file-list="attachList"
@@ -34,7 +36,7 @@
           :before-upload="beforeUploadAttach"
           slot="reference"
         >
-          <span class="action-img attach"></span>
+          <span class="action-img attach"  @click="checkLogin"></span>
         </el-upload>
         <div v-else-if="item.type == 'rate'" slot="reference">
           <span v-show="isRobot === 2" class="action-img rate" :class="item.type" @click="onClick(item.type)"></span>
@@ -52,6 +54,7 @@
 <script>
 import { Popover, Upload } from 'element-ui'
 import { fileUpload } from '@/api/modules/'
+import {mapGetters} from "vuex";
 
 export default {
   name: 'action-container',
@@ -90,7 +93,8 @@ export default {
     return {
       list: this.options,
       imageList: [],
-      attachList: []
+      attachList: [],
+      disabled: false
     }
   },
   watch: {
@@ -99,6 +103,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters('user', ['isLogin']),
     getOptions () {
       const list = this.list
       const arr = list.map(v => {
@@ -181,6 +186,12 @@ export default {
         this.$toast('上传失败,只能选择PDF、WORD、PPT格式')
         return false
       }
+    },
+    checkLogin () {
+      if (!this.isLogin) {
+        this.disabled = true
+        this.$showLoginDialog()
+      }
     }
   }
 }

+ 1 - 0
src/main.js

@@ -7,6 +7,7 @@ import store from './store'
 import '@/assets/style/element-variables.scss'
 import ElementUI, { Message, MessageBox, Loading } from 'element-ui'
 import '@/utils'
+import '@/utils/common'
 import Toast from '@/utils/toast/'
 import $bus from './utils/bus'
 Vue.prototype.$bus = $bus

+ 10 - 0
src/utils/common.js

@@ -0,0 +1,10 @@
+import Vue from 'vue'
+
+Vue.prototype.$showLoginDialog = function () {
+  try {
+    openLoginDig && openLoginDig(...arguments)
+  } catch (error) {
+    console.log(error)
+    location.href = '/notin/page?close_goBack=1'
+  }
+}