Capate 7 years ago
parent
commit
76e85e4cbf
6 changed files with 76 additions and 38 deletions
  1. BIN
      images/diary/no_diary.png
  2. 9 5
      pages/dairy/index.js
  3. 23 9
      pages/dairy/index.wxml
  4. 41 21
      pages/dairy/index.wxss
  5. 1 1
      pages/list/index.wxss
  6. 2 2
      project.config.json

BIN
images/diary/no_diary.png


+ 9 - 5
pages/dairy/index.js

@@ -8,11 +8,10 @@ const
 
 Page({
     data: { // 初始化页面渲染数据
-        pages:[]
+        pages:[],
+        flag: false
     },
     onLoad: function () {
-
-
     },
     onReady:function () {
         //监听页面初次渲染完成
@@ -21,13 +20,18 @@ Page({
         //监听页面显示
         let me = this;
         API.getPesonalPost().then(res =>{
+            
             for (let i = 0;i<res.length;i++){
-                res[i].post = JSON.parse( res[i].post);
+                res[i].post = JSON.parse(res[i].post);
             }
             console.error(res)
             if(res.length>0){
                 me.setData({
-                    pages:res
+                    pages:res  
+                })
+            } else {
+                me.setData({
+                    flag: true 
                 })
             }
         })

+ 23 - 9
pages/dairy/index.wxml

@@ -1,12 +1,26 @@
 <view class="wrapper">
-	<view class="flex">
-		<view class="flex-item flex" wx:for="{{pages}}" wx:key="id" wx:for-index="idx" wx:for-item="page">
-			<view></view>
-			<view class="img">
-				<image src="{{page.post.url}}"  data-objectId="{{page.objectId}}" catch:tap='enter_detail'/>
-			</view>
-			<view class="txt">[{{page.author}}]{{page.section}}</view>
-		</view>
-	</view>
+    <block wx:if="{{pages.length>0}}">
+        <view class="title">我的日志</view>
+        <view class="flex">
+            <view class="flex-item {{idx%3==0||idx%3==1?'mr-25':''}}" wx:for="{{pages}}" wx:key="id" wx:for-index="idx" wx:for-item="page">
+                <view class="img">
+                    <image src="{{page.post.url}}"  data-objectId="{{page.objectId}}" lazy-load="true" catch:tap='enter_detail'/>
+                </view>
+                <view class="txt">[{{page.author}}]{{page.section}}</view>
+            </view>
+        </view>
+    </block>
+    <block wx:elif="{{flag}}">
+        <view class="none">
+        <view class="none-top">
+            <image class="none-img" src="/images/diary/no_diary.png" />
+                <view class="none-txt">一个都没有</view>
+            </view>
+            <view class="none-btn">
+                <button class="weui-btn" type="default" plain="true">新建</button>
+            </view>
+        </view>
+    </block>
+   
 </view>
 

+ 41 - 21
pages/dairy/index.wxss

@@ -3,7 +3,7 @@ page{
 }
 
 .wrapper {
-    padding: 50rpx 30rpx;
+    padding: 50rpx 50rpx;
 }
 
 
@@ -34,6 +34,7 @@ page{
 .title {
     font-size: 50rpx;
     margin-bottom: 30rpx;
+    color: #333;
 }
 
 .flex {
@@ -42,15 +43,15 @@ page{
 }
 .flex-item {
     position: relative;
-    width: 33.33%;
-    /*text-align: center;*/
-    justify-content: center;
+    width: 200rpx;
+    justify-content: flex-start;
 }
+
 .flex-item::after {
     content: '';
     position: absolute;
     top: 20rpx;
-    right: 18rpx;
+    right: 12rpx;
     z-index: -1;
     width: 140rpx;
     height: 140rpx;
@@ -62,11 +63,11 @@ page{
 .flex-item::before{
     content: '';
     position: absolute;
-    top: 30rpx;
-    right: 10rpx;
+    top: 35rpx;
+    right: 2rpx;
     z-index: -1;
     width: 160rpx;
-    height: 120rpx;
+    height: 110rpx;
     border: 1px solid #ddd;
     border-radius: 8rpx;
     background-color: #efefef;
@@ -78,20 +79,39 @@ page{
 .img image {
     width: 100%;
     height: 100%;
-    border-radius: 4rpx;
+    border: 1px solid #ddd;
+    border-radius: 8rpx;
 }
 .txt {
-    width:180rpx;
-    text-align:left;
-    font-size:26rpx;
-    margin:16rpx 0 40rpx;
-    overflow:hidden;
-    text-overflow:ellipsis;
-    display:-webkit-box;
-    -webkit-line-clamp:2;
-    -webkit-box-orient:vertical;
-    font-weight:800;
-    align-items: flex-start;
-    justify-content: flex-start;
+    width: 190rpx;
+    text-align: left;
+    font-size: 28rpx;
+    font-weight: 800;
+    margin: 16rpx 0 40rpx;
+    color: #666;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    display: -webkit-box;
+    -webkit-line-clamp: 2;
+    -webkit-box-orient: vertical;
 }
 
+.none {
+    text-align: center;
+    transform: translateY(50%);
+}
+.none-img {
+    width: 200rpx;
+    height: 200rpx;
+}
+.none-txt {
+    font-size: 50rpx;
+    color: #bfbfbf;
+}
+.none-btn {
+    width: 250rpx;
+    margin: 20rpx auto;
+}
+.mr-25 {
+    margin-right: 25rpx;
+}

+ 1 - 1
pages/list/index.wxss

@@ -5,7 +5,7 @@
   width: 100%;
 
 }
-.button-sp-area{
+.button-sp-area {
   margin:auto;
   padding-top:15px;
   width:60%;

+ 2 - 2
project.config.json

@@ -33,7 +33,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": -1,
+			"current": 1,
 			"list": [
 				{
 					"id": 0,
@@ -44,7 +44,7 @@
 				{
 					"id": 1,
 					"name": "3",
-					"pathName": "pages/edit/index",
+					"pathName": "pages/dairy/index",
 					"query": ""
 				}
 			]