| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <template>
- <div id="navtab">
- <i class="el-icon-arrow-left" @click="tapFirst"></i>
- <div class="list" ref="listNav">
- <div
- class="lis"
- @mouseenter="mouseIn($event, item.id)"
- @mouseleave="mouseLeave()"
- @click="tourl(item)"
- :class="{ showlis: info.supplier_list[tapInd - 1].id == item.id }"
- v-for="(item, index) in listShow(info.supplier_list)"
- :key="index"
- >
- <div>{{ item.store_name == 'null'?item.username.slice(0,5):item.store_name.slice(0,5) }}</div>
- <div>{{ item.store_name == 'null'?item.username.slice(5,7):item.store_name.slice(5,7) }}</div>
- </div>
- </div>
- <i class="el-icon-arrow-right" @click="tapNext"></i>
- </div>
- </template>
- <script>
- import { mapState } from "vuex";
- export default {
- props: {
- info: {
- type: Object,
- default: {},
- },
- timeSet: {
- type: Number,
- default: 3000,
- },
- },
- computed: {
- ...mapState(["basicSet", "basic_info"]),
- },
- data() {
- return {
- showListInd: 0,
- tapInd: 1,
- // arr: ["1", "2", "3", "4", "5", "6", "7", "8"],
- // 后端设置的秒数
- settimeOut: null,
- ceilNum: 0,
- };
- },
- mounted() {
- this.$emit("postChildInd", this.tapInd - 1);
- if (this.timeSet != 0) {
- this.settimeOut = setInterval(() => {
- if (this.tapInd < this.info.supplier_list.length) {
- this.tapInd = this.tapInd + 1;
- } else {
- this.tapInd = 1;
- }
- if (this.tapInd <= 9) {
- this.showListInd = 9;
- } else if (
- this.tapInd > this.showListInd &&
- this.showListInd < this.info.supplier_list.length
- ) {
- this.showListInd = this.showListInd + 9;
- }
- this.$emit("postChildInd", this.tapInd - 1);
- }, this.timeSet);
- }
- },
- methods: {
- tourl(item) {
- let supplier_Id = item.id;
- if (this.$baseURL) {
- // 静态部署环境下
- this.$router.push(
- this.fun.getUrl("supplierGoodList", { id: supplier_Id }, {})
- );
- } else {
- this.$router.push(
- this.fun.getUrl("supplierGoodList-id", { id: supplier_Id }, {})
- );
- }
- },
- mouseLeave() {
- if (this.timeSet != 0) {
- if (!this.settimeOut) {
- this.settimeOut = setInterval(() => {
- if (this.tapInd < this.info.supplier_list.length) {
- this.tapInd = this.tapInd + 1;
- } else {
- this.tapInd = 1;
- }
- this.$emit("postChildInd", this.tapInd - 1);
- }, this.timeSet);
- }
- }
- },
- mouseIn(e, id) {
- for (let i = 0; i < this.info.supplier_list.length; i++) {
- if (this.info.supplier_list[i].id == id) {
- this.tapInd = Number(i + 1);
- }
- }
- // this.tapInd = Number(ind + 1);
- if (this.timeSet != 0) {
- if (this.settimeOut) {
- clearInterval(this.settimeOut);
- this.settimeOut = null;
- }
- }
- this.$emit("postChildInd", this.tapInd - 1);
- },
- tapFirst() {
- if (this.showListInd == 9) return;
- if (this.showListInd - 9 <= 9) return (this.showListInd = 9);
- this.showListInd = this.showListInd - 9;
- },
- tapNext() {
- let len = this.info.supplier_list.length;
- if (len <= 9) return;
- if (this.showListInd == len) return;
- if (this.showListInd + 9 > len) {
- this.showListInd = len;
- } else {
- this.showListInd = this.showListInd + 9;
- }
- },
- listShow(arr) {
- if (this.showListInd == 0) {
- this.showListInd = 9;
- let arrinfo = arr.slice(0, this.showListInd);
- return arrinfo;
- } else {
- let arrinfo = arr.slice(this.showListInd - 9, this.showListInd);
- return arrinfo;
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .el-icon-arrow-left,
- .el-icon-arrow-right {
- font-size: 20px;
- color: #7e7e7e;
- cursor: pointer;
- }
- #navtab {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 32px;
- overflow: hidden;
- }
- ::-webkit-scrollbar {
- display: none;
- }
- .list {
- padding: 20px 0;
- width: 100%;
- display: flex;
- justify-content: flex-start;
- overflow: hidden;
- .showlis {
- color: #2973fd;
- font-size: 14px;
- }
- .lis {
- cursor: pointer;
- flex-shrink: 0;
- margin: 0 0 0 42px;
- width: 77px;
- font-size: 14px;
- font-weight: bold;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-align: center;
- }
- }
- </style>
|