verticalnav.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view>
  3. <view class="fixed">
  4. <cu-custom :isBack="true" bgColor="bg-shadeTop text-white">
  5. <block slot="backText">返回</block>
  6. <block slot="content">垂直导航</block>
  7. </cu-custom>
  8. </view>
  9. <swiper class="screen-swiper round-dot" :indicator-dots="true" :circular="true" :autoplay="true" interval="5000"
  10. duration="500">
  11. <swiper-item v-for="(item,index) in 4" :key="index">
  12. <image :src="'https://ossweb-img.qq.com/images/lol/web201310/skin/big3900'+index+ '.jpg'" mode="aspectFill"></image>
  13. </swiper-item>
  14. </swiper>
  15. <view class="VerticalBox">
  16. <scroll-view class="VerticalNav nav" scroll-y scroll-with-animation :scroll-top="verticalNavTop" style="height:calc(100vh - 375upx)">
  17. <view class="cu-item" :class="index==tabCur?'text-green cur':''" v-for="(item,index) in list" :key="index" @tap="TabSelect"
  18. :data-id="index">
  19. Tab-{{item.name}}
  20. </view>
  21. </scroll-view>
  22. <scroll-view class="VerticalMain" scroll-y scroll-with-animation style="height:calc(100vh - 375upx)"
  23. :scroll-into-view="'main-'+mainCur" @scroll="VerticalMain">
  24. <view class="padding-top padding-lr" v-for="(item,index) in list" :key="index" :id="'main-'+index">
  25. <view class="cu-bar solid-bottom bg-white">
  26. <view class="action">
  27. <text class="cuIcon-title text-green"></text> Tab-{{item.name}}</view>
  28. </view>
  29. <view class="cu-list menu-avatar">
  30. <view class="cu-item">
  31. <view class="cu-avatar round lg" style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg);"></view>
  32. <view class="content">
  33. <view class="text-grey">凯尔</view>
  34. <view class="text-gray text-sm flex">
  35. <text class="text-cut">
  36. <text class="cuIcon-infofill text-red margin-right-xs"></text>
  37. 我已天理为凭,踏入这片荒芜,不再受凡人的枷锁遏制。我已天理为凭,踏入这片荒芜,不再受凡人的枷锁遏制。
  38. </text> </view>
  39. </view>
  40. <view class="action">
  41. <view class="text-grey text-xs">22:20</view>
  42. <view class="cu-tag round bg-grey sm">5</view>
  43. </view>
  44. </view>
  45. <view class="cu-item">
  46. <view class="cu-avatar round lg" style="background-image:url(https://ossweb-img.qq.com/images/lol/img/champion/Taric.png);">
  47. <view class="cu-tag badge">99+</view>
  48. </view>
  49. <view class="content">
  50. <view class="text-grey">
  51. <text class="text-cut">瓦洛兰之盾-塔里克</text>
  52. <view class="cu-tag round bg-orange sm">战士</view>
  53. </view>
  54. <view class="text-gray text-sm flex">
  55. <text class="text-cut">
  56. 塔里克是保护者星灵,用超乎寻常的力量守护着符文之地的生命、仁爱以及万物之美。塔里克由于渎职而被放逐,离开了祖国德玛西亚,前去攀登巨神峰寻找救赎,但他找到的却是来自星界的更高层的召唤。现在的塔里克与古代巨神族的神力相融合,以瓦洛兰之盾的身份,永不疲倦地警惕着阴险狡诈的虚空腐化之力。
  57. </text>
  58. </view>
  59. </view>
  60. <view class="action">
  61. <view class="text-grey text-xs">22:20</view>
  62. <view class="cuIcon-notice_forbid_fill text-gray"></view>
  63. </view>
  64. </view>
  65. <view class="cu-item ">
  66. <view class="cu-avatar radius lg" style="background-image:url(https://ossweb-img.qq.com/images/lol/img/champion/Morgana.png);"></view>
  67. <view class="content">
  68. <view class="text-pink"><text class="text-cut">莫甘娜</text></view>
  69. <view class="text-gray text-sm flex"> <text class="text-cut">凯尔,你被自己的光芒变的盲目!</text></view>
  70. </view>
  71. <view class="action">
  72. <view class="text-grey text-xs">22:20</view>
  73. <view class="cu-tag round bg-red sm">5</view>
  74. </view>
  75. </view>
  76. <view class="cu-item grayscale">
  77. <view class="cu-avatar radius lg" style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big81007.jpg);"></view>
  78. <view class="content">
  79. <view><text class="text-cut">伊泽瑞尔</text>
  80. <view class="cu-tag round bg-orange sm">断开连接...</view>
  81. </view>
  82. <view class="text-gray text-sm flex"> <text class="text-cut"> 等我回来一个打十个</text></view>
  83. </view>
  84. <view class="action">
  85. <view class="text-grey text-xs">22:20</view>
  86. <view class="cu-tag round bg-red sm">5</view>
  87. </view>
  88. </view>
  89. <view class="cu-item cur">
  90. <view class="cu-avatar radius lg" style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big81020.jpg);">
  91. <view class="cu-tag badge"></view>
  92. </view>
  93. <view class="content">
  94. <view>
  95. <text class="text-cut">瓦罗兰大陆-睡衣守护者-新手保护营</text>
  96. <view class="cu-tag round bg-orange sm">6人</view>
  97. </view>
  98. <view class="text-gray text-sm flex">
  99. <text class="text-cut"> 伊泽瑞尔:<text class="cuIcon-locationfill text-orange margin-right-xs"></text> 传送中...</text></view>
  100. </view>
  101. <view class="action">
  102. <view class="text-grey text-xs">22:20</view>
  103. <view class="cuIcon-notice_forbid_fill text-gray"></view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </scroll-view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. export default {
  114. data() {
  115. return {
  116. list: [],
  117. tabCur: 0,
  118. mainCur: 0,
  119. verticalNavTop: 0,
  120. load: true
  121. };
  122. },
  123. onLoad() {
  124. uni.showLoading({
  125. title: '加载中...',
  126. mask: true
  127. });
  128. let list = [{}];
  129. for (let i = 0; i < 26; i++) {
  130. list[i] = {};
  131. list[i].name = String.fromCharCode(65 + i);
  132. list[i].id = i;
  133. }
  134. this.list = list;
  135. this.listCur = list[0];
  136. },
  137. onReady() {
  138. uni.hideLoading()
  139. },
  140. methods: {
  141. TabSelect(e) {
  142. this.tabCur = e.currentTarget.dataset.id;
  143. this.mainCur = e.currentTarget.dataset.id;
  144. this.verticalNavTop = (e.currentTarget.dataset.id - 1) * 50
  145. },
  146. VerticalMain(e) {
  147. // #ifdef MP-ALIPAY
  148. return false //支付宝小程序暂时不支持双向联动
  149. // #endif
  150. let that = this;
  151. let tabHeight = 0;
  152. if (this.load) {
  153. for (let i = 0; i < this.list.length; i++) {
  154. let view = uni.createSelectorQuery().select("#main-" + this.list[i].id);
  155. view.fields({
  156. size: true
  157. }, data => {
  158. this.list[i].top = tabHeight;
  159. tabHeight = tabHeight + data.height;
  160. this.list[i].bottom = tabHeight;
  161. }).exec();
  162. }
  163. this.load = false
  164. }
  165. let scrollTop = e.detail.scrollTop + 10;
  166. for (let i = 0; i < this.list.length; i++) {
  167. if (scrollTop > this.list[i].top && scrollTop < this.list[i].bottom) {
  168. this.verticalNavTop = (this.list[i].id - 1) * 50
  169. this.tabCur = this.list[i].id
  170. console.log(scrollTop)
  171. return false
  172. }
  173. }
  174. }
  175. },
  176. }
  177. </script>
  178. <style>
  179. .fixed {
  180. position: fixed;
  181. z-index: 99;
  182. }
  183. .VerticalNav.nav {
  184. width: 200upx;
  185. white-space: initial;
  186. }
  187. .VerticalNav.nav .cu-item {
  188. width: 100%;
  189. text-align: center;
  190. background-color: #fff;
  191. margin: 0;
  192. border: none;
  193. height: 50px;
  194. position: relative;
  195. }
  196. .VerticalNav.nav .cu-item.cur {
  197. background-color: #f1f1f1;
  198. }
  199. .VerticalNav.nav .cu-item.cur::after {
  200. content: "";
  201. width: 8upx;
  202. height: 30upx;
  203. border-radius: 10upx 0 0 10upx;
  204. position: absolute;
  205. background-color: currentColor;
  206. top: 0;
  207. right: 0upx;
  208. bottom: 0;
  209. margin: auto;
  210. }
  211. .VerticalBox {
  212. display: flex;
  213. }
  214. .VerticalMain {
  215. background-color: #f1f1f1;
  216. flex: 1;
  217. }
  218. </style>