Jelajahi Sumber

完成绑定企业相关交互功能,对云中心在没有登入情况下做处理

Administrator 7 tahun lalu
induk
melakukan
e05b1b0031

+ 2 - 7
middleware/authenticated.js

@@ -1,13 +1,8 @@
 
 export default function ({ isServer, store, req, redirect }) {
-  // If nuxt generate, pass this middleware
   if (isServer && !req) return
 
-  if (!store.state.option.user.logged) {
-    this.$http.get('/logout/crossBefore').then(response => {
-      if (response.data) {
-        window.location.href = response.data.logoutUrl + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
-      }
-    })
+  if (!store.state.option.isLogin.data) {
+    return redirect('/')
   }
 }

+ 109 - 21
pages/bingEnterPrise/index.vue → pages/bindEnterPrise/_uuid.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="x-content">
+  <div class="x-content" @click="onHideBox()">
     <div class="container">
       <div class="w-over-top">
         <div class="w-over">
@@ -7,41 +7,45 @@
           <hr>
           <div class="bind-search">
             <div class="search">
-              <input type="search" class="form-control" placeholder="输入企业名称查询">
-              <i class="delete"></i><i class="icon-search"></i>
-              <ul class="list-unstyled">
-                <li class="hit">3432432</li>
-                <li class="hit">3432432</li>
-                <li class="hit">3432432</li>
-                <li class="hit">3432432</li>
-                <li class="hit">3432432</li>
-                <li class="hit">3432432</li>
+              <input type="search" class="form-control" placeholder="输入企业名称查询"
+                     @click="onShowBox()"
+                     v-model="keyword">
+              <i class="delete" @click="deleteSearch()"></i><i class="icon-search"></i>
+              <ul class="list-unstyled" v-show="isShowBox" @mouseenter="hasBox=true" @mouseleave="hasBox=false">
+                <li class="hit" v-text="keyword" @click="selectInfo(keyword)"></li>
+                <template v-for="item in searchName.content">
+                  <li class="hit" @click="selectInfo(item)" v-text="item"></li>
+                </template>
               </ul>
             </div>
             <div class="search-info">
-              <h3 id="name"><i></i><span>企业名称</span><em>(未注册)</em></h3>
+              <h3 id="name"><i></i><span v-text="enterPrise">企业名称</span><em v-if="hasRegister && searchInfo.length <= 0">(未注册)</em></h3>
               <hr/>
               <div class="row">
                 <div class="col-xs-3"><p>管理员</p></div>
-                <div class="col-xs-9"><span id="admin"></span></div>
+                <div class="col-xs-9"><span v-text="searchInfo.admin ? searchInfo.admin.vipName : ''"></span></div>
               </div>
               <div class="row">
                 <div class="col-xs-3"><p>企业法人</p></div>
-                <div class="col-xs-9"><span id="corporation"></span></div>
+                <div class="col-xs-9"><span v-text="searchInfo.corporation"></span></div>
               </div>
               <div class="row">
                 <div class="col-xs-3"><p>营业执照</p></div>
-                <div class="col-xs-9"><span id="businessCode"></span></div>
+                <div class="col-xs-9"><span v-text="searchInfo.businessCode"></span></div>
               </div>
               <div class="row">
                 <div class="col-xs-3"><p>企业地址</p></div>
-                <div class="col-xs-9"><span id="address"></span></div>
+                <div class="col-xs-9"><span v-text="searchInfo.regAddress"></span></div>
               </div>
             </div>
           </div>
-          <a name="register" href="/sso/register?appId=${appId}">立即注册</a>
-          <a name="apply" href="javascript:void(0)">申请绑定</a>
-          <p id="applyText">管理员审核通过后成功绑定</p>
+          <template v-if="hasRegister && !searchInfo">
+            <a name="register" href="/sso/register">立即注册</a>
+          </template>
+          <template v-if="hasRegister && searchInfo && !searchInfo.admin">
+            <a href="javascript:void(0)" @click="bingEnterPrise()">申请绑定</a>
+            <p id="applyText">管理员审核通过后成功绑定</p>
+          </template>
         </div>
       </div>
     </div>
@@ -50,7 +54,92 @@
 
 <script>
     export default {
-      layout: 'main'
+      layout: 'main',
+      data () {
+        return {
+          keyword: '',
+          number: 5,
+          isShowBox: false,
+          hasBox: false,
+          clickInput: false,
+          enterPrise: '企业名称',
+          hasRegister: false
+        }
+      },
+      watch: {
+        'keyword': function () {
+          this.handleChange()
+        }
+      },
+      created () {
+        this.$store.dispatch('restForName')
+        this.$store.dispatch('restForInfo')
+      },
+      computed: {
+        searchName () {
+          return this.$store.state.search.keywords.data.content ? this.$store.state.search.keywords.data.content : ''
+        },
+        searchInfo () {
+          return this.$store.state.search.enterprise.data.content ? this.$store.state.search.enterprise.data.content : ''
+        }
+      },
+      methods: {
+        handleChange: function () {
+          if (this.keyword) {
+            this.isShowBox = true
+            this.$store.dispatch('searchForName', {keyword: this.keyword, number: this.number})
+          }
+        },
+        onShowBox: function () {
+          if (this.isShowBox) {
+            this.onHideBox()
+          } else {
+            this.isShowBox = true
+            this.clickInput = true
+          }
+        },
+        onHideBox: function () {
+          if (!this.hasBox && !this.clickInput) {
+            this.isShowBox = false
+          } else {
+            this.clickInput = false
+          }
+        },
+        selectInfo: function (item) {
+          this.isShowBox = false
+          this.enterPrise = item
+          this.hasRegister = true
+          this.$store.dispatch('searchForInfo', { name: item })
+          this.$store.dispatch('restForName')
+        },
+        deleteSearch: function () {
+          this.keyword = ''
+          this.enterPrise = '企业名称'
+          this.hasRegister = false
+          this.$store.dispatch('restForName')
+          this.$store.dispatch('restForInfo')
+        },
+        bingEnterPrise: function () {
+          let param = new FormData()
+          param.append('userUU', this.$route.params.uuid)
+          param.append('spaceUU', this.searchInfo.spaceUU)
+          let config = {
+            headers: {'Context-type': 'multipart/form-data'}
+          }
+          this.$http.post('/api/user/apply/bind', param, config)
+            .then(res => {
+              if (res.data.success) {
+                this.$message({
+                  message: '您成功绑定企业',
+                  type: 'success'
+                })
+              }
+              if (res.data.error) {
+                this.$message.error(res.data.errMsg)
+              }
+            })
+        }
+      }
     }
 </script>
 
@@ -225,9 +314,8 @@
     background: url('/img/over_account/search.png')no-repeat;
   }
   .w-over-top .bind-search .search ul{
-    display:none;
     position:absolute;
-    top:34px;
+    top:100%;
     left:0;
     z-index:100;
     width:100%;

+ 2 - 1
pages/cloudcenter/enterprise/index.vue

@@ -102,6 +102,7 @@
   export default {
     name: 'manager',
     layout: 'cloud',
+    middleware: 'authenticated',
     fetch ({store}) {
       return Promise.all([
         store.dispatch('loadApplyList', {page: 1, size: 20}),
@@ -135,7 +136,7 @@
     },
     methods: {
       bingEnterpriseClick: function () {
-        window.location.href = '/bingEnterPrise'
+        window.location.href = '/bindEnterPrise'
       },
       noBingClick: function () {
         window.location.href = '/cloudcenter'

+ 1 - 0
pages/cloudcenter/index.vue

@@ -50,6 +50,7 @@
 <script>
     export default {
       layout: 'cloud',
+      middleware: 'authenticated',
       computed: {
         user () {
           return this.$store.state.option.userInfo.data.content

+ 1 - 1
pages/overRegister/overPersonal.vue → pages/overRegister/_uuid.vue

@@ -49,7 +49,7 @@
       <div class="w-over-bottom">
         <div class="w-over">
           <p>绑定企业后,您还可以开通体验以下服务</p>
-          <a href="/bingEnterPrise">立即绑定企业</a>
+          <a :href="'/bindEnterPrise/' + $route.params.uuid">立即绑定企业</a>
           <div class="media">
             <div class="media-left media-middle">
               <a href="https://www.usoftchina.com/b2b">

+ 28 - 1
store/index.js

@@ -29,7 +29,6 @@ export const actions = {
     commit('option/REQUEST_IS_LOGIN')
     return axios.get('/sso/login/isLogin')
     .then(response => {
-      // console.log(JSON.stringify(response.data))
       commit('option/REQUEST_IS_LOGIN_SUCCESS', response.data)
     }, err => {
       commit('option/REQUEST_IS_LOGIN_FAILURE', err)
@@ -72,6 +71,34 @@ export const actions = {
         commit('cloudCenter/REQUEST_APPLY_FAILURE', err)
       })
   },
+  // 关键字查询企业名称
+  searchForName ({ commit }, params = {}) {
+    commit('search/REQUEST_KEYWORDS')
+    return axios.get('/api/userspace/search/name', {params})
+      .then(res => {
+        commit('search/GET_KEYWORDS_SUCCESS', res.data)
+      }, err => {
+        commit('search/GET_KEYWORDS_FAILURE', err)
+      })
+  },
+  // 清空企业数据
+  restForName ({commit}) {
+    commit('search/REST_KEYWORDS')
+  },
+  // 通过企业名查询企业信息
+  searchForInfo ({commit}, params = {}) {
+    commit('search/REQUEST_ENTERPRISE')
+    return axios.get('/api/userspace/info/name', {params})
+      .then(res => {
+        commit('search/GET_ENTERPRISE_SUCCESS', res.data)
+      }, err => {
+        commit('search/GET_ENTERPRISE_FAILURE', err)
+      })
+  },
+  // 清空查询企业信息数据
+  restForInfo ({commit}) {
+    commit('search/REST_ENTERPRISE')
+  },
   // 获取表单配置
   loadFormData ({ commit }, params = {}) {
     commit('formConfig/REQUEST_FORMDATA')

+ 39 - 0
store/search.js

@@ -0,0 +1,39 @@
+export const state = () => ({
+  keywords: {
+    fetching: false,
+    data: []
+  },
+  enterprise: {
+    fetching: false,
+    data: []
+  }
+})
+
+export const mutations = {
+  REQUEST_KEYWORDS (state) {
+    state.keywords.fetching = true
+  },
+  REST_KEYWORDS (state) {
+    state.keywords.data = []
+  },
+  GET_KEYWORDS_SUCCESS (state, result) {
+    state.keywords.fetching = false
+    state.keywords.data = result
+  },
+  GET_KEYWORDS_FAILURE (state) {
+    state.keywords.fetching = true
+  },
+  REQUEST_ENTERPRISE (state) {
+    state.enterprise.fetching = true
+  },
+  REST_ENTERPRISE (state) {
+    state.enterprise.data = []
+  },
+  GET_ENTERPRISE_SUCCESS (state, result) {
+    state.enterprise.fetching = false
+    state.enterprise.data = result
+  },
+  GET_ENTERPRISE_FAILURE (state) {
+    state.enterprise.fetching = true
+  }
+}

File diff ditekan karena terlalu besar
+ 548 - 12
yarn.lock


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini