• 微信小程序开发的OA会议之会议,投票,个人中心的页面搭建及模板


    目录

    一.自定义组件

    1.1.创建 

    1.2.定义 

    1.3.编写

    1.4.使用

    二.会议

    2.1.数据

    2.2.显示 

    2.3. 样式

    三.个人中心

    3.1.页面

    3.2.样式

    四.投票

    4.1.引用

    4.2.数据

    4.3.页面

    4.4.样式

                    好啦今天就到这里了,希望能帮到你哦!!!


    一.自定义组件

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

    以下的代码都基于我博客中的 : 

    微信小程序的OA会议之首页搭建icon-default.png?t=N7T8https://blog.csdn.net/m0_74915426/article/details/133936420?spm=1001.2014.3001.5502

    1.1.创建 

    在项目中创建一个名为 : components 的文件,来存放组件

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

    1.2.定义 

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

    在 tabs.json 中编写:  

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

     同时,还要在 wxml 文件中编写组件模板,在 wxss 文件中加入组件样式,它们的写法与页面的写法类似。具体细节和注意事项参见 组件模板和样式 。

    1.3.编写

    在 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. Component({
    3. /**
    4. * 组件的属性列表
    5. */
    6. properties: {
    7. // 这里定义了innerText属性,属性值可以在组件使用时指定
    8. innerText: {
    9. type: String,
    10. value: 'default value'
    11. },
    12. tabList:Object
    13. },
    14. /**
    15. * 组件的初始数据
    16. */
    17. data: {
    18. tabIndex:1
    19. },
    20. /**
    21. * 组件的方法列表
    22. */
    23. methods: {
    24. handleItemTap(e){
    25. // 获取索引
    26. const {index} = e.currentTarget.dataset;
    27. // 触发 父组件的事件
    28. this.triggerEvent("tabsItemChange",{index})
    29. this.setData({
    30. tabIndex:index
    31. })
    32. }
    33. }
    34. })

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

    1. .tabs {
    2. position: fixed;
    3. top: 0;
    4. width: 100%;
    5. background-color: #fff;
    6. z-index: 99;
    7. border-bottom: 1px solid #efefef;
    8. padding-bottom: 20rpx;
    9. }
    10. .tabs_title {
    11. /* width: 400rpx; */
    12. width: 90%;
    13. display: flex;
    14. font-size: 9pt;
    15. padding: 0 20rpx;
    16. }
    17. .title_item {
    18. color: #999;
    19. padding: 15rpx 0;
    20. display: flex;
    21. flex: 1;
    22. flex-flow: column nowrap;
    23. justify-content: center;
    24. align-items: center;
    25. }
    26. .item_active {
    27. /* color:#ED8137; */
    28. color: #000000;
    29. font-size: 11pt;
    30. font-weight: 800;
    31. }
    32. .item_active1 {
    33. /* color:#ED8137; */
    34. color: #000000;
    35. font-size: 11pt;
    36. font-weight: 800;
    37. border-bottom: 6rpx solid #333;
    38. border-radius: 2px;
    39. }

    1.4.使用

    在项目的 project.config.json 文件中的setting属性中进行配置,增加以下两个配置 :

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

    如图:

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

    比如说 : 需要在会议页面中进行使用,就要在  会议页面.json (meeting/list/list.json)

     中增加以下设置

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

    然后再 list.js 中进行初始化数据,在data属性中编写 : 

    1. data: {
    2. tabs:['会议中','已完成','已取消','全部会议']
    3. }

     在 list.wxml中使用 

    1. <tabs tabList="{{tabs}}" bindtabsItemChange="tabsItemChange">
    2. tabs>

                                            效果图后面一起

    注意事项: 

    一些需要注意的细节:

    • 因为 WXML 节点标签名只能是小写字母、中划线和下划线的组合,所以自定义组件的标签名也只能包含这些字符。
    • 自定义组件也是可以引用自定义组件的,引用方法类似于页面引用自定义组件的方式(使用 usingComponents 字段)。
    • 自定义组件和页面所在项目根目录名不能以“wx-”为前缀,否则会报错。

    注意,是否在页面文件中使用 usingComponents 会使得页面的 this 对象的原型稍有差异,包括:

    • 使用 usingComponents 页面的原型与不使用时不一致,即 Object.getPrototypeOf(this) 结果不同。
    • 使用 usingComponents 时会多一些方法,如 selectComponent 。
    • 出于性能考虑,使用 usingComponents 时, setData 内容不会被直接深复制,即 this.setData({ field: obj }) 后 this.data.field === obj 。(深复制会在这个值被组件间传递时发生。)

            如果页面比较复杂,新增或删除 usingComponents 定义段时建议重新测试一下。

    二.会议

    学会了自定义组件的使用,在后将会议的页面及效果编写搭建完成

    2.1.数据

    在会议的 list.js 中进行初始化数据进行页面显示效果 :

    1. // pages/vote/list/list.js
    2. Page({
    3. /**
    4. * 页面的初始数据
    5. */
    6. data: {
    7. tabs:['全部','已发起','已参与'],
    8. lists: [
    9. {
    10. 'id': '1',
    11. 'image': '/static/persons/8.jpg',
    12. 'name' : '君总',
    13. 'title': '深圳·北京PM大会',
    14. 'vote' : '是否认同与京东进行产品合作',
    15. 'num' : '304',
    16. 'state':'未投票',
    17. 'time' : '10月09日 17:59',
    18. 'address': '深圳市·南山区'
    19. },
    20. {
    21. 'id': '2',
    22. 'image': '/static/persons/16.jpg',
    23. 'name' : '刘老板',
    24. 'title': 'AIWORLD人工智能大会',
    25. 'vote' : '是否投资AI发展',
    26. 'num' : '480',
    27. 'state':'已投票',
    28. 'time' : '10月09日 17:39',
    29. 'address': '北京市·朝阳区'
    30. },
    31. {
    32. 'id': '3',
    33. 'image': '/static/persons/13.jpg',
    34. 'name' : '肖总',
    35. 'title': 'H100太空商业大会',
    36. 'vote' : '是否太空商业进行合作',
    37. 'num' : '500',
    38. 'state': '未参与',
    39. 'time' : '10月09日 17:31',
    40. 'address': '大连市'
    41. },
    42. {
    43. 'id': '4',
    44. 'image': '/static/persons/15.jpg',
    45. 'name' : ' 文总',
    46. 'title': '2023消费升级创新大会',
    47. 'vote' : '是否对本次创新持续升级',
    48. 'num':'217',
    49. 'state':'已投票',
    50. 'time': '11月20日 16:59',
    51. 'address': '北京市·朝阳区'
    52. }
    53. ],
    54. lists1: [
    55. {
    56. 'id': '1',
    57. 'image': '/static/persons/2.jpg',
    58. 'name' : '张总',
    59. 'title': '深圳·北京PM大会',
    60. 'vote' : '是否认同与京东进行产品合作',
    61. 'num' : '304',
    62. 'state':'未投票',
    63. 'time' : '10月09日 17:59',
    64. 'address': '深圳市·南山区'
    65. },
    66. {
    67. 'id': '2',
    68. 'image': '/static/persons/16.jpg',
    69. 'name' : '陈总',
    70. 'title': 'AIWORLD人工智能大会',
    71. 'vote' : '是否投资AI发展',
    72. 'num' : '480',
    73. 'state':'已投票',
    74. 'time' : '10月09日 17:39',
    75. 'address': '北京市·朝阳区'
    76. },
    77. {
    78. 'id': '3',
    79. 'image': '/static/persons/13.jpg',
    80. 'name' : '杨总',
    81. 'title': 'H100太空商业大会',
    82. 'vote' : '是否太空商业进行合作',
    83. 'num' : '500',
    84. 'state': '未参与',
    85. 'time' : '10月09日 17:31',
    86. 'address': '大连市'
    87. },
    88. {
    89. 'id': '4',
    90. 'image': '/static/persons/20.jpg',
    91. 'name' : ' 冯总 ',
    92. 'title': '2023消费升级创新大会',
    93. 'vote' : '是否对本次创新持续升级',
    94. 'num':'217',
    95. 'state':'已投票',
    96. 'time': '11月20日 16:59',
    97. 'address': '北京市·朝阳区'
    98. }
    99. ],
    100. lists2: [
    101. {
    102. 'id': '1',
    103. 'image': '/static/persons/11.jpg',
    104. 'name' : '徐总',
    105. 'title': '深圳·北京PM大会',
    106. 'vote' : '是否认同与京东进行产品合作',
    107. 'num' : '422',
    108. 'state':'未投票',
    109. 'time' : '10月09日 17:59',
    110. 'address': '深圳市·南山区'
    111. },
    112. {
    113. 'id': '2',
    114. 'image': '/static/persons/16.jpg',
    115. 'name' : '邓总',
    116. 'title': 'AIWORLD人工智能大会',
    117. 'vote' : '是否投资AI发展',
    118. 'num' : '377',
    119. 'state':'已投票',
    120. 'time' : '10月09日 17:39',
    121. 'address': '北京市·朝阳区'
    122. },
    123. {
    124. 'id': '3',
    125. 'image': '/static/persons/17.jpg',
    126. 'name' : '廖总',
    127. 'title': 'H100太空商业大会',
    128. 'vote' : '是否太空商业进行合作',
    129. 'num' : '463',
    130. 'state': '未参与',
    131. 'time' : '10月09日 17:31',
    132. 'address': '大连市'
    133. },
    134. {
    135. 'id': '4',
    136. 'image': '/static/persons/19.jpg',
    137. 'name' : ' 李总 ',
    138. 'title': '2023消费升级创新大会',
    139. 'vote' : '是否对本次创新持续升级',
    140. 'num':'543',
    141. 'state':'已投票',
    142. 'time': '11月20日 16:59',
    143. 'address': '北京市·朝阳区'
    144. }
    145. ]
    146. },
    147. tabsItemChange(e){
    148. console.log(e.detail);
    149. let tolists;
    150. if(e.detail.index==1){
    151. tolists = this.data.lists1;
    152. }else if(e.detail.index==2){
    153. tolists = this.data.lists2;
    154. }else{
    155. tolists = this.data.lists;
    156. }
    157. this.setData({
    158. lists: tolists
    159. })
    160. },
    161. /**
    162. * 生命周期函数--监听页面加载
    163. */
    164. onLoad(options) {
    165. },
    166. /**
    167. * 生命周期函数--监听页面初次渲染完成
    168. */
    169. onReady() {
    170. },
    171. /**
    172. * 生命周期函数--监听页面显示
    173. */
    174. onShow() {
    175. },
    176. /**
    177. * 生命周期函数--监听页面隐藏
    178. */
    179. onHide() {
    180. },
    181. /**
    182. * 生命周期函数--监听页面卸载
    183. */
    184. onUnload() {
    185. },
    186. /**
    187. * 页面相关事件处理函数--监听用户下拉动作
    188. */
    189. onPullDownRefresh() {
    190. },
    191. /**
    192. * 页面上拉触底事件的处理函数
    193. */
    194. onReachBottom() {
    195. },
    196. /**
    197. * 用户点击右上角分享
    198. */
    199. onShareAppMessage() {
    200. }
    201. })

    2.2.显示 

    在会议的 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>
    19. <view class="section bottom-line">
    20. <text>到底啦text>
    21. view>

    2.3. 样式

    在会议的 list.wxss  中进行编写样式,美化页面 :

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

    效果:                         

                                                    

    注 : 其中的图片名称及路径,需要根据自己的图片名称及路径进行修改 

    三.个人中心

    3.1.页面

    在个人中心页面中编写 .wxml 文件(如 : ucenter/index/index.wxml) 进行页面显示

    1. <view class="user">
    2. <image class="user-img" src="/static/persons/2.jpg">image>
    3. <view class="user-name">ಥ慧瑶ಥ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>

    3.2.样式

    在个人中心的 .wxss 样式文件 中进行编写样式,来美化布局的页面效果

    (如 : ucenter/index/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. }

    效果图:

                                    

    四.投票

    4.1.引用

    在 投票页面的 .json 文件( 如: vote/list/list.json )中进行编写 :

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

    4.2.数据

    在 投票页面的 .js 文件( 如: vote/list/list.js )中进行编写初始化数据及方法功能 :

    1. // pages/vote/list/list.js
    2. Page({
    3. /**
    4. * 页面的初始数据
    5. */
    6. data: {
    7. tabs:['全部','已发起','已参与'],
    8. lists: [
    9. {
    10. 'id': '1',
    11. 'image': '/static/persons/8.jpg',
    12. 'name' : '君总',
    13. 'title': '深圳·北京PM大会',
    14. 'vote' : '是否认同与京东进行产品合作',
    15. 'num' : '304',
    16. 'state':'未投票',
    17. 'time' : '10月09日 17:59',
    18. 'address': '深圳市·南山区'
    19. },
    20. {
    21. 'id': '2',
    22. 'image': '/static/persons/16.jpg',
    23. 'name' : '刘老板',
    24. 'title': 'AIWORLD人工智能大会',
    25. 'vote' : '是否投资AI发展',
    26. 'num' : '480',
    27. 'state':'已投票',
    28. 'time' : '10月09日 17:39',
    29. 'address': '北京市·朝阳区'
    30. },
    31. {
    32. 'id': '3',
    33. 'image': '/static/persons/13.jpg',
    34. 'name' : '肖总',
    35. 'title': 'H100太空商业大会',
    36. 'vote' : '是否太空商业进行合作',
    37. 'num' : '500',
    38. 'state': '未参与',
    39. 'time' : '10月09日 17:31',
    40. 'address': '大连市'
    41. },
    42. {
    43. 'id': '4',
    44. 'image': '/static/persons/15.jpg',
    45. 'name' : ' 文总',
    46. 'title': '2023消费升级创新大会',
    47. 'vote' : '是否对本次创新持续升级',
    48. 'num':'217',
    49. 'state':'已投票',
    50. 'time': '11月20日 16:59',
    51. 'address': '北京市·朝阳区'
    52. }
    53. ],
    54. lists1: [
    55. {
    56. 'id': '1',
    57. 'image': '/static/persons/2.jpg',
    58. 'name' : '张总',
    59. 'title': '深圳·北京PM大会',
    60. 'vote' : '是否认同与京东进行产品合作',
    61. 'num' : '304',
    62. 'state':'未投票',
    63. 'time' : '10月09日 17:59',
    64. 'address': '深圳市·南山区'
    65. },
    66. {
    67. 'id': '2',
    68. 'image': '/static/persons/16.jpg',
    69. 'name' : '陈总',
    70. 'title': 'AIWORLD人工智能大会',
    71. 'vote' : '是否投资AI发展',
    72. 'num' : '480',
    73. 'state':'已投票',
    74. 'time' : '10月09日 17:39',
    75. 'address': '北京市·朝阳区'
    76. },
    77. {
    78. 'id': '3',
    79. 'image': '/static/persons/13.jpg',
    80. 'name' : '杨总',
    81. 'title': 'H100太空商业大会',
    82. 'vote' : '是否太空商业进行合作',
    83. 'num' : '500',
    84. 'state': '未参与',
    85. 'time' : '10月09日 17:31',
    86. 'address': '大连市'
    87. },
    88. {
    89. 'id': '4',
    90. 'image': '/static/persons/20.jpg',
    91. 'name' : ' 冯总 ',
    92. 'title': '2023消费升级创新大会',
    93. 'vote' : '是否对本次创新持续升级',
    94. 'num':'217',
    95. 'state':'已投票',
    96. 'time': '11月20日 16:59',
    97. 'address': '北京市·朝阳区'
    98. }
    99. ],
    100. lists2: [
    101. {
    102. 'id': '1',
    103. 'image': '/static/persons/11.jpg',
    104. 'name' : '徐总',
    105. 'title': '深圳·北京PM大会',
    106. 'vote' : '是否认同与京东进行产品合作',
    107. 'num' : '422',
    108. 'state':'未投票',
    109. 'time' : '10月09日 17:59',
    110. 'address': '深圳市·南山区'
    111. },
    112. {
    113. 'id': '2',
    114. 'image': '/static/persons/16.jpg',
    115. 'name' : '邓总',
    116. 'title': 'AIWORLD人工智能大会',
    117. 'vote' : '是否投资AI发展',
    118. 'num' : '377',
    119. 'state':'已投票',
    120. 'time' : '10月09日 17:39',
    121. 'address': '北京市·朝阳区'
    122. },
    123. {
    124. 'id': '3',
    125. 'image': '/static/persons/17.jpg',
    126. 'name' : '廖总',
    127. 'title': 'H100太空商业大会',
    128. 'vote' : '是否太空商业进行合作',
    129. 'num' : '463',
    130. 'state': '未参与',
    131. 'time' : '10月09日 17:31',
    132. 'address': '大连市'
    133. },
    134. {
    135. 'id': '4',
    136. 'image': '/static/persons/19.jpg',
    137. 'name' : ' 李总 ',
    138. 'title': '2023消费升级创新大会',
    139. 'vote' : '是否对本次创新持续升级',
    140. 'num':'543',
    141. 'state':'已投票',
    142. 'time': '11月20日 16:59',
    143. 'address': '北京市·朝阳区'
    144. }
    145. ]
    146. },
    147. tabsItemChange(e){
    148. console.log(e.detail);
    149. let tolists;
    150. if(e.detail.index==1){
    151. tolists = this.data.lists1;
    152. }else if(e.detail.index==2){
    153. tolists = this.data.lists2;
    154. }else{
    155. tolists = this.data.lists;
    156. }
    157. this.setData({
    158. lists: tolists
    159. })
    160. },
    161. /**
    162. * 生命周期函数--监听页面加载
    163. */
    164. onLoad(options) {
    165. },
    166. /**
    167. * 生命周期函数--监听页面初次渲染完成
    168. */
    169. onReady() {
    170. },
    171. /**
    172. * 生命周期函数--监听页面显示
    173. */
    174. onShow() {
    175. },
    176. /**
    177. * 生命周期函数--监听页面隐藏
    178. */
    179. onHide() {
    180. },
    181. /**
    182. * 生命周期函数--监听页面卸载
    183. */
    184. onUnload() {
    185. },
    186. /**
    187. * 页面相关事件处理函数--监听用户下拉动作
    188. */
    189. onPullDownRefresh() {
    190. },
    191. /**
    192. * 页面上拉触底事件的处理函数
    193. */
    194. onReachBottom() {
    195. },
    196. /**
    197. * 用户点击右上角分享
    198. */
    199. onShareAppMessage() {
    200. }
    201. })

    4.3.页面

    在投票页面的 wxml 文件( 如: vote/list/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><text style="margin-right: 13rpx;"> 发 起 人text> : {{item.name}}text>view>
    11. <view class="list-title"><text>会议名称 : {{item.title}}text>view>
    12. <view class="list-title"><text>投票标题 : [ {{item.vote}} ]text>view>
    13. <view class="list-tag">
    14. <view class="state al-center">{{item.state}}view>
    15. <view class="join al-center"><text class="list-num" >{{item.num}}text>人参与投票view>
    16. view>
    17. <view class="list-info"><text>{{item.address}}text> | <text>{{item.time}}text>view>
    18. view>
    19. view>
    20. block>
    21. <view class="section bottom-line">
    22. <text>到底啦text>
    23. view>

    4.4.样式

    在投票页面的 .wxss 文件( 如: vote/list/list.wxss)中进行编写页面样式进行美化效果 :

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

    效果图:

                                            

                    好啦今天就到这里了,希望能帮到你哦!!!

  • 相关阅读:
    AVL树和红黑树的简单实现
    滑动平均窗口的定义,优点,缺点,以及目前的应用!!
    【Python Web】Flask框架(九)MYSQL+python案例
    新手使用gin 创建第一个接口
    网络安全分析——蠕虫病毒动态分析视图
    使用Python CV2自动识别人脸并融合至新图片
    性能提升 25 倍:Rust 有望取代 C 和 C++,成为机器学习首选 Python 后端
    算法基础--位运算
    基于QtGUI的宠物小精灵对战游戏设计
    前端--性能优化【上篇】--网络优化与页面渲染优化
  • 原文地址:https://blog.csdn.net/m0_74915426/article/details/133959147