zs 1 vuosi sitten
vanhempi
commit
2790c4167b
5 muutettua tiedostoa jossa 78 lisäystä ja 17 poistoa
  1. 29 0
      components/tab/index.js
  2. 4 0
      components/tab/index.json
  3. 12 0
      components/tab/index.wxml
  4. 31 0
      components/tab/index.wxss
  5. 2 17
      pages/index/index.js

+ 29 - 0
components/tab/index.js

@@ -0,0 +1,29 @@
+const app = getApp()
+Component({
+    properties: {
+        active: { type: Number, value: 0 },
+        tabList: {
+            type: Array, value: [
+                { title: '报名中', active: 0 },
+                { title: '未开始', active: 1 },
+                { title: '进行中', active: 2 },
+                { title: '已结束', active: 3 }
+            ]
+        },
+    },
+    data: {},
+    methods: {
+        //滑动切换
+        swiperTab: function (e) {
+            const that = this;
+            that.triggerEvent('swiperTab', { active: e.detail.current })
+        },
+        //点击切换
+        clickTab: function (e) {
+            const that = this;
+            if (that.data.active === e.target.dataset.active) return false
+            else that.setData({ active: e.target.dataset.active })
+            that.triggerEvent('clickTab', { active: e.target.dataset.active })
+        },
+    }
+})

+ 4 - 0
components/tab/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 12 - 0
components/tab/index.wxml

@@ -0,0 +1,12 @@
+<view class="tab">
+        <view class="swiper-tab">
+            <view class="swiper-tab-item {{active==item.active?'active':''}}" wx:for="{{tabList}}" wx:key="index" wx:for-item="item" data-active="{{item.active}}" bindtap="clickTab">
+                {{item.title}}
+            </view>
+        </view>
+        <swiper class='swiper' current="{{active}}" duration="300" bindchange="swiperTab">
+            <swiper-item wx:for="{{tabList}}" wx:key="index" wx:for-item="item">
+                <slot></slot>
+            </swiper-item>
+        </swiper>
+    </view>

+ 31 - 0
components/tab/index.wxss

@@ -0,0 +1,31 @@
+@import "../../app.wxss";
+
+.tab {
+    width: 100%;
+}
+
+.tab .swiper-tab {
+    display: flex;
+    justify-content: space-around;
+    width: 100%;
+    border-bottom: 2rpx solid #ccc;
+    text-align: center;
+    height: 88rpx;
+    line-height: 88rpx;
+    font-weight: bold;
+    background-color: var(--rgbfff);
+}
+
+.tab .swiper-tab .swiper-tab-item {
+    color: var(--rgb3AB);
+}
+
+.tab .swiper {
+    width: 100%;
+    height: 84vh;
+}
+
+.active {
+    color: var(--rgb40E) !important;
+    border-bottom: 4rpx solid var(--rgb40E);
+}

+ 2 - 17
pages/index/index.js

@@ -7,11 +7,11 @@ Page({
     data: {
         logo: ''
     },
-    
+
     /**
      * 生命周期函数--监听页面加载
      */
-    async onLoad(options) {},
+    async onLoad(options) { },
 
     /**
      * 生命周期函数--监听页面初次渲染完成
@@ -55,21 +55,6 @@ Page({
                 } else {
                     wx.showToast({ title: `${aee.errmsg}`, icon: 'none' });
                 }
-                // wx.getStorage({
-                //     key: 'openid',
-                //     success(res) {
-                //         if (res.data) wx.redirectTo({ url: '/pagesHome/home/index' })
-                //     },
-                //     async fail(err) {
-                //         const aee = await app.$api('token/app', 'GET', { js_code: js_code, config: wx_config.config });
-                //         if (aee.errcode == '0') {
-                //             wx.setStorage({ key: "openid", data: aee.data.openid })
-                //             wx.redirectTo({ url: '/pagesHome/home/index' })
-                //         } else {
-                //             wx.showToast({ title: `${aee.errmsg}`, icon: 'none' });
-                //         }
-                //     }
-                // })
             },
         });
     },