Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
educationStu
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
向伟
educationStu
Commits
95fff39c
Commit
95fff39c
authored
Jan 07, 2022
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2
parent
6d8243d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
794 additions
and
1129 deletions
+794
-1129
index.vue
src/pages/index/index.vue
+515
-952
common.css
src/static/css/common.css
+1
-0
index.js
src/utils/index.js
+278
-177
No files found.
src/pages/index/index.vue
View file @
95fff39c
<
template
>
<view
class=
"page-box"
>
<!--
<van-nav-bar
:border=
"fasle"
fixed
:z-index=
"99"
>
<view
slot=
"left"
class=
"page-title"
title=
"shouye"
>
首页
</view>
</van-nav-bar>
-->
<navbar>
<view
class=
"navbar-con"
>
<view
class=
"pagetitle"
>
首页
<view
class=
"indexpage"
>
<navbar>
<view
class=
"navbarCon"
>
<view
class=
"pagetitle"
@
click=
"jumpPage('/pages/login/login')"
>
首页
</view>
<view
class=
"loginBox"
>
<image
src=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/login2x.png"
mode=
"aspectFit"
class=
"loginIcon"
id=
"loadImg"
></image>
登录
</view>
<view
class=
"scanBox"
>
<image
src=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/scan2x.png"
mode=
"aspectFit"
class=
"scanIcon"
></image>
<view
class=
"scanText"
>
签到
</view>
</view>
</view>
</navbar>
<view
class=
"activeContent"
v-if=
"ActivityList.length >= 0"
>
<swiper
class=
"swiper"
:indicator-dots=
"indicatorDots"
:autoplay=
"autoplay"
indicator-color=
"#CCCCCC"
indicator-active-color=
"#000000"
:vertical=
"true"
circular
>
<swiper-item
v-for=
"(item, index) in ActivityList"
:key=
"index"
@
click=
"goActiveDetail(item.Id)"
>
<view
class=
"swiperList"
:style=
"
{
'background-image': item.CoverImg
? `url(${item.CoverImg})`
: `url(https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/defaultBgimg.png)`,
}">
<view
class=
"swiper_Time"
>
{{
item
.
BMStart
}}
</view>
<view
class=
"swiper_Name"
>
{{
item
.
ActivityName
}}
</view>
</view>
</swiper-item>
</swiper>
</view>
</navbar>
<view
class=
"con"
>
<view
class=
"personInfo flex flex_start_center"
>
<van-image
round
width=
"100rpx"
height=
"100rpx"
fit=
"cover"
:src=
"userinfo.UserIcon ? userinfo.UserIcon : userinfo.GroupLogo"
class=
"headimg"
@
click=
"jumpPage('/pages/login/login')"
/>
<view
class=
"grow"
>
<view
class=
"name"
v-if=
"userinfo.AccountName"
>
{{
userinfo
.
AccountName
?
userinfo
.
AccountName
:
''
}}
</view>
<view
v-else
>
<indexassembly
@
success=
'againdata'
></indexassembly>
</view>
<view
class=
"phone"
>
{{
userinfo
.
Account
?
userinfo
.
Account
:
''
}}
</view>
</view>
<view
class=
"saleInfo"
>
<view
class=
"info1"
>
<van-icon
name=
"contact"
size=
"23rpx"
style=
"margin-right: 10rpx"
/>
服务人员
</view>
<view
class=
"info2 one_line"
>
<text
style=
"margin-right: 10rpx"
>
课程顾问
</text
>
{{
userinfo
.
EnterPhone2
?
userinfo
.
EnterPhone2
:
'无'
}}
</view>
</view>
</view>
<view
class=
"baseInfo flex flex_wrap"
>
<view
class=
"baseInfo_item flex flex_between_center"
v-for=
"(item, index) in baseInfo"
:key=
"index"
:style=
"
{ 'background-color': item.bgcolor }"
@click="jumpPage(item.jumpUrl)"
>
<view
style=
"height: 100%; max-width: 120rpx"
>
<view
class=
"baseInfo_name"
>
{{
item
.
name
}}
</view>
<view
class=
"baseInfo_desc one_line"
:title=
"item.desc"
>
{{
item
.
desc
}}
</view>
</view>
<van-image
width=
"58rpx"
height=
"66rpx"
fit=
"cover"
:src=
"item.img"
/>
</view>
</view>
<view
class=
"LearningGarden flex flex_wrap"
>
<view
v-for=
"(item, index) in learnList"
:key=
"index"
class=
"LearningGarden-item"
:style=
"
{ backgroundColor: item.bgcolor }"
@click="jumpPage(item.jumpUrl)"
>
<view
class=
"LearningGarden-item-name"
>
{{
item
.
name
}}
</view>
<view
class=
"LearningGarden-item-desc"
>
{{
item
.
desc
}}
</view>
<image
:src=
"item.img"
class=
"LearningGarden-item-img"
/>
</view>
</view>
<view
class=
"title"
v-if=
"indexData && indexData.FeedBackList && indexData.FeedBackList.length > 0"
>
课程反馈
</view>
<view
class=
"feedback"
v-if=
"indexData && indexData.FeedBackList && indexData.FeedBackList.length > 0"
>
<view
class=
"feedback-info flex flex_start_center"
>
<image
:src=
"indexData.FeedBackList[0].TeacherIcon"
class=
"info-headimg"
/>
<view
class=
"grow"
>
<view
class=
"teacher-name one_line"
v-if=
"indexData.FeedBackList[0].TeacherName"
>
{{
indexData
.
FeedBackList
[
0
].
TeacherName
}}
{{
indexData
.
FeedBackList
[
0
].
CourseName
}}
</view
>
<view
class=
"rate"
>
<van-rate
:value=
"indexData.FeedBackList[0].Score"
:count=
"indexData.FeedBackList[0].Score"
icon=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/rate.png"
void-icon=
""
size=
"24rpx"
/>
<text
class=
"FeedBackTime"
>
{{
indexData
.
FeedBackList
[
0
].
ClassDateStr
}}
{{
indexData
.
FeedBackList
[
0
].
StartTime
}}
</text>
</view>
</view>
<view
class=
"feedback-all"
@
click=
"jumpPage('/pages/course/feedback')"
>
全部
<van-icon
name=
"arrow"
style=
"margin-left: 30rpx"
/>
</view>
</view>
<view
class=
"two_line feedback-text"
>
{{
indexData
.
FeedBackList
[
0
].
Comment
}}
</view>
<view
class=
"flex"
>
<view
v-for=
"(item, index) in indexData.FeedBackList[0].PhotoList"
:key=
"index"
v-if=
"index === 0 || index === 1 || index === 2"
class=
"feedback-img"
>
<view
style=
"width: 100%; height: 100%"
>
<image
:src=
"item"
style=
"width: 100%; height: 100%"
mode=
"aspectFill"
v-if=
"item.indexOf('mp4')==-1"
@
click=
"previewImage(item, index)"
>
</image>
<video
:id=
"'myVideo'+index"
:src=
"item"
style=
"width: 100%; height: 100%;"
:controls=
'controls'
:show-center-play-btn=
'false'
:show-fullscreen-btn=
'false'
@
fullscreenchange=
'videoControl'
v-if=
"item.indexOf('mp4')!=-1"
></video>
<view
@
click=
"enlarge(index)"
v-if=
"item.indexOf('mp4')!=-1"
style=
"position: absolute;left: 50%;top: 50%;margin-top: -49rpx;margin-left: -49rpx;width: 98rpx;height: 98rpx;border-radius: 20rpx;background-color: rgba(255,255,255,.4);display: flex;align-items: center;justify-content: center;"
>
<!-- 播放按钮 -->
<image
src=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1616471847000_345.png"
style=
"width: 37rpx;height: 44rpx;"
mode=
""
></image>
<view
class=
"wordBox"
>
<view
class=
"wordTitle"
>
单词积分
</view>
<view
class=
"flex_around_center "
>
<view
class=
"wordItem"
>
<text
class=
"wordItemTitle"
>
今日新词
</text>
<text
class=
"wordItemText"
>
{{
pageData
.
Words
.
NextWord
}}
<text
class=
"wordItemTextUnit"
>
词
</text></text>
</view>
<view
class=
"wordItem"
>
<text
class=
"wordItemTitle"
>
复习词语
</text>
<text
class=
"wordItemText"
>
{{
pageData
.
Words
.
ReviewWord
}}
<text
class=
"wordItemTextUnit"
>
词
</text></text>
</view>
</view>
<view
class=
"layer"
v-if=
"
indexData.FeedBackList[0].PhotoList.length > 3 && index === 2
"
></view>
<view
class=
"layer2 flex flex_center_center"
v-if=
"
indexData.FeedBackList[0].PhotoList.length > 3 && index === 2
"
>
+
{{
indexData
.
FeedBackList
[
0
].
PhotoList
.
length
-
3
}}
</view
>
</view>
</view>
</view>
<view
class=
"activeContent"
v-if=
"ActivityList.length > 0"
>
<swiper
class=
"swiper"
:indicator-dots=
"indicatorDots"
:autoplay=
"autoplay"
indicator-color=
"#CCCCCC"
indicator-active-color=
"#000000"
:vertical=
"true"
circular
>
<swiper-item
v-for=
"(item, index) in ActivityList"
:key=
"index"
@
click=
"goActiveDetail(item.Id)"
>
<view
class=
"swiperList"
:style=
"
{
'background-image': item.CoverImg
? `url(${item.CoverImg})`
: `url(https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/defaultBgimg.png)`,
}"
>
<view
class=
"swiper_Time"
>
{{
item
.
BMStart
}}
</view>
<view
class=
"swiper_Name"
>
{{
item
.
ActivityName
}}
</view>
</view>
</swiper-item>
</swiper>
</view>
<view
class=
"timetable"
>
<view
class=
"timetable_item flex flex_between_center"
>
<text
class=
"timetable_title"
>
我的课表
</text>
<view
class=
"timetable_btn"
@
click=
"
jumpPage(`/pages/course/timeTable?classId=$
{indexData.ClassId}`)
"
v-if="indexData.ClassPlan.TimeStart"
>
全部
<van-icon
name=
"arrow"
style=
"margin-left: 30rpx"
/>
</view>
</view>
<view
class=
"timetable_item2"
>
日期:
<text
v-if=
"indexData.ClassPlan.NewPlanDateTimeStr"
>
{{
indexData
.
ClassPlan
.
NewPlanDateTimeStr
}}
</text>
<text
v-else
>
暂无
</text>
</view>
<view
class=
"timetable_item2"
>
时间:
<text
v-if=
"indexData.ClassPlan.TimeStr"
>
{{
indexData
.
ClassPlan
.
TimeStr
}}
</text>
<text
v-else
>
暂无
</text>
</view>
<view
class=
"timetable_item2"
>
老师:
<text
v-if=
"indexData.ClassPlan.TeacherName"
>
{{
indexData
.
ClassPlan
.
TeacherName
}}
</text>
<text
v-else
>
暂无
</text>
</view>
<view
class=
"timetable_item2"
>
状态:
<text
v-if=
"indexData.ClassPlan.TimeStatusStr === 0"
>
待上课
</text>
<text
v-if=
"indexData.ClassPlan.TimeStatusStr === 1"
>
上课中
</text>
<text
v-if=
"indexData.ClassPlan.TimeStatusStr === 2"
>
下课
</text>
</view>
</view>
<van-cell-group
:border=
"false"
>
<van-cell
title=
"我的考试"
title-class=
"title"
:border=
"false"
>
<view
class=
"value"
@
click=
"
jumpPage(`/pages/exam/examPaperList?Id=$
{indexData.GuestId}`)
"
>
查看更多
</view>
</van-cell>
</van-cell-group>
<view
v-if=
"indexData && indexData.paperList && indexData.paperList.length == 0"
>
<van-empty
description=
"暂无数据"
/>
</view>
<view
class=
"mytest flex"
v-if=
"indexData && indexData.paperList && indexData.paperList.length > 0"
>
<view
v-for=
"(item, index) in indexData.paperList"
:key=
"index"
class=
"test-item no_shrink"
:style=
"
{
'background-image': item.PicList[0]
? `url(${item.PicList[0]})`
: `url(https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/defaultBgimg.png)`,
}"
@click="getItemStatus(item)"
>
<view
class=
"testName"
>
{{
item
.
PaperName
}}
</view>
<view
class=
"testTime"
>
考试时间:
{{
item
.
ExamStartTime
}}
</view>
<view
class=
"teacherInfo-bg"
></view>
<view
class=
"teacherInfo flex flex_between_center"
>
<view
class=
"flex flex_start_center"
>
<!--
<van-image
round
width=
"45rpx"
height=
"45rpx"
fit=
"cover"
src=
"https://img.yzcdn.cn/vant/cat.jpeg"
/>
<view
class=
"teacherName"
>
{{
indexData
.
TeacherName
}}
</view>
-->
</view>
<view
class=
"test-status"
:class=
"
{
'status-blue': item.ExamStatusStr == '未开始',
'status-green': item.ExamStatusStr == '已开始',
'status-black': item.ExamStatusStr == '完成',
'status-red': item.ExamStatusStr == '缺考',
}"
>
{{
item
.
ExamStatusStr
}}
</view>
</view>
</view>
</view>
</view>
<van-toast
id=
"van-toast"
/>
</view>
</view>
<view
class=
"wordDuration"
>
预计用时10分钟
</view>
<view
class=
"wordBtn"
>
开始学习
</view>
</view>
<view
class=
"courseBox"
>
<view
class=
"courseInnerBox"
>
<view
class=
"top"
>
<image
src=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/classtime.png"
mode=
"aspectFit"
class=
"courseIcon"
></image>
<text
class=
"courseDateStr"
style=
"margin: 0 16rpx 0 8rpx;"
>
{{
pageData
.
ClassNext
.
DateStr
||
'暂无'
}}
</text>
<text
class=
"courseDateStr"
v-if=
"pageData.ClassNext.DateStart"
>
{{
pageData
.
ClassNext
.
DateStart
}}
</text>
<image
src=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/classroom.png"
mode=
"aspectFit"
class=
"courseIcon"
style=
"margin: 0 12rpx 0 50rpx;"
></image>
<text
class=
"courseDateStr"
style=
"margin-right: 30rpx;"
>
{{
pageData
.
ClassNext
.
RoomName
||
'暂无'
}}
</text>
</view>
<view
class=
"flex"
>
<view
class=
"courseNameBox"
>
<view
class=
"className"
>
{{
pageData
.
ClassNext
.
ClassName
||
'暂无'
}}
</view>
<view
class=
"courseName"
>
{{
pageData
.
ClassNext
.
CourseName
||
'暂无'
}}
</view>
</view>
<image
src=
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/female2x.png"
mode=
"aspectFit"
class=
"courseIcon2"
></image>
</view>
</view>
<view
class=
"courseTitle"
>
下节课
</view>
</view>
<view
class=
"learningGarden"
>
<view
class=
"learningGardenSbutitle"
>
扩展学习
</view>
<view
v-for=
"(item,index) in pageData.LearningGardenList"
:key=
"index"
v-if=
"item.List.length>0"
>
<view
class=
"learningGardenTitle"
>
{{
item
.
Name
}}
</view>
<view
class=
"gardenCon"
v-for=
"(item1,index1) in item.List"
:key=
"index1"
id=
"img"
>
<image
:src=
"item1.Img"
mode=
"aspectFill"
style=
"width: 100%;height:100%;border-radius: 24rpx 24rpx 0 0;"
></image>
<view
class=
"gardenTextBox"
:style=
"
{background:'linear-gradient(0deg,'+getColor(item1.Img)}">
<view
class=
"gardenTitle one_line"
>
<!--
{{
item1
.
Title
}}
-->
{{
getColor
(
item1
.
Img
)
}}
</view>
<view
class=
"gardenDigest one_line"
>
{{
item1
.
Digest
}}
</view>
</view>
</view>
</view>
</view>
<canvas
canvas-id=
"myCanvas"
class=
"canvas"
style=
"position:absolute;left: -1000px;"
></canvas>
<van-toast
id=
"van-toast"
/>
</view>
</
template
>
<
script
>
import
{
ref
,
reactive
,
toRefs
,
toRef
,
getCurrentInstance
,
watch
,
computed
,
onMounted
,
provide
,
}
from
"vue"
;
import
{
getIndexInfo
}
from
"../../api/index"
;
import
{
getActivityList
}
from
"../../api/activity"
;
import
{
desensitization
}
from
"../../utils/index"
;
import
indexassembly
from
'./components/indexassembly.vue'
import
navbar
from
'../../components/navbar.vue'
export
default
{
components
:
{
indexassembly
,
navbar
,
},
setup
(
props
)
{
let
{
proxy
}
=
getCurrentInstance
();
proxy
.
$isLogin
();
let
data
=
reactive
({
statusBarHeight
:
0
,
userinfo
:
{},
indexData
:
{
FeedBackList
:
[],
},
baseInfo
:
[
{
name
:
"学区"
,
desc
:
""
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/icon2.png"
,
bgcolor
:
"#CCEDFE"
,
jumpUrl
:
""
,
},
{
name
:
"课程"
,
desc
:
"N1~N3"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/icon1.png"
,
bgcolor
:
"#DDE6FF"
,
jumpUrl
:
"/pages/course/course"
,
},
{
name
:
"进度"
,
desc
:
"上到哪里了"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/icon4.png"
,
bgcolor
:
"#FFEFE4"
,
jumpUrl
:
`/pages/progress/progress`
,
},
{
name
:
"剩余课时"
,
desc
:
"100"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/icon3.png"
,
bgcolor
:
"#FFEAFE"
,
jumpUrl
:
`/pages/surplusTime/surplusTime`
,
},
{
name
:
"电子合同"
,
desc
:
"5个"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/icon5.png"
,
bgcolor
:
"#D9FAF1"
,
jumpUrl
:
"/pages/contract/contract"
,
},
{
name
:
"我的老师"
,
desc
:
"李琴"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/icon6.png"
,
bgcolor
:
"#FFE7E6"
,
jumpUrl
:
"/pages/course/askForLeaveList"
,
},
],
// 学习园地
learnList
:
[
{
name
:
"日语学习园地"
,
desc
:
"日本語の勉強"
,
bgcolor
:
"#F6E5FE"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/garden1.png"
,
jumpUrl
:
"/pages/learningGarden/learningGardenList"
,
},
{
name
:
"韩语学习园地"
,
desc
:
"정원"
,
bgcolor
:
"#FEF5D6"
,
img
:
"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/garden2.png"
,
jumpUrl
:
""
,
},
],
indicatorDots
:
true
,
//是否显示轮播指示点
autoplay
:
false
,
ActiveMsg
:
{
pageIndex
:
1
,
pageSize
:
10
,
ActivityType
:
0
,
SelectIsEnd
:
0
,
},
ActivityList
:
[],
//活动数据
videoContext
:
null
});
let
methods
=
{
jumpPage
(
url
)
{
uni
.
navigateTo
({
url
:
url
,
});
},
async
getIndexdata
()
{
let
res
=
await
getIndexInfo
();
if
(
res
)
{
data
.
indexData
=
res
.
Data
;
uni
.
setStorageSync
(
"indexData"
,
res
.
Data
);
data
.
baseInfo
[
0
].
desc
=
res
.
Data
.
SName
;
data
.
baseInfo
[
1
].
desc
=
res
.
Data
.
CourseName
;
data
.
baseInfo
[
1
].
jumpUrl
=
"/pages/course/course?id="
+
res
.
Data
.
CourseId
;
data
.
baseInfo
[
2
].
jumpUrl
=
"/pages/progress/progress?id="
+
res
.
Data
.
ClassId
;
data
.
baseInfo
[
3
].
desc
=
res
.
Data
.
SurplusHours
+
"课时"
;
data
.
baseInfo
[
3
].
jumpUrl
=
"/pages/surplusTime/surplusTime?id="
+
res
.
Data
.
ClassId
;
data
.
baseInfo
[
4
].
desc
=
res
.
Data
.
ContractNum
;
data
.
baseInfo
[
5
].
desc
=
res
.
Data
.
TeacherName
;
}
},
async
getActivityData
()
{
let
res
=
await
getActivityList
(
data
.
ActiveMsg
);
if
(
res
.
resultCode
==
1
)
{
data
.
ActivityList
=
res
.
data
.
pageData
;
}
},
//根据状态跳转
getItemStatus
(
item
)
{
//ExamStatus 1未开始 2已开始 3已考试 4缺考 5已阅卷
if
(
item
.
ExamStatus
==
5
)
{
this
.
jumpPage
(
`/pages/exam/examScore?GuestId=
${
item
.
GuestId
}
&&PaperId=
${
item
.
PaperId
}
&&Id=
${
item
.
Id
}
&&Exam_Student_Id=
${
item
.
Exam_Student_Id
}
&&ExamStatus=
${
item
.
ExamStatus
}
`
);
}
else
{
this
.
jumpPage
(
`/pages/exam/examPaper?GuestId=
${
item
.
GuestId
}
&&PaperId=
${
item
.
PaperId
}
&&Id=
${
item
.
Id
}
&&Exam_Student_Id=
${
item
.
Exam_Student_Id
}
&&ExamStatus=
${
item
.
ExamStatus
}
`
);
}
},
//跳转至详情
goActiveDetail
(
Id
)
{
this
.
jumpPage
(
`/pages/activity/activityDetails?Id=
${
Id
}
`
);
},
previewImage
(
item
,
i
)
{
let
arr
=
[
item
]
uni
.
previewImage
({
urls
:
arr
,
current
:
i
,
longPressActions
:
{
itemList
:
[
"发送给朋友"
,
"保存图片"
,
"收藏"
],
success
:
function
(
data
)
{},
fail
:
function
(
err
)
{
console
.
log
(
err
.
errMsg
);
},
},
});
},
enlarge
(
i
)
{
// 全屏
data
.
videoContext
=
uni
.
createVideoContext
(
'myVideo'
+
i
);
data
.
videoContext
.
requestFullScreen
({
direction
:
0
})
},
videoControl
(
e
){
if
(
e
.
detail
.
fullScreen
==
false
){
data
.
videoContext
.
stop
()
data
.
controls
=
false
}
else
{
data
.
videoContext
.
play
()
data
.
controls
=
true
}
},
againdata
(){
data
.
userinfo
=
uni
.
getStorageSync
(
"userInfo"
);
that
.
getIndexdata
();
that
.
getActivityData
();
data
.
userinfo
.
EnterPhone2
=
desensitization
(
data
.
userinfo
.
EnterPhone
,
3
,
-
4
);
}
};
onMounted
(()
=>
{
console
.
log
(
process
.
env
);
console
.
log
(
uni
.
getSystemInfoSync
());
data
.
statusBarHeight
=
uni
.
getSystemInfoSync
().
statusBarHeight
;
data
.
userinfo
=
uni
.
getStorageSync
(
"userInfo"
);
data
.
userinfo
.
EnterPhone2
=
desensitization
(
data
.
userinfo
.
EnterPhone
,
3
,
-
4
);
});
let
that
=
methods
;
return
{
...
toRefs
(
data
),
...
methods
,
};
},
onShow
()
{
this
.
getIndexdata
();
this
.
getActivityData
();
},
onLoad
()
{
uni
.
setNavigationBarTitle
({
title
:
"首页"
,
});
},
onShareAppMessage
()
{
return
{
title
:
"甲小鹤"
,
query
:
"/pages/index/index"
,
imageUrl
:
""
,
};
},
onShareTimeline
()
{
return
{
title
:
"甲小鹤"
,
query
:
"/pages/index/index"
,
imageUrl
:
""
,
};
},
};
import
vue
,
{
ref
,
reactive
,
toRefs
,
toRef
,
getCurrentInstance
,
watch
,
computed
,
onMounted
,
provide
,
nextTick
,
}
from
"vue"
;
import
{
getActivityList
}
from
"../../api/activity"
;
import
{
getImageColor
}
from
'../../utils/index.js'
import
indexassembly
from
'./components/indexassembly.vue'
import
navbar
from
'../../components/navbar.vue'
export
default
{
components
:
{
indexassembly
,
navbar
,
},
setup
(
props
)
{
let
{
proxy
}
=
getCurrentInstance
();
proxy
.
$isLogin
();
let
data
=
reactive
({
ActiveMsg
:
{
pageIndex
:
1
,
pageSize
:
10
,
ActivityType
:
0
,
SelectIsEnd
:
0
,
},
ActivityList
:
[],
pageData
:
{},
});
let
methods
=
{
jumpPage
(
url
)
{
uni
.
navigateTo
({
url
:
url
,
});
},
async
getActivityData
()
{
let
res
=
await
getActivityList
(
data
.
ActiveMsg
);
if
(
res
.
resultCode
==
1
)
{
data
.
ActivityList
=
res
.
data
.
pageData
;
}
},
getIndexData
()
{
proxy
.
$request
(
"/AppletIndex/GetIndexInfo_V2"
,
{}).
then
(
res
=>
{
// console.log(222, res)
data
.
pageData
=
res
.
Data
})
},
async
getColor
(
src
)
{
let
res
=
await
getImageColor
(
'myCanvas'
,
'img'
,
src
)
const
formatres
=
`rgba(
${
res
.
r
}
,
${
res
.
g
}
,
${
res
.
b
}
)`
console
.
log
(
168
,
formatres
)
return
formatres
}
};
onMounted
(()
=>
{
methods
.
getIndexData
();
});
return
{
...
toRefs
(
data
),
...
methods
,
};
},
onShow
()
{
this
.
getActivityData
();
},
onLoad
()
{
uni
.
setNavigationBarTitle
({
title
:
"首页"
,
});
},
onShareAppMessage
()
{
return
{
title
:
"甲小鹤"
,
query
:
"/pages/index/index"
,
imageUrl
:
""
,
};
},
onShareTimeline
()
{
return
{
title
:
"甲小鹤"
,
query
:
"/pages/index/index"
,
imageUrl
:
""
,
};
},
};
</
script
>
<
style
scoped
>
.navbar-con
{
.indexpage
{
min-height
:
100vh
;
background-color
:
#F5F5F5
;
box-sizing
:
border-box
;
padding-bottom
:
40
rpx
;
}
.navbarCon
{
height
:
100%
;
box-sizing
:
border-box
;
padding
:
0
30
rpx
;
display
:
flex
;
align-items
:
center
;
}
.pagetitle
{
.pagetitle
{
font-size
:
46
rpx
;
font-weight
:
800
;
color
:
#111111
;
margin-right
:
30
rpx
;
}
.loginBox
{
height
:
100%
;
display
:
flex
;
align-items
:
center
;
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
800
;
color
:
#4C50E7
;
margin-right
:
220
rpx
;
}
.loginIcon
{
width
:
50
rpx
;
height
:
50
rpx
;
margin-right
:
10
rpx
;
}
.scanBox
{
width
:
40
rpx
;
display
:
flex
;
flex-wrap
:
wrap
;
}
.scanIcon
{
width
:
40
rpx
;
height
:
40
rpx
;
}
.scanText
{
font-size
:
20
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
800
;
color
:
#111111
;
line-height
:
20
rpx
;
}
.activeContent
{
width
:
100%
;
height
:
300
rpx
;
border-radius
:
20
rpx
;
margin-bottom
:
50
rpx
;
overflow
:
hidden
;
box-sizing
:
border-box
;
padding
:
0
30
rpx
;
}
.swiperList
{
position
:
relative
;
width
:
100%
;
height
:
300
rpx
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
background-clip
:
border-box
;
box-sizing
:
border-box
;
overflow
:
hidden
;
color
:
#fff
;
border-radius
:
20
rpx
;
}
.swiper_Time
{
position
:
absolute
;
top
:
20
rpx
;
right
:
40
rpx
;
font-size
:
26
rpx
;
}
.swiper_Name
{
position
:
absolute
;
bottom
:
20
rpx
;
left
:
30
rpx
;
font-size
:
26
rpx
;
}
.swiper
{
position
:
relative
;
border-radius
:
20
rpx
;
}
.swiper
/
deep
/
.wx-swiper-dot
{
width
:
10
rpx
;
height
:
10
rpx
;
margin-right
:
0
;
}
.wordBox
{
box-sizing
:
border-box
;
/* height: 390rpx; */
background-color
:
#EBEBEB
;
padding
:
30
rpx
;
margin-bottom
:
50
rpx
;
}
.wordTitle
{
font-size
:
28
rpx
;
font-weight
:
bold
;
color
:
#111111
;
margin-bottom
:
45
rpx
;
}
.wordItem
{
width
:
200
rpx
;
display
:
flex
;
flex-wrap
:
wrap
;
justify-content
:
center
;
}
.wordItemTitle
{
width
:
100%
;
font-size
:
22
rpx
;
font-weight
:
500
;
color
:
#666666
;
text-align
:
center
;
margin-bottom
:
10
rpx
;
}
.wordItemText
{
font-size
:
78
rpx
;
line-height
:
60
rpx
;
font-weight
:
800
;
font-style
:
italic
;
color
:
#111111
;
white-space
:
nowrap
;
}
.wordItemTextUnit
{
font-size
:
22
rpx
;
font-weight
:
400
;
font-style
:
normal
;
margin-left
:
10
rpx
;
}
.wordDuration
{
margin
:
50
rpx
0
15
rpx
;
font-size
:
22
rpx
;
font-weight
:
500
;
color
:
#999999
;
text-align
:
center
;
}
.wordBtn
{
width
:
130
rpx
;
height
:
50
rpx
;
background-color
:
#4C50E7
;
border-radius
:
25
rpx
;
margin
:
10
rpx
auto
;
font-size
:
22
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#FEFEFF
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
}
.courseBox
{
width
:
690
rpx
;
margin
:
0
auto
;
height
:
350
rpx
;
background
:
linear-gradient
(
0deg
,
#FFFFFF
,
#4C50E7
);
box-shadow
:
2
rpx
4
rpx
40
rpx
0
rpx
rgba
(
212
,
212
,
212
,
0.6
);
border-radius
:
24
rpx
;
box-sizing
:
border-box
;
padding
:
10
rpx
;
position
:
relative
;
margin-bottom
:
50
rpx
;
}
.courseInnerBox
{
width
:
100%
;
height
:
100%
;
background-color
:
#FFFFFF
;
border-radius
:
24
rpx
;
}
.courseTitle
{
box-sizing
:
border-box
;
padding
:
10
rpx
20
rpx
10
rpx
10
rpx
;
background
:
linear-gradient
(
0deg
,
#6C70EB
,
#505FEB
);
position
:
absolute
;
top
:
10
rpx
;
left
:
10
rpx
;
border-bottom-right-radius
:
30
rpx
;
font-size
:
28
rpx
;
font-weight
:
500
;
color
:
#FFFFFF
;
}
.courseInnerBox
.top
{
display
:
flex
;
justify-content
:
flex-end
;
align-items
:
center
;
height
:
60
rpx
;
margin-bottom
:
50
rpx
;
}
.courseIcon
{
width
:
30
rpx
;
height
:
30
rpx
;
}
.courseDateStr
{
font-size
:
22
rpx
;
font-weight
:
500
;
color
:
#111111
;
}
.courseIcon2
{
width
:
235
rpx
;
height
:
225
rpx
;
}
.courseNameBox
{
width
:
410
rpx
;
box-sizing
:
border-box
;
padding
:
0
25
rpx
;
}
.className
{
font-size
:
22
rpx
;
font-weight
:
500
;
color
:
#666666
;
margin-bottom
:
20
rpx
;
}
.courseName
{
width
:
355
rrpx
;
height
:
75
rpx
;
background-color
:
#F5F5F5
;
border-radius
:
35
rpx
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
font-size
:
42
rpx
;
font-weight
:
bold
;
color
:
#111111
;
}
.learningGarden
{
box-sizing
:
border-box
;
padding
:
0
30
rpx
;
}
.learningGardenSbutitle
{
font-size
:
28
rpx
;
font-weight
:
500
;
color
:
#666666
;
margin-bottom
:
15
rpx
;
}
.learningGardenTitle
{
font-size
:
46
rpx
;
font-weight
:
800
;
color
:
#111111
;
margin-bottom
:
35
rpx
;
}
.gardenCon
{
width
:
680
rpx
;
height
:
455
rpx
;
border-radius
:
24
rpx
;
margin-bottom
:
30
rpx
;
overflow
:
hidden
;
position
:
relative
;
}
.gardenTextBox
{
position
:
absolute
;
left
:
0
;
bottom
:
0
;
width
:
100%
;
height
:
180
rpx
;
background
:
linear-gradient
(
0deg
,
#FBD140
);
box-sizing
:
border-box
;
padding
:
80
rpx
40
rpx
0
;
overflow
:
hidden
;
}
.gardenTitle
{
font-size
:
28
rpx
;
font-weight
:
bold
;
color
:
#FFFFFF
;
white-space
:
nowrap
;
}
.gardenDigest
{
font-size
:
20
rpx
;
font-weight
:
500
;
color
:
#FFFFFF
;
margin-top
:
15
rpx
;
white-space
:
nowrap
;
}
.con
{
box-sizing
:
border-box
;
/* padding: 0rpx 30rpx 50rpx; */
}
.page-title
{
font-size
:
44
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#0f1b35
;
}
.personInfo
{
height
:
100
rpx
;
position
:
relative
;
margin-bottom
:
50
rpx
;
}
.headimg
{
margin-right
:
30
rpx
;
}
.name
{
font-size
:
30
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#0f1b35
;
}
.phone
{
font-size
:
26
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#999999
;
}
.saleInfo
{
/* width: 200rpx; */
height
:
66
rpx
;
background-color
:
#00acf9
;
border-radius
:
33
rpx
0
rpx
0
rpx
33
rpx
;
position
:
absolute
;
top
:
50%
;
transform
:
translateY
(
-50%
);
right
:
-30
rpx
;
z-index
:
10
;
box-sizing
:
border-box
;
padding
:
0
20
rpx
;
font-family
:
PingFang
SC
;
color
:
#ffffff
;
}
.saleInfo
.info1
{
text-align
:
center
;
font-size
:
22
rpx
;
font-weight
:
bold
;
}
.saleInfo
.info2
{
font-size
:
20
rpx
;
}
.baseInfo
{
margin-bottom
:
10
rpx
;
}
.baseInfo_item
{
width
:
220
rpx
;
height
:
140
rpx
;
border-radius
:
20
rpx
;
box-sizing
:
border-box
;
padding
:
38
rpx
20
rpx
;
margin-right
:
15
rpx
;
margin-bottom
:
30
rpx
;
}
.baseInfo
.baseInfo_item
:nth-child
(
3n
)
{
margin-right
:
0
rpx
;
}
.baseInfo_name
{
font-size
:
28
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#0f1b35
;
margin
:
-7
rpx
0
3
rpx
0
;
}
.baseInfo_desc
{
font-size
:
22
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#333e52
;
}
.timetable
{
height
:
360
rpx
;
background-image
:
url("https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/coursebg.png")
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
border-radius
:
20
rpx
;
overflow
:
hidden
;
box-sizing
:
border-box
;
padding
:
30
rpx
30
rpx
0
50
rpx
;
margin-bottom
:
50
rpx
;
}
.timetable_item
{
color
:
#fff
;
margin-bottom
:
20
rpx
;
}
.timetable_title
{
font-size
:
32
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
}
.timetable_btn
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
/* font-weight: 500; */
}
.timetable_item2
{
color
:
#fff
;
margin-bottom
:
20
rpx
;
font-size
:
26
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
}
/
deep
/
.title
{
font-size
:
32
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
800
;
color
:
#0f1b35
;
}
/
deep
/
.value
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#333f53
;
}
/
deep
/
.van-cell
{
padding
:
0
;
}
.mytest
{
width
:
720
rpx
;
height
:
250
rpx
;
margin-top
:
30
rpx
;
overflow-x
:
scroll
;
overflow-y
:
hidden
;
-webkit-overflow-scrolling
:
touch
;
transition
:
all
0.5s
;
}
.test-item
{
width
:
620
rpx
;
height
:
250
rpx
;
box-sizing
:
border-box
;
border-radius
:
20
rpx
;
overflow
:
hidden
;
margin-right
:
30
rpx
;
background-repeat
:
no-repeat
;
background-position
:
center
;
background-size
:
cover
;
background-origin
:
border-box
;
background-clip
:
border-box
;
padding-top
:
60
rpx
;
padding-left
:
44
rpx
;
position
:
relative
;
}
.testName
{
font-size
:
40
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#0f1b35
;
margin-bottom
:
20
rpx
;
}
.testTime
{
font-size
:
28
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#0f1b35
;
}
.teacherInfo-bg
{
position
:
absolute
;
left
:
0
;
bottom
:
0
;
width
:
620
rpx
;
height
:
70
rpx
;
background-image
:
linear-gradient
(
90deg
,
#000000
,
#ffffff
);
opacity
:
0.4
;
z-index
:
1
;
}
.teacherInfo
{
position
:
absolute
;
left
:
0
;
bottom
:
0
;
width
:
620
rpx
;
height
:
70
rpx
;
z-index
:
2
;
box-sizing
:
border-box
;
padding
:
0
30
rpx
;
}
.teacherName
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#ffffff
;
margin-left
:
10
rpx
;
}
.test-status
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
/* color: #00acf9; */
}
.status-blue
{
color
:
#00acf9
;
}
.status-green
{
color
:
#00df9f
;
}
.status-black
{
color
:
#111111
;
}
.status-red
{
color
:
#ff3816
;
}
.LearningGarden
{
box-sizing
:
border-box
;
margin-bottom
:
10
rpx
;
}
.LearningGarden-item
{
width
:
330
rpx
;
height
:
140
rpx
;
border-radius
:
20
rpx
;
margin-right
:
30
rpx
;
margin-bottom
:
30
rpx
;
box-sizing
:
border-box
;
padding
:
30
rpx
20
rpx
;
position
:
relative
;
}
.LearningGarden
.LearningGarden-item
:nth-child
(
2n
)
{
margin-right
:
0
rpx
!important
;
}
.LearningGarden-item-name
{
width
:
220
rpx
;
font-size
:
28
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#0f1b35
;
}
.LearningGarden-item-desc
{
width
:
220
rpx
;
font-size
:
22
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#333e52
;
margin-top
:
10
rpx
;
}
.LearningGarden-item-img
{
width
:
64
rpx
;
height
:
66
rpx
;
position
:
absolute
;
top
:
38
rpx
;
right
:
20
rpx
;
}
.feedback
{
margin
:
30
rpx
0
;
}
.feedback-info
{
height
:
60
rpx
;
}
.info-headimg
{
width
:
60
rpx
;
height
:
60
rpx
;
background-color
:
#c4a1a1
;
border-radius
:
50%
;
margin-right
:
20
rpx
;
}
.teacher-name
{
max-width
:
500
rpx
;
font-size
:
26
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#111111
;
}
.FeedBackTime
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#111111
;
margin-left
:
20
rpx
;
}
.feedback-all
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
500
;
color
:
#999999
;
}
.feedback-text
{
font-size
:
24
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
400
;
color
:
#111111
;
margin
:
20
rpx
0
;
}
.feedback-img
{
width
:
210
rpx
;
height
:
210
rpx
;
border-radius
:
20
rpx
;
background-color
:
#eee
;
overflow
:
hidden
;
margin-right
:
30
rpx
;
position
:
relative
;
box-shadow
:
0
rpx
10
rpx
30
rpx
0
rpx
rgba
(
36
,
36
,
36
,
0.2
);
}
.feedback-img
:nth-child
(
3n
)
{
margin-right
:
0
rpx
!important
;
}
.layer
{
width
:
210
rpx
;
height
:
210
rpx
;
border-radius
:
20
rpx
;
background-color
:
#cbd9ed
;
opacity
:
0.5
;
position
:
absolute
;
top
:
0
;
right
:
0
;
}
.layer2
{
width
:
210
rpx
;
height
:
210
rpx
;
border-radius
:
20
rpx
;
font-size
:
36
rpx
;
font-family
:
PingFang
SC
;
font-weight
:
bold
;
color
:
#111111
;
position
:
absolute
;
top
:
0
;
right
:
0
;
z-index
:
5
;
}
.activeContent
{
width
:
100%
;
height
:
250
rpx
;
border-radius
:
20
rpx
;
margin-bottom
:
30
rpx
;
overflow
:
hidden
;
}
.swiperList
{
position
:
relative
;
width
:
100%
;
height
:
250
rpx
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
background-clip
:
border-box
;
box-sizing
:
border-box
;
overflow
:
hidden
;
color
:
#fff
;
border-radius
:
20
rpx
;
}
.swiper_Time
{
position
:
absolute
;
top
:
20
rpx
;
right
:
40
rpx
;
font-size
:
26
rpx
;
}
.swiper_Name
{
position
:
absolute
;
bottom
:
20
rpx
;
left
:
30
rpx
;
font-size
:
26
rpx
;
}
.swiper
{
position
:
relative
;
border-radius
:
20
rpx
;
}
/* .swiper /deep/ .wx-swiper-dots {
position: absolute;
right: -10rpx;
top: 50%;
transform: translateY(-50%);
z-index: 999;
} */
.swiper
/
deep
/
.wx-swiper-dot
{
width
:
10
rpx
;
height
:
10
rpx
;
margin-right
:
0
;
}
</
style
>
src/static/css/common.css
View file @
95fff39c
...
...
@@ -25,6 +25,7 @@
}
.flex_around_center
{
display
:
flex
;
justify-content
:
space-around
;
align-items
:
center
;
flex-flow
:
row
wrap
...
...
src/utils/index.js
View file @
95fff39c
//脱敏
export
let
desensitization
=
(
str
,
beginLen
,
endLen
)
=>
{
let
len
=
str
.
length
;
let
firstStr
=
str
.
substr
(
0
,
beginLen
);
let
lastStr
=
str
.
substr
(
endLen
);
let
middleStr
=
str
.
substring
(
beginLen
,
len
-
Math
.
abs
(
endLen
)).
replace
(
/
[\s\S]
/ig
,
'*'
);
let
tempStr
=
firstStr
+
middleStr
+
lastStr
;
return
tempStr
;
let
len
=
str
.
length
;
let
firstStr
=
str
.
substr
(
0
,
beginLen
);
let
lastStr
=
str
.
substr
(
endLen
);
let
middleStr
=
str
.
substring
(
beginLen
,
len
-
Math
.
abs
(
endLen
)).
replace
(
/
[\s\S]
/ig
,
'*'
);
let
tempStr
=
firstStr
+
middleStr
+
lastStr
;
return
tempStr
;
}
export
let
uploadFile
=
(
path
,
file
,
successCallback
)
=>
{
for
(
let
i
=
0
;
i
<
file
.
length
;
i
++
)
{
UploadSelfFile
(
path
,
file
[
i
],
successCallback
)
}
for
(
let
i
=
0
;
i
<
file
.
length
;
i
++
)
{
UploadSelfFile
(
path
,
file
[
i
],
successCallback
)
}
}
//获取base64格式路径
export
let
urlTobase64
=
(
file
,
suc
)
=>
{
uni
.
getFileSystemManager
().
readFile
({
filePath
:
file
,
//选择图片返回的相对路径
encoding
:
'base64'
,
//编码格式
success
:
(
res
)
=>
{
//成功的回调
let
data
=
res
.
data
;
let
base64
=
'data:image/png;base64,'
+
data
suc
(
base64
);
}
});
uni
.
getFileSystemManager
().
readFile
({
filePath
:
file
,
//选择图片返回的相对路径
encoding
:
'base64'
,
//编码格式
success
:
(
res
)
=>
{
//成功的回调
let
data
=
res
.
data
;
let
base64
=
'data:image/png;base64,'
+
data
suc
(
base64
);
}
});
}
/**
* 上传文件
*/
export
function
UploadSelfFile
(
path
,
file
,
callback
,
configObj
)
{
//用户登录缓存
var
cacheInfo
=
uni
.
getStorageSync
(
"userInfo"
)
//上传配置
var
uploadConfig
=
""
;
if
(
cacheInfo
&&
cacheInfo
.
UploadConfig
)
{
uploadConfig
=
cacheInfo
.
UploadConfig
;
}
//获取文件扩展名
var
index
=
file
.
url
.
lastIndexOf
(
"."
);
var
suffix
=
file
.
url
.
substr
(
index
);
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
let
str
=
'/Test'
;
var
newPath
=
"/EduSystem"
+
str
+
'/Upload/'
+
path
;
uni
.
showLoading
({
title
:
'文件上传中...'
});
if
(
uploadConfig
)
{
switch
(
uploadConfig
.
StoreType
)
{
//上传文件到腾讯云
case
1
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
callback
);
break
;
//上传文件到阿里云
case
2
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToALi
(
uploadConfig
,
newPath
,
file
,
callback
);
break
;
//上传文件到自己文件服务器
case
3
:
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
callback
,
configObj
);
break
;
}
}
//用户登录缓存
var
cacheInfo
=
uni
.
getStorageSync
(
"userInfo"
)
//上传配置
var
uploadConfig
=
""
;
if
(
cacheInfo
&&
cacheInfo
.
UploadConfig
)
{
uploadConfig
=
cacheInfo
.
UploadConfig
;
}
//获取文件扩展名
var
index
=
file
.
url
.
lastIndexOf
(
"."
);
var
suffix
=
file
.
url
.
substr
(
index
);
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
let
str
=
'/Test'
;
var
newPath
=
"/EduSystem"
+
str
+
'/Upload/'
+
path
;
uni
.
showLoading
({
title
:
'文件上传中...'
});
if
(
uploadConfig
)
{
switch
(
uploadConfig
.
StoreType
)
{
//上传文件到腾讯云
case
1
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToTencent
(
uploadConfig
,
newPath
,
file
,
callback
);
break
;
//上传文件到阿里云
case
2
:
newPath
+=
"/"
+
timestamp1
+
""
+
suffix
;
UploadFileToALi
(
uploadConfig
,
newPath
,
file
,
callback
);
break
;
//上传文件到自己文件服务器
case
3
:
UploadFileToSystem
(
uploadConfig
,
newPath
,
file
,
callback
,
configObj
);
break
;
}
}
}
/**
* 上传文件到本地文件系统
*/
export
function
UploadFileToSystem
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
,
configObj
)
{
let
url
=
uploadConfig
.
UploadDomain
+
"/Upload?filePath="
+
fileFullPath
;
if
(
configObj
)
{
//是否转换图片
if
(
configObj
.
isTrans
&&
configObj
.
isTrans
==
1
)
{
url
+=
"&isTrans=1"
}
if
(
configObj
.
isCreateCover
&&
configObj
.
isCreateCover
==
1
)
{
url
+=
"&isCreateCover=1"
}
}
uni
.
uploadFile
({
url
:
url
,
filePath
:
fileObj
.
url
,
name
:
'file'
,
formData
:
{
'myfile'
:
fileObj
},
success
(
res
)
{
uni
.
hideLoading
();
let
jsonObj
=
JSON
.
parse
(
res
.
data
)
let
index
=
jsonObj
.
FilePath
.
indexOf
(
"."
)
let
suffix
=
jsonObj
.
FilePath
.
slice
(
index
+
1
)
let
uploadResult
=
{
name
:
fileObj
.
name
,
url
:
uploadConfig
.
CustomDomain
+
'/'
+
jsonObj
.
FilePath
,
type
:
fileObj
.
type
,
suffix
:
suffix
,
// VideoCoverImg: uploadConfig.CustomDomain + jsonObj.VideoCoverImg,
}
successCall
(
uploadResult
);
},
fail
(
err
)
{
console
.
log
(
"uploadErr"
,
err
)
}
});
let
url
=
uploadConfig
.
UploadDomain
+
"/Upload?filePath="
+
fileFullPath
;
if
(
configObj
)
{
//是否转换图片
if
(
configObj
.
isTrans
&&
configObj
.
isTrans
==
1
)
{
url
+=
"&isTrans=1"
}
if
(
configObj
.
isCreateCover
&&
configObj
.
isCreateCover
==
1
)
{
url
+=
"&isCreateCover=1"
}
}
uni
.
uploadFile
({
url
:
url
,
filePath
:
fileObj
.
url
,
name
:
'file'
,
formData
:
{
'myfile'
:
fileObj
},
success
(
res
)
{
uni
.
hideLoading
();
let
jsonObj
=
JSON
.
parse
(
res
.
data
)
let
index
=
jsonObj
.
FilePath
.
indexOf
(
"."
)
let
suffix
=
jsonObj
.
FilePath
.
slice
(
index
+
1
)
let
uploadResult
=
{
name
:
fileObj
.
name
,
url
:
uploadConfig
.
CustomDomain
+
'/'
+
jsonObj
.
FilePath
,
type
:
fileObj
.
type
,
suffix
:
suffix
,
// VideoCoverImg: uploadConfig.CustomDomain + jsonObj.VideoCoverImg,
}
successCall
(
uploadResult
);
},
fail
(
err
)
{
console
.
log
(
"uploadErr"
,
err
)
}
});
}
/**
* 上传文件到阿里云
*/
export
function
UploadFileToALi
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
)
{
// var OSS = require('ali-oss');
// var oss = new OSS({
// region: uploadConfig.Region,
// accessKeyId: uploadConfig.SecretId,
// accessKeySecret: uploadConfig.SecretKey,
// bucket: uploadConfig.Bucket
// })
// var result = oss.multipartUpload(fileFullPath, fileObj, {
// progress: function* (p) { }
// }).then(res => {
// uni.hideLoading()
// var uploadResult = {
// Code: 1,
// FileName: fileObj.name,
// FileUrl: res.res.requestUrls[0].split('?')[0].replace('http', 'https')
// }
// if (successCall) {
// successCall(uploadResult);
// }
// })
// var OSS = require('ali-oss');
// var oss = new OSS({
// region: uploadConfig.Region,
// accessKeyId: uploadConfig.SecretId,
// accessKeySecret: uploadConfig.SecretKey,
// bucket: uploadConfig.Bucket
// })
// var result = oss.multipartUpload(fileFullPath, fileObj, {
// progress: function* (p) { }
// }).then(res => {
// uni.hideLoading()
// var uploadResult = {
// Code: 1,
// FileName: fileObj.name,
// FileUrl: res.res.requestUrls[0].split('?')[0].replace('http', 'https')
// }
// if (successCall) {
// successCall(uploadResult);
// }
// })
}
/**
* 上传文件到腾讯云
*/
export
function
UploadFileToTencent
(
uploadConfig
,
fileFullPath
,
fileObj
,
successCall
)
{
// var COS = require('cos-js-sdk-v5');
// var cos = new COS({
// SecretId: uploadConfig.SecretId,
// SecretKey: uploadConfig.SecretKey,
// });
// cos.putObject({
// Bucket: uploadConfig.Bucket,
// Region: uploadConfig.Region, //存储桶所在地域,必须字段
// Key: fileFullPath, //文件名
// StorageClass: 'STANDARD',
// Body: fileObj, // 上传文件对象
// onProgress: function (progressData) { }
// }, function (err, data) {
// uni.hideLoading()
// if (data && data.statusCode == 200) {
// var uploadResult = {
// Code: 1,
// FileName: fileObj.name,
// FileUrl: "https://" + data.Location
// }
// if (successCall) {
// successCall(uploadResult);
// }
// } else {
// /*上传文件异常*/
// console.log(err || data);
// }
// });
// var COS = require('cos-js-sdk-v5');
// var cos = new COS({
// SecretId: uploadConfig.SecretId,
// SecretKey: uploadConfig.SecretKey,
// });
// cos.putObject({
// Bucket: uploadConfig.Bucket,
// Region: uploadConfig.Region, //存储桶所在地域,必须字段
// Key: fileFullPath, //文件名
// StorageClass: 'STANDARD',
// Body: fileObj, // 上传文件对象
// onProgress: function (progressData) { }
// }, function (err, data) {
// uni.hideLoading()
// if (data && data.statusCode == 200) {
// var uploadResult = {
// Code: 1,
// FileName: fileObj.name,
// FileUrl: "https://" + data.Location
// }
// if (successCall) {
// successCall(uploadResult);
// }
// } else {
// /*上传文件异常*/
// console.log(err || data);
// }
// });
}
// 数字转汉字
export
let
changeNumToHan
=
(
num
)
=>
{
var
arr1
=
new
Array
(
'零'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
,
'七'
,
'八'
,
'九'
);
var
arr2
=
new
Array
(
''
,
'十'
,
'百'
,
'千'
,
'万'
,
'十'
,
'百'
,
'千'
,
'亿'
,
'十'
,
'百'
,
'千'
,
'万'
,
'十'
,
'百'
,
'千'
,
'亿'
);
//可继续追加更高位转换值
if
(
!
num
||
isNaN
(
num
))
{
return
"零"
;
}
var
english
=
num
.
toString
().
split
(
""
)
var
result
=
""
;
for
(
var
i
=
0
;
i
<
english
.
length
;
i
++
)
{
var
des_i
=
english
.
length
-
1
-
i
;
//倒序排列设值
result
=
arr2
[
i
]
+
result
;
var
arr1_index
=
english
[
des_i
];
result
=
arr1
[
arr1_index
]
+
result
;
}
//将【零千、零百】换成【零】 【十零】换成【十】
result
=
result
.
replace
(
/零
(
千|百|十
)
/g
,
'零'
).
replace
(
/十零/g
,
'十'
);
//合并中间多个零为一个零
result
=
result
.
replace
(
/零+/g
,
'零'
);
//将【零亿】换成【亿】【零万】换成【万】
result
=
result
.
replace
(
/零亿/g
,
'亿'
).
replace
(
/零万/g
,
'万'
);
//将【亿万】换成【亿】
result
=
result
.
replace
(
/亿万/g
,
'亿'
);
//移除末尾的零
result
=
result
.
replace
(
/零+$/
,
''
)
//将【零一十】换成【零十】
//result = result.replace(/零一十/g, '零十');//貌似正规读法是零一十
//将【一十】换成【十】
result
=
result
.
replace
(
/^一十/g
,
'十'
)
return
result
;
var
arr1
=
new
Array
(
'零'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
,
'七'
,
'八'
,
'九'
);
var
arr2
=
new
Array
(
''
,
'十'
,
'百'
,
'千'
,
'万'
,
'十'
,
'百'
,
'千'
,
'亿'
,
'十'
,
'百'
,
'千'
,
'万'
,
'十'
,
'百'
,
'千'
,
'亿'
);
//可继续追加更高位转换值
if
(
!
num
||
isNaN
(
num
))
{
return
"零"
;
}
var
english
=
num
.
toString
().
split
(
""
)
var
result
=
""
;
for
(
var
i
=
0
;
i
<
english
.
length
;
i
++
)
{
var
des_i
=
english
.
length
-
1
-
i
;
//倒序排列设值
result
=
arr2
[
i
]
+
result
;
var
arr1_index
=
english
[
des_i
];
result
=
arr1
[
arr1_index
]
+
result
;
}
//将【零千、零百】换成【零】 【十零】换成【十】
result
=
result
.
replace
(
/零
(
千|百|十
)
/g
,
'零'
).
replace
(
/十零/g
,
'十'
);
//合并中间多个零为一个零
result
=
result
.
replace
(
/零+/g
,
'零'
);
//将【零亿】换成【亿】【零万】换成【万】
result
=
result
.
replace
(
/零亿/g
,
'亿'
).
replace
(
/零万/g
,
'万'
);
//将【亿万】换成【亿】
result
=
result
.
replace
(
/亿万/g
,
'亿'
);
//移除末尾的零
result
=
result
.
replace
(
/零+$/
,
''
)
//将【零一十】换成【零十】
//result = result.replace(/零一十/g, '零十');//貌似正规读法是零一十
//将【一十】换成【十】
result
=
result
.
replace
(
/^一十/g
,
'十'
)
return
result
;
}
// 判断登录
export
let
isLogin
=
()
=>
{
let
userinfo
=
uni
.
getStorageSync
(
'userInfo'
);
if
(
!
userinfo
||
userinfo
===
""
)
{
uni
.
showToast
({
title
:
'请登录账号'
,
duration
:
2000
,
icon
:
"error"
,
// success: () => {
// setTimeout(() => {
// uni.navigateTo({
// url: '/pages/login/login'
// });
// clearTimeout();
// }, 2000)
let
userinfo
=
uni
.
getStorageSync
(
'userInfo'
);
if
(
!
userinfo
||
userinfo
===
""
)
{
uni
.
showToast
({
title
:
'请登录账号'
,
duration
:
2000
,
icon
:
"error"
,
// success: () => {
// setTimeout(() => {
// uni.navigateTo({
// url: '/pages/login/login'
// });
// clearTimeout();
// }, 2000)
// }
});
// }
});
}
}
}
export
let
getImageColor
=
async
(
canvasID
,
imgID
,
imgSrc
)
=>
{
let
res
=
{
r
:
1
,
g
:
1
,
b
:
1
}
const
canvas
=
uni
.
createCanvasContext
(
canvasID
)
let
imgWidth
let
imgHeight
await
new
Promise
(
resolve
=>
{
uni
.
createSelectorQuery
().
select
(
"#"
+
imgID
).
boundingClientRect
(
res
=>
{
console
.
log
(
234
,
res
)
imgWidth
=
res
?.
width
??
10
;
imgHeight
=
res
?.
height
??
10
;
resolve
()
}).
exec
()
})
canvas
.
fillRect
(
0
,
0
,
imgWidth
,
imgHeight
)
let
base64Img
=
await
netUrlTobase64
(
imgSrc
)
canvas
.
drawImage
(
base64Img
,
0
,
0
,
imgWidth
,
imgHeight
)
res
=
await
new
Promise
((
resolve
,
reject
)
=>
{
canvas
.
draw
(
true
,
(
e
)
=>
{
// 获取像素数据
uni
.
canvasGetImageData
({
// #ifdef MP-WEIXIN
canvasId
:
canvas
.
canvasId
,
// #endif
// #ifndef MP-WEIXIN
canvasId
:
canvas
.
id
,
// #endif
x
:
0
,
y
:
0
,
width
:
imgWidth
,
height
:
imgHeight
,
success
:
(
res
)
=>
{
let
data
=
res
.
data
;
var
r
=
1
,
g
=
1
,
b
=
1
;
// 取所有像素的平均值
for
(
var
row
=
0
;
row
<
imgHeight
;
row
++
)
{
for
(
var
col
=
0
;
col
<
imgWidth
;
col
++
)
{
// console.log(data[((img.width * row) + col) * 4])
if
(
row
==
0
)
{
r
+=
data
[((
imgWidth
*
row
)
+
col
)];
g
+=
data
[((
imgWidth
*
row
)
+
col
)
+
1
];
b
+=
data
[((
imgWidth
*
row
)
+
col
)
+
2
];
}
else
{
r
+=
data
[((
imgWidth
*
row
)
+
col
)
*
4
];
g
+=
data
[((
imgWidth
*
row
)
+
col
)
*
4
+
1
];
b
+=
data
[((
imgWidth
*
row
)
+
col
)
*
4
+
2
];
}
}
}
// 求取平均值
r
/=
(
imgWidth
*
imgHeight
);
g
/=
(
imgWidth
*
imgHeight
);
b
/=
(
imgWidth
*
imgHeight
);
// 将最终的值取整
r
=
Math
.
round
(
r
);
g
=
Math
.
round
(
g
);
b
=
Math
.
round
(
b
);
let
obj
=
{
r
,
g
,
b
}
resolve
(
obj
);
},
fail
:
(
fail
)
=>
{
reject
(
fail
);
}
});
})
})
return
res
}
// 网络图片转base64
export
let
netUrlTobase64
=
async
(
url
,
suc
)
=>
{
let
toBase64Url
=
""
toBase64Url
=
await
new
Promise
(
resolve
=>
{
uni
.
request
({
url
:
url
,
method
:
'GET'
,
responseType
:
'arraybuffer'
,
success
(
res
)
{
const
base64
=
wx
.
arrayBufferToBase64
(
res
.
data
);
//把arraybuffer转成base64
const
conType
=
res
.
header
[
'Content-Type'
]
toBase64Url
=
'data:'
+
conType
+
';base64,'
+
base64
;
//不加上这串字符,在页面无法显示
resolve
(
toBase64Url
)
}
});
})
return
toBase64Url
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment