guhongwei 4 éve
szülő
commit
d137373689

+ 3 - 0
commpents/newsList/detail.wxml

@@ -5,6 +5,9 @@
   <view class="date">
     发布时间:{{detail.create_time}}
   </view>
+  <view class="origin">
+    信息来源:{{detail.origin}}
+  </view>
   <view class="content">
     {{detail.content}}
   </view>

+ 6 - 0
commpents/newsList/detail.wxss

@@ -10,6 +10,12 @@
   color: #666;
 }
 
+.main .origin {
+  font-size: 14px;
+  margin: 0 0 8px 0;
+  color: #666;
+}
+
 .main .title .content {
   font-size: 14px;
   color: #666;

+ 2 - 1
commpents/newsList/index.wxml

@@ -12,7 +12,8 @@
       </view>
     </view>
     <view class="right">
-      <image src="{{item.url}}"></image>
+      <image wx:if="{{item.img.length>0}}" src="{{item.img[0].url}}"></image>
+      <image wx:else src='/image/logo.png'></image>
     </view>
   </view>
 </view>

BIN
image/logo.png


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 16 - 5
pages/news/detail.js


+ 32 - 33
pages/news/index.js

@@ -13,38 +13,8 @@ Page({
     },
     currentTab: 0,
     // 國内新聞
-    list: [
-      {
-        id: '1',
-        title: '國内信息',
-        brief: '信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介',
-        create_time: '2021-01-01',
-        url: '/image/home/image1.jpg'
-      },
-      {
-        id: '2',
-        title: '國内信息',
-        brief: '信息简介',
-        create_time: '2021-01-01',
-        url: '/image/home/image1.jpg'
-      },
-    ],
-    lists: [
-      {
-        id: '1',
-        title: '健康资讯',
-        brief: '信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介信息简介',
-        create_time: '2021-01-01',
-        url: '/image/home/image1.jpg'
-      },
-      {
-        id: '2',
-        title: '健康资讯',
-        brief: '信息简介',
-        create_time: '2021-01-01',
-        url: '/image/home/image1.jpg'
-      },
-    ]
+    oneList: [],
+    twoList: []
   },
   // 禁止左右滑动
   stopTab: function (e) {
@@ -70,7 +40,36 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/st/system/news`,
+      method: "get",
+      header: { 'x-tenant': 'test' },
+      data: { "type": '国内新闻' },
+      success: res => {
+        this.setData({ oneList: res.data.data })
+      },
+      error: err => {
+        wx.showToast({
+          title: err.msg,
+          icon: 'error'
+        })
+      }
+    })
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/st/system/news`,
+      method: "get",
+      header: { 'x-tenant': 'test' },
+      data: { "type": '健康资讯' },
+      success: res => {
+        this.setData({ twoList: res.data.data })
+      },
+      error: err => {
+        wx.showToast({
+          title: err.msg,
+          icon: 'error'
+        })
+      }
+    })
   },
 
   /**

+ 2 - 2
pages/news/index.wxml

@@ -8,12 +8,12 @@
     <swiper current="{{currentTab}}" style="height:{{windowHeight-height-40}}px">
       <swiper-item catchtouchmove="stopTab">
         <view class="one_1" style="height:{{windowHeight-height-40}}px">
-          <news-list list="{{list}}" bind:detail="detail"></news-list>
+          <news-list list="{{oneList}}" bind:detail="detail"></news-list>
         </view>
       </swiper-item>
       <swiper-item catchtouchmove="stopTab">
         <view class="one_1" style="height:{{windowHeight-height-40}}px">
-          <news-list list="{{lists}}" bind:detail="detail"></news-list>
+          <news-list list="{{twoList}}" bind:detail="detail"></news-list>
         </view>
       </swiper-item>
     </swiper>