更新代码

This commit is contained in:
duan
2025-01-06 18:28:10 +08:00
parent 4ccddee396
commit 0cdd737ca5
6 changed files with 393 additions and 342 deletions

233
App.vue
View File

@@ -1,124 +1,123 @@
<script> <script>
import http from '@/http/http.js' import { init } from '@/api/init.js'
export default { import http from '@/http/http.js'
onLaunch: function() { export default {
console.log('App Launch') onLaunch: function () {
// const systemInfo = uni.getSystemInfoSync(); console.log('App Launch')
// const isA = systemInfo.platform === 'android' // const systemInfo = uni.getSystemInfoSync();
// if (isA) { // const isA = systemInfo.platform === 'android'
// uni.setStorageSync('isAI', true) // if (isA) {
// } else { // uni.setStorageSync('isAI', true)
// uni.setStorageSync('isAI', false) // } else {
// } // uni.setStorageSync('isAI', false)
// }
}, },
onShow: function() { onShow: function () {
// ios是否在审核 init()
http.request({ // ios是否在审核
url: 'app/common/type/919', http.request({
}).then(res => { url: '/common/type/919',
if (res.code == 0) { }).then(res => {
uni.setStorageSync('isExamine', res.data.value) if (res.code == 0) {
} uni.setStorageSync('isExamine', res.data.value)
}) }
}, })
onHide: function() { },
console.log('App Hide') onHide: function () {
} console.log('App Hide')
} }
}
</script> </script>
<style lang="scss"> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
@import "uview-plus/index.scss"; @import "uview-plus/index.scss";
ul, ul,
li { li {
list-style: none; list-style: none;
} }
.show { .show {
display: none !important; display: none !important;
} }
.hidden { .hidden {
display: block !important; display: block !important;
} }
page, page,
view, view,
scroll-view, scroll-view,
swiper, swiper,
swiper-item, swiper-item,
match-media, match-media,
movable-area, movable-area,
movable-view, movable-view,
cover-view, cover-view,
cover-image, cover-image,
icon, icon,
text, text,
rich-text, rich-text,
progress, progress,
button, button,
checkbox-group, checkbox-group,
editor, editor,
form, form,
input, input,
label, label,
picker, picker,
picker-view, picker-view,
radio-group, radio-group,
slider, slider,
switch, switch,
textarea, textarea,
navigator, navigator,
audio, audio,
camera, camera,
image, image,
video, video,
live-player, live-player,
live-pusher, live-pusher,
map, map,
canvas, canvas,
web-view { web-view {
box-sizing: border-box; box-sizing: border-box;
padding: 0; padding: 0;
margin: 0; margin: 0;
text-decoration: none; text-decoration: none;
outline: none; outline: none;
} }
.initStyle { .initStyle {
padding: 20rpx; padding: 20rpx;
background-color: #2a2a2a; background-color: #2a2a2a;
height: 100vh; height: 100vh;
color: #fff; color: #fff;
} }
.fc { .fc {
color: #f4f693; color: #f4f693;
} }
.inputClass { .inputClass {
line-height: 80rpx; line-height: 80rpx;
} }
.inputClass input { .inputClass input {
background-color: #fff; background-color: #fff;
height: 80rpx; height: 80rpx;
padding: 10rpx; padding: 10rpx;
color: #000; color: #000;
} }
.result { .result {
position: absolute; position: absolute;
font-size: 100rpx; font-size: 100rpx;
left: 50%; left: 50%;
top: 800rpx; top: 800rpx;
transform: translateX(-50%); transform: translateX(-50%);
} }
</style> </style>

35
api/index/index.js Normal file
View File

@@ -0,0 +1,35 @@
import http from '@/http/http.js'
// 获取弹窗信息
export const announcement = (data) => {
return http.request({
url: '/announcement',
data
})
}
// 获取公告
export const messageselectMessage = (data) => {
return http.request({
url: '/message/selectMessage',
data: {
page: 1,
limit: 5,
state: 1
}
})
}
// 获取推荐视频
export const courseselectCourse = (data) => {
return http.request({
url: '/course/selectCourse',
data
})
}
// 搜索
export const selectCourseTitles = (data) => {
return http.request({
url: '/course/selectCourseTitles',
data
})
}

13
api/init.js Normal file
View File

@@ -0,0 +1,13 @@
import http from '@/http/http.js'
export async function init() {
//热搜词
http.request({
url: 'common/type/249',
}).then(res => {
if (res.code == 0) {
uni.setStorageSync('moreSearch', res.data.value)
}
})
}

