小程序-功能完善
This commit is contained in:
@@ -22,7 +22,7 @@ server.on("request", (req, res) => {
|
|||||||
msg: "登录成功",
|
msg: "登录成功",
|
||||||
userInfo: {
|
userInfo: {
|
||||||
username: "张三",
|
username: "张三",
|
||||||
userType: "admin"
|
userType: "user" // "admin" "user"
|
||||||
}
|
}
|
||||||
// status: 'failed',
|
// status: 'failed',
|
||||||
// msg: "用户名或密码不正确",
|
// msg: "用户名或密码不正确",
|
||||||
|
|||||||
@@ -13,5 +13,41 @@ export default defineAppConfig({
|
|||||||
navigationBarBackgroundColor: '#000',
|
navigationBarBackgroundColor: '#000',
|
||||||
navigationBarTitleText: 'WeChat',
|
navigationBarTitleText: 'WeChat',
|
||||||
navigationBarTextStyle: 'white'
|
navigationBarTextStyle: 'white'
|
||||||
}
|
},
|
||||||
|
"tabBar": {
|
||||||
|
"selectedColor": "#FF8966",
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"pagePath": "pages/index/index",
|
||||||
|
"text": "首页",
|
||||||
|
"iconPath": "image/icon/_home.png",
|
||||||
|
"selectedIconPath": "image/icon/home.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pagePath": "pages/residents/code",
|
||||||
|
"text": "进出码",
|
||||||
|
"iconPath": "image/icon/_code.png",
|
||||||
|
"selectedIconPath": "image/icon/code.png"
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// "pagePath": "pages/report/report",
|
||||||
|
// "text": "日报",
|
||||||
|
// "iconPath": "/icon/_report.png",
|
||||||
|
// "selectedIconPath": "/icon/report.png"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "pagePath": "pages/apply/apply",
|
||||||
|
// "text": "申请",
|
||||||
|
// "iconPath": "/icon/_apply.png",
|
||||||
|
// "selectedIconPath": "/icon/apply.png"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "pagePath": "pages/person/person",
|
||||||
|
// "text": "我的",
|
||||||
|
// "selectedColor": "#FF8966",
|
||||||
|
// "iconPath": "/icon/_person.png",
|
||||||
|
// "selectedIconPath": "/icon/person.png"
|
||||||
|
// }
|
||||||
|
]
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const App = createApp({
|
|||||||
App.use(setGlobalDataPlugin, {
|
App.use(setGlobalDataPlugin, {
|
||||||
globalData: {
|
globalData: {
|
||||||
baseUrl: "http://localhost:8080", // 不带最后的 /
|
baseUrl: "http://localhost:8080", // 不带最后的 /
|
||||||
userInfo: null
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
BIN
miniprogram-taro/src/image/icon/_code.png
Normal file
BIN
miniprogram-taro/src/image/icon/_code.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
BIN
miniprogram-taro/src/image/icon/_home.png
Normal file
BIN
miniprogram-taro/src/image/icon/_home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB |
BIN
miniprogram-taro/src/image/icon/home.png
Normal file
BIN
miniprogram-taro/src/image/icon/home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
@@ -1,7 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<view style="background-color: #F6F6F6;height: 100%;">
|
<view style="background-color: #F6F6F6;height: 100%;">
|
||||||
<image src="../../image/home.jpg" style="width: 100%;height: 130px;"></image>
|
<image src="../../image/home.jpg" style="width: 100%;height: 130px;"></image>
|
||||||
<view style="display: block;" wx:if="{{isStudent}}">
|
<view style="display: block; padding-left: 30px; padding-top: 12px;">
|
||||||
|
<text>欢迎你,{{ displayUsername }}!</text>
|
||||||
|
</view>
|
||||||
|
<view style="display: block;" v-if="isUser">
|
||||||
<view style="display: flex;text-align: center;margin-top: 20px;">
|
<view style="display: flex;text-align: center;margin-top: 20px;">
|
||||||
<view style="width: 25%;">
|
<view style="width: 25%;">
|
||||||
<image src="../../image/icon/code.png" style="width: 40px;height: 40px;" @tap='goCode'></image>
|
<image src="../../image/icon/code.png" style="width: 40px;height: 40px;" @tap='goCode'></image>
|
||||||
@@ -36,7 +39,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view style="display: block;" wx:if="{{isManager}}">
|
<view style="display: block;" v-if="isAdmin">
|
||||||
<view style="display: flex;text-align: center;margin-top: 20px;">
|
<view style="display: flex;text-align: center;margin-top: 20px;">
|
||||||
<view style="width: 25%;">
|
<view style="width: 25%;">
|
||||||
<image src="../../image/icon/danger.png" style="width: 40px;height: 40px;" bindtap='goCode'></image>
|
<image src="../../image/icon/danger.png" style="width: 40px;height: 40px;" bindtap='goCode'></image>
|
||||||
@@ -84,29 +87,37 @@ import './index.css'
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
userInfo: null,
|
||||||
|
displayUsername: "",
|
||||||
|
isUser: false,
|
||||||
|
isAdmin: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
eventCenter.once(getCurrentInstance().router.onShow, () => {
|
eventCenter.once(getCurrentInstance().router.onShow, () => {
|
||||||
console.log('onShow')
|
console.log('onShow')
|
||||||
if (!wx.getStorageSync("userInfo")) {
|
this.userInfo = Taro.getStorageSync("userInfo");
|
||||||
|
this.displayUsername = this.userInfo?.username ?? "请登录";
|
||||||
|
if (!this.userInfo) {
|
||||||
console.log("用户未登录")
|
console.log("用户未登录")
|
||||||
Taro.redirectTo({
|
Taro.redirectTo({
|
||||||
url: '/pages/index/login',
|
url: '/pages/index/login'
|
||||||
// success: function (res) {
|
|
||||||
// // 通过eventChannel向被打开页面传送数据
|
|
||||||
// res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
this.isUser = this.userInfo.userType == "user";
|
||||||
|
this.isAdmin = this.userInfo.userType == "admin";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goCode() {
|
goCode() {
|
||||||
Taro.navigateTo({
|
// Taro.navigateTo({
|
||||||
url: '/pages/residents/code',
|
// url: '/pages/residents/code'
|
||||||
// success: function (res) {
|
// })
|
||||||
// // 通过eventChannel向被打开页面传送数据
|
Taro.switchTab({
|
||||||
// res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
|
url: '/pages/residents/code'
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
.time-text {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#qrcode {
|
||||||
|
width: 70vw;
|
||||||
|
height: 70vw;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
<view style="background-color: #F6F6F6;height: 100%;">
|
<view style="background-color: #F6F6F6;height: 100%;">
|
||||||
<image src="../../image/home.jpg" style="width: 100%;height: 130px;"></image>
|
<image src="../../image/home.jpg" style="width: 100%;height: 130px;"></image>
|
||||||
</view>
|
</view>
|
||||||
|
<view style="text-align: center; margin-top: 100px;">
|
||||||
|
<view><text>{{ stuId }} {{ name }}</text></view>
|
||||||
|
<image id="qrcode" src="{{imgUrl}}"></image>
|
||||||
|
<view><text class="time-text">{{ time }}</text></view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
28
miniprogram-taro/src/utils/utils.js
Normal file
28
miniprogram-taro/src/utils/utils.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const formatTime = date => {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
const hour = date.getHours()
|
||||||
|
const minute = date.getMinutes()
|
||||||
|
const second = date.getSeconds()
|
||||||
|
|
||||||
|
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatNumber = n => {
|
||||||
|
n = n.toString()
|
||||||
|
return n[1] ? n : `0${n}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatDate = date => {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
|
||||||
|
return [year, month, day].map(formatNumber).join('-')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
formatTime,
|
||||||
|
formatDate
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user