更新代码

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

View File

@@ -1,4 +1,5 @@
<script>
import { init } from '@/api/init.js'
import http from '@/http/http.js'
export default {
onLaunch: function () {
@@ -13,9 +14,10 @@
},
onShow: function () {
init()
// ios是否在审核
http.request({
url: 'app/common/type/919',
url: '/common/type/919',
}).then(res => {
if (res.code == 0) {
uni.setStorageSync('isExamine', res.data.value)
@@ -118,7 +120,4 @@
top: 800rpx;
transform: translateX(-50%);
}
</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() {
const headerObject = {}
headerObject["token"] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNjkyNSIsImlhdCI6MTczNTg4OTk5NCwiZXhwIjoxNzM2NDk0Nzk0fQ.j-KFEE1FHckmFCO8UA884RBWvpMv8MfEGj7GPGf3kVo6sHeORl043Yle_w7HdTZKPpQqSr2LQLCq_rUxG4qqwA'
// headerObject["token"] = uni.getStorageSync('token')
headerObject["token"] = uni.getStorageSync('token')
return headerObject
}

View File

@@ -58,6 +58,7 @@
import {
reactive
} from 'vue';
import { announcement, messageselectMessage,courseselectCourse } from '@/api/index/index.js'
import {
onLoad,
onReachBottom
@@ -91,10 +92,8 @@
})
// 获取弹窗信息
function getPop() {
http.request({
url: 'app/announcement',
}).then(res => {
async function getPop() {
let res = await announcement()
if (res.code == 0) {
if (res.data && res.data.state == 1) {
datas.ruleShow = true
@@ -108,7 +107,6 @@
icon: 'none'
});
}
})
}
// 搜索跳转
function moreVideo() {
@@ -117,15 +115,8 @@
});
}
// 公告
function getMsg() {
http.request({
url: 'app/message/selectMessage',
data: {
page: 1,
limit: 5,
state: 1
}
}).then(res => {
async function getMsg() {
let res = await messageselectMessage()
if (res.code == 0) {
datas.noticeList = res.data.list
} else {
@@ -135,23 +126,20 @@
icon: 'none'
});
}
})
}
//获取推荐视频
function getrecomVideo(sort, active = 1) {
async function getrecomVideo(sort, active = 1) {
datas.active = active
if (sort) {
datas.page = 1
}
http.request({
url: 'app/course/selectCourse',
data: {
let res = await courseselectCourse({
page: datas.page,
limit: 12,
sort: sort,
classifyId: ''
}
}).then(res => {
})
if (res.code == 0) {
if (datas.page == 1) {
datas.list = res.data.list
@@ -165,7 +153,6 @@
icon: 'none'
});
}
})
}
</script>

View File

@@ -3,7 +3,8 @@
<u-sticky :enable="true">
<view class="search-box">
<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>
</u-sticky>
</view>
@@ -26,6 +27,7 @@
</template>
<script setup>
import { selectCourseTitles } from '@/api/index/index.js'
import {
reactive
} from 'vue';
@@ -34,6 +36,8 @@
} from '@dcloudio/uni-app'
let datas = reactive({
hotKeywordList: [], //热搜
keywordList: [],// 搜索列表
keyword: "",// 搜索关键字
})
onShow(() => {
getList()
@@ -46,6 +50,20 @@
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>
<style scoped lang="scss">