list.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view class="app-page">
  3. <view class="love-card">
  4. <view class="head">
  5. <image class="avatar" :src="loveConfig.boy.avatar" mode="scaleToFill"></image>
  6. <view class="love-days">
  7. <view class="tip-text">相恋</view>
  8. <view class="number">
  9. <text class="boy">-</text>
  10. <text class="days">{{ calcLoveDays }}</text>
  11. <text class="girl">-</text>
  12. </view>
  13. <view class="tip-text">天</view>
  14. </view>
  15. <image class="avatar" :src="loveConfig.girl.avatar" mode="scaleToFill"></image>
  16. </view>
  17. <view class="foot">
  18. <view class="text" v-if="false">
  19. 我们已经相恋
  20. <text class="number">- {{ calcLoveDays }} -</text>
  21. 天啦
  22. </view>
  23. 看看我们的恋爱清单都完成了哪些吧
  24. </view>
  25. </view>
  26. <view v-if="list.length == 0" class="list empty">
  27. <view class="card">
  28. <image class="empty-image" :src="loveConfig.loveImageUrl" mode="scaleToFill"></image>
  29. <view class="empty-text">暂时还没有恋爱清单,快去制定你们的恋爱清单吧~</view>
  30. </view>
  31. </view>
  32. <view v-else class="list">
  33. <block v-for="(item, index) in list" :key="index">
  34. <view class="card" :style="{ '--delay': calcCardDelay(index) }">
  35. <view class="head">
  36. <view class="status">
  37. <view v-if="!item.finish" class="text">进行中</view>
  38. <view v-else class="text finish">已完成</view>
  39. </view>
  40. <view class="title">
  41. <view class="title-name">{{ item.title }}</view>
  42. <view class="title-desc">{{ item.desc }}</view>
  43. </view>
  44. <view class="actions" @click="fnOnItemOpen(item)">
  45. <text class="icon">{{ item.open ? '-' : '+' }}</text>
  46. </view>
  47. </view>
  48. <view v-if="item.open" class="body">
  49. <view class="desc">
  50. <view class="desc-label">开始时间:</view>
  51. <view class="desc-value">{{ item.detail.start || '暂无计划' }}</view>
  52. </view>
  53. <view class="desc" v-if="item.detail.desc">
  54. <view class="desc-label">事件描述:</view>
  55. <view class="desc-value">{{ item.detail.desc }}</view>
  56. </view>
  57. <view class="desc">
  58. <view class="desc-label">完成时间:</view>
  59. <view class="desc-value">{{ item.detail.end || '未开始或正在进行中...' }}</view>
  60. </view>
  61. <view class="desc">
  62. <view class="desc-label">完成打卡:</view>
  63. <view class="desc-value">{{ item.detail.moment || '未开始或正在进行中...' }}</view>
  64. </view>
  65. <view class="desc" v-if="item.detail.other">
  66. <view class="desc-label">爱心备注:</view>
  67. <view class="desc-value">{{ item.detail.other }}</view>
  68. </view>
  69. </view>
  70. </view>
  71. </block>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import LoveConfig from '@/config/love.config.js';
  77. export default {
  78. data() {
  79. return {
  80. loveConfig: LoveConfig,
  81. list: []
  82. };
  83. },
  84. computed: {
  85. calcLoveDays() {
  86. const start = new Date(this.loveConfig.loveStartDate),
  87. now = new Date();
  88. const T = now.getTime() - start.getTime();
  89. const i = 24 * 60 * 60 * 1000;
  90. const d = T / i;
  91. const D = Math.floor(d);
  92. return D;
  93. },
  94. calcCardDelay() {
  95. return index => {
  96. return Math.random() * index + 1 + 's';
  97. };
  98. }
  99. },
  100. created() {
  101. this.fnFormatList();
  102. },
  103. methods: {
  104. fnFormatList() {
  105. this.list = LoveConfig.loveList.map(item => {
  106. item['open'] = false;
  107. return item;
  108. });
  109. },
  110. fnOnItemOpen(item) {
  111. item.open = !item.open;
  112. this.$forceUpdate();
  113. }
  114. }
  115. };
  116. </script>
  117. <style scoped lang="scss">
  118. .app-page {
  119. width: 100vw;
  120. min-height: 100vh;
  121. box-sizing: border-box;
  122. padding: 36rpx;
  123. /* #ifdef H5 */
  124. padding-top: 60rpx;
  125. /* #endif */
  126. /* #ifndef H5 */
  127. padding-top: 180rpx;
  128. /* #endif */
  129. background: linear-gradient(
  130. 135deg,
  131. rgba(247, 149, 51, 0.1),
  132. rgba(243, 112, 85, 0.1) 15%,
  133. rgba(239, 78, 123, 0.1) 30%,
  134. rgba(161, 102, 171, 0.1) 44%,
  135. rgba(80, 115, 184, 0.1) 58%,
  136. rgba(16, 152, 173, 0.1) 72%,
  137. rgba(7, 179, 155, 0.1) 86%,
  138. rgba(109, 186, 130, 0.1)
  139. );
  140. // background: rgba(247, 246, 242, 1);
  141. color: #55423b;
  142. }
  143. .love-card {
  144. width: 100%;
  145. display: flex;
  146. flex-direction: column;
  147. align-items: center;
  148. box-sizing: border-box;
  149. padding: 0 24rpx;
  150. padding-top: 66rpx;
  151. padding-bottom: 52rpx;
  152. border-radius: 50rpx;
  153. border: 4rpx solid rgba(96, 77, 68, 0.9);
  154. border-color: #faf8eb;
  155. background-color: rgba(255, 199, 184, 0.9);
  156. margin-bottom: 52rpx;
  157. box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.1);
  158. transition: transform 0.5s ease-in-out;
  159. &:hover {
  160. transform: translateY(-6rpx);
  161. }
  162. .head {
  163. display: flex;
  164. .avatar {
  165. width: 150rpx;
  166. height: 150rpx;
  167. box-sizing: border-box;
  168. border-radius: 50%;
  169. border: 6rpx solid rgba(255, 255, 255, 0.7);
  170. &.boy {
  171. border-color: #56bbf9;
  172. }
  173. &.girl {
  174. border-color: #f88ca2;
  175. }
  176. }
  177. .love-days {
  178. margin: 0 12rpx;
  179. display: flex;
  180. flex-direction: column;
  181. align-items: center;
  182. justify-content: center;
  183. font-size: 26rpx;
  184. .tip-text {
  185. color: #333;
  186. }
  187. .number {
  188. font-size: 46rpx;
  189. padding: 12rpx 0;
  190. > .boy {
  191. color: #56bbf9;
  192. margin-right: 12rpx;
  193. }
  194. > .girl {
  195. color: #f88ca2;
  196. margin-left: 12rpx;
  197. }
  198. }
  199. .days {
  200. animation: daysAni 6s ease-in-out infinite;
  201. font-weight: bold;
  202. }
  203. }
  204. }
  205. .foot {
  206. display: none;
  207. margin-top: 36rpx;
  208. font-size: 24rpx;
  209. }
  210. }
  211. @keyframes daysAni {
  212. 0% {
  213. color: #f88ca2;
  214. }
  215. 50% {
  216. color: #56bbf9;
  217. }
  218. 100% {
  219. color: #f88ca2;
  220. }
  221. }
  222. .list {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. box-sizing: border-box;
  228. }
  229. .empty {
  230. height: calc(100vh - 180rpx - 280rpx - 36rpx);
  231. .card {
  232. height: 100%;
  233. padding: 100rpx;
  234. margin-bottom: 0;
  235. text-align: center;
  236. justify-content: center;
  237. color: rgba(96, 77, 68, 0.9);
  238. }
  239. &-image {
  240. width: 300rpx;
  241. height: 300rpx;
  242. }
  243. &-text {
  244. margin-top: 36rpx;
  245. line-height: 50rpx;
  246. }
  247. }
  248. .card {
  249. width: 100%;
  250. display: flex;
  251. flex-direction: column;
  252. align-items: center;
  253. box-sizing: border-box;
  254. padding: 24rpx;
  255. border-radius: 50rpx;
  256. border: 4rpx solid rgba(96, 77, 68, 0.9);
  257. border-color: #fff;
  258. // background-color: #faf8eb;
  259. background-color: #ffffff;
  260. margin-bottom: 36rpx;
  261. box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.1);
  262. transition: transform 0.3s ease-in-out;
  263. animation: cardAni 3s ease-in-out infinite;
  264. animation-delay: var(--delay);
  265. &:hover {
  266. transform: translateY(-8rpx);
  267. }
  268. .head {
  269. width: 100%;
  270. display: flex;
  271. align-items: center;
  272. box-sizing: border-box;
  273. .status {
  274. width: 100rpx;
  275. display: flex;
  276. .text {
  277. width: 100rpx;
  278. height: 100rpx;
  279. border-radius: 50%;
  280. background-color: #ffc6ba;
  281. font-size: 24rpx;
  282. line-height: 100rpx;
  283. text-align: center;
  284. &.finish {
  285. background-color: #bfe9ef;
  286. }
  287. }
  288. }
  289. .title {
  290. width: 0;
  291. flex-grow: 1;
  292. box-sizing: border-box;
  293. padding-left: 30rpx;
  294. padding-right: 24rpx;
  295. &-name {
  296. font-weight: bold;
  297. font-size: 30rpx;
  298. color: #333;
  299. }
  300. &-desc {
  301. margin-top: 8rpx;
  302. font-size: 26rpx;
  303. color: rgba(96, 77, 68, 1);
  304. text-overflow: ellipsis;
  305. overflow: hidden;
  306. white-space: nowrap;
  307. }
  308. }
  309. .actions {
  310. width: 50rpx;
  311. .icon {
  312. display: inline-block;
  313. width: 45rpx;
  314. height: 45rpx;
  315. background-color: rgba(96, 77, 68, 0.2);
  316. border-radius: 50%;
  317. text-align: center;
  318. line-height: 45rpx;
  319. font-size: 32rpx;
  320. font-weight: bold;
  321. }
  322. }
  323. }
  324. .body {
  325. margin-top: 24rpx;
  326. width: 100%;
  327. background-color: #ffffff;
  328. // background-color: #faf8eb;
  329. background-color: rgba(96, 77, 68, 0.05);
  330. border-radius: 24rpx;
  331. box-sizing: border-box;
  332. padding: 24rpx;
  333. padding-bottom: 12rpx;
  334. font-size: 26rpx;
  335. }
  336. }
  337. @keyframes cardAni {
  338. 0% {
  339. transform: translateY(0rpx);
  340. }
  341. 50% {
  342. transform: translateY(-10rpx);
  343. }
  344. 100% {
  345. transform: translateY(0rpx);
  346. }
  347. }
  348. .desc {
  349. display: flex;
  350. margin-bottom: 12rpx;
  351. &-label {
  352. color: #333;
  353. width: 140rpx;
  354. // font-weight: bold;
  355. }
  356. &-value {
  357. width: 0;
  358. flex-grow: 1;
  359. line-height: 1.5;
  360. }
  361. }
  362. </style>