smartmeter-app/pages/index/index.vue

579 lines
12 KiB
Vue
Raw Normal View History

2023-11-27 09:57:03 +08:00
<template>
<!-- 头部代码 -->
<view class="view_by">
2023-12-19 23:00:57 +08:00
<u-navbar :is-back="false" title='首页' title-color="#2E4975" :border-bottom="false" :background="true"
id="navbar">
</u-navbar>
<view class="noinfo">
<view class="noinfo_tit">
当前暂无学习数据快去布置作业吧
</view>
<view class="noinfo_btn">
去安排
<image src="https://file.langsi.online/yasiimg/web/static/urw7xsodoO8Ay2ZWizL4" mode=""></image>
</view>
</view>
<view class="top_message" v-if="false">
2023-12-19 23:00:57 +08:00
<view class="top_message_left">
<view class="top_message_left_top">
32
</view>
2023-12-19 23:00:57 +08:00
<view class="top_message_left_bot">
已完成人数
</view>
</view>
2023-12-19 23:00:57 +08:00
<view class="top_message_cent">
</view>
<view class="top_message_right">
<view class="top_message_right_top">
90%
</view>
2023-12-19 23:00:57 +08:00
<view class="top_message_right_bot">
已完成作业正确率
</view>
</view>
</view>
2023-12-19 23:00:57 +08:00
<view class="work_msa">
<view class="work_img">
<image src="https://file.langsi.online/yasiimg/web/static/ukr9UZt8xuv2DgcwkWCq" mode=""></image>
</view>
2023-12-19 23:00:57 +08:00
<view class="work_msa_top">
<view class="work_msa_top_left">
作业完成情况
</view>
2023-12-19 23:00:57 +08:00
<view class="work_msa_top_right">
2024-01-15 21:29:11 +08:00
本周<!-- <view class="iconfont icon-arrow-down"></view> -->
</view>
</view>
<view class="echarts">
2023-12-19 23:00:57 +08:00
<!-- <mpvue-echarts id="main" ref="pieChart" :echarts="echarts" @onInit="initChart" /> -->
<l-echart ref="chart" @finished="initChart"></l-echart>
</view>
</view>
2023-12-19 23:00:57 +08:00
<div class="data">
8月31日<view class="iconfont icon-arrow-down"></view>
</div>
<view class="class_infobox">
<view class="class_info" style="width:80rpx ;">
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
<view class="class_info_bot">
21
</view>
<view class="class_info_top">
完成人数
</view>
</view>
2023-12-19 23:00:57 +08:00
<view class="class_info">
<view class="class_info_bot">
6
</view>
2023-12-19 23:00:57 +08:00
<view class="class_info_top">
平均成绩/
</view>
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
</view>
<view class="class_info">
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
<view class="class_info_bot">
80%
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
</view>
<view class="class_info_top">
作业正确率
</view>
</view>
2023-12-19 23:00:57 +08:00
</view>
<div class="card">
<view class="card_left">
<view class="stu_img">
<image src="https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49" mode=""></image>
</view>
2023-12-19 23:00:57 +08:00
<view class="stu_info">
<view class="stu_info_top">
口语单科模考
</view>
2023-12-19 23:00:57 +08:00
<view class="stu_info_bot">
李斯丹妮
</view>
</view>
</view>
2023-12-19 23:00:57 +08:00
<view class="card_right">
<view class="card_right_top">
正确率 80%
</view>
2023-12-19 23:00:57 +08:00
<view class="card_right_bot">
2023/02/23 12:00
</view>
</view>
</div>
2024-01-15 21:29:11 +08:00
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">xxxxxxxxxxxxxxxx</button>
2023-11-27 09:57:03 +08:00
</view>
2023-11-27 09:57:03 +08:00
</template>
<script>
import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
2023-11-27 09:57:03 +08:00
export default {
components: {
LEchart
},
2023-11-27 09:57:03 +08:00
data() {
return {
2023-12-19 23:00:57 +08:00
flag: true
2023-11-27 09:57:03 +08:00
}
},
2024-01-15 21:29:11 +08:00
onLoad() {
this.getUserInfo()
},
2023-11-27 09:57:03 +08:00
methods: {
2024-01-15 21:29:11 +08:00
getPhoneNumber(e) {
2024-01-16 14:44:34 +08:00
let that = this
2024-01-15 21:29:11 +08:00
console.log("eeeeeeee", e)
wx.login({
success(res) {
if (res.code) {
console.log('登录!', res)
//发起网络请求
2024-01-16 14:44:34 +08:00
// wx.request({
// url: 'https://api.admin-v2.langsi.online/admin-api/system/auth/mini-login',
// header: {
// "Tenant-Id": 1
// },
// method: "POST",
// data: {
// loginCode: res.code,
// phoneCode: e.detail.code,
// encryptedData: e.detail.encryptedData,
// iv: e.detail.iv
// }
// })
let data ={
loginCode: res.code,
phoneCode: e.detail.code,
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}
that.$u.post('https://api.admin-v2.langsi.online/admin-api/system/auth/mini-login',data).then(res => {
uni.setStorageSync('token','Bearer '+ res.data.accessToken);
2024-01-15 21:29:11 +08:00
})
} else {
console.log('登录失败!', res.errMsg)
}
},
fail(err) {
console.log(err)
}
})
},
getUserInfo(e) {
2024-01-16 14:44:34 +08:00
let that = this
2024-01-15 21:29:11 +08:00
wx.login({
success(res) {
if (res.code) {
console.log('登录!', res)
wx.getUserInfo({
success(rrr) {
console.log("xxxxx", rrr)
2024-01-16 14:44:34 +08:00
let data ={
loginCode: res.code,
encryptedData: rrr.encryptedData,
iv: rrr.iv
}
that.$u.post('https://api.admin-v2.langsi.online/admin-api/system/auth/mini-login',data).then(res => {
if (res.code == 200) {
uni.setStorageSync('token','Bearer '+ res.data.accessToken);
} else {
2024-01-15 21:29:11 +08:00
}
2024-01-16 14:44:34 +08:00
2024-01-15 21:29:11 +08:00
})
2024-01-16 14:44:34 +08:00
//发起网络请求
// wx.request({
// url: 'https://api.admin-v2.langsi.online/admin-api/system/auth/mini-login',
// header: {
// "Tenant-Id": 1
// },
// method: "POST",
// data: {
// loginCode: res.code,
// encryptedData: rrr.encryptedData,
// iv: rrr.iv
// }
// })
2024-01-15 21:29:11 +08:00
}
})
} else {
console.log('登录失败!', res.errMsg)
}
}
})
},
// async userlogin() {
// let code = await this.wxLogin();
// console.log(code);
// let data={
// loginCode:code
// }
// this.$u.post('https://api.admin-v2.langsi.online/admin-api/system/auth/mini-login',data).then(res => {
// if (res.code == 10003) {
// // console.log("新用户登录")
// uni.setStorageSync('token','Bearer '+ res.data);
// this.getuser()
// } else if (res.code == 200) {
// console.log("老用户登录", res.data)
// uni.setStorageSync('token','Bearer '+ res.data);
// this.isLogin = true
// this.getuser()
// } else if (res.code == 30003) {
// this.userlogin()
// }
// })
// uni.hideLoading();
// },
// 获取个人信息
async getuser() {
await this.$u.get('/app-api/user/info').then(res => {
if (res.code == 200) {
if (res.data.headImgUrl == "") {
this.userlogin()
}
this.userInfo = res.data
// this.getstatistics()
} else {
this.userlogin()
}
})
},
async initChart() {
let _this = this
const option = {
2024-01-15 21:29:11 +08:00
grid: {
left: 0,
right: 0,
top: 10,
bottom: 0,
containLabel: true,
},
xAxis: {
type: 'category',
2023-12-19 23:00:57 +08:00
data: ['Mon', '', 'Wed', '', 'Fri', '', 'Sun']
},
yAxis: {
type: 'value',
2023-12-19 23:00:57 +08:00
min: 0,
max: 100,
interval: 20,
axisLabel: {
formatter: '{value}%'
}
},
series: [{
2023-12-19 23:00:57 +08:00
data: [90, 45, 66, 82, 37, 65, 40],
type: 'bar',
itemStyle: {
normal: {
color: '#2D7CE6',
barBorderRadius: [5, 5, 0, 0] // 设置四个角的半径都为10像素
}
}
}]
2023-12-19 23:00:57 +08:00
};
const chart = await this.$refs.chart.init(echarts);
chart.setOption(option)
//return chart
},
2023-11-27 09:57:03 +08:00
}
}
</script>
2023-12-19 23:00:57 +08:00
<style lang="scss">
page {
background: linear-gradient(180deg, #E1EEFF 0%, #FFFFFF 100%);
2023-12-19 23:00:57 +08:00
}
2023-12-19 23:00:57 +08:00
.view_by {
padding: 0 32rpx;
2024-01-15 21:29:11 +08:00
.noinfo {
margin-top: 62rpx;
margin-left: 186rpx;
display: flex;
flex-wrap: wrap;
2024-01-15 21:29:11 +08:00
.noinfo_tit {
font-size: 28rpx;
font-family: 'PingFang', 'PingFang';
font-weight: 500;
color: #627698;
}
2024-01-15 21:29:11 +08:00
.noinfo_btn {
margin-top: 18rpx;
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
width: 160rpx;
height: 56rpx;
background: #2D7CE6;
border-radius: 86rpx 86rpx 86rpx 86rpx;
font-size: 20rpx;
font-family: 'PingFang', 'PingFang';
font-weight: 500;
color: #FFFFFF;
2024-01-15 21:29:11 +08:00
image {
margin-left: 8rpx;
width: 16rpx;
height: 16rpx;
}
}
}
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.top_message {
display: flex;
2023-12-19 23:00:57 +08:00
flex-wrap: nowrap;
justify-content: space-between;
2023-12-19 23:00:57 +08:00
.top_message_left {
margin-left: 60rpx;
display: flex;
flex-wrap: wrap;
2023-12-19 23:00:57 +08:00
.top_message_left_top {
width: 100%;
text-align: center;
font-size: 76rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 800;
color: #2E4975;
}
2023-12-19 23:00:57 +08:00
.top_message_left_bot {
width: 100%;
text-align: center;
font-size: 28rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 500;
color: #2E4975;
}
}
2023-12-19 23:00:57 +08:00
.top_message_cent {
width: 0;
height: 146rpx;
border-radius: 0rpx 0rpx 0rpx 0rpx;
margin-left: 2rpx;
border: 2rpx solid rgba(0, 0, 0, 0.11);
}
2023-12-19 23:00:57 +08:00
.top_message_right {
margin-right: 60rpx;
display: flex;
2023-12-19 23:00:57 +08:00
flex-wrap: wrap;
2023-12-19 23:00:57 +08:00
.top_message_right_top {
width: 100%;
text-align: center;
font-size: 76rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 800;
color: #2E4975;
}
2023-12-19 23:00:57 +08:00
.top_message_right_bot {
width: 100%;
text-align: center;
font-size: 28rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 500;
color: #2E4975;
}
}
}
2023-12-19 23:00:57 +08:00
.work_msa {
position: relative;
2023-12-19 23:00:57 +08:00
padding: 32rpx;
margin-top: 32rpx;
width: 686rpx;
height: 459rpx;
background: #FFFFFF;
border-radius: 20rpx 20rpx 20rpx 20rpx;
2024-01-15 21:29:11 +08:00
.work_img {
position: absolute;
left: 22rpx;
top: -190rpx;
2024-01-15 21:29:11 +08:00
height: 190rpx;
width: 145.28rpx;
}
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.work_msa_top {
display: flex;
2023-12-19 23:00:57 +08:00
flex-wrap: nowrap;
justify-content: space-between;
2023-12-19 23:00:57 +08:00
// justify-content: center;
.work_msa_top_left {
font-size: 28rpx;
font-family: 'PingFang', 'PingFang';
font-weight: 800;
color: #2E4975;
}
2023-12-19 23:00:57 +08:00
.work_msa_top_right {
display: flex;
align-items: center;
flex-wrap: nowrap;
font-size: 24rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 500;
color: rgba(46, 73, 117, 0.65);
2023-12-19 23:00:57 +08:00
.icon-arrow-down {
margin-left: 8rpx;
font-size: 24rpx;
}
}
}
}
2023-12-19 23:00:57 +08:00
.echarts {
// width: 100%;
// height: 80%;
width: 622rpx;
height: 350rpx;
}
2024-01-15 21:29:11 +08:00
.data {
display: flex;
2023-12-19 23:00:57 +08:00
flex-wrap: nowrap;
align-items: center;
2023-12-19 23:00:57 +08:00
margin-top: 32rpx;
font-size: 24rpx;
font-family: 'PingFang', 'PingFang';
font-weight: 800;
color: #2E4975;
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.icon-arrow-down {
2024-01-15 21:29:11 +08:00
color: #2E4975;
2023-12-19 23:00:57 +08:00
margin-left: 8rpx;
font-size: 24rpx;
}
}
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.class_infobox {
margin-top: 20rpx;
display: flex;
2023-12-19 23:00:57 +08:00
flex-wrap: nowrap;
align-items: center;
2023-12-19 23:00:57 +08:00
justify-content: space-around;
width: 686rpx;
height: 128rpx;
2024-01-15 21:29:11 +08:00
background: linear-gradient(179deg, rgba(255, 237, 223, 0.65) 0%, #FFFFFF 100%);
border-radius: 20rpx 20rpx 20rpx 20rpx;
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.class_info {
width: 110rpx;
display: flex;
2023-12-19 23:00:57 +08:00
flex-wrap: wrap;
justify-content: center;
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.class_info_top {
margin-top: 12rpx;
font-size: 20rpx;
2023-12-19 23:00:57 +08:00
font-family: 'PingFang', 'PingFang';
font-weight: 500;
2023-12-19 23:00:57 +08:00
color: rgba(7, 47, 90, 0.5);
}
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
.class_info_bot {
2024-01-15 21:29:11 +08:00
2023-12-19 23:00:57 +08:00
font-size: 28rpx;
font-family: 'PingFang', 'PingFang';
font-weight: 800;
2023-12-19 23:00:57 +08:00
color: #2D7CE6;
}
}
}
2024-01-15 21:29:11 +08:00
.card {
display: flex;
2023-12-19 23:00:57 +08:00
justify-content: space-between;
align-items: center;
2023-12-19 23:00:57 +08:00
margin-top: 20rpx;
padding: 24rpx;
width: 686rpx;
height: 124rpx;
background: #FFFFFF;
border-radius: 20rpx 20rpx 20rpx 20rpx;
2024-01-15 21:29:11 +08:00
.card_left {
2023-12-19 23:00:57 +08:00
display: flex;
flex-wrap: nowrap;
2024-01-15 21:29:11 +08:00
.stu_img {
2023-12-19 23:00:57 +08:00
width: 76rpx;
height: 76rpx;
border-radius: 50%;
}
2024-01-15 21:29:11 +08:00
.stu_info {
2023-12-19 23:00:57 +08:00
margin-left: 16rpx;
2024-01-15 21:29:11 +08:00
.stu_info_top {
2023-12-19 23:00:57 +08:00
font-size: 28rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: bold;
color: #072F5A;
}
2024-01-15 21:29:11 +08:00
.stu_info_bot {
2023-12-19 23:00:57 +08:00
margin-top: 4rpx;
font-size: 20rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 500;
2024-01-15 21:29:11 +08:00
color: rgba(46, 73, 117, 0.5);
2023-12-19 23:00:57 +08:00
}
}
}
2024-01-15 21:29:11 +08:00
.card_right {
.card_right_top {
2023-12-19 23:00:57 +08:00
text-align: right;
font-size: 20rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 500;
color: #F18F21;
}
2024-01-15 21:29:11 +08:00
.card_right_bot {
2023-12-19 23:00:57 +08:00
margin-top: 4rpx;
text-align: right;
font-size: 20rpx;
font-family: 'PingFang', 'PingFang';
2023-12-19 23:00:57 +08:00
font-weight: 500;
2024-01-15 21:29:11 +08:00
color: rgba(7, 47, 90, 0.4);
2023-12-19 23:00:57 +08:00
}
}
}
2023-11-27 09:57:03 +08:00
}
2023-12-19 23:00:57 +08:00
</style>