demo.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div>
  3. <div>
  4. <wuc-tab :tab-list="tabList" :tabCur.sync="TabCur" tab-class="text-center bg-white wuc-tab fixed" :tab-style="CustomBar" select-class="text-blue" @change="tabChange"></wuc-tab>
  5. <div class="cu-bar bg-white solid-bottom" style="margin-top:100upx">
  6. <div class="action">
  7. <text class="cuIcon-titles text-orange"></text>基本使用(tab固定,只支持点击标签切换)
  8. </div>
  9. </div>
  10. <div class="bg-white padding margin text-center text-black">{{tabList[TabCur].name}}</div>
  11. </div>
  12. <div>
  13. <div class="cu-bar bg-white margin-top solid-bottom">
  14. <div class="action">
  15. <text class="cuIcon-titles text-orange"></text>居中选中放大(外部触发切换)
  16. </div>
  17. </div>
  18. <wuc-tab :tab-list="tabList2" :tabCur="TabCur2" @change="tabChange2" tab-class="text-center text-black bg-white" select-class="text-blue text-xl"></wuc-tab>
  19. <swiper :current="TabCur2" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange2">
  20. <swiper-item v-for="(item,index) in tabList2" :key="index">
  21. <div class="bg-white padding margin text-center text-black">{{item.name}}</div>
  22. </swiper-item>
  23. </swiper>
  24. </div>
  25. <div>
  26. <div class="cu-bar bg-white margin-top solid-bottom">
  27. <div class="action">
  28. <text class="cuIcon-titles text-orange"></text>平分
  29. </div>
  30. </div>
  31. <wuc-tab :tab-list="tabList3" textFlex :tabCur.sync="TabCur3" tab-class="text-center text-black bg-white" select-class="text-orange"></wuc-tab>
  32. <swiper :current="TabCur3" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange3">
  33. <swiper-item v-for="(item,index) in tabList3" :key="index">
  34. <div class="bg-white padding margin text-center text-black">{{item.name}}</div>
  35. </swiper-item>
  36. </swiper>
  37. </div>
  38. <div>
  39. <div class="cu-bar bg-white margin-top solid-bottom">
  40. <div class="action">
  41. <text class="cuIcon-titles text-orange"></text>背景
  42. </div>
  43. </div>
  44. <wuc-tab :tab-list="tabList4" :tabCur.sync="TabCur4" tab-class="text-center text-white bg-blue" select-class="text-white"></wuc-tab>
  45. <swiper :current="TabCur4" class="swiper row" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange4">
  46. <swiper-item v-for="(item,index) in tabList4" :key="index">
  47. <div class="bg-white padding margin text-center text-black">{{item.name}}</div>
  48. </swiper-item>
  49. </swiper>
  50. </div>
  51. <div>
  52. <div class="cu-bar bg-white margin-top solid-bottom">
  53. <div class="action">
  54. <text class="cuIcon-titles text-orange"></text>图标
  55. </div>
  56. </div>
  57. <wuc-tab :tab-list="tabList5" :tabCur.sync="TabCur5" tab-class="text-center text-black bg-white" select-class="text-blue" />
  58. <swiper :current="TabCur5" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange5">
  59. <swiper-item v-for="(item,index) in tabList5" :key="index">
  60. <div class="bg-white padding margin text-center text-black">{{item.name}}</div>
  61. </swiper-item>
  62. </swiper>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import WucTab from '@/components/wuc-tab/wuc-tab.vue';
  68. import { obj2style } from '@/utils/index';
  69. export default {
  70. data() {
  71. return {
  72. tabList: [
  73. { name: '选项卡一' },
  74. { name: '选项卡二' },
  75. { name: '选项卡三' },
  76. { name: '选项卡四' },
  77. { name: '选项卡五' },
  78. { name: '选项卡六' },
  79. { name: '选项卡七' },
  80. { name: '选项卡八' }
  81. ],
  82. tabList2: [{ name: '精选' }, { name: '订阅' }],
  83. tabList3: [{ name: '精选' }, { name: '订阅' }],
  84. tabList4: [
  85. { name: '推荐' },
  86. { name: '热点' },
  87. { name: '视频' },
  88. { name: '问答' },
  89. { name: '社会' },
  90. { name: '娱乐' },
  91. { name: '科技' },
  92. { name: '汽车' }
  93. ],
  94. tabList5: [
  95. { name: '短信', icon: 'cuIcon-comment' },
  96. { name: '电话', icon: 'cuIcon-dianhua' },
  97. { name: 'wifi', icon: 'cuIcon-wifi' }
  98. ],
  99. TabCur: 0,
  100. TabCur2: 0,
  101. TabCur3: 0,
  102. TabCur4: 0,
  103. TabCur5: 0
  104. };
  105. },
  106. components: { WucTab },
  107. computed: {
  108. CustomBar() {
  109. let style = {};
  110. // #ifdef MP-WEIXIN
  111. const systemInfo = uni.getSystemInfoSync();
  112. let CustomBar =
  113. systemInfo.platform === "android"
  114. ? systemInfo.statusBarHeight + 50
  115. : systemInfo.statusBarHeight + 45;
  116. style['top'] = CustomBar + 'px';
  117. // #endif
  118. // #ifdef H5
  119. style['top'] = 0 + 'px';
  120. // #endif
  121. return obj2style(style);
  122. }
  123. },
  124. methods: {
  125. tabChange(index) {
  126. this.TabCur = index;
  127. },
  128. tabChange2(index) {
  129. this.TabCur2 = index;
  130. },
  131. swiperChange2(e) {
  132. let { current } = e.target;
  133. this.TabCur2 = current;
  134. },
  135. swiperChange3(e) {
  136. let { current } = e.target;
  137. this.TabCur3 = current;
  138. },
  139. swiperChange4(e) {
  140. let { current } = e.target;
  141. this.TabCur4 = current;
  142. },
  143. swiperChange5(e) {
  144. this.TabCur5 = e.target.current;
  145. }
  146. },
  147. onReady() {}
  148. };
  149. </script>
  150. <style>
  151. @import "~@/styles/icon.scss";
  152. div,
  153. scroll-view,
  154. swiper {
  155. box-sizing: border-box;
  156. }
  157. div {
  158. font-size: 28upx;
  159. background-color: #f1f1f1;
  160. }
  161. .swiper {
  162. height: 140upx;
  163. }
  164. .cu-bar {
  165. display: flex;
  166. position: relative;
  167. align-items: center;
  168. min-height: 100upx;
  169. justify-content: space-between;
  170. }
  171. .cu-bar .action {
  172. display: flex;
  173. align-items: center;
  174. height: 100%;
  175. justify-content: center;
  176. max-width: 100%;
  177. background-color: #ffffff;
  178. }
  179. .cu-bar .action:first-child {
  180. margin-left: 30upx;
  181. font-size: 30upx;
  182. }
  183. .solid,
  184. .solid-bottom {
  185. position: relative;
  186. }
  187. .solid::after,
  188. .solid-bottom::after{
  189. content: " ";
  190. width: 200%;
  191. height: 200%;
  192. position: absolute;
  193. top: 0;
  194. left: 0;
  195. border-radius: inherit;
  196. transform: scale(0.5);
  197. transform-origin: 0 0;
  198. pointer-events: none;
  199. box-sizing: border-box;
  200. }
  201. .solid::after {
  202. border: 1upx solid rgba(0, 0, 0, 0.1);
  203. }
  204. .solid-bottom::after {
  205. border-bottom: 1upx solid rgba(0, 0, 0, 0.1);
  206. }
  207. .text-orange{
  208. color:#f37b1d
  209. }
  210. .text-black{
  211. color:#333333;
  212. }
  213. .bg-white{
  214. background-color: #ffffff;
  215. }
  216. .padding {
  217. padding: 30upx;
  218. }
  219. .margin {
  220. margin: 30upx;
  221. }
  222. .margin-top {
  223. margin-top: 30upx;
  224. }
  225. .text-center {
  226. text-align: center;
  227. }
  228. </style>