Explorar o código

店铺页网址问题

yangc %!s(int64=7) %!d(string=hai) anos
pai
achega
68cb92583d
Modificáronse 4 ficheiros con 77 adicións e 52 borrados
  1. 40 43
      components/store/BaseInfo.vue
  2. 6 2
      components/store/common/StoreHeader.vue
  3. 2 2
      plugins/axios.js
  4. 29 5
      utils/baseUtils.js

+ 40 - 43
components/store/BaseInfo.vue

@@ -35,7 +35,7 @@
             <div><span class="public">地址:</span><span v-text="storeInfo.enterprise.address || '-'"></span></div>
             <div><span class="public">电话:</span><span v-text="storeInfo.enterprise.enTel || '-'"></span></div>
             <div><span class="public">传真:</span><span v-text="storeInfo.enterprise.enFax || '-'"></span></div>
-            <div><span class="public">官网地址:</span><a :href=storeInfo.enterprise.enUrl target="_blank">{{storeInfo.enterprise.enUrl || '-'}}</a></div>
+            <div><span class="public">官网地址:</span><a @click="goTarget(storeInfo.enterprise.enUrl)">{{storeInfo.enterprise.enUrl || '-'}}</a></div>
             <div v-if="storeInfo.enterprise.enPhone && storeInfo.enterprise.enPhone.length > 0"><span class="public">手机:</span><span v-text="storeInfo.enterprise.enPhone">136********</span></div>
             <div v-if="storeInfo.enterprise.enWeixin && storeInfo.enterprise.enWeixin.length > 0"><span class="public">微信:</span><span v-text="storeInfo.enterprise.enWeixin">好名字更容易让人记住你</span></div>
             <div v-if="storeInfo.enterprise.enQQ && storeInfo.enterprise.enQQ.length > 0"><span class="public">Q&nbsp;Q:</span><span v-text="storeInfo.enterprise.enQQ">123456789</span></div>
@@ -82,52 +82,49 @@
   </div>
 </template>
 <script>
-
-function isPdf (path) {
-  // 根据path文件名来判断文件是否是PDF文件
-  if (path) {
-    let str = path.slice(path.lastIndexOf('.')).toLowerCase()
-    if (str === '.pdf') {
-      return true
-    } else {
-      return false
-    }
-  } else {
-    return false
-  }
-}
-
-export default {
-  name: 'base-info',
-  data () {
-    return {
-      imgUrl: '',
-      isShow: false
-    }
-  },
-  computed: {
-    storeInfo () {
-      return this.$store.state.shop.storeInfo.store.data
+  import {startWith, judgeIsPdf} from '~utils/baseUtils'
+  export default {
+    name: 'base-info',
+    data () {
+      return {
+        imgUrl: '',
+        isShow: false
+      }
     },
-    qualifications () {
-      let storeInfo = this.$store.state.shop.storeInfo.store.data
-      let qualifications = JSON.parse(JSON.stringify(storeInfo.qualifications))
-      qualifications = qualifications.filter(qualification => {
-        return qualification && qualification.type === 'APTITUDE'
-      })
-      for (let i = 0; i < qualifications.length; i++) {
-        qualifications[i].isPdf = isPdf(qualifications[i].resourceUrl)
+    computed: {
+      storeInfo () {
+        return this.$store.state.shop.storeInfo.store.data
+      },
+      qualifications () {
+        let storeInfo = this.$store.state.shop.storeInfo.store.data
+        let qualifications = JSON.parse(JSON.stringify(storeInfo.qualifications))
+        qualifications = qualifications.filter(qualification => {
+          return qualification && qualification.type === 'APTITUDE'
+        })
+        for (let i = 0; i < qualifications.length; i++) {
+          qualifications[i].isPdf = judgeIsPdf(qualifications[i].resourceUrl)
+        }
+        return qualifications || []
+      }
+    },
+    methods: {
+      showImg (imgUrl) {
+        this.imgUrl = imgUrl
+        this.isShow = true
+      },
+      goTarget: function (url) {
+        if (url) {
+          if (startWith(url, 'http://') || startWith(url, 'https://')) {
+            window.open(url)
+          } else {
+            window.open(`http://${url}`)
+          }
+        } else {
+          this.$message.error('地址错误')
+        }
       }
-      return qualifications || []
-    }
-  },
-  methods: {
-    showImg (imgUrl) {
-      this.imgUrl = imgUrl
-      this.isShow = true
     }
   }
-}
 </script>
 <style scoped>
   #introduction-fragment .intro-title h3 {

+ 6 - 2
components/store/common/StoreHeader.vue

@@ -337,17 +337,21 @@ export default {
 		color: rgb(33,71,151);
 	}
   #nav_fragment .shop-contact li {
-    height: 25px;
+    max-height: 50px;
+    overflow: hidden;
   }
   #nav_fragment .shop-contact span{
     display:inline-block;
-    height: 100%
+    height: 100%;
+    max-width: 300px;
+    word-break: break-all;
   }
   #nav_fragment .shop-contact .public {
     width:44px;
     display:inline-block;
     text-align: justify;
     vertical-align:top;
+    height: fit-content;
   }
   #nav_fragment .shop-contact .public::after{
     content:"";

+ 2 - 2
plugins/axios.js

@@ -47,12 +47,12 @@ service.interceptors.response.use(response => {
       }
     }
   }
-  if (!isServer && --reqCount === 0) {
+  if (--reqCount <= 0 && !isServer) {
     document.getElementById('loading').setAttribute('class', 'loading')
   }
   return response
 }, error => {
-  if (!isServer && --reqCount === 0) {
+  if (--reqCount <= 0 && !isServer) {
     document.getElementById('loading').setAttribute('class', 'loading')
   }
   return Promise.reject(error)

+ 29 - 5
utils/baseUtils.js

@@ -1,6 +1,7 @@
 
 const NULL_ARR = ['空', '没', '无', '-', '—', 'null', '#N/A']
 
+// 获取字符串字符长度
 const getRealLength = function (str) {
   let len = 0
   for (let i = 0; i < str.length; i++) {
@@ -135,14 +136,22 @@ export const formatDate = (date, fmt) => {
   return fmt
 }
 
+// 检查空字符串或规定状态下空字符
 export const checkNullStr = (str) => {
-  let flag = true
-  NULL_ARR.map(s => {
-    flag = str === s ? false : flag
-  })
-  return flag
+  // NULL_ARR.map(s => {
+  //   if (str === s) {
+  //     return false
+  //   }
+  // })
+  for (let i = 0; i < NULL_ARR.length; i++) {
+    if (str === NULL_ARR[i]) {
+      return false
+    }
+  }
+  return true
 }
 
+// 联系卖家
 export const goLinkUser = ($this, enuu) => {
   if ($this.user.logged) {
     // $this.$http.get('/basic/enterprise/' + $this.storeInfo.enUU + '/info').then(response => {
@@ -174,3 +183,18 @@ export const goLinkUser = ($this, enuu) => {
     $this.$router.push(`/auth/login?returnUrl=${window.location.href}`)
   }
 }
+
+// 判断字符串开头
+export const startWith = function (str, s) {
+  let reg = new RegExp('^' + s)
+  return reg.test(str)
+}
+
+// 根据path文件名来判断文件是否是PDF文件
+export const judgeIsPdf = function (path) {
+  if (path) {
+    return path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf'
+  } else {
+    return false
+  }
+}