【微信小程序】无纸化会议OA系统之首页搭建(下)

简介: 【微信小程序】无纸化会议OA系统之首页搭建(下)

二、首页布局搭建


1.底部页面的搭建

一个微信小程序必不可少的就是底部导航栏,所以我们先搭建一个底部导航栏 ,根据微信小程序的开发者文档可知,底部导航栏需要在api.json定义tabBar并做好相应的配置(注意先在pages做好页面的定义)。

底部导航栏没有图标是显得非常单调的,所以我们还要创建一个文件夹名为static用来存放图片

继续在static文件夹下创建一个文件名为tabBar,将我们所需的图标放入,搭配属性iconPath引用图标即可。

{
  "pages":[
    "pages/index/index",
    "pages/meeting/list/list",
    "pages/vote/list/list",
    "pages/ucenter/index/index",
    "pages/pageOne/pageOne",
    "pages/pageTwo/pageTwo",
    "pages/users/user",
    "pages/logs/logs"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "Weixin",
    "navigationBarTextStyle":"black"
  },
  "tabBar": {
    "list": [{
      "pagePath": "pages/index/index",
      "text": "首页",
      "iconPath": "/static/tabBar/coding.png",
      "selectedIconPath": "/static/tabBar/coding-active.png"
    }, {
      "pagePath": "pages/meeting/list/list",
      "text": "会议",
      "iconPath": "/static/tabBar/sdk.png",
      "selectedIconPath": "/static/tabBar/sdk-active.png"
    }, {
      "pagePath": "pages/vote/list/list",
      "text": "投票",
      "iconPath": "/static/tabBar/template.png",
        "selectedIconPath": "/static/tabBar/template-active.png"
    }
    , {
      "pagePath": "pages/ucenter/index/index",
      "text": "设置",
      "iconPath": "/static/tabBar/component.png",
        "selectedIconPath": "/static/tabBar/component-active.png"
    }]
  },
  "style": "v2",
  "sitemapLocation": "sitemap.json"
}


895c455d038a4d868bc6f3f7d30a71ab.gif


2.首页轮播图搭建


2.1.后端接口管理

轮播图这种资源一定是从数据库来的数据,那么我们怎么通过微信小程序开发获取后端呢?

还是一样看官网,通过官网可知我们发送ajax请求是wx.restartMiniProgram(Object object)

其他的东西还是基本与我们发送ajax请求一致的。

为了后期方便维护我们先将所有的后端接口通过一个文件来保存,在根目录下新建config文件夹随后建立api.js文件。

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


还是一样先定义本机开发的API地址,具体的请求在下面定义方便管理。


2.2.Mock模拟数据

今天不带大家展示请求后端所以我们利用Mock来制造一些“假数据”来模拟一下。

Mock 的入口在工具调试面板顶部的 Tab,点 + 新建规则

f70c695001d8428381587138e2696876.png

08f3170511774f7281ddcc2f51586948.png

Mock模拟的轮播图数据:

{
  "data": {
    "images":[
  {
    "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner1.png",
    "text": "1"
  },
  {
    "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner2.png",
    "text": "2"
  },
  {
    "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner3.png",
    "text": "3"
  },
  {
    "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner4.png",
    "text": "4"
  },
  {
    "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner5.png",
    "text": "5"
  },
  {
    "img": "https://cdn-we-retail.ym.tencent.com/tsr/home/v2/banner6.png",
    "text": "6"
  }
]
  },
  "statusCode": "200",
  "header": {
    "content-type":"applicaiton/json;charset=utf-8"
  }
}


// index.js
// 获取应用实例
const app = getApp()
const api = require("../../config/api")
Page({
  data: {
    imgSrcs:[]
  },
  loadSwiperImgs(){
    let that=this;
    wx.request({
        url: api.SwiperImgs,
        dataType: 'json',
        success(res) {
          console.log(res)
          that.setData({
              imgSrcs:res.data.images
          })
        }
      })
  },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad() {
    if (wx.getUserProfile) {
      this.setData({
        canIUseGetUserProfile: true
      })
    }
    this.loadSwiperImgs();
  },
})

index.wxml

<!--index.wxml-->
<view class="myswiper">
  <swiper indicator-dots="true" autoplay="true">
        <block wx:for="{{imgSrcs}}" wx:key="{{text}}">
          <swiper-item>
          <image src="{{item.img}}"></image>
          </swiper-item>
        </block>
      </swiper>
</view>


小贴士:

有一部分的友友可能遇到以下问题: http://localhost:8080 不在以下 request 合法域名列表中

a4bc19759fe64e2eb56657ed2d800c3f.png

因为我们现在的小程序开发默认检查安全证书(域名为https)所以我们的请求过不去,我们只需点击微信小程序开发中的详情按钮,再继续点击本地设置不校验合法域名选项打开。

ad2cf0cfbf0c445198e00b30fb2c63d3.png


3.首页会议信息搭建

我们照猫画虎,和我们轮播图的流程一样,定义接口发送ajax再利用Mock模拟数据根据官网提供的组件进行完善。

<view class="mobi-title">
    <text class="mobi-icon"></text>
    <text>会议信息</text>
</view>
<block wx:for-items="{{lists}}" wx:for-item="item" wx:key="item.id">
    <view class="list" data-id="{{item.id}}">
        <view class="list-img">
            <image class="video-img" mode="scaleToFill" src="{{item.image}}"></image>
        </view>
        <view class="list-detail">
            <view class="list-title"><text>{{item.title}}</text></view>
            <view class="list-tag">
                <view class="state">{{item.state}}</view>
                <view class="join"><text class="list-num">{{item.num}}</text>人报名</view>
            </view>
            <view class="list-info"><text>{{item.location}}</text>|<text>{{item.starttime}}</text></view>
        </view>
    </view>
</block>
<view class="mysection">
    <text>到底啦</text>
</view>


// index.js
// 获取应用实例
const app = getApp()
const api = require("../../config/api")
Page({
  data: {
    imgSrcs:[]
  },
  loadSwiperImgs(){
    let that=this;
    wx.request({
        url: api.SwiperImgs,
        dataType: 'json',
        success(res) {
          console.log(res)
          that.setData({
              imgSrcs:res.data.images
          })
        }
      })
  },
    //首页会议信息的ajax
    loadMeetingInfos(){
      let that=this;
      wx.request({
          url: api.MettingInfos,
          dataType: 'json',
          success(res) {
            console.log(res)
            that.setData({
                lists:res.data.lists
            })
          }
        })
    },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad() {
    if (wx.getUserProfile) {
      this.setData({
        canIUseGetUserProfile: true
      })
    }
    this.loadSwiperImgs();
    this.loadMeetingInfos();
  },
})

WXSS

/**index.wxss**/
.swiper-item {
  height: 300rpx;
  width: 100%;
  border-radius: 10rpx;
}
/**index.wxss**/
.myswiper{
  padding:0 0 0 25px;
  }
  .mobi-title{
    background-color: rgb(252, 248, 248);
    margin-left: 5px;
  color: gray;
  font-weight: 600;
  }
  .mobi-icon{
    border-left: red solid 1px ;
    margin-right: 3px;
  }
  .list{
    display: flex;
    border-bottom: rgb(233, 231, 231) solid 3px;
  }
  .list-img{
    display: flex;
    align-items: center;
   margin-right: 15px;
  }
  .video-img{
    width: 120rpx;
    height: 120rpx;
  }
  .list-title{
    font-weight: bold;
  }
  .list-tag{
    display: flex;
  }
  .state{
    border: rgb(35, 171, 224) solid 1px;
    color: rgb(35, 171, 224);
    align-items: center;
    width: 65px;
    display: flex;
    justify-content: center;
  }
  .join{
    margin-left: 8px;
    color: lightgray;
  }
  .list-num{
    color: red;
    font-weight: 600;
  }
  .list-info{
    display: flex;
    color: lightgray;
    margin-top: 10px;
  }
  .mysection{
    display: flex;
    justify-content: center;
  }
  .userinfo {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #aaa;
  }
  .userinfo-avatar {
    overflow: hidden;
    width: 128rpx;
    height: 128rpx;
    margin: 20rpx;
    border-radius: 50%;
  }
  .usermotto {
    margin-top: 200px;
  }


Mock模拟的会议信息数据:

{
  "data": {
    "lists": [
        {
          "id": "1",
          "image": "/static/persons/1.jpg",
          "title": "对话产品总监 | 深圳·北京PM大会 【深度对话小米/京东/等产品总监】",
          "num":"304",
          "state":"进行中",
          "starttime": "2022-03-13 00:00:00",
          "location": "深圳市·南山区"
        },
        {
          "id": "1",
          "image": "/static/persons/2.jpg",
          "title": "AI WORLD 2016世界人工智能大会",
          "num":"380",
          "state":"已结束",
          "starttime": "2022-03-15 00:00:00",
          "location": "北京市·朝阳区"
        },
        {
          "id": "1",
          "image": "/static/persons/3.jpg",
          "title": "H100太空商业大会",
          "num":"500",
          "state":"进行中",
          "starttime": "2022-03-13 00:00:00",
          "location": "大连市"
        },
        {
          "id": "1",
          "image": "/static/persons/4.jpg",
          "title": "报名年度盛事,大咖云集!2016凤凰国际论坛邀您“与世界对话”",
          "num":"150",
          "state":"已结束",
          "starttime": "2022-03-13 00:00:00",
          "location": "北京市·朝阳区"
        },
        {
          "id": "1",
          "image": "/static/persons/5.jpg",
          "title": "新质生活 · 品质时代 2016消费升级创新大会",
          "num":"217",
          "state":"进行中",
          "starttime": "2022-03-13 00:00:00",
          "location": "北京市·朝阳区"
        }
      ]
  },
  "statusCode": "200",
  "header": {
    "content-type":"applicaiton/json;charset=utf-8"
  }
}


效果展示

12aa60d14ac649f5bfcfd02f02ba9007.gif

目录
相关文章
|
29天前
|
小程序 Java 关系型数据库
基于微信小程序的智慧养老服务系统
本系统基于Java、MySQL和Spring Boot技术,构建高效、安全的养老院管理系统,提升信息处理速度与管理规范性,实现数据自动化备份与网络化管理,助力养老机构信息化升级。
|
1月前
|
JavaScript 小程序 Java
基于微信小程序的线上博物馆系统
线上博物馆系统利用互联网与数字技术,实现文化遗产的数字化保护与传播,打破时空限制,推动文化传承与教育创新。结合Java、Vue及Uniapp等技术,构建跨平台、高互动的在线展览平台,提升公众文化体验。
|
3月前
|
缓存 小程序 开发工具
最新原创uniapp+vue3仿微信界面聊天app系统
最新原创研发uniapp+vue3实战跨端仿微信App界面聊天程序。支持运行到H5+小程序+APP端。
229 6
最新原创uniapp+vue3仿微信界面聊天app系统
|
8月前
|
存储 移动开发 小程序
校园圈子系统小程序(圈子论坛、私信聊天、资料共享、二手交易、兼职,跑腿)开源码开发/微信公众号、小程序、H5多端账号同步/搭建多城市的综合社交生活平台
基于开源技术栈构建的校园圈子系统小程序,整合社交与生活服务功能,涵盖兴趣圈子、私信聊天、资料共享、二手交易、兼职跑腿等六大核心模块。通过多端账号同步(微信公众号/小程序/H5),实现数据实时交互,满足学生群体的多元化需求。项目精准锚定校园市场,以“社交+服务”双轮驱动,提供一站式解决方案,支持快速部署与多校区运营,同时具备广告、佣金、会员等多元变现能力,是打造校园生态的理想工具。
837 2
校园圈子系统小程序(圈子论坛、私信聊天、资料共享、二手交易、兼职,跑腿)开源码开发/微信公众号、小程序、H5多端账号同步/搭建多城市的综合社交生活平台
|
10月前
|
存储 缓存 关系型数据库
社交软件红包技术解密(六):微信红包系统的存储层架构演进实践
微信红包本质是小额资金在用户帐户流转,有发、抢、拆三大步骤。在这个过程中对事务有高要求,所以订单最终要基于传统的RDBMS,这方面是它的强项,最终订单的存储使用互联网行业最通用的MySQL数据库。支持事务、成熟稳定,我们的团队在MySQL上有长期技术积累。但是传统数据库的扩展性有局限,需要通过架构解决。
258 18
|
10月前
|
存储 缓存 监控
社交软件红包技术解密(四):微信红包系统是如何应对高并发的
本文将为读者介绍微信百亿级别红包背后的高并发设计实践,内容包括微信红包系统的技术难点、解决高并发问题通常使用的方案,以及微信红包系统的所采用高并发解决方案。
296 13
|
10月前
|
存储 监控 容灾
社交软件红包技术解密(五):微信红包系统是如何实现高可用性的
本次分享介绍了微信红包后台系统的高可用实践经验,主要包括后台的 set 化设计、异步化设计、订单异地存储设计、存储层容灾设计与平行扩缩容等。听众可以了解到微信红包后台架构的设计细节,共同探讨高可用设计实践上遇到的问题与解决方案。
312 5
|
12月前
|
移动开发 小程序
仿青藤之恋社交交友软件系统源码 即时通讯 聊天 微信小程序 App H5三端通用
仿青藤之恋社交交友软件系统源码 即时通讯 聊天 微信小程序 App H5三端通用
924 3
|
7月前
|
监控 前端开发 小程序
陪练,代练,护航,代打小程序源码/前端UNIAPP-VUE2.0开发 后端Thinkphp6管理/具备家政服务的综合型平台
这款APP通过技术创新,将代练、家政、娱乐社交等场景融合,打造“全能型生活服务生态圈”。以代练为切入点,提供模块化代码支持快速搭建平台,结合智能匹配与技能审核机制,拓展家政服务和商业管理功能。技术架构具备高安全性和扩展性,支持多业务复用,如押金冻结、录屏监控等功能跨领域应用。商业模式多元,包括交易抽成、增值服务及广告联名,同时设计跨领域积分体系提升用户粘性,实现生态共生与B端赋能。
704 12

热门文章

最新文章