Browse Source

首页最新供需

zhaoxiaohai 3 years ago
parent
commit
05480a3bf4

+ 9 - 0
components/My_DisplayItem/index.js

@@ -16,6 +16,9 @@ Component({
         borTop: {
             type: Number,
             value: 2
+        },
+        content: {
+            type: Object
         }
     },
 
@@ -30,6 +33,12 @@ Component({
      * 组件的方法列表
      */
     methods: {
+        jumpDetails() {
+            console.log(this.data.content)
+            wx.navigateTo({
+                url: '/pages/tabbar-pages/supplyAndDemand/particulars?tsupplyanddemandid=' + this.data.content.tsupplyanddemandid + '&type=1',
+            })
+        }
 
     }
 })

+ 7 - 6
components/My_DisplayItem/index.wxml

@@ -1,21 +1,22 @@
-<view class="display-item-box" style="padding-top: {{padTop}}rpx; border-top: {{borTop}}rpx solid rgba(151, 151, 151, .1);">
+<view class="display-item-box" style="padding-top: {{padTop}}rpx; border-top: {{borTop}}rpx solid rgba(151, 151, 151, .1);" bindtap="jumpDetails">
     <!-- 展示图片 -->
     <view class="display-item-image">
-        <image src="/static/userImage.png" mode="aspectFit"></image>
+        <image wx:if="{{content.attinfos[0]}}" src="{{content.attinfos[0].fobsurl}}" mode="aspectFill"></image>
+        <image wx:else src="/static/userImage.png" mode="aspectFit"></image>
     </view>
     <!-- 展示文本信息 -->
     <view class="display-item-textExplain">
-        <view class="textExplain-title">家纺城产业互联平台上线</view>
-        <view class="textExplain-explain u-line-1">家纺城产业互联平台上线家纺城产业546555554</view>
+        <view class="textExplain-title">{{content.ftitle}}</view>
+        <view class="textExplain-explain u-line-1">{{content.fcontent}}</view>
         <view class="textExplain-userData-time">
             <view class="textExplain-userData">
-                <image src="/static/userImage.png" mode="aspectFit"></image>家纺城-小布
+                <image src="{{content.headportraiturl}}" mode="aspectFit"></image>{{content.createby}}
                 <slot name="button">
 
                 </slot>
             </view>
             <view class="textExplain-time">
-                12-07 12:24
+                {{content.checkdate}}
             </view>
         </view>
     </view>

+ 54 - 4
pages/tabbar-pages/home/index.js

@@ -1,9 +1,14 @@
+import {
+    ApiModel
+} from "../../../utils/api";
+const _Http = new ApiModel();
+const handleList = require("../../../utils/processingData");
 Page({
-
     /**
      * 页面的初始数据
      */
     data: {
+        productList: [], //供需列表
         //轮播图列表
         swiperBannerList: [{
             id: "001",
@@ -38,20 +43,65 @@ Page({
         ]
     },
     /* tabs切换 */
-    tabsSelectedIitem(text) {
+    /* tabsSelectedIitem(text) {
         console.log(text.detail)
+    }, */
+    /* 宫格区跳转 */
+    gridJumpPage(e) {
+        const {
+            name
+        } = e.target.dataset;
+        if (name == '供需广场') {
+            wx.switchTab({
+                url: '/pages/tabbar-pages/supplyAndDemand/index',
+            })
+        } else if (name == '私域直播') {
+            wx.navigateTo({
+                url: '/pages/liveStreaming/index',
+            })
+        }
     },
     /* 获得展示区标题 */
     getExhibitionTitle(title) {
         console.log(title.detail)
+        if (title.detail == '最新供需') {
+            wx.switchTab({
+                url: '/pages/tabbar-pages/supplyAndDemand/index',
+            })
+        }
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-
+        /* 获取最新供需列表 */
+        _Http.basic({
+            "accesstoken": wx.getStorageSync('userData').token,
+            "classname": "customer.supplyanddemand.supplyanddemand",
+            "method": "query_supplyanddemandList",
+            "content": {
+                "getdatafromdbanyway": true,
+                "pageNumber": 1,
+                "pageSize": 8,
+                "where": {
+                    "fissupply": "0",
+                    "fstatus": "待对接"
+                }
+            }
+        }).then(res => {
+            console.log(res)
+            if (res.msg != '成功') return;
+            const data = handleList.getYTD(res.data)
+            const productList = handleList.listOrdering(data);
+            this.setData({
+                productList
+            })
+        })
+    },
+    /* 一键联系 */
+    contact() {
+        console.log('一键联系')
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 3 - 4
pages/tabbar-pages/home/index.wxml

@@ -28,12 +28,12 @@
     <!-- 标题前图片 -->
     <image slot="display-box-img" class="display-title_image" src="/static/icon-03.png" mode="aspectFit"></image>
     <!-- 圆角按钮tabs -->
-    <My_RoundedCornerButtonTabs list="{{roundedList}}" bind:tabsSelectedIitem="tabsSelectedIitem"></My_RoundedCornerButtonTabs>
+    <!-- <My_RoundedCornerButtonTabs list="{{roundedList}}" bind:tabsSelectedIitem="tabsSelectedIitem"></My_RoundedCornerButtonTabs> -->
     <!-- 列表展示区 -->
     <view slot="display-box-showList">
-        <My_DisplayItem wx:for="{{3}}" padTop="{{index==0?'0':'20'}}" borTop="{{index==0?'0':'2'}}">
+        <My_DisplayItem wx:for="{{productList}}" content="{{item}}" padTop="{{index==0?'0':'20'}}" borTop="{{index==0?'0':'2'}}">
             <view class="display-box-showList-button-box" slot="button">
-                <van-button custom-class="display-box-showList-button" color="linear-gradient(180deg, #84E3EC 0%, #4DC2D4 100%)"></van-button>
+                <van-button custom-class="display-box-showList-button" catchtap="contact" color="linear-gradient(180deg, #84E3EC 0%, #4DC2D4 100%)"></van-button>
                 <view class="display-box-showList-button-text">
                     一键联系
                 </view>
@@ -42,7 +42,6 @@
     </view>
 </My_DisplayBox>
 
-
 <My_DisplayBox title="合作商家" bind:getExhibitionTitle="getExhibitionTitle">
     <!-- 标题前图片 -->
     <image slot="display-box-img" class="display-title_image" src="/static/icon-04.png" mode="aspectFit"></image>

+ 12 - 1
utils/processingData.js

@@ -7,6 +7,16 @@ function checkdate(data) {
     return data;
 }
 
+/* 截取时间 只取年月日 */
+function getYTD(data) {
+    for (let i = 0; i < data.length; i++) {
+        let checkdate = data[i].checkdate;
+        const YTD = checkdate.split(' ');
+        data[i].checkdate = YTD[0];
+    }
+    return data;
+}
+
 /* 供需列表数据排序 */
 function listOrdering(data) {
     /* 处理排序 */
@@ -22,5 +32,6 @@ function listOrdering(data) {
 
 module.exports = {
     checkdate,
-    listOrdering
+    listOrdering,
+    getYTD
 }