lxm-fold-grid.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view>
  3. <view class="cu-bar bg-transparent">
  4. <view class="action">
  5. <text class="cuIcon-back text-gray"></text>
  6. </view>
  7. <view class="content text-bold">
  8. </view>
  9. <view class="action">
  10. <text class="cuIcon-cardboardfill text-grey"></text>
  11. <text class="cuIcon-add text-red"></text>发布
  12. </view>
  13. </view>
  14. <view class="cu-bar bg-transparent search">
  15. <view class="cu-avatar round "
  16. style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big91012.jpg);"></view>
  17. <view class="text-left padding">
  18. 在XX创作的第1274天
  19. </view>
  20. <view class="action">
  21. <view class="padding-xs">
  22. <view class='cu-tag round light bg-red'>实名认证</view>
  23. </view>
  24. </view>
  25. </view>
  26. <luyj-grid-link :list="list" @gridExc="clickGrid"></luyj-grid-link>
  27. <view class="tower-swiper" @touchmove="TowerMove" @touchstart="TowerStart" @touchend="TowerEnd">
  28. <view class="tower-item" :class="item.zIndex==1?'none':''" v-for="(item,index) in swiperList" :key="index"
  29. :style="[{'--index': item.zIndex,'--left':item.mLeft}]" :data-direction="direction">
  30. <view class="swiper-item">
  31. <image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
  32. </view>
  33. </view>
  34. </view>
  35. <scroll-view scroll-x class="bg-green nav text-center">
  36. <view class="cu-item" :class="0==TabCur?'text-white cur':''" @tap="tabSelect" data-id="0">
  37. <text class="cuIcon-camerafill"></text> 数码
  38. </view>
  39. <view class="cu-item" :class="1==TabCur?'text-white cur':''" @tap="tabSelect" data-id="1">
  40. <text class="cuIcon-upstagefill"></text> 排行榜
  41. </view>
  42. <view class="cu-item" :class="2==TabCur?'text-white cur':''" @tap="tabSelect" data-id="2">
  43. <text class="cuIcon-clothesfill"></text> 皮肤
  44. </view>
  45. </scroll-view>
  46. </view>
  47. </template>
  48. <script>
  49. import data from '@/common/data/data.js'; // 数据
  50. export default {
  51. data() {
  52. return {
  53. TabCur: 0,
  54. scrollLeft: 0,
  55. list: data.current_list,
  56. cardCur: 0,
  57. swiperList: [{
  58. id: 0,
  59. type: 'image',
  60. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big84000.jpg'
  61. }, {
  62. id: 1,
  63. type: 'image',
  64. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big37006.jpg',
  65. }, {
  66. id: 2,
  67. type: 'image',
  68. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big39000.jpg'
  69. }, {
  70. id: 3,
  71. type: 'image',
  72. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'
  73. }, {
  74. id: 4,
  75. type: 'image',
  76. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big25011.jpg'
  77. }, {
  78. id: 5,
  79. type: 'image',
  80. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big21016.jpg'
  81. }, {
  82. id: 6,
  83. type: 'image',
  84. url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg'
  85. }],
  86. dotStyle: false,
  87. towerStart: 0,
  88. direction: ''
  89. }
  90. },
  91. onLoad() {
  92. this.TowerSwiper('swiperList');
  93. // 初始化towerSwiper 传已有的数组名即可
  94. },
  95. methods: {
  96. tabSelect(e) {
  97. this.TabCur = e.currentTarget.dataset.id;
  98. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  99. },
  100. DotStyle(e) {
  101. this.dotStyle = e.detail.value
  102. },
  103. // cardSwiper
  104. cardSwiper(e) {
  105. this.cardCur = e.detail.current
  106. },
  107. // towerSwiper
  108. // 初始化towerSwiper
  109. TowerSwiper(name) {
  110. let list = this[name];
  111. for (let i = 0; i < list.length; i++) {
  112. list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
  113. list[i].mLeft = i - parseInt(list.length / 2)
  114. }
  115. this.swiperList = list
  116. },
  117. // towerSwiper触摸开始
  118. TowerStart(e) {
  119. this.towerStart = e.touches[0].pageX
  120. },
  121. // towerSwiper计算方向
  122. TowerMove(e) {
  123. this.direction = e.touches[0].pageX - this.towerStart > 0 ? 'right' : 'left'
  124. },
  125. // towerSwiper计算滚动
  126. TowerEnd(e) {
  127. let direction = this.direction;
  128. let list = this.swiperList;
  129. if (direction == 'right') {
  130. let mLeft = list[0].mLeft;
  131. let zIndex = list[0].zIndex;
  132. for (let i = 1; i < this.swiperList.length; i++) {
  133. this.swiperList[i - 1].mLeft = this.swiperList[i].mLeft
  134. this.swiperList[i - 1].zIndex = this.swiperList[i].zIndex
  135. }
  136. this.swiperList[list.length - 1].mLeft = mLeft;
  137. this.swiperList[list.length - 1].zIndex = zIndex;
  138. } else {
  139. let mLeft = list[list.length - 1].mLeft;
  140. let zIndex = list[list.length - 1].zIndex;
  141. for (let i = this.swiperList.length - 1; i > 0; i--) {
  142. this.swiperList[i].mLeft = this.swiperList[i - 1].mLeft
  143. this.swiperList[i].zIndex = this.swiperList[i - 1].zIndex
  144. }
  145. this.swiperList[0].mLeft = mLeft;
  146. this.swiperList[0].zIndex = zIndex;
  147. }
  148. this.direction = ""
  149. this.swiperList = this.swiperList
  150. },
  151. }
  152. }
  153. </script>
  154. <style>
  155. .tower-swiper .tower-item {
  156. transform: scale(calc(0.5 + var(--index) / 10));
  157. margin-left: calc(var(--left) * 100upx - 150upx);
  158. z-index: var(--index);
  159. }
  160. </style>