slide-item.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="slide-box">
  3. <tantan ref="jmList" @onChange="getDiscoverList" @onClickImage="clickImage"></tantan>
  4. </view>
  5. </template>
  6. <script>
  7. import tantan from '@/components/dgex-tantan/dgex-tantan.vue'
  8. import {getDiscoverList, getMoments} 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.getDiscoverList()
  27. this.getMoments()
  28. },
  29. methods: {
  30. getMoments(){
  31. getMoments({'pageNo':1,'pageSize':20}).then((res)=>{
  32. })
  33. },
  34. getDiscoverList(){
  35. if(this.isAjax){
  36. return
  37. }
  38. this.isAjax=true
  39. getDiscoverList({'count':10}).then((res)=>{
  40. this.isAjax=false
  41. if(res.code===0){
  42. this.list=res
  43. let arr=[]
  44. res.data.forEach((item)=>{
  45. let galleryUrls=item.galleryUrls
  46. let age=tools.getAge(item.dateOfBirth)
  47. if(galleryUrls.length>0){
  48. if(galleryUrls.length>8){
  49. galleryUrls=galleryUrls.slice(0,7)
  50. }
  51. let newdata = {
  52. image: galleryUrls[0],
  53. images: galleryUrls,
  54. imgIndex:0,
  55. title: item.nickname,
  56. userId: item.userId,
  57. age: age,
  58. online: item.online,
  59. longitude: item.longitude,
  60. latitude: item.latitude,
  61. distance: 17,
  62. city: item.province+' '+item.city,
  63. weChat: item.wechatId,
  64. likeCount: item.likeCount,
  65. tagList: item.tagList,
  66. slogan: item.slogan,
  67. animation:{}
  68. }
  69. console.log(newdata)
  70. arr.push(newdata)
  71. }
  72. })
  73. this.$refs.jmList.setData(arr)
  74. }
  75. })
  76. },
  77. clickImage(data) {
  78. console.log(data);
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped lang="scss">
  84. .slide-box{
  85. margin-top: 10rpx;
  86. box-sizing: border-box;
  87. }
  88. </style>