coll.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="coll">
  3. <view class="collect">
  4. <view class="collect-item flexs" v-for="(item, index) in collList" :key="index" @click="goMessage(item, 0)">
  5. <view class="collect-item-icon"><image :src="item.image" mode="aspectFill"></image></view>
  6. <view class="collect-item-main">
  7. <view class="collect-name">{{ item.box_name }}</view>
  8. <view class="collect-money">{{ item.coin_price }}金币</view>
  9. <view class="collect-time flex">
  10. <text>时间:{{ item.star_time }}</text>
  11. <image src="/static/image/me/shanchu@2x.png" mode="" @click.stop="delStar(index, item)"></image>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. page: 1,
  23. pages: null,
  24. collList: [] //收藏列表
  25. };
  26. },
  27. methods: {
  28. //去详情
  29. goMessage(item, type) {
  30. uni.navigateTo({ url: '/pages/index/details?id=' + item.box_id + '&type=' + type });
  31. },
  32. //删除收藏
  33. delStar(index, item) {
  34. uni.showModal({
  35. title: '删除',
  36. content: '是否删除收藏?',
  37. success: res => {
  38. if (res.confirm) {
  39. this.$api.cancelStar({ star_id: item.star_id, msg: '收藏删除中' }).then(res => {
  40. if (res.code === 1) {
  41. uni.showToast({ title: res.msg });
  42. this.collList.splice(index, 1);
  43. }
  44. });
  45. console.log('用户点击确定');
  46. } else if (res.cancel) {
  47. console.log('用户点击取消');
  48. }
  49. }
  50. });
  51. },
  52. //获取收藏列表
  53. loadData() {
  54. this.$api.myStar({ page: this.page }).then(res => {
  55. uni.stopPullDownRefresh();
  56. if (res.code === 1) {
  57. this.collList = this.page == 1 ? res.data.data : [...this.collList, ...res.data.data];
  58. this.pages = res.data.last_page;
  59. }
  60. });
  61. }
  62. },
  63. onLoad() {
  64. this.loadData();
  65. },
  66. onPullDownRefresh() {
  67. this.page = 1;
  68. this.loadData();
  69. },
  70. onReachBottom() {
  71. if (this.page < this.pages) {
  72. this.page++;
  73. this.loadData();
  74. }
  75. }
  76. };
  77. </script>
  78. <style lang="scss">
  79. .collect {
  80. padding: 30rpx 30rpx 0 30rpx;
  81. .collect-item {
  82. padding: 30rpx;
  83. margin-bottom: 20rpx;
  84. background: #ffffff;
  85. border-radius: 20rpx;
  86. .collect-item-icon {
  87. image {
  88. width: 168rpx;
  89. height: 168rpx;
  90. border-radius: 10rpx;
  91. }
  92. margin-right: 20rpx;
  93. }
  94. .collect-item-main {
  95. flex: 1;
  96. }
  97. .collect-name {
  98. font-size: 28rpx;
  99. display: -webkit-box;
  100. -webkit-box-orient: vertical;
  101. -webkit-line-clamp: 2;
  102. overflow: hidden;
  103. }
  104. .collect-money {
  105. color: #cf271b;
  106. font-size: 28rpx;
  107. margin: 15rpx 0;
  108. }
  109. .collect-time {
  110. text {
  111. color: #999999;
  112. font-size: 22rpx;
  113. }
  114. image {
  115. width: 44rpx;
  116. height: 44rpx;
  117. }
  118. }
  119. }
  120. }
  121. </style>