更新代码

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

131
App.vue
View File

@@ -1,7 +1,8 @@
<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 {
onLaunch: function () {
console.log('App Launch') console.log('App Launch')
// const systemInfo = uni.getSystemInfoSync(); // const systemInfo = uni.getSystemInfoSync();
// const isA = systemInfo.platform === 'android' // const isA = systemInfo.platform === 'android'
@@ -12,113 +13,111 @@
// } // }
}, },
onShow: function() { onShow: function () {
init()
// ios是否在审核 // ios是否在审核
http.request({ http.request({
url: 'app/common/type/919', url: '/common/type/919',
}).then(res => { }).then(res => {
if (res.code == 0) { if (res.code == 0) {
uni.setStorageSync('isExamine', res.data.value) uni.setStorageSync('isExamine', res.data.value)
} }
}) })
}, },
onHide: function() { onHide: function () {
console.log('App Hide') 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,16 +55,17 @@
</template> </template>
<script setup> <script setup>
import { import {
reactive reactive
} from 'vue'; } from 'vue';
import { import { announcement, messageselectMessage,courseselectCourse } from '@/api/index/index.js'
import {
onLoad, onLoad,
onReachBottom onReachBottom
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import contentlist from './components/contentlist.vue' import contentlist from './components/contentlist.vue'
import http from '@/http/http.js' import http from '@/http/http.js'
let datas = reactive({ let datas = reactive({
noticeList: [], //公告列表 noticeList: [], //公告列表
active: 1, // 最新、最热。。。切换顶部导航栏 active: 1, // 最新、最热。。。切换顶部导航栏
@@ -78,23 +79,21 @@
//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',
}).then(res => {
if (res.code == 0) { if (res.code == 0) {
if (res.data && res.data.state == 1) { if (res.data && res.data.state == 1) {
datas.ruleShow = true datas.ruleShow = true
@@ -108,24 +107,16 @@
icon: 'none' icon: 'none'
}); });
} }
}) }
} // 搜索跳转
// 搜索跳转 function moreVideo() {
function moreVideo() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/index/search/index' url: '/pages/index/search/index'
}); });
} }
// 公告 // 公告
function getMsg() { async function getMsg() {
http.request({ let res = await messageselectMessage()
url: 'app/message/selectMessage',
data: {
page: 1,
limit: 5,
state: 1
}
}).then(res => {
if (res.code == 0) { if (res.code == 0) {
datas.noticeList = res.data.list datas.noticeList = res.data.list
} else { } else {
@@ -135,23 +126,20 @@
icon: 'none' icon: 'none'
}); });
} }
}) }
} //获取推荐视频
//获取推荐视频 async function getrecomVideo(sort, active = 1) {
function getrecomVideo(sort, active = 1) {
datas.active = active datas.active = active
if (sort) { if (sort) {
datas.page = 1 datas.page = 1
} }
http.request({ let res = await courseselectCourse({
url: 'app/course/selectCourse',
data: {
page: datas.page, page: datas.page,
limit: 12, limit: 12,
sort: sort, sort: sort,
classifyId: '' classifyId: ''
} })
}).then(res => {
if (res.code == 0) { if (res.code == 0) {
if (datas.page == 1) { if (datas.page == 1) {
datas.list = res.data.list datas.list = res.data.list
@@ -165,12 +153,11 @@
icon: 'none' icon: 'none'
}); });
} }
}) }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.indexStyle { .indexStyle {
height: 555rpx; height: 555rpx;
position: relative; position: relative;
@@ -236,9 +223,9 @@
} }
} }
} }
.navTop { .navTop {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@@ -249,5 +236,5 @@
margin-left: 20rpx; margin-left: 20rpx;
padding: 6rpx 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,30 +27,47 @@
</template> </template>
<script setup> <script setup>
import { import { selectCourseTitles } from '@/api/index/index.js'
import {
reactive reactive
} from 'vue'; } from 'vue';
import { import {
onShow onShow
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
let datas = reactive({ let datas = reactive({
hotKeywordList: [], //热搜 hotKeywordList: [], //热搜
}) keywordList: [],// 搜索列表
onShow(() => { keyword: "",// 搜索关键字
})
onShow(() => {
getList() 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%;
@@ -58,27 +76,27 @@
// 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>