slide-item.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="slide-box">
  3. <tantan ref="jmList" @onChange="change" @onClickImage="clickImage"></tantan>
  4. </view>
  5. </template>
  6. <script>
  7. import tantan from '@/components/dgex-tantan/dgex-tantan.vue'
  8. import {getDiscoverList} from "@/api/discovery";
  9. import tools from "@/service/tools";
  10. export default {
  11. name: "slide-item",
  12. components: {
  13. tantan
  14. },
  15. props: {},
  16. data() {
  17. return {
  18. page:1,
  19. total:undefined,
  20. isAjax:false,
  21. list:[],
  22. }
  23. },
  24. watch: {},
  25. mounted() {
  26. // this.change({'currentIndex':1})
  27. this.getDiscoverList()
  28. },
  29. methods: {
  30. getDiscoverList(){
  31. if(this.isAjax){
  32. return
  33. }
  34. this.isAjax=true
  35. getDiscoverList({'count':10}).then((res)=>{
  36. this.isAjax=false
  37. this.list=res
  38. let arr=[]
  39. res.forEach((item)=>{
  40. let galleryUrls=item.galleryUrls
  41. let age=tools.getAge(item.dateOfBirth)
  42. if(galleryUrls.length>0){
  43. if(galleryUrls.length>8){
  44. galleryUrls=galleryUrls.slice(0,7)
  45. }
  46. let newdata = {
  47. image: galleryUrls[0],
  48. images: galleryUrls,
  49. imgIndex:0,
  50. title: item.nickname,
  51. age: age,
  52. online: item.online,
  53. longitude: item.longitude,
  54. latitude: item.latitude,
  55. distance: 17,
  56. city: item.province+' '+item.city,
  57. weChat: item.wechatId,
  58. animation:{}
  59. }
  60. console.log(newdata)
  61. arr.push(newdata)
  62. }
  63. })
  64. this.$refs.jmList.setData(arr)
  65. })
  66. },
  67. change(data) {
  68. // 判断倒数
  69. let arr=[]
  70. // 模拟一下最加数据
  71. const tu = [
  72. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  73. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  74. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  75. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  76. ]
  77. for (let index = 0; index < 10; index++) {
  78. const n = Math.floor(Math.random() * (tu.length - 1))
  79. let newdata = {
  80. image: tu[n],
  81. images: [
  82. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  83. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  84. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
  85. 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
  86. ],
  87. imgIndex:0,
  88. title: '你好',
  89. age: '19',
  90. distance: '19.6',
  91. city: '香港九龙城',
  92. weChat: 'siococos',
  93. animation:{}
  94. }
  95. arr.push(newdata)
  96. }
  97. this.$refs.jmList.setData(arr)
  98. // console.log(data);
  99. },
  100. clickImage(data) {
  101. console.log(data);
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped lang="scss">
  107. .slide-box{
  108. margin-top: 10rpx;
  109. box-sizing: border-box;
  110. }
  111. </style>