Browse Source

开发作品页面及公共banner组件

bayi 2 years ago
parent
commit
7ed8c894d1

+ 1 - 1
api/global.js

@@ -13,5 +13,5 @@ module.exports = {
   // 提交任务
   submitTask: data => request('/v3/task', 'post', data),
   // 获取轮播图列表
-  getBannerList: data => request(`/v3/column/${data}`, 'get', data),
+  getBannerList: data => request(`/v3/banner/${data}`, 'get', data),
 }

+ 3 - 3
app.json

@@ -1,5 +1,6 @@
 {
   "pages": [
+    "pages/works/index",
     "pages/index/index",
     "pages/collection/index",
     "pages/personal/index",
@@ -12,8 +13,7 @@
     "pages/my/index",
     "pages/editUser/index",
     "pages/notice/index",
-    "pages/follow/index",
-    "pages/logs/logs"
+    "pages/follow/index"
   ],
   "tabBar": {
     "custom": true,
@@ -24,7 +24,7 @@
       "pagePath": "pages/index/index",
       "text": "推荐"
     }, {
-      "pagePath": "pages/logs/logs",
+      "pagePath": "pages/works/index",
       "text": "作品"
     }]
   },

+ 29 - 0
components/banner/index.js

@@ -0,0 +1,29 @@
+import {
+  getBannerList
+} from '~/api/global'
+Component({
+  properties: {
+
+  },
+  data: {
+    bannerList: []
+  },
+  lifetimes: {
+    attached() {
+      console.log('111');
+    },
+  },
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    async getBannerList() {
+      let bannerList = await getBannerList(1)
+      console.log(bannerList);
+      this.setData({
+        bannerList
+      })
+    },
+    bannelEvent() {},
+  }
+})

+ 4 - 0
components/banner/index.json

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

+ 29 - 0
components/banner/index.less

@@ -0,0 +1,29 @@
+.header {
+  position: relative;
+
+  .headerBg {
+    position: absolute;
+    z-index: -2;
+    width: 100%;
+    height: 100%;
+    background-color: white;
+  }
+
+  .swiper {
+    margin: 0 auto;
+    width: 710rpx;
+    height: 216rpx;
+    border-radius: 20rpx;
+    overflow: hidden;
+    box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
+
+    .swiper-item {
+      width: 100%;
+      height: 100%;
+      border-radius: 20rpx;
+      overflow: hidden;
+      object-fit: cover;
+    }
+
+  }
+}

+ 10 - 0
components/banner/index.wxml

@@ -0,0 +1,10 @@
+<view class="header">
+  <view class="headerBg"></view>
+  <swiper class="swiper" autoplay circular indicator-dots indicator-active-color="#fff" indicator-color='#ecececa1'>
+    <block wx:for="{{bannerList}}" wx:key="id">
+      <swiper-item bindtap='bannelEvent'>
+        <image src="{{item.icon}}" class="swiper-item" mode="" />
+      </swiper-item>
+    </block>
+  </swiper>
+</view>

+ 25 - 0
components/banner/index.wxss

@@ -0,0 +1,25 @@
+.header {
+  position: relative;
+}
+.header .headerBg {
+  position: absolute;
+  z-index: -2;
+  width: 100%;
+  height: 100%;
+  background-color: white;
+}
+.header .swiper {
+  margin: 0 auto;
+  width: 710rpx;
+  height: 216rpx;
+  border-radius: 20rpx;
+  overflow: hidden;
+  box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
+}
+.header .swiper .swiper-item {
+  width: 100%;
+  height: 100%;
+  border-radius: 20rpx;
+  overflow: hidden;
+  object-fit: cover;
+}

+ 1 - 1
custom-tab-bar/index.js

@@ -25,7 +25,7 @@ Component({
             "iconPath": "/static/tj.png",
             "selectedIconPath": "/static/tj2.png"
         }, {
-            "pagePath": "/pages/logs/logs",
+            "pagePath": "/pages/works/index",
             "text": "作品",
             "iconPath": "/static/zp.png",
             "selectedIconPath": "/static/zp2.png"

+ 2 - 2
pages/index/index.js

@@ -49,8 +49,8 @@ Page({
       },
     })
     this.storeBindings.updateStoreBindings()
-    // let res = await getBannerList()
-    // console.log(res);
+    /*  let res = await getBannerList(1)
+     console.log(res); */
   },
   loadMore() {
     if (this.data.currentType == '1') {

+ 0 - 1
pages/index/index.json

@@ -6,5 +6,4 @@
   },
   "navigationStyle": "custom",
   "enablePullDownRefresh": false
-
 }

+ 1 - 1
pages/index/index.wxml

@@ -1,6 +1,6 @@
 <navigationBar bind:reload='resetData'></navigationBar>
 <view class="recommend">
-  <!-- 头部及轮播图 -->
+  <!-- 轮播图 -->
   <view class="header">
     <view class="headerBg"></view>
     <swiper class="swiper" autoplay circular indicator-dots indicator-active-color="#fff" indicator-color='#ecececa1'>

+ 0 - 18
pages/logs/logs.js

@@ -1,18 +0,0 @@
-// logs.js
-const util = require('../../utils/util.js')
-
-Page({
-  data: {
-    logs: []
-  },
-  onLoad() {
-    this.setData({
-      logs: (wx.getStorageSync('logs') || []).map(log => {
-        return {
-          date: util.formatTime(new Date(log)),
-          timeStamp: log
-        }
-      })
-    })
-  }
-})

+ 0 - 4
pages/logs/logs.json

@@ -1,4 +0,0 @@
-{
-  "navigationBarTitleText": "查看启动日志",
-  "usingComponents": {}
-}

+ 0 - 6
pages/logs/logs.wxml

@@ -1,6 +0,0 @@
-<!--logs.wxml-->
-<view class="container log-list">
-  <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
-    <text class="log-item">{{index + 1}}. {{log.date}}</text>
-  </block>
-</view>

+ 0 - 8
pages/logs/logs.wxss

@@ -1,8 +0,0 @@
-.log-list {
-  display: flex;
-  flex-direction: column;
-  padding: 40rpx;
-}
-.log-item {
-  margin: 10rpx;
-}

+ 32 - 0
pages/works/index.js

@@ -0,0 +1,32 @@
+const app = getApp()
+import {
+  getBannerList
+} from '~/api/global'
+Page({
+  data: {
+    bannerList: []
+  },
+  onShow() {
+    if (typeof this.getTabBar === 'function') {
+      this.getTabBar().setData({
+        selected: 2
+      })
+    }
+    getApp().callBack = (res) => {
+    }
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 8 - 0
pages/works/index.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+    "navigationBar": "/components/navigationBar/index",
+    "worksList": "/components/worksList/index",
+    "banner": "/components/banner/index"
+  },
+  "navigationStyle": "custom"
+}

+ 3 - 0
pages/works/index.less

@@ -0,0 +1,3 @@
+.worksBox {
+
+}

+ 5 - 0
pages/works/index.wxml

@@ -0,0 +1,5 @@
+<navigationBar bind:reload='resetData'></navigationBar>
+<view class="worksBox">
+  <!-- 轮播图 -->
+  <banner />
+</view>

+ 0 - 0
pages/works/index.wxss