• 微信小程序开发的OA会议之会议个人中心的页面搭建及模板,自定义组件的学习


    目录

    一.自定义组件及会议效果编写

    效果显示 

     二.个人中心布局

    编写结果

    ​编辑 


    一.自定义组件及会议效果编写

    在页面中创建一个以components命名的项目来存放组件

    再在components文件夹中创建一个组件,名为 :tabs ,创建操作如图所示

     

    刚刚创建好会报一个编码错误我们需要在项目的 project.config.json 文件中的setting属性中进行配置,增加以下两个配置 :

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

    需要在哪个页面中进行使用,就需要在哪个页面中进行引用配置

    如下图所示 

     

     

    在 tabs.json 中编写:  

    1. {
    2. "component": true,
    3. "usingComponents": {}
    4. }

    在 tabs.wxml 中进行编写模板: 

    1. <view class="tabs">
    2. <view class="tabs_title">
    3. <view wx:for="{{tabList}}" wx:key="id" class="title_item {{index==tabIndex?'item_active':''}}" bindtap="handleItemTap" data-index="{{index}}">
    4. <view style="margin-bottom:5rpx">{{item}}view>
    5. <view style="width:30px" class="{{index==tabIndex?'item_active1':''}}">view>
    6. view>
    7. view>
    8. <view class="tabs_content">
    9. <slot>slot>
    10. view>
    11. view>

    在 tabs.js 中进行编写需要功能 : 

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

     在 tabs.wxss 中进行编写样式:

    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. }

    在会议页面.json (meeting/list/list.json)中增加以下设置

     

    再 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. })

     在 list.wxml中使用  

     

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

    在会议的 list.wxss  中进行编写样式

    1. /* pages/meeting/list/list.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. }

    到这里自定义组件将会议的页面搭建以及效果显示完成

    效果显示 

     

     二.个人中心布局

     ucenter/index/index.wxml进行页面显示编写

    1. <view class="user">
    2. <image class="user-img" src="/static/persons/2.jpg">image>
    3. <view class="user-name">Fithe.view>
    4. <text class="user-up">修改text>
    5. view>
    6. <view class="cells">
    7. <view class="cell-items">
    8. <image src="/static/tabBar/sdk.png" class="cell-items-icon">image>
    9. <text class="cell-items-title">我主持的会议text>
    10. <text class="cell-items-num">1text>
    11. <text class="cell-items-detail">text>
    12. view>
    13. <view style="height: 5rpx;background-color: rgba(135, 206, 250, 0.075);">view>
    14. <view class="cell-items">
    15. <image src="/static/tabBar/sdk.png" class="cell-items-icon">image>
    16. <text class="cell-items-title">我参与的会议text>
    17. <text class="cell-items-num">10text>
    18. <text class="cell-items-detail">text>
    19. view>
    20. view>
    21. <view style="height: 27rpx;background-color: rgba(135, 206, 250, 0.075);">view>
    22. <view class="cells">
    23. <view class="cell-items">
    24. <image src="/static/tabBar/sdk.png" class="cell-items-icon">image>
    25. <text class="cell-items-title">我发布的投票text>
    26. <text class="cell-items-num">1text>
    27. <text class="cell-items-detail">text>
    28. view>
    29. <view style="height: 5rpx;background-color: rgba(135, 206, 250, 0.075);">view>
    30. <view class="cell-items">
    31. <image src="/static/tabBar/sdk.png" class="cell-items-icon">image>
    32. <text class="cell-items-title">我参与的投票text>
    33. <text class="cell-items-num">10text>
    34. <text class="cell-items-detail">text>
    35. view>
    36. view>
    37. <view style="height: 27rpx;background-color: rgba(135, 206, 250, 0.075);">view>
    38. <view class="cells">
    39. <view class="cell-items">
    40. <image src="/static/tabBar/template.png" class="cell-items-icon">image>
    41. <text class="cell-items-title">信息text>
    42. <text class="cell-items-ion">text>
    43. view>
    44. <view style="height: 5rpx;background-color: rgba(135, 206, 250, 0.075);">view>
    45. <view class="cell-items">
    46. <image src="/static/tabBar/component.png" class="cell-items-icon">image>
    47. <text class="cell-items-title">设置text>
    48. <text class="cell-items-ion">text>
    49. view>
    50. view>

    在index.wxss中编写样式 

    1. /* pages/ucenter/index/index.wxss */
    2. Page{
    3. background-color: rgba(135, 206, 250, 0.075);
    4. }
    5. .user{
    6. display: flex;
    7. width: 100%;
    8. align-items:center;
    9. background-color: white;
    10. margin-bottom: 28rpx;
    11. }
    12. .user-img{
    13. height: 170rpx;
    14. width: 170rpx;
    15. margin: 30rpx;
    16. border: 1px solid #cdd7ee;
    17. border-radius: 6px;
    18. }
    19. .user-name{
    20. width: 380rpx;
    21. margin-left: 20rpx;
    22. font-weight: 550;
    23. }
    24. .user-up{
    25. color: rgb(136, 133, 133);
    26. }
    27. .cells{
    28. background-color: white;
    29. }
    30. .cell-items{
    31. display: flex;
    32. align-items:center;
    33. height: 110rpx;
    34. }
    35. .cell-items-title{
    36. width: 290rpx;
    37. }
    38. .cell-items-icon{
    39. width: 50rpx;
    40. height: 50rpx;
    41. margin: 20rpx;
    42. }
    43. .cell-items-num{
    44. padding-left: 30rpx;
    45. margin-left: 200rpx;
    46. width: 70rpx;
    47. }
    48. .cell-items-ion{
    49. margin-left: 295rpx;
    50. }
    编写结果
     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    3.应用程序进程启动过程
    记录Centos7.9 安装mongodb 6.0 过程遇到的坑和解决办法
    C++数据结构X篇_18_二叉树的创建(根据遍历结果创建二叉树;#号法创建树)
    【学习笔记】NOIP暴零赛
    leetcode:169多数元素------摩尔投票法
    C++入门01—从hello word!开始
    spark中的cache和checkpoint
    [需求管理-3]:什么是需求分析?常用的需求分析的流程与方法
    中缀表达式转后缀表达式,及含多位负数的中缀表达式计算(中缀转后缀解法)
    Avalon总线协议汇总
  • 原文地址:https://blog.csdn.net/2201_75455485/article/details/133932251