• 会议OA小程序【会议管理,个人中心页面布局】


    目录

    一. 自定义组件介绍

    1.1 概念

    1.2 创建自定义组件

    二. 会议管理页面布局

    使用自定义组件

    页面布局及样式

    三. 个人中心页面布局


    一. 自定义组件介绍

    1.1 概念

    小程序基础库版本 1.6.3 开始,小程序支持简洁的组件化编程。所有自定义组件相关特性都需要基础库版本 1.6.3 或更高。

    开发者可以将页面内的功能模块抽象成自定义组件,以便在不同的页面中重复使用;也可以将复杂的页面拆分成多个低耦合的模块,有助于代码维护。自定义组件在使用时与基础组件非常相似。

    1.2 创建自定义组件

    类似于页面,一个自定义组件由 json, wxml ,wxss ,js 4个文件组成。要编写一个自定义组件,首先需要在 json 文件中进行自定义组件声明(将 component 字段设为 true 可将这一组文件设为自定义组件):

    1. {
    2. "component": true
    3. }

     同时,还要在 wxml 文件中编写组件模板,在 wxss 文件中加入组件样式,它们的写法与页面的写法类似。

    代码示例:

    1. <!--components/tabs/tabs.wxml-->
    2. <view class="tabs">
    3. <view class="tabs_title">
    4. <view wx:for="{{tabList}}" wx:key="id" class="title_item {{index==tabIndex?'item_active':''}}" bindtap="handleItemTap" data-index="{{index}}">
    5. <view style="margin-bottom:5rpx">{{item}}</view>
    6. <view style="width:30px" class="{{index==tabIndex?'item_active1':''}}"></view>
    7. </view>
    8. </view>
    9. <view class="tabs_content">
    10. <slot></slot>
    11. </view>
    12. </view>
    1. /* components/tabs/tabs.wxss */
    2. .tabs {
    3. position: fixed;
    4. top: 0;
    5. width: 100%;
    6. background-color: #fff;
    7. z-index: 99;
    8. border-bottom: 1px solid #efefef;
    9. padding-bottom: 20rpx;
    10. }
    11. .tabs_title {
    12. /* width: 400rpx; */
    13. width: 90%;
    14. display: flex;
    15. font-size: 9pt;
    16. padding: 0 20rpx;
    17. }
    18. .title_item {
    19. color: #999;
    20. padding: 15rpx 0;
    21. display: flex;
    22. flex: 1;
    23. flex-flow: column nowrap;
    24. justify-content: center;
    25. align-items: center;
    26. }
    27. .item_active {
    28. /* color:#ED8137; */
    29. color: #000000;
    30. font-size: 11pt;
    31. font-weight: 800;
    32. }
    33. .item_active1 {
    34. /* color:#ED8137; */
    35. color: #000000;
    36. font-size: 11pt;
    37. font-weight: 800;
    38. border-bottom: 6rpx solid #333;
    39. border-radius: 2px;
    40. }

    注意:在组件wxss中不应使用ID选择器、属性选择器和标签名选择器。 

    在自定义组件的 js 文件中,需要使用 Component() 来注册组件,并提供组件的属性定义、内部数据和自定义方法。

    组件的属性值和内部数据将被用于组件 wxml 的渲染,其中,属性值是可由组件外部传入的。

    代码示例:

    1. // components/tabs/tabs.js
    2. Component({
    3. /**
    4. * 组件的属性列表
    5. */
    6. properties: {
    7. tabList:Object
    8. },
    9. /**
    10. * 组件的初始数据
    11. */
    12. data: {
    13. },
    14. /**
    15. * 组件的方法列表
    16. */
    17. methods: {
    18. handleItemTap(e){
    19. // 获取索引
    20. const {index} = e.currentTarget.dataset;
    21. // 触发 父组件的事件
    22. this.triggerEvent("tabsItemChange",{index})
    23. this.setData({
    24. tabIndex:index
    25. })
    26. }
    27. }
    28. })

    更多详细内容参见微信小程序自定义组件 

    二. 会议管理页面布局

    在project.config.json中添加以下代码防止项目出现报错 

    1. "ignoreDevUnusedFiles": false,
    2. "ignoreUploadUnusedFiles": false,

    使用自定义组件

    list.json

    1. {
    2. "usingComponents": {
    3. "tabs":"/components/tabs/tabs"
    4. }
    5. }

    页面布局及样式

    list.wxml

    1. <!--pages/meeting/list/list.wxml-->
    2. <tabs tabList="{{tabs}}" bindtabsItemChange="tabsItemChange">
    3. </tabs>
    4. <view style="height: 100rpx;"></view>
    5. <block wx:for-items="{{lists}}" wx:for-item="item" wx:key="item.id">
    6. <view class="list" data-id="{{item.id}}">
    7. <view class="list-img al-center">
    8. <image class="video-img" mode="scaleToFill" src="{{item.image}}"></image>
    9. </view>
    10. <view class="list-detail">
    11. <view class="list-title"><text>{{item.title}}</text></view>
    12. <view class="list-tag">
    13. <view class="state al-center">{{item.state}}</view>
    14. <view class="join al-center"><text class="list-num">{{item.num}}</text>人报名</view>
    15. </view>
    16. <view class="list-info"><text>{{item.address}}</text>|<text>{{item.time}}</text></view>
    17. </view>
    18. </view>
    19. </block>

    list.wxss

    1. /* pages/meeting/list/list.wxss */
    2. .mobi-title {
    3. font-size: 12pt;
    4. color: #777;
    5. line-height: 110%;
    6. font-weight: bold;
    7. width: 100%;
    8. padding: 15rpx;
    9. background-color: #f3f3f3;
    10. }
    11. .mobi-icon {
    12. padding: 0rpx 3rpx;
    13. border-radius: 3rpx;
    14. background-color: #ff7777;
    15. position: relative;
    16. margin-right: 10rpx;
    17. }
    18. /*list*/
    19. .list {
    20. display: flex;
    21. flex-direction: row;
    22. width: 100%;
    23. padding: 0 20rpx 0 0;
    24. border-top: 1px solid #eeeeee;
    25. background-color: #fff;
    26. margin-bottom: 5rpx;
    27. /* border-radius: 20rpx;
    28. box-shadow: 0px 0px 10px 6px rgba(0,0,0,0.1); */
    29. }
    30. .list-img {
    31. display: flex;
    32. margin: 10rpx 10rpx;
    33. width: 150rpx;
    34. height: 220rpx;
    35. justify-content: center;
    36. align-items: center;
    37. }
    38. .list-img .video-img {
    39. width: 120rpx;
    40. height: 120rpx;
    41. }
    42. .list-detail {
    43. margin: 10rpx 10rpx;
    44. display: flex;
    45. flex-direction: column;
    46. width: 600rpx;
    47. height: 220rpx;
    48. }
    49. .list-title text {
    50. font-size: 11pt;
    51. color: #333;
    52. font-weight: bold;
    53. }
    54. .list-detail .list-tag {
    55. display: flex;
    56. height: 70rpx;
    57. }
    58. .list-tag .state {
    59. font-size: 9pt;
    60. color: #81aaf7;
    61. width: 120rpx;
    62. border: 1px solid #93b9ff;
    63. border-radius: 2px;
    64. margin: 10rpx 0rpx;
    65. display: flex;
    66. justify-content: center;
    67. align-items: center;
    68. }
    69. .list-tag .join {
    70. font-size: 11pt;
    71. color: #bbb;
    72. margin-left: 20rpx;
    73. display: flex;
    74. justify-content: center;
    75. align-items: center;
    76. }
    77. .list-tag .list-num {
    78. font-size: 11pt;
    79. color: #ff6666;
    80. }
    81. .list-info {
    82. font-size: 9pt;
    83. color: #bbb;
    84. margin-top: 20rpx;
    85. }
    86. .bottom-line{
    87. display: flex;
    88. height: 60rpx;
    89. justify-content: center;
    90. align-items: center;
    91. background-color: #f3f3f3;
    92. }
    93. .bottom-line text{
    94. font-size: 9pt;
    95. color: #666;
    96. }

    list.js

    1. // pages/meeting/list/list.js
    2. Page({
    3. /**
    4. * 页面的初始数据
    5. */
    6. data: {
    7. tabs:['会议中','已完成','已取消','全部会议'],
    8. lists: [
    9. {
    10. 'id': '1',
    11. 'image': '/static/persons/1.jpg',
    12. 'title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】',
    13. 'num':'304',
    14. 'state':'进行中',
    15. 'time': '10月09日 17:59',
    16. 'address': '深圳市·南山区'
    17. },
    18. {
    19. 'id': '1',
    20. 'image': '/static/persons/2.jpg',
    21. 'title': 'AI WORLD 2016世界人工智能大会',
    22. 'num':'380',
    23. 'state':'已结束',
    24. 'time': '10月09日 17:39',
    25. 'address': '北京市·朝阳区'
    26. },
    27. {
    28. 'id': '1',
    29. 'image': '/static/persons/3.jpg',
    30. 'title': 'H100太空商业大会',
    31. 'num':'500',
    32. 'state':'进行中',
    33. 'time': '10月09日 17:31',
    34. 'address': '大连市'
    35. },
    36. {
    37. 'id': '1',
    38. 'image': '/static/persons/4.jpg',
    39. 'title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”',
    40. 'num':'150',
    41. 'state':'已结束',
    42. 'time': '10月09日 17:21',
    43. 'address': '北京市·朝阳区'
    44. },
    45. {
    46. 'id': '1',
    47. 'image': '/static/persons/5.jpg',
    48. 'title': '新质生活 · 品质时代 2016消费升级创新大会',
    49. 'num':'217',
    50. 'state':'进行中',
    51. 'time': '10月09日 16:59',
    52. 'address': '北京市·朝阳区'
    53. }
    54. ],
    55. lists1: [
    56. {
    57. 'id': '1',
    58. 'image': '/static/persons/1.jpg',
    59. 'title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】',
    60. 'num':'304',
    61. 'state':'进行中',
    62. 'time': '10月09日 17:59',
    63. 'address': '深圳市·南山区'
    64. },
    65. {
    66. 'id': '1',
    67. 'image': '/static/persons/2.jpg',
    68. 'title': 'AI WORLD 2016世界人工智能大会',
    69. 'num':'380',
    70. 'state':'已结束',
    71. 'time': '10月09日 17:39',
    72. 'address': '北京市·朝阳区'
    73. },
    74. {
    75. 'id': '1',
    76. 'image': '/static/persons/3.jpg',
    77. 'title': 'H100太空商业大会',
    78. 'num':'500',
    79. 'state':'进行中',
    80. 'time': '10月09日 17:31',
    81. 'address': '大连市'
    82. }
    83. ],
    84. lists2: [
    85. {
    86. 'id': '1',
    87. 'image': '/static/persons/1.jpg',
    88. 'title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】',
    89. 'num':'304',
    90. 'state':'进行中',
    91. 'time': '10月09日 17:59',
    92. 'address': '深圳市·南山区'
    93. },
    94. {
    95. 'id': '1',
    96. 'image': '/static/persons/2.jpg',
    97. 'title': 'AI WORLD 2016世界人工智能大会',
    98. 'num':'380',
    99. 'state':'已结束',
    100. 'time': '10月09日 17:39',
    101. 'address': '北京市·朝阳区'
    102. }
    103. ],
    104. lists3: [
    105. {
    106. 'id': '1',
    107. 'image': '/static/persons/1.jpg',
    108. 'title': '对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】',
    109. 'num':'304',
    110. 'state':'进行中',
    111. 'time': '10月09日 17:59',
    112. 'address': '深圳市·南山区'
    113. },
    114. {
    115. 'id': '1',
    116. 'image': '/static/persons/2.jpg',
    117. 'title': 'AI WORLD 2016世界人工智能大会',
    118. 'num':'380',
    119. 'state':'已结束',
    120. 'time': '10月09日 17:39',
    121. 'address': '北京市·朝阳区'
    122. },
    123. {
    124. 'id': '1',
    125. 'image': '/static/persons/3.jpg',
    126. 'title': 'H100太空商业大会',
    127. 'num':'500',
    128. 'state':'进行中',
    129. 'time': '10月09日 17:31',
    130. 'address': '大连市'
    131. },
    132. {
    133. 'id': '1',
    134. 'image': '/static/persons/4.jpg',
    135. 'title': '报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”',
    136. 'num':'150',
    137. 'state':'已结束',
    138. 'time': '10月09日 17:21',
    139. 'address': '北京市·朝阳区'
    140. },
    141. {
    142. 'id': '1',
    143. 'image': '/static/persons/5.jpg',
    144. 'title': '新质生活 · 品质时代 2016消费升级创新大会',
    145. 'num':'217',
    146. 'state':'进行中',
    147. 'time': '10月09日 16:59',
    148. 'address': '北京市·朝阳区'
    149. }
    150. ]
    151. },
    152. /**
    153. * 生命周期函数--监听页面加载
    154. */
    155. onLoad(options) {
    156. },
    157. /**
    158. * 生命周期函数--监听页面显示
    159. */
    160. onShow() {
    161. },
    162. tabsItemChange(e){
    163. let tolists;
    164. if(e.detail.index==1){
    165. tolists = this.data.lists1;
    166. }else if(e.detail.index==2){
    167. tolists = this.data.lists2;
    168. }else{
    169. tolists = this.data.lists3;
    170. }
    171. this.setData({
    172. lists: tolists
    173. })
    174. }
    175. })

    效果展示

     

    三. 个人中心页面布局

    index.wxml

    1. <!--pages/ucenter/index/index.wxml-->
    2. <!-- <text>pages/ucenter/index/index.wxml</text> -->
    3. <view class="userInfo">
    4. <image class="userInfo-head" src="/static/images/avatar.png"></image>
    5. <text class="userInfo-login">用户登录</text>
    6. <text class="userInfo-set">修改</text>
    7. </view>
    8. <view class="cells">
    9. <view class="cell-items1">
    10. <image src="/static/tabBar/sdk.png" class="cell-items-icon"></image>
    11. <text class="cell-items-title">我主持的会议</text>
    12. <text class="cell-items-num">1</text>
    13. <text class="cell-items-detail"></text>
    14. </view>
    15. <hr/>
    16. <view class="cell-items2">
    17. <image src="/static/tabBar/sdk.png" class="cell-items-icon"></image>
    18. <text class="cell-items-title2">我参与的会议</text>
    19. <text class="cell-items-num">1</text>
    20. <text class="cell-items-detail"></text>
    21. </view>
    22. </view>
    23. <view class="cells">
    24. <view class="cell-items1">
    25. <image src="/static/tabBar/sdk.png" class="cell-items-icon"></image>
    26. <text class="cell-items-title">我发布的投票</text>
    27. <text class="cell-items-num">1</text>
    28. <text class="cell-items-detail"></text>
    29. </view>
    30. <hr/>
    31. <view class="cell-items2">
    32. <image src="/static/tabBar/sdk.png" class="cell-items-icon"></image>
    33. <text class="cell-items-title2">我参与的投票</text>
    34. <text class="cell-items-num">1</text>
    35. <text class="cell-items-detail"></text>
    36. </view>
    37. </view>
    38. <view class="cells">
    39. <view class="cell-items1">
    40. <image src="/static/tabBar/sdk.png" class="cell-items-icon"></image>
    41. <text space="ensp" class="cell-items-title">消 息</text>
    42. <text class="cell-items-num">1</text>
    43. <text class="cell-items-detail"></text>
    44. </view>
    45. <hr/>
    46. <view class="cell-items2">
    47. <image src="/static/tabBar/sdk.png" class="cell-items-icon"></image>
    48. <text space="ensp" class="cell-items-title2">设 置</text>
    49. <text class="cell-items-num">1</text>
    50. <text class="cell-items-detail"></text>
    51. </view>
    52. </view>

    index.wxss

    1. /* pages/ucenter/index/index.wxss */
    2. Page{
    3. background-color: rgba(135, 206, 250, 0.075);
    4. }
    5. .userInfo{
    6. display: flex;
    7. height: 300rpx;
    8. width: 100%;
    9. background-color: #fff;
    10. border-bottom: 15px solid lightgray;
    11. }
    12. .userInfo-head{
    13. height: 250rpx;
    14. width: 250rpx;
    15. margin: 20rpx;
    16. }
    17. .userInfo-login{
    18. width: 400rpx;
    19. margin:150rpx 20rpx;
    20. }
    21. .userInfo-set{
    22. /* height: 100rpx; */
    23. width: 100rpx;
    24. margin:150rpx 20rpx;
    25. }
    26. .cells{
    27. background-color: #fff;
    28. height: 270rpx;
    29. }
    30. .cell-items1,.cell-items2{
    31. height: 120rpx;
    32. display: flex;
    33. /* margin: 30rpx 0 0 0; */
    34. /* border-bottom: 1px solid lightskyblue; */
    35. }
    36. .cell-items2{
    37. /* height: 120rpx;
    38. display: flex;
    39. margin: 20rpx 0 0 0; */
    40. border-bottom: 15px solid lightgray;
    41. }
    42. .cell-items-icon{
    43. height: 80rpx;
    44. width: 80rpx;
    45. margin: 15rpx;
    46. }
    47. .cell-items-title{
    48. display: flex;
    49. font-weight: 700;
    50. font-size: 15px;
    51. /* margin: 20rpx 0 0 50rpx; */
    52. margin-top: 10rpx;
    53. padding: 15rpx;
    54. }
    55. .cell-items-title2{
    56. display: flex;
    57. font-weight: 700;
    58. font-size: 15px;
    59. margin-top: 10rpx;
    60. /* align-items: center; */
    61. padding: 15rpx;
    62. /* border-top: 20rpx; */
    63. }
    64. .cell-items-num{
    65. margin: 20rpx 0 0 300rpx;
    66. }
    67. .cell-items-detail{
    68. margin: 20rpx 0 0 20rpx;
    69. }
    70. .cells > hr{
    71. display: block;
    72. height: 1px;
    73. background-color: rgba(135, 206, 250, 0.075);
    74. }

    效果展示

     

  • 相关阅读:
    【2023,学点儿新Java-48】变量与运算符 (阶段性复习):关键字和保留,回顾:标识符的命名规则,变量的基本使用
    活动回顾 | 基于英特尔技术的端到端音视频优化
    LLm微调使用的数据集
    ①【数据库操作】 MySQL数据库的查询、创建、删除、使用。
    从普通查询商品到高并发查询商品的优化思路
    React-性能优化的手段
    淘宝退货退款测试用例
    [附源码]计算机毕业设计JAVA教师业绩考核系统
    基于android实现的在线投票App毕业设计源码
    【ESP32_8266_WiFi (十三)】ESP8266自动配网 – WiFiManager库使用说明
  • 原文地址:https://blog.csdn.net/lijie1025/article/details/133902756