• 会议OA项目-首页->flex弹性布局,轮播图后台数据获取及组件使用(后台数据交互mockjs),首页布局


    • flex弹性布局
    • 轮播图后台数据获取及组件使用(后台数据交互mockjs)
    • 首页布局

    1.flex弹性布局

    什么是flex布局

    1) Flex是Flexible Box的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性

    2) 任何一个容器都可以指定为Flex布局。

    3) display: ‘flex’

    ![](images/3791e575c48b3698be6a94ae1dbff79d.png)

    容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end;交叉轴的开始位置叫做cross start,结束位置叫做cross end。

    项目默认沿主轴排列。单个项目占据的主轴空间叫做main size,占据的交叉轴空间叫做cross size。

    1. //oamin\app.json
    2. {
    3. "pages": [
    4. "pages/index/index",
    5. "pages/meeting/list/list",
    6. "pages/vote/list/list",
    7. "pages/ucenter/index/index",
    8. "pages/logs/logs"
    9. ],
    10. "window": {
    11. "backgroundTextStyle": "light",
    12. "navigationBarBackgroundColor": "#fff",
    13. "navigationBarTitleText": "Weixin",
    14. "navigationBarTextStyle": "black"
    15. },
    16. "tabBar": {
    17. "list": [{
    18. "pagePath": "pages/index/index",
    19. "text": "首页",
    20. "iconPath": "/static/tabBar/coding.png",
    21. "selectedIconPath": "/static/tabBar/coding-active.png"
    22. },
    23. {
    24. "pagePath": "pages/meeting/list/list",
    25. "iconPath": "/static/tabBar/sdk.png",
    26. "selectedIconPath": "/static/tabBar/sdk-active.png",
    27. "text":"会议"
    28. },
    29. {
    30. "pagePath": "pages/vote/list/list",
    31. "iconPath": "/static/tabBar/template.png",
    32. "selectedIconPath": "/static/tabBar/template-active.png",
    33. "text": "投票"
    34. },
    35. {
    36. "pagePath": "pages/ucenter/index/index",
    37. "iconPath": "/static/tabBar/component.png",
    38. "selectedIconPath": "/static/tabBar/component-active.png",
    39. "text": "设置"
    40. }],
    41. "style": "v2",
    42. "sitemapLocation": "sitemap.json"
    43. }
    44. }
    1. "box">
    2. 1
    3. 2
    4. 3
    5. 4
    6. 5
    7. 6
    8. 7
    9. 8
    10. 9
    11. 10
    12. 11
    13. 12
    1. /* pages/vote/list/list.wxss */
    2. .box{
    3. height: 750rpx;
    4. width: 750rpx;
    5. background-color: aquamarine;
    6. display: flex;
    7. /* flex-direction: column; */
    8. /* flex-direction: column-reverse; */
    9. flex-wrap: wrap;
    10. /* flex-flow: row; */
    11. /* flex-flow: row wrap; */
    12. /* justify-content: flex-end; */
    13. align-items: flex-end;
    14. }
    15. view{
    16. height: 100rpx;
    17. width: 100rpx;
    18. border: 1px solid red;
    19. }

    flex属性

    - **flex-direction** 主轴的方向  默认为row
    - flex-wrap 如果一条轴线排不下,如何换行
    - flex-flow  是flex-direction属性和flex-wrap属性的简写形式
    - **justify-content** 定义了项目在主轴上的对齐方式
    - **align-items** 定义项目在交叉轴上如何对齐
    - align-content 属性定义了多根轴线的对齐方式

    注意,设为Flex布局以后,子元素的float、clear和vertical-align属性将失效。

    ### 学习地址(pages/vote/list/list.wxss页面的代码意思在以下链接):

    http://www.runoob.com/w3cnote/flex-grammar.html

    2.轮播图后台数据获取及组件使用(后台数据交互mockjs)

    1. //oamin\config\app.js
    2. // 以下是业务服务器API地址
    3. // 本机开发API地址
    4. var WxApiRoot = 'http://localhost:8080/demo/wx/';
    5. // 测试环境部署api地址
    6. // var WxApiRoot = 'http://192.168.0.101:8070/demo/wx/';
    7. // 线上平台api地址
    8. //var WxApiRoot = 'https://www.oa-mini.com/demo/wx/';
    9. module.exports = {
    10. IndexUrl: WxApiRoot + 'home/index', //首页数据接口
    11. SwiperImgs: WxApiRoot+'swiperImgs', //轮播图
    12. MettingInfos: WxApiRoot+'meeting/list', //会议信息
    13. };
    1. // index.js
    2. // 获取应用实例
    3. const app = getApp()
    4. const api=require("../../config/app.js")
    5. Page({
    6. data: {
    7. imgSrcs:[]
    8. },
    9. // 事件处理函数
    10. bindViewTap() {
    11. wx.navigateTo({
    12. url: '../logs/logs'
    13. })
    14. },
    15. loadSwiperImgs(){
    16. let that=this;
    17. wx.request({
    18. url: api.SwiperImgs,
    19. dataType: 'json',
    20. success(res) {
    21. console.log(res)
    22. that.setData({
    23. imgSrcs:res.data.images
    24. })
    25. }
    26. })
    27. },
    28. onLoad() {
    29. if (wx.getUserProfile) {
    30. this.setData({
    31. canIUseGetUserProfile: true
    32. })
    33. }
    34. this.loadSwiperImgs();
    35. },
    36. getUserProfile(e) {
    37. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
    38. wx.getUserProfile({
    39. desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
    40. success: (res) => {
    41. console.log(res)
    42. this.setData({
    43. userInfo: res.userInfo,
    44. hasUserInfo: true
    45. })
    46. }
    47. })
    48. },
    49. getUserInfo(e) {
    50. // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
    51. console.log(e)
    52. this.setData({
    53. userInfo: e.detail.userInfo,
    54. hasUserInfo: true
    55. })
    56. }
    57. })
    1. "{{true}}" autoplay="{{true}}">
    2. for="{{imgSrcs}}" wx:key="*text">
    3. "{{item.img}}">

    3.首页布局

    1. "{{true}}" autoplay="{{true}}">
    2. for="{{imgSrcs}}" wx:key="*text">
    3. "{{item.img}}">
    4. "mobi-title">
    5. "mobi-icon">
    6. 会议信息
    7. for-items="{{lists}}" wx:for-item="item" wx:key="item.id">
    8. "list" data-id="{{item.id}}">
    9. "list-img">
    10. "video-img" mode="scaleToFill" src="{{item.image}}">
    11. "list-detail">
    12. "list-title">{{item.title}}
    13. "list-tag">
    14. "state">{{item.state}}
    15. "join">"list-num">{{item.num}}人报名
    16. "list-info">{{item.location}}|{{item.starttime}}
    17. "section bottom-line">
    18. 到底啦
    1. /**index.wxss**/
    2. .mobi-title{
    3. background-color: lightgray;
    4. padding: 10px;
    5. }
    6. .mobi-icon{
    7. border:1rpx solid red;
    8. margin-right: 5px;
    9. }
    10. .mobi-title text{
    11. font-weight: 700;
    12. color: #7B7B7B;
    13. }
    14. .list{
    15. display: flex;
    16. align-items: center;
    17. /* background-color: lightblue; */
    18. border-bottom: 3px solid lightgray;
    19. }
    20. .list-img{
    21. padding:0 10px;
    22. }
    23. .video-img{
    24. height: 80px;
    25. width: 80px;
    26. }
    27. .list-detail{
    28. }
    29. .list-title{
    30. font-weight: 700;
    31. margin: 3px 0;
    32. }
    33. .list-tag{
    34. display: flex;
    35. align-items: center;
    36. }
    37. .state{
    38. border:1px solid lightblue;
    39. padding: 3px 6px;
    40. color: lightblue;
    41. margin: 0 5px 10px 0;
    42. }
    43. .join{
    44. color: lightblue;
    45. }
    46. .list-num{
    47. color: red;
    48. font-weight: 700;
    49. }
    50. .list-info{
    51. color: lightblue;
    52. font-size: 12px;
    53. }

  • 相关阅读:
    美团图灵机器学习平台性能起飞的秘密(一)
    socket学习一、socket、bind/connect、listen函数详解
    MySQL中创建partition表的几种方式
    互联网大厂的缓存策略:抵抗超高并发的秘密武器,已开源!
    idea注释代码三种方式
    第三十五章 使用 CSP 进行基于标签的开发 - 使用服务器端方法的提示
    Java随笔-TCP/IP网络数据传输
    软考 系统架构设计师系列知识点之大数据(1)
    Dubbo中的Triple协议和应用级服务发现
    conda环境下pip安装tb_nightly失败解决方案
  • 原文地址:https://blog.csdn.net/weixin_73471776/article/details/133883257