zhaoxiaohai 3 years ago
parent
commit
78c12aebce
2 changed files with 51 additions and 3 deletions
  1. 50 2
      pages/tabbar-pages/message/index.js
  2. 1 1
      pages/tabbar-pages/message/index.wxml

+ 50 - 2
pages/tabbar-pages/message/index.js

@@ -1,18 +1,66 @@
+import {
+    ApiModel
+} from "../../../utils/api";
+const _Http = new ApiModel();
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-
+        tabsActive: 0, //tabs 下标
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        this.getList()
+    },
+    /* tabs切换 */
+    tabsOnChange(e) {
+        const {
+            index,
+            title
+        } = e.detail;
+        this.setData({
+            tabsActive: index
+        })
+        this.getList()
+    },
+    /* 列表请求 */
+    getList() {
+        let type = "公共";
+        switch (this.data.tabsActive) {
+            case 1:
+                type = "商户";
+                break;
+            case 2:
+                type = "公共";
+                break;
+            case 3:
+                type = "团队";
+                break;
+            default:
+                break;
+        }
+        _Http.basic({
+            "accesstoken": wx.getStorageSync('userData').token,
+            "classname": "system.message.Message",
+            "method": "queryMessage",
+            "content": {
+                "getdatafromdbanyway": true,
+                "pageNumber": 1,
+                "pageSize": 20,
+                "ftype": type
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: 'none'
+            });
+        })
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 1 - 1
pages/tabbar-pages/message/index.wxml

@@ -1,7 +1,7 @@
 <!-- 自定义头部 -->
 <My_navBar></My_navBar>
 <!-- 信息 -->
-<van-tabs active="{{ active }}" color='#4DC2D4' title-active-color="#4DC2D4" title-inactive-color='rgba(0,0,0,.3)' tab-active-class='tab-active-class' tab-class="tab-class" nav-class='' line-width='60rpx' line-height='6rpx' swipeable bind:change="onChange">
+<van-tabs active="{{ tabsActive }}" color='#4DC2D4' title-active-color="#4DC2D4" title-inactive-color='rgba(0,0,0,.3)' tab-active-class='tab-active-class' tab-class="tab-class" nav-class='' line-width='60rpx' line-height='6rpx' swipeable bind:change="tabsOnChange">
     <view class="nav-class"></view>
     <van-tab title="公共消息">
         <view class="msg-box">