list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="app-page" @touchstart="fnOnTouchstart" @touchend="fnOnTouchend" @touchcancel="fnOnTouchend">
  3. <view class="love-card" :class="{ ani: isDoAni }">
  4. <view class="head">
  5. <image class="avatar" :src="$utils.checkAvatarUrl(loveConfig.loveInfo.boyAvatar)" 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="$utils.checkAvatarUrl(loveConfig.loveInfo.girlAvatar)" 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="$utils.checkImageUrl(loveConfig.pageImages.heartImageUrl)" 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" :class="{ ani: isDoAni }" :style="{ '--delay': calcCardDelay(index) }">
  35. <view class="head">
  36. <view class="status">
  37. <view v-if="item.status==='wait'" class="text">未开始</view>
  38. <view v-else-if="item.status==='doing'" class="text">进行中</view>
  39. <view v-else-if="item.status==='complete'" class="text finish">已完成</view>
  40. </view>
  41. <view class="title">
  42. <view class="title-name">{{ item.title }}</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 && item.content" class="body">
  49. <view v-if="item.content" class="desc">
  50. <view class="desc-label">事件内容:</view>
  51. <view class="desc-value">{{ item.content || "-" }}</view>
  52. </view>
  53. <view v-if="item.status==='complete' && item.completeDate" class="desc">
  54. <view class="desc-label">完成时间:</view>
  55. <view class="desc-value">{{ item.completeDate || '-' }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. </block>
  60. </view>
  61. <scroll-btn :scrollTop.sync="scrollTop" @on-status="fnOnScrollStatus"></scroll-btn>
  62. </view>
  63. </template>
  64. <script>
  65. import ScrollBtn from '@/components/scroll-btn/scroll-btn.vue';
  66. export default {
  67. components: {
  68. ScrollBtn
  69. },
  70. data() {
  71. return {
  72. isDoAni: true,
  73. scrollTop: 0,
  74. list: []
  75. };
  76. },
  77. computed: {
  78. loveConfig() {
  79. return this.$tm.vx.getters().getConfigs.loveConfig;
  80. },
  81. calcLoveDays() {
  82. const formatStartDate = this.loveConfig.loveDate.replace(/-/g, '/');
  83. const start = new Date(formatStartDate),
  84. now = new Date();
  85. const T = now.getTime() - start.getTime();
  86. const i = 24 * 60 * 60 * 1000;
  87. const d = T / i;
  88. const D = Math.floor(d);
  89. return D;
  90. },
  91. calcCardDelay() {
  92. return index => {
  93. return Math.random() * index + 1 + 's';
  94. };
  95. }
  96. },
  97. watch: {
  98. loveConfig: {
  99. deep: true,
  100. immediate: true,
  101. handler(newVal) {
  102. if (!newVal) return;
  103. this.fnGetList();
  104. }
  105. }
  106. },
  107. onPageScroll(e) {
  108. this.scrollTop = e.scrollTop;
  109. },
  110. methods: {
  111. fnGetList() {
  112. this.list = this.loveConfig.loveDaily.list.map(item => {
  113. item['open'] = false;
  114. return item;
  115. });
  116. },
  117. fnOnItemOpen(item) {
  118. item.open = !item.open;
  119. this.$forceUpdate();
  120. },
  121. fnOnScrollStatus(isEnd) {
  122. this.isDoAni = isEnd;
  123. },
  124. fnOnTouchstart() {
  125. this.isDoAni = false;
  126. },
  127. fnOnTouchend() {
  128. this.isDoAni = true;
  129. }
  130. }
  131. };
  132. </script>
  133. <style scoped lang="scss">
  134. .app-page {
  135. width: 100vw;
  136. min-height: 100vh;
  137. box-sizing: border-box;
  138. padding: 36rpx;
  139. /* #ifdef H5 */
  140. padding-top: 60rpx;
  141. /* #endif */
  142. /* #ifndef H5 */
  143. padding-top: 180rpx;
  144. /* #endif */
  145. background: linear-gradient(135deg,
  146. rgba(247, 149, 51, 0.1),
  147. rgba(243, 112, 85, 0.1) 15%,
  148. rgba(239, 78, 123, 0.1) 30%,
  149. rgba(161, 102, 171, 0.1) 44%,
  150. rgba(80, 115, 184, 0.1) 58%,
  151. rgba(16, 152, 173, 0.1) 72%,
  152. rgba(7, 179, 155, 0.1) 86%,
  153. rgba(109, 186, 130, 0.1));
  154. }
  155. .love-card {
  156. width: 100%;
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. box-sizing: border-box;
  161. padding: 0 24rpx;
  162. padding-top: 66rpx;
  163. padding-bottom: 52rpx;
  164. border-radius: 50rpx;
  165. border: 4rpx solid rgba(96, 77, 68, 0.9);
  166. border-color: #faf8eb;
  167. background-color: rgba(255, 199, 184, 0.9);
  168. margin-bottom: 52rpx;
  169. box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.1);
  170. &.ani {
  171. animation: loveCardAni 3s ease-in-out infinite;
  172. }
  173. .head {
  174. display: flex;
  175. .avatar {
  176. width: 150rpx;
  177. height: 150rpx;
  178. box-sizing: border-box;
  179. border-radius: 50%;
  180. border: 6rpx solid rgba(255, 255, 255, 0.7);
  181. &.boy {
  182. border-color: #56bbf9;
  183. }
  184. &.girl {
  185. border-color: #f88ca2;
  186. }
  187. }
  188. .love-days {
  189. margin: 0 12rpx;
  190. display: flex;
  191. flex-direction: column;
  192. align-items: center;
  193. justify-content: center;
  194. font-size: 26rpx;
  195. .tip-text {
  196. color: #333;
  197. }
  198. .number {
  199. font-size: 46rpx;
  200. padding: 12rpx 0;
  201. > .boy {
  202. color: #56bbf9;
  203. margin-right: 12rpx;
  204. }
  205. > .girl {
  206. color: #f88ca2;
  207. margin-left: 12rpx;
  208. }
  209. }
  210. .days {
  211. animation: daysAni 6s ease-in-out infinite;
  212. font-weight: bold;
  213. }
  214. }
  215. }
  216. .foot {
  217. display: none;
  218. margin-top: 36rpx;
  219. font-size: 24rpx;
  220. }
  221. }
  222. @keyframes daysAni {
  223. 0% {
  224. color: #f88ca2;
  225. }
  226. 50% {
  227. color: #56bbf9;
  228. }
  229. 100% {
  230. color: #f88ca2;
  231. }
  232. }
  233. @keyframes loveCardAni {
  234. 0% {
  235. transform: scale(1);
  236. }
  237. 50% {
  238. transform: scale(1.03);
  239. }
  240. 100% {
  241. transform: scale(1);
  242. }
  243. }
  244. .list {
  245. display: flex;
  246. flex-direction: column;
  247. align-items: center;
  248. justify-content: center;
  249. box-sizing: border-box;
  250. }
  251. .empty {
  252. height: calc(100vh - 180rpx - 280rpx - 36rpx);
  253. .card {
  254. height: 100%;
  255. padding: 100rpx;
  256. margin-bottom: 0;
  257. text-align: center;
  258. justify-content: center;
  259. color: rgba(96, 77, 68, 0.9);
  260. }
  261. &-image {
  262. width: 300rpx;
  263. height: 300rpx;
  264. }
  265. &-text {
  266. margin-top: 36rpx;
  267. line-height: 50rpx;
  268. }
  269. }
  270. .card {
  271. width: 100%;
  272. display: flex;
  273. flex-direction: column;
  274. align-items: center;
  275. box-sizing: border-box;
  276. padding: 24rpx;
  277. border-radius: 50rpx;
  278. border: 4rpx solid rgba(96, 77, 68, 0.9);
  279. border-color: #fff;
  280. // background-color: #faf8eb;
  281. background-color: #ffffff;
  282. margin-bottom: 36rpx;
  283. box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.05);
  284. animation-delay: var(--delay);
  285. &.ani {
  286. // animation: cardAni 3s ease-in-out infinite;
  287. }
  288. .head {
  289. width: 100%;
  290. display: flex;
  291. align-items: center;
  292. box-sizing: border-box;
  293. .status {
  294. width: 100rpx;
  295. display: flex;
  296. .text {
  297. width: 100rpx;
  298. height: 100rpx;
  299. border-radius: 50%;
  300. background-color: #ffc6ba;
  301. font-size: 24rpx;
  302. line-height: 100rpx;
  303. text-align: center;
  304. color: #55423b;
  305. &.finish {
  306. background-color: #bfe9ef;
  307. }
  308. }
  309. }
  310. .title {
  311. width: 0;
  312. flex-grow: 1;
  313. box-sizing: border-box;
  314. padding-left: 30rpx;
  315. padding-right: 24rpx;
  316. &-name {
  317. font-weight: bold;
  318. font-size: 30rpx;
  319. color: #333;
  320. }
  321. &-desc {
  322. margin-top: 8rpx;
  323. font-size: 26rpx;
  324. color: #555;
  325. text-overflow: ellipsis;
  326. overflow: hidden;
  327. white-space: nowrap;
  328. }
  329. }
  330. .actions {
  331. width: 50rpx;
  332. .icon {
  333. display: inline-block;
  334. width: 45rpx;
  335. height: 45rpx;
  336. background-color: rgba(96, 77, 68, 0.2);
  337. border-radius: 50%;
  338. text-align: center;
  339. line-height: 45rpx;
  340. font-size: 32rpx;
  341. font-weight: bold;
  342. }
  343. }
  344. }
  345. .body {
  346. margin-top: 24rpx;
  347. width: 100%;
  348. background-color: #ffffff;
  349. // background-color: #faf8eb;
  350. background-color: rgba(96, 77, 68, 0.05);
  351. border-radius: 24rpx;
  352. box-sizing: border-box;
  353. padding: 24rpx;
  354. padding-bottom: 12rpx;
  355. font-size: 26rpx;
  356. }
  357. }
  358. @keyframes cardAni {
  359. 0% {
  360. transform: translateY(0rpx);
  361. }
  362. 50% {
  363. transform: translateY(-10rpx);
  364. }
  365. 100% {
  366. transform: translateY(0rpx);
  367. }
  368. }
  369. .desc {
  370. display: flex;
  371. margin-bottom: 12rpx;
  372. &-label {
  373. color: #333;
  374. width: 140rpx;
  375. // font-weight: bold;
  376. }
  377. &-value {
  378. width: 0;
  379. flex-grow: 1;
  380. line-height: 1.5;
  381. color: #333;
  382. }
  383. }
  384. </style>