index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view>
  3. <z-swiper v-model="swiperList" :options="options" @slideChange="onChange">
  4. <z-swiper-item :custom-style="slideCustomStyle" v-for="(item,index) in swiperList" :key="index">
  5. <scroll-view class="content-box" :scroll-y="true" :bounces="false">
  6. <image class="image" :src="item.image" mode="aspectFill">
  7. </image>
  8. {{item.image}}
  9. <user-content></user-content>
  10. </scroll-view>
  11. </z-swiper-item>
  12. </z-swiper>
  13. </view>
  14. </template>
  15. <script>
  16. import Black from '@/components/en-utils/en-blank/en-blank'
  17. import pagingList from '@/components/en-list/en-list'
  18. import enPrice from '@/components/en-utils/en-price/en-price'
  19. import {likeGoods} from "@/api/goods";
  20. import UserContent from "@/pages/index/model/user-content";
  21. export default {
  22. components:{
  23. UserContent,
  24. Black,
  25. pagingList,
  26. enPrice,
  27. },
  28. data() {
  29. return {
  30. slideCustomStyle: {
  31. display: 'flex',
  32. alignItems: 'center',
  33. justifyContent: 'center',
  34. borderRadius: '36rpx'
  35. },
  36. options: {
  37. speed:600,
  38. loop : true,
  39. effect: 'cards',
  40. cardsEffect: {
  41. rotate: false,
  42. perSlideOffset: 1,
  43. perSlideRotate: 1
  44. }
  45. },
  46. swiperList: [
  47. {
  48. image: 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  49. images: [
  50. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  51. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  52. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  53. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  54. ],
  55. title: '你好',
  56. age: '19',
  57. distance: '19.6',
  58. city: '香港九龙城',
  59. weChat: 'siococos',
  60. },
  61. {
  62. image: 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  63. images: [
  64. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  65. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  66. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  67. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  68. ],
  69. title: '你好',
  70. age: '19',
  71. distance: '19.6',
  72. city: '香港九龙城',
  73. weChat: 'siococos',
  74. },
  75. {
  76. image: 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  77. images: [
  78. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  79. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  80. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  81. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  82. ],
  83. title: '你好',
  84. age: '19',
  85. distance: '19.6',
  86. city: '香港九龙城',
  87. weChat: 'siococos',
  88. }
  89. ],
  90. swiperIndex:1
  91. }
  92. },
  93. mounted() {
  94. const arr = []
  95. /* 测试数据*/
  96. const tu = [
  97. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  98. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  99. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  100. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  101. ]
  102. for (let index = 0; index < 10; index++) {
  103. const n = Math.floor(Math.random() * (tu.length - 1))
  104. let data = {
  105. image: tu[n],
  106. images: [
  107. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  108. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  109. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  110. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  111. ],
  112. title: '你好',
  113. age: '19',
  114. distance: '19.6',
  115. city: '香港九龙城',
  116. weChat: 'siococos',
  117. }
  118. arr.push(data)
  119. }
  120. this.list = arr
  121. // this.setSwiperList(0)
  122. },
  123. methods:{
  124. onChange(swiper, index) {
  125. console.log(this.swiperList)
  126. uni.showToast({
  127. title: '当前 swiper 索引:' + index,
  128. icon: 'none'
  129. })
  130. this.setSwiperList(index)
  131. },
  132. setSwiperList(swiperIndex){
  133. this.swiperIndex=swiperIndex
  134. if(this.swiperList.length<=0){
  135. this.swiperList.push( this.list.splice(0,1))
  136. let newSwiperItem=this.list.splice(0,1);
  137. console.log(newSwiperItem)
  138. this.swiperList.push(newSwiperItem)
  139. this.swiperList.push(newSwiperItem)
  140. console.log(this.swiperList)
  141. }else {
  142. let newSwiperItem=this.list.splice(0,1);
  143. console.log(newSwiperItem)
  144. // this.swiperList.forEach((item,key)=>{
  145. // if(key!==this.swiperIndex){
  146. // this.swiperList[key]=newSwiperItem;
  147. // }
  148. // })
  149. }
  150. this.change()
  151. },
  152. change() {
  153. // 判断倒数
  154. if ( this.list.length<=5) {
  155. // 模拟一下最加数据
  156. const tu = [
  157. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  158. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  159. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  160. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  161. ]
  162. for (let index = 0; index < 10; index++) {
  163. const n = Math.floor(Math.random() * (tu.length - 1))
  164. let newdata = {
  165. image: tu[n],
  166. images: [
  167. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  168. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  169. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  170. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  171. ],
  172. title: '你好',
  173. age: '19',
  174. distance: '19.6',
  175. city: '香港九龙城',
  176. weChat: 'siococos',
  177. }
  178. this.list.push(newdata)
  179. }
  180. }
  181. // console.log(data);
  182. },
  183. }
  184. }
  185. </script>
  186. <style scoped lang="scss">
  187. .content-box{
  188. overscroll-behavior: none;
  189. margin-top: 20rpx;
  190. width: 730rpx;
  191. height: 1200rpx;
  192. border-radius: 24rpx;
  193. overflow: hidden;
  194. .image {
  195. height: 1200rpx;
  196. width: 730rpx;
  197. }
  198. }
  199. </style>