• 使用微信小程序编写会议OA项目-首页



    目录

    一.什么是flwx布局

    二.flex属性 

    三.轮播图后台数据获取及组件使用 

    四.首页布局 


    一.什么是flwx布局

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

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

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

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

     

    在app.json中编写 pages

    1. "pages":[
    2. "pages/index/index",
    3. "pages/meeting/list/list",
    4. "pages/vote/list/list",
    5. "pages/ucenter/index/index",
    6. "pages/logs/logs"
    7. ],
    1. "tabBar": {
    2. "list": [{
    3. "pagePath": "pages/index/index",
    4. "text": "首页",
    5. "iconPath": "/static/tabBar/coding.png",
    6. "selectedIconPath": "/static/tabBar/coding-active.png"
    7. },
    8. {
    9. "pagePath": "pages/meeting/list/list",
    10. "iconPath": "/static/tabBar/sdk.png",
    11. "selectedIconPath": "/static/tabBar/sdk-active.png",
    12. "text": "会议"
    13. },
    14. {
    15. "pagePath": "pages/vote/list/list",
    16. "iconPath": "/static/tabBar/template.png",
    17. "selectedIconPath": "/static/tabBar/template-active.png",
    18. "text": "投票"
    19. },
    20. {
    21. "pagePath": "pages/ucenter/index/index",
    22. "iconPath": "/static/tabBar/component.png",
    23. "selectedIconPath": "/static/tabBar/component-active.png",
    24. "text": "设置"
    25. }]
    26. },

     list.wxml中编写投票管理

     

    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

    在list.wxss中编写样式 

    1. /* pages/vote/list/list.wxss */
    2. .box{
    3. height: 750rpx;
    4. width: 750rpx;
    5. background-color: aqua;
    6. display: flex;
    7. /* flex-direction: column; */
    8. /* flex-direction: column-reverse; */
    9. flex-wrap: wrap;
    10. /* flex-flow: row wrap; */
    11. /* justify-content: flex-end; */
    12. /* align-items: flex-end; */
    13. }
    14. view{
    15. height: 100rpx;
    16. width: 100rpx;
    17. border: 1px solid red;
    18. }

     

    二.flex属性 

    flex-direction 主轴的方向 

     flex-wrap 如果一条轴线排不下,如何换行

     

    flex-flow 是flex-direction属性和flex-wrap属性的简写形式 

     

    justify-content 定义了项目在主轴上的对齐方式 

     

    align-items 定义项目在交叉轴上如何对齐 

     

    三.轮播图后台数据获取及组件使用 

    在app.js中编写url路径

    1. // 以下是业务服务器API地址
    2. // 本机开发API地址
    3. var WxApiRoot = 'http://localhost:8080/demo/wx/';
    4. // 测试环境部署api地址
    5. // var WxApiRoot = 'http://192.168.0.101:8070/demo/wx/';
    6. // 线上平台api地址
    7. //var WxApiRoot = 'https://www.oa-mini.com/demo/wx/';
    8. module.exports = {
    9. IndexUrl: WxApiRoot + 'home/index', //首页数据接口
    10. SwiperImgs: WxApiRoot+'swiperImgs', //轮播图
    11. MettingInfos: WxApiRoot+'meeting/list', //会议信息
    12. };

    在index.js中获取轮播图 

    1. // 获取应用实例
    2. const app = getApp()
    3. const api=require("../../config/app.js")
    4. Page({
    5. data: {
    6. imgSrcs:[]
    7. },
    1. loadSwiperImgs(){
    2. let that=this;
    3. wx.request({
    4. url: api.SwiperImgs,
    5. dataType: 'json',
    6. success(res) {
    7. console.log(res)
    8. that.setData({
    9. imgSrcs:res.data.images
    10. })
    11. }
    12. })
    13. },
    14. onLoad() {
    15. if (wx.getUserProfile) {
    16. this.setData({
    17. canIUseGetUserProfile: true
    18. })
    19. }
    20. this.loadSwiperImgs();
    21. },

    中途会报几个小错,使用Mock解决 

     

    Json数据包代码如下 

     

    1. {
    2. "data": {
    3. "images":[
    4. {
    5. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner1.png",
    6. "text": "1"
    7. },
    8. {
    9. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner2.png",
    10. "text": "2"
    11. },
    12. {
    13. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner3.png",
    14. "text": "3"
    15. },
    16. {
    17. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner4.png",
    18. "text": "4"
    19. },
    20. {
    21. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner5.png",
    22. "text": "5"
    23. },
    24. {
    25. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner6.png",
    26. "text": "6"
    27. }
    28. ]
    29. },
    30. "statusCode": "200",
    31. "header": {
    32. "content-type":"applicaiton/json;charset=utf-8"
    33. }
    34. }

    在index.wxml中编写 

    1. "true" autoplay="true" >
    2. for="{{imgSrcs}}" wx:key="*text">
    3. " {{item.img}}">

    测试结果 

    四.首页布局 

    在index.js中添加内容

    1. lists:[
    2. {
    3. "id": "1",
    4. "image": "/static/persons/1.jpg",
    5. "title": "对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】",
    6. "num":"304",
    7. "state":"进行中",
    8. "starttime": "2022-03-13 00:00:00",
    9. "location": "深圳市·南山区"
    10. },
    11. {
    12. "id": "1",
    13. "image": "/static/persons/2.jpg",
    14. "title": "AI WORLD 2016世界人工智能大会",
    15. "num":"380",
    16. "state":"已结束",
    17. "starttime": "2022-03-15 00:00:00",
    18. "location": "北京市·朝阳区"
    19. },
    20. {
    21. "id": "1",
    22. "image": "/static/persons/3.jpg",
    23. "title": "H100太空商业大会",
    24. "num":"500",
    25. "state":"进行中",
    26. "starttime": "2022-03-13 00:00:00",
    27. "location": "大连市"
    28. },
    29. {
    30. "id": "1",
    31. "image": "/static/persons/4.jpg",
    32. "title": "报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”",
    33. "num":"150",
    34. "state":"已结束",
    35. "starttime": "2022-03-13 00:00:00",
    36. "location": "北京市·朝阳区"
    37. },
    38. {
    39. "id": "1",
    40. "image": "/static/persons/5.jpg",
    41. "title": "新质生活 · 品质时代 2016消费升级创新大会",
    42. "num":"217",
    43. "state":"进行中",
    44. "starttime": "2022-03-13 00:00:00",
    45. "location": "北京市·朝阳区"
    46. }
    47. ]

    在index.wxml中 将:

    "list-info">{{item.address}}|{{item.time}}

    修改为: 

     "list-info">{{item.location}}|{{item.starttime}}

    在index.wxss中调试样式 

    1. /**index.wxss**/
    2. .mobi-title{
    3. background-color: green;
    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: aqua;
    13. }
    14. .list{
    15. display: flex;
    16. align-items: center;
    17. /* background-color: yellowgreen; */
    18. border-bottom: 3px solid yellowgreen;
    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: 2px solid red;
    39. padding: 3px 6px;
    40. color: red;
    41. margin:0 5px 10px 0;
    42. }
    43. .join{
    44. color: yellowgreen;
    45. }
    46. .list-num{
    47. color: aqua;
    48. font-weight: 700;
    49. }
    50. .list-info{
    51. color: yellowgreen;
    52. font-size: 12px;
    53. }

    测试结果 

     

     

     

  • 相关阅读:
    iOS_Custom Transition Animation 自定义转场动画
    Matlab杂项记录
    第六章 图 十、关键路径
    学Python如此简单--OS模块
    Tomcat10的坑
    HTML Component Library for Delphi
    Vue开发 提交后台,二维码,自定义
    Dockerfile自定义容器
    D. Fixed Point Guessing(二分+交互式问题)
    设计模式——迭代器模式
  • 原文地址:https://blog.csdn.net/2201_75455485/article/details/133881477