|
|
@@ -6,17 +6,42 @@
|
|
|
</div>
|
|
|
<div class="title">
|
|
|
<h1>{{storeInfo.storeName}}</h1>
|
|
|
- <p>{{storeInfo.description}}</p>
|
|
|
+ <p>{{storeInfo.description | descFilter}}</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+ let getRealLen = function (str) {
|
|
|
+ let len = 0
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
+ if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
|
|
+ len += 2
|
|
|
+ } else {
|
|
|
+ len++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return len
|
|
|
+ }
|
|
|
+ let cutOutString = function (str, len) {
|
|
|
+ for (let i = 1; i <= str.length; i++) {
|
|
|
+ if (getRealLen(str.substr(0, i)) > len) {
|
|
|
+ str = str.substr(0, i - 1)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str
|
|
|
+ }
|
|
|
export default {
|
|
|
computed: {
|
|
|
storeInfo () {
|
|
|
return this.$store.state.shop.storeInfo.store.data
|
|
|
}
|
|
|
+ },
|
|
|
+ filters: {
|
|
|
+ descFilter: function (val) {
|
|
|
+ return getRealLen(val) > 88 ? cutOutString(val, 88) + '...' : val
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|