前言:
本篇博客使用結(jié)合了SpringMVC,mybatis,maven,小程序,如果不熟悉使用可以翻看我之前的博客,以便大家可以更好的學(xué)習(xí)?。?!
一,會(huì)議OA首頁(yè)數(shù)據(jù)的后臺(tái)交互
這是我們今天完成后的效果:
1.1啟動(dòng)開(kāi)發(fā)工具,導(dǎo)入后臺(tái)
導(dǎo)入框架:
配置maven
注意數(shù)據(jù)庫(kù)的名稱:
啟動(dòng)
1.2導(dǎo)入數(shù)據(jù)表
1.3前臺(tái)頁(yè)面的編碼(小程序端)
根據(jù)圖片加載去定義會(huì)議信息
二,會(huì)議狀態(tài),會(huì)議人數(shù)轉(zhuǎn)換
2.1顯示會(huì)議
連接后臺(tái)的url
list
2.2自定義公共類,方便調(diào)用
在/utils/util.js中定義
導(dǎo)入utils,再調(diào)用封裝的request
index.js
// index.js
// 獲取應(yīng)用實(shí)例
const app = getApp()
const api = require("../../config/api")
const utils = require("../../utils/util")
Page({
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"
}
],
"lists": [
]
},
// 事件處理函數(shù)
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
loadmeetinfos(){
let that=this;
utils.request(api.IndexUrl).then(res=>{
that.setData({
lists:res.data.infoList
})
});
// let that=this;
// wx.request({
// url: api.IndexUrl,
// dataType: 'json',
// success(res) {
// console.log(res)
// that.setData({
// lists:res.data.data.infoList
// })
// }
// })
},
loadSwiperImgs(){
let that=this;
wx.request({
url: api.SwiperImgs,
dataType: 'json',
success(res) {
console.log(res)
that.setData({
imgSrcs:res.data.images
})
}
})
}
,
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
this.loadSwiperImgs();
this.loadmeetinfos();
},
getUserProfile(e) {
// 推薦使用wx.getUserProfile獲取用戶信息,開(kāi)發(fā)者每次通過(guò)該接口獲取用戶個(gè)人信息均需用戶確認(rèn),開(kāi)發(fā)者妥善保管用戶快速填寫的頭像昵稱,避免重復(fù)彈窗
wx.getUserProfile({
desc: '展示用戶信息', // 聲明獲取用戶個(gè)人信息后的用途,后續(xù)會(huì)展示在彈窗中,請(qǐng)謹(jǐn)慎填寫
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推薦使用getUserInfo獲取用戶信息,預(yù)計(jì)自2021年4月13日起,getUserInfo將不再?gòu)棾鰪棿?,并直接返回匿名的用戶個(gè)人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
2.3wxs的使用
訪問(wèn)官網(wǎng):創(chuàng)建自定義的wxs
comm.wxs
function getStateName(state){
if(state==1){
return "待審核"
}else if(state==2){
return "審核"
}
else if(state==3){
return "審核失敗"
}
else if(state==4){
return "其他"
}
}
function getnum(canyuzhe,liexizhe,zhuchiren){
var person = canyuzhe+','+liexizhe+","+zhuchiren+"";
return person.split(",").length;
}
function formatDate(ts, option) {
var date = getDate(ts)
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var week = date.getDay()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
//獲取 年月日
if (option == 'YY-MM-DD') return [year, month, day].map(formatNumber).join('-')
//獲取 年月
if (option == 'YY-MM') return [year, month].map(formatNumber).join('-')
//獲取 年
if (option == 'YY') return [year].map(formatNumber).toString()
//獲取 月
if (option == 'MM') return [mont].map(formatNumber).toString()
//獲取 日
if (option == 'DD') return [day].map(formatNumber).toString()
//獲取 年月日 周一 至 周日
if (option == 'YY-MM-DD Week') return [year, month, day].map(formatNumber).join('-') + ' ' + getWeek(week)
//獲取 月日 周一 至 周日
if (option == 'MM-DD Week') return [month, day].map(formatNumber).join('-') + ' ' + getWeek(week)
//獲取 周一 至 周日
if (option == 'Week') return getWeek(week)
//獲取 時(shí)分秒
if (option == 'hh-mm-ss') return [hour, minute, second].map(formatNumber).join(':')
//獲取 時(shí)分
if (option == 'hh-mm') return [hour, minute].map(formatNumber).join(':')
//獲取 分秒
if (option == 'mm-dd') return [minute, second].map(formatNumber).join(':')
//獲取 時(shí)
if (option == 'hh') return [hour].map(formatNumber).toString()
//獲取 分
if (option == 'mm') return [minute].map(formatNumber).toString()
//獲取 秒
if (option == 'ss') return [second].map(formatNumber).toString()
//默認(rèn) 時(shí)分秒 年月日
return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
function formatNumber(n) {
n = n.toString()
return n[1] ? n : '0' + n
}
function getWeek(n) {
switch(n) {
case 1:
return '星期一'
case 2:
return '星期二'
case 3:
return '星期三'
case 4:
return '星期四'
case 5:
return '星期五'
case 6:
return '星期六'
case 7:
return '星期日'
}
}
module.exports = {
getStateName: getStateName,
getnum: getnum,
formatDate: formatDate,
getWeek: getWeek
};
index.wxml文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-714612.html
<!--index.wxml-->
<view class="myswiper">
<swiper indicator-dots="true" autoplay="true">
<block wx:for="{{images}}" wx:key="{{text}}">
<swiper-item>
<image src="{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
</view>
<!-- 導(dǎo)入tools的路徑 -->
<wxs src="/utils/comm.wxs" module="tools" ></wxs>
<view class="mobi-title">
<text class="mobi-icon"></text>
<text>會(huì)議信息</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 !=null ? item.image : '/static/persons/水果1.png'}}"></image>
</view>
<view class="list-detail">
<view class="list-title"><text>{{item.title}}</text></view>
<view class="list-tag">
<view class="state">{{tools.getStateName(item.state)}}</view>
<view class="join"><text class="list-num">{{tools.getnum(item.canyuzhe,item.liexizhe,item.zhuchiren)}}</text>人報(bào)名</view>
</view>
<view class="list-info"><text>{{item.address}}</text>|<text>{{tools.formatDate(item.starttime)}}</text></view>
</view>
</view>
</block>
<view class="section bottom-line">
<text>到底啦</text>
</view>
效果:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-714612.html
到了這里,關(guān)于微信小程序之會(huì)議OA首頁(yè)數(shù)據(jù)交互,會(huì)議狀態(tài),會(huì)議人數(shù)轉(zhuǎn)換,會(huì)議室交互,WXS的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!