Browse Source

始宁农业小程序:农事天地-新增

panyong 2 years ago
parent
commit
219a0d9b44

+ 7 - 0
htmldev/shiningWxMini/mixin/pages.js

@@ -61,6 +61,13 @@ module.exports = {
                   shop_address: item.shop_address ? JSON.parse(item.shop_address) : {}
                 }
               }
+              if (that.data.listUrl === '/api/user/track/list') {
+                console.log(item)
+                return {
+                  ...item,
+                  track_img_url: item.track_img_url ? JSON.parse(item.track_img_url) : {}
+                }
+              }
               return {
                 ...item
               }

+ 53 - 9
htmldev/shiningWxMini/pages/news/news.js

@@ -1,15 +1,36 @@
+const pages = require('../../mixin/pages')
+
 Page({
 
   /**
    * 页面的初始数据
    */
-  data: {},
+  data: {
+    ...pages.data(),
+    listUrl: '/api/user/track/list',
+    searchForm: {
+      'key_words': ''
+      // 'follow_type': 1
+    },
+    nav: [
+      {
+        name: '推荐',
+        value: '1'
+      },
+      {
+        name: '关注',
+        value: '2'
+      }
+    ],
+    active: '1'
+  },
+  ...pages.methods,
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    this.fetchOrderList()
   },
 
   /**
@@ -44,21 +65,44 @@ Page({
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh() {
-
+    if (this.data.freshing) {
+      return
+    }
+    this.setData({
+      freshing: true
+    })
+    this.bindCallBack()
   },
 
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom() {
-
+    this.fetchOrderList()
   },
+  bindCallBack() {
+    this.refreshOrderList()
+  },
+  handleNav(e) {
+    const { value } = e.detail
+    const searchForm = JSON.parse(JSON.stringify(this.data.searchForm))
+    if (value === '1' && searchForm.hasOwnProperty('follow_type')) {
+      delete searchForm.follow_type
+    } else if (value === '2') {
+      searchForm.follow_type = 1
+    }
+
+    this.setData({
+      active: value,
+      searchForm: searchForm
+    }, () => {
+      this.refreshOrderList()
+    })
+  },
+  followUser(e) {
+    const { item } = e.target.dataset
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
+    console.log(item)
   },
   jumpAddNews() {
     wx.navigateTo({

+ 9 - 2
htmldev/shiningWxMini/pages/news/news.json

@@ -1,3 +1,10 @@
 {
-  "usingComponents": {}
-}
+  "usingComponents": {
+    "customer-tab": "../../components/customer-tab/index",
+    "van-loading": "@vant/weapp/loading/index"
+  },
+  "backgroundColor": "#F6F6F6",
+  "backgroundTextStyle": "dark",
+  "enablePullDownRefresh": true,
+  "onReachBottomDistance": 50
+}

+ 36 - 10
htmldev/shiningWxMini/pages/news/news.wxml

@@ -2,17 +2,29 @@
   <view class="app_page-header-search">
     <view class="app_page-header-search-warp app_width-690">
       <label for="header-search">
-        <image src=""></image>
+        <image src="../../image/common/search@2x.png"></image>
       </label>
-      <input placeholder-class="app_header-search-placeholder" value="" placeholder="搜索"></input>
+      <input
+        placeholder-class="app_header-search-placeholder"
+        value="{{searchForm.key_words}}"
+        placeholder="搜索信息"
+        data-formkey="key_words"
+        bind:input="handleKeyWords"></input>
     </view>
     <view class="leaving-a-message" bind:tap="jumpLeavingAMessage" wx:if="{{false}}">
       <image src="../../image/common/message@2x.png"></image>
       <view>8</view>
     </view>
   </view>
+  <customer-tab
+    nav="{{nav}}"
+    active="{{active}}"
+    bind:change="handleNav"/>
   <view class="main">
-    <view class="list">
+    <view
+      class="list"
+      wx:for="{{listData}}"
+      wx:key="id">
       <view class="top">
         <view class="portrait">
           <image src=""></image>
@@ -21,18 +33,23 @@
           <view class="user-name">农户张三</view>
           <view class="business-name">商铺:xxxx西瓜店</view>
         </view>
-        <button class="follow">关注</button>
+        <button
+          class="follow"
+          wx:if="{{item.follow_status === 0}}"
+          data-item="{{item}}"
+          bind:tap="followUser">关注
+        </button>
       </view>
       <view class="news">
-        <view class="text">
-          哈拉啊啊啊啦啦啦啦啦啦阿拉,啊啦啦啦阿拉啦啦啦啦啦啦,啦啦啦啦啦阿拉啦啦。啦啦啦啦啦啦啦啦,啦啦啦啦啦啦啦阿拉啦啦啦啦。阿卡卡卡卡看。
-        </view>
+        <view class="text">{{item.track_content}}</view>
         <view class="photo-wrap">
           <view
             class="box"
-            wx:for="{{6}}"
-            wx:key="index">
-            <image src=""></image>
+            wx:for="{{item.track_img_url}}"
+            wx:for-item="img"
+            wx:for-index="idx"
+            wx:key="idx">
+            <image src="{{img}}"></image>
           </view>
         </view>
       </view>
@@ -60,6 +77,15 @@
         </view>
       </view>
     </view>
+    <view
+      class="pullup-wrapper"
+      wx:if="{{!isRefresh}}">
+      <van-loading
+        wx:if="{{!finished}}"
+        size="24px"
+        type="spinner">加载中...
+      </van-loading>
+    </view>
   </view>
 </view>
 <view