• 微信小程序之会议OA首页数据交互,会议状态,会议人数转换,会议室交互,WXS的使用


    前言:

    本篇博客使用结合了SpringMVC,mybatis,maven,小程序,如果不熟悉使用可以翻看我之前的博客,以便大家可以更好的学习!!!

    一,会议OA首页数据的后台交互

    这是我们今天完成后的效果:

    1.1启动开发工具,导入后台

    导入框架:

    配置maven

    注意数据库的名称:

    启动

    1.2导入数据表

    1.3前台页面的编码(小程序端)

    根据图片加载去定义会议信息

    二,会议状态,会议人数转换

    2.1显示会议

    连接后台的url

    list

    2.2自定义公共类,方便调用

    在/utils/util.js中定义

    导入utils,再调用封装的request

    index.js

    1. // index.js
    2. // 获取应用实例
    3. const app = getApp()
    4. const api = require("../../config/api")
    5. const utils = require("../../utils/util")
    6. Page({
    7. data: {
    8. "images":[
    9. {
    10. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner1.png",
    11. "text": "1"
    12. },
    13. {
    14. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner2.png",
    15. "text": "2"
    16. },
    17. {
    18. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner3.png",
    19. "text": "3"
    20. },
    21. {
    22. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner4.png",
    23. "text": "4"
    24. },
    25. {
    26. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner5.png",
    27. "text": "5"
    28. },
    29. {
    30. "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner6.png",
    31. "text": "6"
    32. }
    33. ],
    34. "lists": [
    35. ]
    36. },
    37. // 事件处理函数
    38. bindViewTap() {
    39. wx.navigateTo({
    40. url: '../logs/logs'
    41. })
    42. },
    43. loadmeetinfos(){
    44. let that=this;
    45. utils.request(api.IndexUrl).then(res=>{
    46. that.setData({
    47. lists:res.data.infoList
    48. })
    49. });
    50. // let that=this;
    51. // wx.request({
    52. // url: api.IndexUrl,
    53. // dataType: 'json',
    54. // success(res) {
    55. // console.log(res)
    56. // that.setData({
    57. // lists:res.data.data.infoList
    58. // })
    59. // }
    60. // })
    61. },
    62. loadSwiperImgs(){
    63. let that=this;
    64. wx.request({
    65. url: api.SwiperImgs,
    66. dataType: 'json',
    67. success(res) {
    68. console.log(res)
    69. that.setData({
    70. imgSrcs:res.data.images
    71. })
    72. }
    73. })
    74. }
    75. ,
    76. onLoad() {
    77. if (wx.getUserProfile) {
    78. this.setData({
    79. canIUseGetUserProfile: true
    80. })
    81. }
    82. this.loadSwiperImgs();
    83. this.loadmeetinfos();
    84. },
    85. getUserProfile(e) {
    86. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
    87. wx.getUserProfile({
    88. desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
    89. success: (res) => {
    90. console.log(res)
    91. this.setData({
    92. userInfo: res.userInfo,
    93. hasUserInfo: true
    94. })
    95. }
    96. })
    97. },
    98. getUserInfo(e) {
    99. // 不推荐使用getUserInfo获取用户信息,预计自2021413日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
    100. console.log(e)
    101. this.setData({
    102. userInfo: e.detail.userInfo,
    103. hasUserInfo: true
    104. })
    105. }
    106. })

    2.3wxs的使用

    访问官网:创建自定义的wxs

    comm.wxs

    1. function getStateName(state){
    2. if(state==1){
    3. return "待审核"
    4. }else if(state==2){
    5. return "审核"
    6. }
    7. else if(state==3){
    8. return "审核失败"
    9. }
    10. else if(state==4){
    11. return "其他"
    12. }
    13. }
    14. function getnum(canyuzhe,liexizhe,zhuchiren){
    15. var person = canyuzhe+','+liexizhe+","+zhuchiren+"";
    16. return person.split(",").length;
    17. }
    18. function formatDate(ts, option) {
    19. var date = getDate(ts)
    20. var year = date.getFullYear()
    21. var month = date.getMonth() + 1
    22. var day = date.getDate()
    23. var week = date.getDay()
    24. var hour = date.getHours()
    25. var minute = date.getMinutes()
    26. var second = date.getSeconds()
    27. //获取 年月日
    28. if (option == 'YY-MM-DD') return [year, month, day].map(formatNumber).join('-')
    29. //获取 年月
    30. if (option == 'YY-MM') return [year, month].map(formatNumber).join('-')
    31. //获取 年
    32. if (option == 'YY') return [year].map(formatNumber).toString()
    33. //获取 月
    34. if (option == 'MM') return [mont].map(formatNumber).toString()
    35. //获取 日
    36. if (option == 'DD') return [day].map(formatNumber).toString()
    37. //获取 年月日 周一 至 周日
    38. if (option == 'YY-MM-DD Week') return [year, month, day].map(formatNumber).join('-') + ' ' + getWeek(week)
    39. //获取 月日 周一 至 周日
    40. if (option == 'MM-DD Week') return [month, day].map(formatNumber).join('-') + ' ' + getWeek(week)
    41. //获取 周一 至 周日
    42. if (option == 'Week') return getWeek(week)
    43. //获取 时分秒
    44. if (option == 'hh-mm-ss') return [hour, minute, second].map(formatNumber).join(':')
    45. //获取 时分
    46. if (option == 'hh-mm') return [hour, minute].map(formatNumber).join(':')
    47. //获取 分秒
    48. if (option == 'mm-dd') return [minute, second].map(formatNumber).join(':')
    49. //获取 时
    50. if (option == 'hh') return [hour].map(formatNumber).toString()
    51. //获取 分
    52. if (option == 'mm') return [minute].map(formatNumber).toString()
    53. //获取 秒
    54. if (option == 'ss') return [second].map(formatNumber).toString()
    55. //默认 时分秒 年月日
    56. return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
    57. }
    58. function formatNumber(n) {
    59. n = n.toString()
    60. return n[1] ? n : '0' + n
    61. }
    62. function getWeek(n) {
    63. switch(n) {
    64. case 1:
    65. return '星期一'
    66. case 2:
    67. return '星期二'
    68. case 3:
    69. return '星期三'
    70. case 4:
    71. return '星期四'
    72. case 5:
    73. return '星期五'
    74. case 6:
    75. return '星期六'
    76. case 7:
    77. return '星期日'
    78. }
    79. }
    80. module.exports = {
    81. getStateName: getStateName,
    82. getnum: getnum,
    83. formatDate: formatDate,
    84. getWeek: getWeek
    85. };

    index.wxml

    1. <!--index.wxml-->
    2. <view class="myswiper">
    3. <swiper indicator-dots="true" autoplay="true">
    4. <block wx:for="{{images}}" wx:key="{{text}}">
    5. <swiper-item>
    6. <image src="{{item.img}}"></image>
    7. </swiper-item>
    8. </block>
    9. </swiper>
    10. </view>
    11. <!-- 导入tools的路径 -->
    12. <wxs src="/utils/comm.wxs" module="tools" ></wxs>
    13. <view class="mobi-title">
    14. <text class="mobi-icon"></text>
    15. <text>会议信息</text>
    16. </view>
    17. <block wx:for-items="{{lists}}" wx:for-item="item" wx:key="item.id">
    18. <view class="list" data-id="{{item.id}}">
    19. <view class="list-img">
    20. <image class="video-img" mode="scaleToFill" src="{{item.image !=null ? item.image : '/static/persons/水果1.png'}}"></image>
    21. </view>
    22. <view class="list-detail">
    23. <view class="list-title"><text>{{item.title}}</text></view>
    24. <view class="list-tag">
    25. <view class="state">{{tools.getStateName(item.state)}}</view>
    26. <view class="join"><text class="list-num">{{tools.getnum(item.canyuzhe,item.liexizhe,item.zhuchiren)}}</text>人报名</view>
    27. </view>
    28. <view class="list-info"><text>{{item.address}}</text>|<text>{{tools.formatDate(item.starttime)}}</text></view>
    29. </view>
    30. </view>
    31. </block>
    32. <view class="section bottom-line">
    33. <text>到底啦</text>
    34. </view>

    效果:


  • 相关阅读:
    [C++]多态(下)
    校园快餐店网上订餐管理系统(JSP+MySQL+MyEclipse)
    Python教程(15)——Python流程控制语句详解
    Linux 查看属于某个组(例如docker组)的所有用户
    Vuex
    如何用神经网络预测数据,神经网络预测的软件有
    【Linux---02】CentOS操作系统的说明「简单使用 | 文件目录 | 常用命令」
    8类放球问题
    rust元组
    SpringMvc+Spring+MyBatis+Maven+Ajax+Json注解开发 利用Maven的依赖导入不使用架包模式 (实操十)
  • 原文地址:https://blog.csdn.net/m0_73647713/article/details/133949616