演示项目-图书馆
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 lines
5.0 KiB

2 years ago
  1. <template>
  2. <div>
  3. <div class="text" v-if="!textFlex">
  4. <div class="wuc-tab-item" :class="[index === tabCur ? selectClass + ' cur':'']" v-for="(item,index) in tabList"
  5. :key="item.id"
  6. :id="item.id"
  7. @click="tabSelect(index,item.id,index,item.code,item.id,item)" >
  8. <div :class="item.icon"></div>
  9. <span>{{item.name}}</span>
  10. </div>
  11. </div>
  12. <div class="flex text-center" v-if="textFlex">
  13. <div class="wuc-tab-item flex-sub" :class="index === tabCur ? selectClass + ' cur':''" v-for="(item,index) in tabList"
  14. :key="index"
  15. :id="index"
  16. @click="tabSelect(index,item.code,item.id,item)" >
  17. <div :class="item.icon"></div>
  18. <span>{{item.name}}</span>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { reactive,computed,onMounted,getCurrentInstance } from 'vue';
  25. export default {
  26. name: "wuc-tab",
  27. data() {
  28. return {};
  29. },
  30. props: {
  31. tabList: {
  32. type: Array,
  33. default() {
  34. return [];
  35. },
  36. },
  37. tabCur: {
  38. type: Number,
  39. default() {
  40. return 0;
  41. },
  42. },
  43. tabClass: {
  44. type: String,
  45. default() {
  46. return "";
  47. },
  48. },
  49. tabStyle: {
  50. type: String,
  51. default() {
  52. return "";
  53. },
  54. },
  55. textFlex: {
  56. type: Boolean,
  57. default() {
  58. return true;
  59. },
  60. },
  61. selectClass: {
  62. type: String,
  63. default() {
  64. return "text-blue";
  65. },
  66. },
  67. },
  68. setup(props, context){
  69. const { proxy } = getCurrentInstance()
  70. let moveHandle = () => {
  71. }
  72. let tabSelect = (index, e, s, item) => {
  73. context.emit("update:tabCur", index);
  74. context.emit("change", index);
  75. context.emit("chengeid", e);
  76. context.emit("chengeclass", s);
  77. context.emit("changeitem", item);
  78. if(index > 0) {
  79. let tab = document.getElementsByClassName('wuc-tab-item');
  80. for (let i = 0; i < tab.length; i++) {
  81. tab[i].style.color = '#666666';
  82. }
  83. } else {
  84. let tab = document.getElementsByClassName('wuc-tab-item');
  85. for (let i = 0; i < tab.length; i++) {
  86. tab[i].style.color = '#fff';
  87. }
  88. }
  89. }
  90. return {
  91. scrollLeft: computed(function(){
  92. return (props.tabCur - 1) * 60;
  93. }
  94. ),
  95. moveHandle,
  96. tabSelect
  97. }
  98. }
  99. };
  100. </script>
  101. <style scoped>
  102. div,
  103. scroll-view,
  104. swiper {
  105. box-sizing: border-box;
  106. }
  107. .wuc-tab {
  108. white-space: nowrap;
  109. }
  110. .wuc-tab :deep(.uni-scroll-view::-webkit-scrollbar) {
  111. display: none;
  112. }
  113. .wuc-tab-item {
  114. color: white;
  115. display: inline-block;
  116. margin: 0 0.10rem;
  117. padding: 0 0.20rem;
  118. font-size: 0.32rem;
  119. }
  120. .wuc-tab.fixed {
  121. position: fixed;
  122. width: 100%;
  123. top: 0;
  124. z-index: 1024;
  125. box-shadow: 0 0.01rem 0.06rem rgba(0, 0, 0, 0.1);
  126. }
  127. .flex-sub {
  128. flex: 1 !important;
  129. }
  130. .text-red {
  131. color: #333333;
  132. font-size: 0.36rem;
  133. font-weight: bold;
  134. position: relative;
  135. height: 0.80rem;
  136. }
  137. .text-red:after {
  138. content: "";
  139. position: absolute;
  140. bottom: 0px;
  141. top: auto;
  142. left: 60%;
  143. height:0.08rem;
  144. margin-left: -20%;
  145. width: 0.43rem;
  146. border-radius: 0.15rem;
  147. background-color: #0499f8;
  148. }
  149. .text-blue {
  150. color: #333333 !important;
  151. font-size: 0.36rem;
  152. font-weight: bold;
  153. height: 0.82rem;
  154. line-height: 0.82rem;
  155. position: relative;
  156. }
  157. .text-blue:after {
  158. content: "";
  159. position: absolute;
  160. bottom: 0px;
  161. top: auto;
  162. left: 50%;
  163. height: 0.08rem;
  164. margin-left: -0.20rem;
  165. width: 0.36rem;
  166. border-radius: 0.04rem;
  167. background-color: #0499f8;
  168. }
  169. .text-list1 span {
  170. font-weight: bold;
  171. }
  172. .text-list2 span {
  173. background: rgba(7, 27, 77, 0.4);
  174. border-radius: 0.36rem;
  175. padding: 0.06rem 0.24rem;
  176. }
  177. .text-Subclass span {
  178. background: #16c7c5;
  179. border-radius: 0.36rem;
  180. color: #ffffff;
  181. padding: 0.06rem 0.24rem;
  182. }
  183. .text-white {
  184. color: #ffffff;
  185. font-size: 0.36rem;
  186. font-weight: bold;
  187. height: 0.82rem;
  188. line-height: 0.82rem;
  189. position: relative;
  190. }
  191. .text-white:after {
  192. content: "";
  193. position: absolute;
  194. bottom: 0px;
  195. top: auto;
  196. left: 50%;
  197. height: 0.08rem;
  198. margin-left: -0.20rem;
  199. width: 0.36rem;
  200. border-radius: 0.04rem;
  201. background-color: #ffffff;
  202. }
  203. .bg-white {
  204. background-color: #ffffff;
  205. }
  206. .bg-blue {
  207. background-color: rgb(4, 167, 242);
  208. color: white;
  209. border-radius: 0.40rem;
  210. padding: 0 0.20rem;
  211. }
  212. .text-orange {
  213. color: #f37b1d;
  214. }
  215. .text-xl {
  216. font-size: 0.36rem;
  217. }
  218. .knowLEdgeTab {
  219. color: #e5e5e5;
  220. font-size: 0.36rem;
  221. height: 0.90rem;
  222. line-height: 0.90rem;
  223. }
  224. .sortItem .wuc-tab-item {
  225. color: #333333;
  226. font-size: 0.28rem;
  227. padding: 0 0.50rem;
  228. height: 0.60rem;
  229. line-height: 0.60rem;
  230. background-color: #f3f5f4;
  231. border-radius: 0.30rem;
  232. }
  233. .sortOnItem {
  234. color: #1685fb !important;
  235. background-color: #e7f5fe !important;
  236. }
  237. .FindTabClass {
  238. color: #222222;
  239. font-size: 0.28rem;
  240. height: 0.84rem;
  241. line-height: 0.76rem;
  242. }
  243. .topTabList2 .wuc-tab-item{
  244. color: #333333;
  245. }
  246. .topTabList2 .text-white:after{
  247. background-color: #333333;
  248. }
  249. </style>