View File

@@ -13,8 +13,7 @@ const loadingShowTime = 200
function getHeader() { function getHeader() {
const headerObject = {} const headerObject = {}
headerObject["token"] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNjkyNSIsImlhdCI6MTczNTg4OTk5NCwiZXhwIjoxNzM2NDk0Nzk0fQ.j-KFEE1FHckmFCO8UA884RBWvpMv8MfEGj7GPGf3kVo6sHeORl043Yle_w7HdTZKPpQqSr2LQLCq_rUxG4qqwA' headerObject["token"] = uni.getStorageSync('token')
// headerObject["token"] = uni.getStorageSync('token')
return headerObject return headerObject
} }

View File

@@ -10,7 +10,7 @@
</view> </view>
</view> </view>
<template v-if="datas.noticeList.length > 0 "> <template v-if="datas.noticeList.length > 0">
<view class="gongao"> <view class="gongao">
<view class="gongaoicon"> <view class="gongaoicon">
公告 公告
@@ -44,7 +44,7 @@
<contentlist :list='datas.list'></contentlist> <contentlist :list='datas.list'></contentlist>
<!-- <u-image v-if="isShowMoneyPay" @click="goMsg('/me/VjgyqAzklr/VjgyqAzklr')" :src="`../../static/red-pack-new.gif`" <!-- <u-image v-if="isShowMoneyPay" @click="goMsg('/me/VjgyqAzklr/VjgyqAzklr')" :src="`../../static/red-pack-new.gif`"
style="width: 200rpx;height: 200rpx;position: fixed;right: 10rpx;bottom: 180rpx;"></u-image> --> style="width: 200rpx;height: 200rpx;position: fixed;right: 10rpx;bottom: 180rpx;"></u-image> -->
<u-modal :show="datas.ruleShow" v-if="datas.isExamine==0" confirm-text="知道了" @confirm='datas.ruleShow=false' <u-modal :show="datas.ruleShow" v-if="datas.isExamine == 0" confirm-text="知道了" @confirm='datas.ruleShow = false'
:title="datas.rule_title" :title-style="{ fontWeight: '700' }" confirm-color="rgb(255, 117, 129)"> :title="datas.rule_title" :title-style="{ fontWeight: '700' }" confirm-color="rgb(255, 117, 129)">
<view class="" style="padding-top: 30rpx;text-align: left;"> <view class="" style="padding-top: 30rpx;text-align: left;">
<scroll-view scroll-y="true" style="max-height: 50vh;"> <scroll-view scroll-y="true" style="max-height: 50vh;">
@@ -55,199 +55,186 @@
</template> </template>
<script setup> <script setup>
import { import {
reactive reactive
} from 'vue'; } from 'vue';
import { import { announcement, messageselectMessage,courseselectCourse } from '@/api/index/index.js'
onLoad, import {
onReachBottom onLoad,
} from '@dcloudio/uni-app' onReachBottom
import contentlist from './components/contentlist.vue' } from '@dcloudio/uni-app'
import http from '@/http/http.js' import contentlist from './components/contentlist.vue'
let datas = reactive({ import http from '@/http/http.js'
noticeList: [], //公告列表 let datas = reactive({
noticeList: [], //公告列表
active: 1, // 最新、最热。。。切换顶部导航栏 active: 1, // 最新、最热。。。切换顶部导航栏
list: [], // 底部短剧内容 list: [], // 底部短剧内容
page: 1, // 首页推荐分页 page: 1, // 首页推荐分页
ruleShow: false, ruleShow: false,
rule_title: '', // 首页弹窗标题 rule_title: '', // 首页弹窗标题
rule_content: '', // 首页弹窗内容 rule_content: '', // 首页弹窗内容
//ios是否在审核 1是审核 //ios是否在审核 1是审核
isExamine: uni.getStorageSync('isExamine') isExamine: uni.getStorageSync('isExamine')
}) })
onLoad(() => { onLoad(() => {
getMsg() getMsg()
getrecomVideo() getrecomVideo()
getPop() getPop()
}) })
onReachBottom(() => { onReachBottom(() => {
++datas.page ++datas.page
getrecomVideo() getrecomVideo()
}) })
// 获取弹窗信息 // 获取弹窗信息
function getPop() { async function getPop() {
http.request({ let res = await announcement()
url: 'app/announcement', if (res.code == 0) {
}).then(res => { if (res.data && res.data.state == 1) {
if (res.code == 0) { datas.ruleShow = true
if (res.data && res.data.state == 1) { datas.rule_title = res.data.title
datas.ruleShow = true datas.rule_content = res.data.content
datas.rule_title = res.data.title }
datas.rule_content = res.data.content } else {
} uni.showToast({
} else { title: res.msg,
uni.showToast({ duration: 1000,
title: res.msg, icon: 'none'
duration: 1000,
icon: 'none'
});
}
})
}
// 搜索跳转
function moreVideo() {
uni.navigateTo({
url: '/pages/index/search/index'
}); });
} }
// 公告 }
function getMsg() { // 搜索跳转
http.request({ function moreVideo() {
url: 'app/message/selectMessage', uni.navigateTo({
data: { url: '/pages/index/search/index'
page: 1, });
limit: 5, }
state: 1 // 公告
} async function getMsg() {
}).then(res => { let res = await messageselectMessage()
if (res.code == 0) { if (res.code == 0) {
datas.noticeList = res.data.list datas.noticeList = res.data.list
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
duration: 1000, duration: 1000,
icon: 'none' icon: 'none'
}); });
}
})
} }
//获取推荐视频 }
function getrecomVideo(sort, active = 1) { //获取推荐视频
datas.active = active async function getrecomVideo(sort, active = 1) {
if (sort) { datas.active = active
datas.page = 1 if (sort) {
datas.page = 1
}
let res = await courseselectCourse({
page: datas.page,
limit: 12,
sort: sort,
classifyId: ''
})
if (res.code == 0) {
if (datas.page == 1) {
datas.list = res.data.list
} else {
datas.list = [...datas.list, ...res.data.list]
} }
http.request({ } else {
url: 'app/course/selectCourse', uni.showToast({
data: { title: res.msg,
page: datas.page, duration: 1000,
limit: 12, icon: 'none'
sort: sort, });
classifyId: ''
}
}).then(res => {
if (res.code == 0) {
if (datas.page == 1) {
datas.list = res.data.list
} else {
datas.list = [...datas.list, ...res.data.list]
}
} else {
uni.showToast({
title: res.msg,
duration: 1000,
icon: 'none'
});
}
})
} }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.indexStyle { .indexStyle {
height: 555rpx;
position: relative;
>image {
width: 100%;
height: 555rpx; height: 555rpx;
position: relative; position: absolute;
>image {
width: 100%;
height: 555rpx;
position: absolute;
}
.indexStyleTwo {
display: flex;
align-items: center;
justify-content: space-between;
padding: 88rpx 25rpx;
>image {
width: 187rpx;
height: 50rpx;
}
>view {
z-index: 50;
width: 236rpx;
line-height: 43rpx;
background: rgba(255, 255, 255, 0.29);
border-radius: 7rpx 7rpx 7rpx 7rpx;
font-weight: 400;
font-size: 21rpx;
color: rgba(255, 255, 255, 0.85);
display: flex;
align-items: center;
}
}
.gongao {
position: absolute;
bottom: 75rpx;
left: 70rpx;
border-radius: 21rpx 21rpx 21rpx 21rpx;
width: 611rpx;
height: 78rpx;
background-color: rgba(255, 255, 255, .65);
display: flex;
align-items: center;
padding: 12rpx;
box-sizing: border-box;
.gongaoicon {
color: #ffffff;
width: 98rpx;
height: 50rpx;
line-height: 50rpx;
text-align: center;
font-size: 25rpx;
background-image: url('../../static/index/gonggaobg.png');
background-size: 98rpx 50rpx;
}
.swiperstyle {
height: 78rpx;
width: 80%;
}
}
} }
.navTop { .indexStyleTwo {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 0 20rpx; padding: 88rpx 25rpx;
>image {
width: 187rpx;
height: 50rpx;
}
>view { >view {
background-color: #f0f0f0; z-index: 50;
margin-left: 20rpx; width: 236rpx;
padding: 6rpx 20rpx line-height: 43rpx;
background: rgba(255, 255, 255, 0.29);
border-radius: 7rpx 7rpx 7rpx 7rpx;
font-weight: 400;
font-size: 21rpx;
color: rgba(255, 255, 255, 0.85);
display: flex;
align-items: center;
} }
} }
.gongao {
position: absolute;
bottom: 75rpx;
left: 70rpx;
border-radius: 21rpx 21rpx 21rpx 21rpx;
width: 611rpx;
height: 78rpx;
background-color: rgba(255, 255, 255, .65);
display: flex;
align-items: center;
padding: 12rpx;
box-sizing: border-box;
.gongaoicon {
color: #ffffff;
width: 98rpx;
height: 50rpx;
line-height: 50rpx;
text-align: center;
font-size: 25rpx;
background-image: url('../../static/index/gonggaobg.png');
background-size: 98rpx 50rpx;
}
.swiperstyle {
height: 78rpx;
width: 80%;
}
}
}
.navTop {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20rpx;
>view {
background-color: #f0f0f0;
margin-left: 20rpx;
padding: 6rpx 20rpx
}
}
</style> </style>

View File

@@ -3,19 +3,20 @@
<u-sticky :enable="true"> <u-sticky :enable="true">
<view class="search-box"> <view class="search-box">
<u-search bg-color="#f2f2f2" style="width: 100%;" placeholder="搜索更多资源" :focus="true" :show-action="true" <u-search bg-color="#f2f2f2" style="width: 100%;" placeholder="搜索更多资源" :focus="true" :show-action="true"
:animation="true" action-text="取消" @custom="goBack()" @search="doSearch(false)"></u-search> :animation="true" action-text="取消" v-model="datas.keyword" @custom="goBack()"
@search="doSearch(false)"></u-search>
</view> </view>
</u-sticky> </u-sticky>
</view> </view>
<view class="search-keyword"> <view class="search-keyword">
<view class="keyword-block" v-if="datas.hotKeywordList.length !=0"> <view class="keyword-block" v-if="datas.hotKeywordList.length != 0">
<view class="keyword-list-header"> <view class="keyword-list-header">
<view>热搜</view> <view>热搜</view>
</view> </view>
<view class="keyword" v-if="forbid==''"> <view class="keyword" v-if="forbid == ''">
<view v-for="(keyword,index) in datas.hotKeywordList" @tap="doSearchs(keyword)" :key="index" <view v-for="(keyword, index) in datas.hotKeywordList" @tap="doSearchs(keyword)" :key="index"
v-if="keyword"> v-if="keyword">
{{keyword}} {{ keyword }}
</view> </view>
</view> </view>
<view class="hide-hot-tis" v-else> <view class="hide-hot-tis" v-else>
@@ -26,59 +27,76 @@
</template> </template>
<script setup> <script setup>
import { import { selectCourseTitles } from '@/api/index/index.js'
reactive import {
} from 'vue'; reactive
import { } from 'vue';
onShow import {
} from '@dcloudio/uni-app' onShow
let datas = reactive({ } from '@dcloudio/uni-app'
hotKeywordList: [], //热搜 let datas = reactive({
}) hotKeywordList: [], //热搜
onShow(() => { keywordList: [],// 搜索列表
getList() keyword: "",// 搜索关键字
}) })
onShow(() => {
getList()
})
function getList() { function getList() {
if (uni.getStorageSync('moreSearch')) { if (uni.getStorageSync('moreSearch')) {
datas.hotKeywordList = (uni.getStorageSync('moreSearch')).split(',') datas.hotKeywordList = (uni.getStorageSync('moreSearch')).split(',')
} else { } else {
datas.hotKeywordList = [] datas.hotKeywordList = []
}
} }
}
// 搜索
async function doSearch() {
let res = await selectCourseTitles({
title: datas.keyword,
limit: 20,
page: 1,
})
datas.keywordList = res.data.list
}
// 取消返回首页
function goBack() {
uni.navigateBack()
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.search-box { .search-box {
width: 100%; width: 100%;
/* background-color: rgb(242, 242, 242); */ /* background-color: rgb(242, 242, 242); */
padding: 15upx 2.5%; padding: 15upx 2.5%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
// position: sticky; // position: sticky;
// top: 0; // top: 0;
background-color: #ffffff; background-color: #ffffff;
} }
.search-keyword { .search-keyword {
width: 100%; width: 100%;
} }
.keyword-block { .keyword-block {
padding: 10upx 0; padding: 10upx 0;
} }
.keyword-block .keyword-list-header { .keyword-block .keyword-list-header {
width: 94%; width: 94%;
padding: 10upx 3%; padding: 10upx 3%;
font-size: 27upx; font-size: 27upx;
color: #333; color: #333;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.keyword-block .keyword-list-header image { .keyword-block .keyword-list-header image {
width: 40upx; width: 40upx;
height: 40upx; height: 40upx;
} }
</style> </style>