| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- <template>
- <view class="app-page" @touchstart="fnOnTouchstart" @touchend="fnOnTouchend" @touchcancel="fnOnTouchend">
- <view class="love-card" :class="{ ani: isDoAni }">
- <view class="head">
- <image class="avatar" :src="loveConfig.boy.avatar" mode="scaleToFill"></image>
- <view class="love-days">
- <view class="tip-text">相恋</view>
- <view class="number">
- <text class="boy">-</text>
- <text class="days">{{ calcLoveDays }}</text>
- <text class="girl">-</text>
- </view>
- <view class="tip-text">天</view>
- </view>
- <image class="avatar" :src="loveConfig.girl.avatar" mode="scaleToFill"></image>
- </view>
- <view class="foot">
- <view class="text" v-if="false">
- 我们已经相恋
- <text class="number">- {{ calcLoveDays }} -</text>
- 天啦
- </view>
- 看看我们的恋爱清单都完成了哪些吧
- </view>
- </view>
- <view v-if="list.length == 0" class="list empty">
- <view class="card">
- <image class="empty-image" :src="loveConfig.loveImageUrl" mode="scaleToFill"></image>
- <view class="empty-text">暂时还没有恋爱清单,快去制定你们的恋爱清单吧~</view>
- </view>
- </view>
- <view v-else class="list">
- <block v-for="(item, index) in list" :key="index">
- <view class="card" :class="{ ani: isDoAni }" :style="{ '--delay': calcCardDelay(index) }">
- <view class="head">
- <view class="status">
- <view v-if="!item.finish" class="text">进行中</view>
- <view v-else class="text finish">已完成</view>
- </view>
- <view class="title">
- <view class="title-name">{{ item.title }}</view>
- <view class="title-desc">{{ item.desc }}</view>
- </view>
- <view class="actions" @click="fnOnItemOpen(item)">
- <text class="icon">{{ item.open ? '-' : '+' }}</text>
- </view>
- </view>
- <view v-if="item.open" class="body">
- <view class="desc">
- <view class="desc-label">开始时间:</view>
- <view class="desc-value">{{ item.detail.start || '暂无计划' }}</view>
- </view>
- <view class="desc" v-if="item.detail.desc">
- <view class="desc-label">事件描述:</view>
- <view class="desc-value">{{ item.detail.desc }}</view>
- </view>
- <view class="desc">
- <view class="desc-label">完成时间:</view>
- <view class="desc-value">{{ item.detail.end || '未开始或正在进行中...' }}</view>
- </view>
- <view class="desc">
- <view class="desc-label">完成打卡:</view>
- <view class="desc-value">{{ item.detail.moment || '未开始或正在进行中...' }}</view>
- </view>
- <view class="desc" v-if="item.detail.other">
- <view class="desc-label">爱心备注:</view>
- <view class="desc-value">{{ item.detail.other }}</view>
- </view>
- </view>
- </view>
- </block>
- </view>
- <scroll-btn :scrollTop.sync="scrollTop" @on-status="fnOnScrollStatus"></scroll-btn>
- </view>
- </template>
- <script>
- import LoveConfig from '@/config/love.config.js';
- import ScrollBtn from '@/components/scroll-btn/scroll-btn.vue';
- export default {
- components: { ScrollBtn },
- data() {
- return {
- isDoAni: true,
- scrollTop: 0,
- loveConfig: LoveConfig,
- list: []
- };
- },
- computed: {
- calcLoveDays() {
- const formatStartDate = this.loveConfig.loveStartDate.replace(/-/g, '/');
- const start = new Date(formatStartDate),
- now = new Date();
- const T = now.getTime() - start.getTime();
- const i = 24 * 60 * 60 * 1000;
- const d = T / i;
- const D = Math.floor(d);
- return D;
- },
- calcCardDelay() {
- return index => {
- return Math.random() * index + 1 + 's';
- };
- }
- },
- created() {
- this.fnGetList();
- },
- onPageScroll(e) {
- this.scrollTop = e.scrollTop;
- },
- methods: {
- fnGetList() {
- if (LoveConfig.loveList.useApi && LoveConfig.loveList.api) {
- uni.request({
- url: LoveConfig.loveList.api,
- header: {
- ContentType: 'application/json'
- },
- method: 'GET',
- dataType: 'json',
- success: res => {
- if (res.statusCode == 200 && res.data.status == 200) {
- this.list = res.data.data.map(item => {
- item['open'] = false;
- return item;
- });
- } else {
- uni.$tm.toast('数据请求失败,请检查接口!');
- }
- },
- fail: err => {
- uni.$tm.toast('数据请求失败,请检查接口!');
- }
- });
- } else {
- this.list = LoveConfig.loveList.data.map(item => {
- item['open'] = false;
- return item;
- });
- }
- },
- fnOnItemOpen(item) {
- item.open = !item.open;
- this.$forceUpdate();
- },
- fnOnScrollStatus(isEnd) {
- this.isDoAni = isEnd;
- },
- fnOnTouchstart() {
- this.isDoAni = false;
- },
- fnOnTouchend() {
- this.isDoAni = true;
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .app-page {
- width: 100vw;
- min-height: 100vh;
- box-sizing: border-box;
- padding: 36rpx;
- /* #ifdef H5 */
- padding-top: 60rpx;
- /* #endif */
- /* #ifndef H5 */
- padding-top: 180rpx;
- /* #endif */
- background: linear-gradient(
- 135deg,
- rgba(247, 149, 51, 0.1),
- rgba(243, 112, 85, 0.1) 15%,
- rgba(239, 78, 123, 0.1) 30%,
- rgba(161, 102, 171, 0.1) 44%,
- rgba(80, 115, 184, 0.1) 58%,
- rgba(16, 152, 173, 0.1) 72%,
- rgba(7, 179, 155, 0.1) 86%,
- rgba(109, 186, 130, 0.1)
- );
- }
- .love-card {
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-sizing: border-box;
- padding: 0 24rpx;
- padding-top: 66rpx;
- padding-bottom: 52rpx;
- border-radius: 50rpx;
- border: 4rpx solid rgba(96, 77, 68, 0.9);
- border-color: #faf8eb;
- background-color: rgba(255, 199, 184, 0.9);
- margin-bottom: 52rpx;
- box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.1);
- &.ani {
- animation: loveCardAni 3s ease-in-out infinite;
- }
- .head {
- display: flex;
- .avatar {
- width: 150rpx;
- height: 150rpx;
- box-sizing: border-box;
- border-radius: 50%;
- border: 6rpx solid rgba(255, 255, 255, 0.7);
- &.boy {
- border-color: #56bbf9;
- }
- &.girl {
- border-color: #f88ca2;
- }
- }
- .love-days {
- margin: 0 12rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: 26rpx;
- .tip-text {
- color: #333;
- }
- .number {
- font-size: 46rpx;
- padding: 12rpx 0;
- > .boy {
- color: #56bbf9;
- margin-right: 12rpx;
- }
- > .girl {
- color: #f88ca2;
- margin-left: 12rpx;
- }
- }
- .days {
- animation: daysAni 6s ease-in-out infinite;
- font-weight: bold;
- }
- }
- }
- .foot {
- display: none;
- margin-top: 36rpx;
- font-size: 24rpx;
- }
- }
- @keyframes daysAni {
- 0% {
- color: #f88ca2;
- }
- 50% {
- color: #56bbf9;
- }
- 100% {
- color: #f88ca2;
- }
- }
- @keyframes loveCardAni {
- 0% {
- transform: scale(1);
- }
- 50% {
- transform: scale(1.03);
- }
- 100% {
- transform: scale(1);
- }
- }
- .list {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- box-sizing: border-box;
- }
- .empty {
- height: calc(100vh - 180rpx - 280rpx - 36rpx);
- .card {
- height: 100%;
- padding: 100rpx;
- margin-bottom: 0;
- text-align: center;
- justify-content: center;
- color: rgba(96, 77, 68, 0.9);
- }
- &-image {
- width: 300rpx;
- height: 300rpx;
- }
- &-text {
- margin-top: 36rpx;
- line-height: 50rpx;
- }
- }
- .card {
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-sizing: border-box;
- padding: 24rpx;
- border-radius: 50rpx;
- border: 4rpx solid rgba(96, 77, 68, 0.9);
- border-color: #fff;
- // background-color: #faf8eb;
- background-color: #ffffff;
- margin-bottom: 36rpx;
- box-shadow: 0rpx 4rpx 24rpx rgba(0, 0, 0, 0.05);
- animation-delay: var(--delay);
- &.ani {
- animation: cardAni 3s ease-in-out infinite;
- }
- .head {
- width: 100%;
- display: flex;
- align-items: center;
- box-sizing: border-box;
- .status {
- width: 100rpx;
- display: flex;
- .text {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background-color: #ffc6ba;
- font-size: 24rpx;
- line-height: 100rpx;
- text-align: center;
- color: #55423b;
- &.finish {
- background-color: #bfe9ef;
- }
- }
- }
- .title {
- width: 0;
- flex-grow: 1;
- box-sizing: border-box;
- padding-left: 30rpx;
- padding-right: 24rpx;
- &-name {
- font-weight: bold;
- font-size: 30rpx;
- color: #333;
- }
- &-desc {
- margin-top: 8rpx;
- font-size: 26rpx;
- color: #555;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- }
- }
- .actions {
- width: 50rpx;
- .icon {
- display: inline-block;
- width: 45rpx;
- height: 45rpx;
- background-color: rgba(96, 77, 68, 0.2);
- border-radius: 50%;
- text-align: center;
- line-height: 45rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- }
- }
- .body {
- margin-top: 24rpx;
- width: 100%;
- background-color: #ffffff;
- // background-color: #faf8eb;
- background-color: rgba(96, 77, 68, 0.05);
- border-radius: 24rpx;
- box-sizing: border-box;
- padding: 24rpx;
- padding-bottom: 12rpx;
- font-size: 26rpx;
- }
- }
- @keyframes cardAni {
- 0% {
- transform: translateY(0rpx);
- }
- 50% {
- transform: translateY(-10rpx);
- }
- 100% {
- transform: translateY(0rpx);
- }
- }
- .desc {
- display: flex;
- margin-bottom: 12rpx;
- &-label {
- color: #333;
- width: 140rpx;
- // font-weight: bold;
- }
- &-value {
- width: 0;
- flex-grow: 1;
- line-height: 1.5;
- color: #333;
- }
- }
- </style>
|