conversion.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="">
  3. <view class="conversion-bg">
  4. <image src="/static/conversion-bg.png"></image>
  5. </view>
  6. <!-- #ifndef MP-ALIPAY -->
  7. <view class="tower-swiper" :style="{'height':scrollHeight+'px'}" @touchmove="TowerMove" @touchstart="TowerStart"
  8. @touchend="TowerEnd">
  9. <view class="tower-item" v-for="(item,index) in swiperList" :key="index" :style="[{'--index': item.zIndex,'--bottom':item.mLeft}]"
  10. :data-direction="direction">
  11. <view class="swiper-item" @tap="onNavConver(item.page_type,$event)">
  12. <image :src="item.url" mode="aspectFit" v-if="item.type=='image'"></image>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- #endif -->
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. mapState
  22. } from 'vuex'
  23. export default {
  24. computed: mapState(['oldSwiperList']),
  25. data() {
  26. let tempList = [{
  27. id: 0,
  28. type: 'image',
  29. url: '/static/conversion/personal.png',
  30. name: "个人中心",
  31. page_type: "personal",
  32. zIndex: 2,
  33. mLeft: 0
  34. }, {
  35. id: 1,
  36. type: 'image',
  37. url: '/static/conversion/game.png',
  38. name: '游戏',
  39. page_type: "game",
  40. zIndex: 1,
  41. mLeft: 1
  42. }]
  43. return {
  44. cardCur: 0,
  45. swiperList: tempList,
  46. dotStyle: false,
  47. towerStart: 0,
  48. towerStartY: 0,
  49. direction: '',
  50. scrollHeight: 100,
  51. bTouchMove: false,
  52. }
  53. },
  54. onLoad() {
  55. let _this = this
  56. uni.getSystemInfo({
  57. success(res) {
  58. _this.scrollHeight = res.windowHeight;
  59. console.log("res==", res)
  60. }
  61. })
  62. if (this.oldSwiperList.length != 0)
  63. this.swiperList = this.oldSwiperList;
  64. },
  65. methods: {
  66. // 初始化towerSwiper
  67. TowerSwiper(name) {
  68. let list = this[name];
  69. for (let i = 0; i < list.length; i++) {
  70. list[i].zIndex = list.length - i; // parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
  71. list[i].mLeft = i; //i - parseInt(list.length/2)
  72. console.log(list[i].zIndex, list[i].mLeft, 0.5 + list[i].zIndex / 20);
  73. }
  74. this.swiperList = list
  75. },
  76. // towerSwiper触摸开始
  77. TowerStart(e) {
  78. this.towerStart = e.touches[0].pageX;
  79. this.towerStartY = e.touches[0].pageY;
  80. },
  81. // towerSwiper计算方向
  82. TowerMove(e) {
  83. // 简化,点击及操作
  84. this.direction = 'left'; // e.touches[0].pageX - this.towerStart > 0 ? 'right' : 'left'
  85. let moveX = e.touches[0].pageX - this.towerStart > 0 ? true : false;
  86. let moveY = e.touches[0].pageY - this.towerStartY > 0 ? true : false;
  87. this.bTouchMove = moveX || moveY;
  88. },
  89. // towerSwiper计算滚动
  90. TowerEnd(e) {
  91. if (!this.bTouchMove) return;
  92. let direction = this.direction;
  93. let list = this.swiperList;
  94. if (direction == 'right') {
  95. let mLeft = list[0].mLeft;
  96. let zIndex = list[0].zIndex;
  97. for (let i = 1; i < this.swiperList.length; i++) {
  98. this.swiperList[i - 1].mLeft = this.swiperList[i].mLeft
  99. this.swiperList[i - 1].zIndex = this.swiperList[i].zIndex
  100. }
  101. this.swiperList[list.length - 1].mLeft = mLeft;
  102. this.swiperList[list.length - 1].zIndex = zIndex;
  103. } else {
  104. let mLeft = list[list.length - 1].mLeft;
  105. let zIndex = list[list.length - 1].zIndex;
  106. for (let i = this.swiperList.length - 1; i > 0; i--) {
  107. this.swiperList[i].mLeft = this.swiperList[i - 1].mLeft
  108. this.swiperList[i].zIndex = this.swiperList[i - 1].zIndex
  109. }
  110. this.swiperList[0].mLeft = mLeft;
  111. this.swiperList[0].zIndex = zIndex;
  112. this.$store.state.oldSwiperList = this.swiperList;
  113. console.log("this.$store.state.oldSwiperList=", this.$store.state.oldSwiperList);
  114. }
  115. this.direction = ""
  116. this.swiperList = this.swiperList
  117. this.bTouchMove = false;
  118. },
  119. // 跳转对应页面
  120. onNavConver(type, event) {
  121. console.log("===", type, event);
  122. let url = '';
  123. switch (type) {
  124. case "personal":
  125. //个人中心页面
  126. url = '../../personal-page/personal/personal';
  127. break;
  128. case "game":
  129. url = '../../game-page/game/game';
  130. break;
  131. default:
  132. url = '../../personal-page/personal/personal';
  133. break;
  134. }
  135. uni.reLaunch({
  136. url: url,
  137. success: res => {},
  138. fail: () => {},
  139. complete: () => {}
  140. });
  141. }
  142. }
  143. }
  144. </script>
  145. <style>
  146. .conversion-container {
  147. position: relative;
  148. }
  149. .conversion-bg {
  150. position: absolute;
  151. left: 0;
  152. top: 0;
  153. bottom: 0;
  154. right: 0;
  155. width: 750rpx;
  156. height: 100%;
  157. }
  158. .conversion-bg image {
  159. width: 100%;
  160. height: 100%;
  161. }
  162. .tower-swiper .tower-item {
  163. transform: scale(calc(0.6 + var(--index)/10));
  164. margin-bottom: calc(var(--bottom) * 70px - 100px);
  165. z-index: var(--index);
  166. }
  167. .swiper-item image,
  168. .swiper-item video {
  169. width: 100%;
  170. display: block;
  171. height: 100%;
  172. margin: 0;
  173. pointer-events: none;
  174. }
  175. swiper-item {
  176. width: 610upx !important;
  177. left: 70upx;
  178. box-sizing: border-box;
  179. padding: 40upx 0upx 70upx;
  180. overflow: initial;
  181. }
  182. swiper-item .swiper-item {
  183. width: 100%;
  184. display: block;
  185. height: 100%;
  186. border-radius: 10upx;
  187. transform: scale(0.9);
  188. transition: all 0.2s ease-in 0s;
  189. overflow: hidden;
  190. }
  191. swiper-item.cur .swiper-item {
  192. transform: none;
  193. transition: all 0.2s ease-in 0s;
  194. }
  195. .tower-swiper {
  196. height: 1334upx;
  197. position: relative;
  198. max-width: 750upx;
  199. overflow: hidden;
  200. /* background-color: #007AFF; */
  201. }
  202. /* .tower-swiper .tower-item {
  203. position: absolute;
  204. width: 750upx;
  205. height: 100%;
  206. top: 0;
  207. bottom: 10%;
  208. left: 0;
  209. margin: auto;
  210. transition: all 0.2s ease-in 0s;
  211. opacity: 1;
  212. } */
  213. .tower-swiper .tower-item.none {
  214. /* opacity: 0; */
  215. }
  216. .tower-swiper .tower-item .swiper-item {
  217. width: 100%;
  218. height: 100%;
  219. border-radius: 45upx;
  220. overflow: hidden;
  221. }
  222. </style>