favorites.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="favorites-page">
  3. <!-- 列表 -->
  4. <view class="fav-list">
  5. <view
  6. class="fav-card"
  7. v-for="(item, idx) in list"
  8. :key="idx"
  9. >
  10. <image
  11. :src="item.img"
  12. class="fav-img"
  13. ></image>
  14. <view class="fav-content">
  15. <view class="fav-header">
  16. <image
  17. :src="item.avatar"
  18. class="avatar"
  19. ></image>
  20. <text class="nickname">{{ item.nickname }}</text>
  21. <text class="tag">{{ item.tag }}</text>
  22. <view style="position: relative;left: 0;top: 0;">
  23. <image
  24. src="/static/crowdFunding/more.png"
  25. class="more-img"
  26. @click="toggleDropdown(idx)"
  27. ></image>
  28. <view
  29. class="dropdown-menu"
  30. v-if="currentDropdownIndex === idx"
  31. >
  32. <view
  33. class="dropdown-item"
  34. @tap="handleOption('cancelCollection', idx)"
  35. >取消收藏</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="fav-title two-omit">{{ item.title }}</view>
  40. <view class="fav-bottom">
  41. <text class="amount">已筹 ¥{{ item.amount }}万</text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. list: [
  53. {
  54. img: "/static/crowdFunding/top-img.png",
  55. avatar: "/static/home/avator.png",
  56. nickname: "也许时间是一种解药",
  57. tag: "发起人",
  58. title: "糖指数100%12分BJD可动人偶盲盒糖指数100%12分BJD可动人偶盲盒糖指数100%12分BJD可动人偶盲盒",
  59. amount: "769.8",
  60. },
  61. {
  62. img: "/static/crowdFunding/top-img.png",
  63. avatar: "/static/home/avator.png",
  64. nickname: "也许时间是一种解药",
  65. tag: "发起人",
  66. title: "糖指数100%12分BJD可动人偶盲盒",
  67. amount: "769.8",
  68. },
  69. {
  70. img: "/static/crowdFunding/top-img.png",
  71. avatar: "/static/home/avator.png",
  72. nickname: "也许时间是一种解药",
  73. tag: "发起人",
  74. title: "糖指数100%12分BJD可动人偶盲盒",
  75. amount: "769.8",
  76. },
  77. ],
  78. currentDropdownIndex: null,
  79. };
  80. },
  81. methods: {
  82. goBack() {
  83. uni.navigateBack();
  84. },
  85. toggleDropdown(idx) {
  86. this.currentDropdownIndex = this.currentDropdownIndex === idx ? null : idx;
  87. },
  88. // 处理下拉菜单选项点击
  89. handleOption(type, idx) {
  90. this.currentDropdownIndex = null;
  91. if (type === "cancelCollection") {
  92. uni.showToast({
  93. title: '取消收藏成功',
  94. icon: 'success',
  95. duration: 2000
  96. });
  97. // 这里可以加删除逻辑
  98. }
  99. },
  100. },
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .favorites-page {
  105. min-height: 100vh;
  106. background: #f2f6f2;
  107. .fav-list {
  108. padding: 24rpx 0;
  109. .fav-card {
  110. display: flex;
  111. background: #fff;
  112. border-radius: 18rpx;
  113. margin: 0 24rpx 24rpx 24rpx;
  114. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  115. padding: 20rpx;
  116. .fav-img {
  117. width: 140rpx;
  118. height: 140rpx;
  119. border-radius: 12rpx;
  120. object-fit: cover;
  121. flex-shrink: 0;
  122. }
  123. .fav-content {
  124. flex: 1;
  125. margin-left: 20rpx;
  126. display: flex;
  127. flex-direction: column;
  128. justify-content: space-between;
  129. .fav-header {
  130. display: flex;
  131. align-items: center;
  132. .avatar {
  133. width: 44rpx;
  134. height: 44rpx;
  135. border-radius: 50%;
  136. margin-right: 12rpx;
  137. }
  138. .nickname {
  139. font-weight: 400;
  140. font-size: 24rpx;
  141. color: #1f1f1f;
  142. font-family: "PingFang SC-Bold";
  143. max-width: 250rpx;
  144. margin-right: 12rpx;
  145. }
  146. .tag {
  147. font-size: 20rpx;
  148. color: #acf934;
  149. background: #1f1f1f;
  150. border-radius: 8rpx;
  151. padding: 2rpx 12rpx;
  152. margin-right: auto;
  153. margin-left: 4rpx;
  154. }
  155. .more-img {
  156. width: 36rpx;
  157. height: 36rpx;
  158. margin-left: 12rpx;
  159. }
  160. }
  161. .fav-title {
  162. font-size: 26rpx;
  163. color: #222;
  164. font-weight: 500;
  165. margin: 10rpx 0 0 0;
  166. overflow: hidden;
  167. text-overflow: ellipsis;
  168. width: 100%;
  169. }
  170. .fav-bottom {
  171. margin-top: 10rpx;
  172. display: flex;
  173. justify-content: flex-end;
  174. align-items: center;
  175. .amount {
  176. font-size: 22rpx;
  177. color: #bdbdbd;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. .dropdown-menu {
  184. position: absolute;
  185. top: calc(100% + 10rpx);
  186. right: 20rpx;
  187. background-color: #ffffff;
  188. border-radius: 20rpx;
  189. padding: 0;
  190. width: 150rpx;
  191. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  192. z-index: 100;
  193. transform-origin: top right;
  194. animation: dropdownAnimation 0.2s ease-out;
  195. overflow: hidden;
  196. .dropdown-item {
  197. padding: 15rpx 0;
  198. color: #333333;
  199. font-size: 24rpx;
  200. position: relative;
  201. text-align: center;
  202. &:not(:last-child)::after {
  203. content: "";
  204. position: absolute;
  205. left: 0;
  206. right: 0;
  207. bottom: 0;
  208. height: 1rpx;
  209. background-color: #eeeeee;
  210. }
  211. &:active {
  212. background-color: #f8f8f8;
  213. }
  214. }
  215. }
  216. @keyframes dropdownAnimation {
  217. 0% {
  218. opacity: 0;
  219. transform: scale(0.95) translateY(-5rpx);
  220. }
  221. 100% {
  222. opacity: 1;
  223. transform: scale(1) translateY(0);
  224. }
  225. }
  226. }
  227. </style>