# Conflicts:
#	jiuyi2/common/js/config.js
#	jiuyi2/vite.config.js
This commit is contained in:
sx 2025-02-23 20:22:45 +08:00
commit 0a930aa170
10 changed files with 468 additions and 487 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/jiuyi/unpackage
/jiuyi2/.hbuilderx
/jiuyi/.hbuilderx
unpackage

View File

@ -301,9 +301,9 @@ const video = {
*/
hotVideos(param) {
return util.request({
url: `/home/hotVideos`,
url: `/video/search/getHot`,
// query: param.query,
method: 'POST',
method: 'GET',
})
},
@ -325,8 +325,8 @@ const video = {
*/
videoSearch(param) {
return util.request({
url: `/home/videoSearch`,
query: param.query,
url: `/video/search/searchData`,
data: param.query,
method: 'POST',
})
},

View File

@ -111,7 +111,6 @@ function getList() {
uni.$chat.getConversationList().then(rs => {
let res = rs.data.conversationList
console.log(res);
let arr = []
res.forEach(item => {
let obj = {}

View File

@ -1,107 +1,108 @@
<script setup>
/**
/**
* 搜索
*/
import {
import {
ref,
reactive,
getCurrentInstance,
computed,
} from 'vue';
import {
} from 'vue';
import {
onLoad,
onReady,
onPullDownRefresh,
onReachBottom
} from '@dcloudio/uni-app'
} from '@dcloudio/uni-app'
//
import util from '@/common/js/util';
// api
import api from '@/api/index.js'
//
import statusBar from '@/components/header/statusBar.vue'
//
import util from '@/common/js/util';
// api
import api from '@/api/index.js'
//
import statusBar from '@/components/header/statusBar.vue'
import { set } from 'lodash';
const {
const {
proxy
} = getCurrentInstance()
//
const searchState = ref(false)
//
const searchLog = reactive([])
//
const hotVideoList = reactive([])
//
const tabList = reactive([{
} = getCurrentInstance()
//
const searchState = ref(false)
//
const searchLog = reactive([])
//
const hotVideoList = reactive([])
//
const tabList = reactive([{
name: '视频',
getList: () => getVideoList(),
getMoreList: () => getMoreVideoList(),
refreshList: () => refreshVideoList()
},
{
},
{
name: '用户',
getList: () => getFriendList(),
getMoreList: () => getMoreFriendList(),
refreshList: () => refreshFriendList()
},
])
//
const tabIndex = ref(0)
//
const keyword = ref('')
//
const videoList = reactive({
},
])
//
const tabIndex = ref(0)
//
const keyword = ref('')
//
const videoList = reactive({
data: [],
pageNum: 1,
pageSize: 10,
total: 0,
})
//
const userList = reactive({
})
//
const userList = reactive({
data: [],
pageNum: 1,
pageSize: 10,
total: 0,
})
})
onLoad(() => {
//
const userinfo = computed(() => {
let resuilt = uni.$store.state.userinfo
return resuilt
})
onLoad(() => {
//
getSearchLog()
//
getHotVideo()
})
})
onReachBottom(() => {
onReachBottom(() => {
//
if (searchState.value) tabList[tabIndex.value].getMoreList()
})
})
onPullDownRefresh(() => {
onPullDownRefresh(() => {
if (!searchState.value) {
uni.stopPullDownRefresh()
return
}
//
tabList[tabIndex.value].refreshList()
})
})
//
function getSearchLog() {
//
api.video.videoSearchLog().then(rs => {
if (rs.code == 200) {
searchLog.push(...rs.data)
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
//
function getSearchLog() {
let searchList = uni.getStorageSync('searchLog');
if (searchList) {
searchList = Array.from(new Set(searchList))
searchLog.push(...searchList)
}
}
//
function getHotVideo() {
//
function getHotVideo() {
//
api.video.hotVideos().then(rs => {
if (rs.code == 200) {
@ -113,30 +114,30 @@
showCancel: false,
})
})
}
}
// tab
function handleTabIndex(index) {
// tab
function handleTabIndex(index) {
if (tabIndex.value === index) return
tabIndex.value = index
//
tabList[tabIndex.value].refreshList()
}
}
/**
/**
* 查看用户主页
* @param {Object} item
*/
function handleUser(item) {
function handleUser(item) {
uni.navigateTo({
url: util.setUrl('/pages/index/videoHome', {
userId: item.userId
})
})
}
}
//
function handleSearch() {
//
function handleSearch() {
if (!keyword.value) {
searchState.value = false
return
@ -144,45 +145,54 @@
//
tabList[tabIndex.value].getList()
}
//
function refreshVideoList() {
//
let searchList = uni.getStorageSync('searchLog');
searchList = searchList == '' ? [] : searchList;
searchList.push(keyword.value)
searchList = Array.from(new Set(searchList))
searchList = searchList.reverse()
uni.setStorageSync("searchLog", searchList)
}
//
function refreshVideoList() {
videoList.pageNum = 1
videoList.total = 0
getVideoList()
}
}
//
function getMoreVideoList() {
//
function getMoreVideoList() {
if (videoList.data.length >= videoList.total) return
videoList.pageNum++
getVideoList()
}
//
function getVideoList() {
let obj = {
content: keyword.value,
type: +tabIndex.value + 1,
userId: userinfo.value.id,
}
//
function getVideoList() {
api.video.videoSearch({
query: {
//
search: keyword.value,
pageNum: videoList.pageNum,
pageSize: videoList.pageSize,
}
}).then(rs => {
console.log('videoSearch', rs)
api.video.videoSearch({ query: obj }).then(rs => {
// console.log('videoSearch', rs)
if (rs.code == 200) {
if (videoList.pageNum) videoList.data.length = 0
//
videoList.data.push(...rs.rows.map(item => {
item.format_videoUrl = util.format_url(item.videoUrl, 'video')
item.format_header = util.format_url(item.header, 'img')
item.format_imageUrl = util.format_url(item.imageUrl, 'img')
item.format_header = util.format_url(item.avatar, 'img')
item.format_imageUrl = util.format_url(item.coverUrl, 'img')
return item
}))
//
videoList.total = rs.total
console.log('videoList', videoList.data)
// console.log('videoList', videoList.data)
return
}
util.alert({
@ -192,37 +202,36 @@
}).finally(() => {
uni.stopPullDownRefresh()
})
}
}
//
function refreshFriendList() {
//
function refreshFriendList() {
userList.pageNum = 1
userList.total = 0
getFriendList()
}
}
//
function getMoreFriendList() {
//
function getMoreFriendList() {
if (userList.data.length >= userList.total) return
userList.pageNum++
getFriendList()
}
}
//
function getFriendList() {
api.video.searchFriendByName({
path: [keyword.value],
query: {
pageNum: userList.pageNum,
pageSize: userList.pageSize,
//
function getFriendList() {
let obj = {
content: keyword.value,
type: +tabIndex.value + 1,
userId: userinfo.value.id,
}
}).then(rs => {
console.log(rs)
api.video.videoSearch({ query: obj }).then(rs => {
if (rs.code == 200) {
if (userList.pageNum) userList.data.length = 0
//
userList.data.push(...rs.rows.map(item => {
item.format_userPortrait = util.format_url(item.userPortrait, 'img')
item.userId = item.id
item.format_userPortrait = util.format_url(item.avatar, 'img')
return item
}))
//
@ -236,30 +245,42 @@
}).finally(() => {
uni.stopPullDownRefresh()
})
}
}
/**
/**
* 点击当前元素搜索
* @param {Object} item 被点击的元素
* @param {String} key
*/
function handleItemSearch(item, key) {
keyword.value = item[key]
function handleItemSearch(item, key) {
if (key == 'search') {
keyword.value = item
} else if (key == 'title') {
keyword.value = item.topic
}
//
handleSearch()
}
}
//
function handleVideo(item) {
console.log('handleVideo', item)
//
//
function handleVideo(item) {
uni.navigateTo({
url: util.setUrl('/pages/index/videoDetail', {
videoId: item.videoId
videoId: item.id
})
})
}
}
//
function deleteSearch() {
util.alert({
content: '确认删除历史记录吗?',
}).then(rs => {
uni.removeStorageSync('searchLog')
searchLog = searchLog.splice(0, searchLog.length)
})
}
</script>
<template>
@ -292,10 +313,12 @@
<view class="searchList mtb30 mlr30">
<view class="rows">
<view class="title c333 f28 b">历史记录</view>
<uni-icons type="trash" size="24rpx" color="#999" @click="deleteSearch" />
</view>
<view class="list mt20 c333 f24">
<view class="item dib mtb10 mlr10 ptb10 plr20 bar" v-for="(item,index) in searchLog" :key="index" @click="handleItemSearch(item,'search')">{{item.search}}</view>
<view class="item dib mtb10 mlr10 ptb10 plr20 bar" v-for="(item, index) in searchLog" :key="index"
@click="handleItemSearch(item, 'search')">{{ item }}</view>
<view class="nomore mtb20" v-if="!searchLog[0]">暂无搜索记录</view>
</view>
@ -308,7 +331,8 @@
</view>
<view class="list mt20 c333 f24">
<view class="item dib mtb10 mlr10 ptb10 plr20 bar" v-for="(item,index) in 15" :key="index">电商</view>
<view class="item dib mtb10 mlr10 ptb10 plr20 bar" v-for="(item, index) in 15" :key="index">电商
</view>
</view>
</view>
@ -316,19 +340,20 @@
<view class="hotList mtb30 mlr30 c333">
<view class="title f28 b">热门搜索</view>
<view class="list">
<view class="item df aic jcsb ptb20" v-for="(item,index) in hotVideoList" :key="index" @click="handleItemSearch(item,'title')">
<view class="rank c666 f32 b">{{index + 1}}</view>
<view class="item df aic jcsb ptb20" v-for="(item, index) in hotVideoList" :key="index"
@click="handleItemSearch(item, 'title')">
<view class="rank c666 f32 b">{{ index + 1 }}</view>
<view class="content df aic f1 mlr15 f24">
<text>{{item.title}}</text>
<template v-if="0">
<view class="label hot" v-if="index % 2 == 0"></view>
<view class="label new" v-if="index % 2 == 1"></view>
<text>{{ item.topic }}</text>
<template v-if="index < 3">
<view class="label hot" v-if="index < 3"></view>
<view class="label new" v-if="0"></view>
</template>
<view class="f1"></view>
</view>
<view class="number f22">热度{{item.play}}</view>
<view v-if="0" class="number f22">热度{{ item.play }}</view>
<view class="change wh40" v-if="0">
<image src="/static/hotSearchUp.png" mode="aspectFit" v-if="1" />
<image src="/static/hotSearchDefault.png" mode="aspectFit" v-else-if="1" />
@ -343,8 +368,9 @@
<template v-else>
<!-- tab -->
<view class="tabList df plr15">
<view class="item df fdc aic plr20" v-for="(item,index) in tabList" :key="index" :class="{'active': index === tabIndex}" @click="handleTabIndex(index)">
<view class="txt">{{item.name}}</view>
<view class="item df fdc aic plr20" v-for="(item, index) in tabList" :key="index"
:class="{ 'active': index === tabIndex }" @click="handleTabIndex(index)">
<view class="txt">{{ item.name }}</view>
<view class="line"></view>
</view>
</view>
@ -353,7 +379,8 @@
<view class="listBox ptb15 plr15">
<!-- 视频列表 -->
<view class="videoList" v-if="tabIndex === 0">
<view class="item oh mb25 plr30 c333 bfff br20" v-for="(item,index) in videoList.data" :key="index" @click="handleVideo(item)">
<view class="item oh mb25 plr30 c333 bfff br20" v-for="(item, index) in videoList.data" :key="index"
@click="handleVideo(item)">
<!-- 用户 -->
<view class="userinfo df aic mtb25">
<view class="avatar" @click.stop="handleUser(item)">
@ -361,13 +388,13 @@
</view>
<view class="user ml15 f1">
<view class="nickname f32">{{item.userName}}</view>
<view class="date mt10 c999 f24">{{item.createTime}}</view>
<view class="nickname f32">{{ item.userNickname }}</view>
<view class="date mt10 c999 f24">{{ item.createTime }}</view>
</view>
</view>
<!-- 简介 -->
<view class="desc mtb20 f28">{{item.title}}</view>
<view class="desc mtb20 f28">{{ item.title }}</view>
<!-- 封面图 -->
<view class="coverImg mtb20">
@ -378,21 +405,22 @@
<view class="menu df mtb20 c333 f28">
<!-- 点赞数量 -->
<view class="option f1 fmid">
<image class="wh30" src="/static/indexLike.png" mode="aspectFit" v-if="item.isLike == 0" />
<image class="wh30" src="/static/indexLike.png" mode="aspectFit"
v-if="item.isLike == 1" />
<image class="wh30" src="/static/indexLike1.png" mode="aspectFit" v-else />
<view class="number ml10">{{item.likes}}</view>
<view class="number ml10">{{ item.likeCount }}</view>
</view>
<!-- 评论数量 -->
<view class="option f1 fmid">
<image class="wh30" src="/static/indexMsg.png" mode="aspectFit" />
<view class="number ml10">{{item.comment}}</view>
<view class="number ml10">{{ item.reviewCount }}</view>
</view>
<!-- 收藏数量 -->
<view class="option f1 fmid">
<image class="wh30" src="/static/indexCollect.png" mode="aspectFit" />
<view class="number ml10">{{item.collect}}</view>
<view class="number ml10">{{ item.collectCount }}</view>
</view>
<!-- 转发数量 -->
@ -419,25 +447,28 @@
</view>
</view>
</view>
<view v-if="videoList.data.length == 0" class="mtb20 nomore">暂无更多</view>
</view>
<!-- 用户列表 -->
<view class="userList" v-if="tabIndex === 1">
<view class="item df aic mtb40 plr10" v-for="(item,index) in userList.data" :key="index" @click="handleUser(item)">
<view class="item df aic mtb40 plr10" v-for="(item, index) in userList.data" :key="index"
@click="handleUser(item)">
<view class="avatar fs0">
<image class="wh110 cir" :src="item.format_userPortrait" mode="aspectFill" />
</view>
<view class="user oh f1 mlr25">
<view class="nickname c333 f32">{{item.userNickname}}</view>
<view class="fans c999 f24">粉丝{{item.userFans}}</view>
<view class="nickname c333 f32">{{ item.userNickname }}</view>
<view class="fans c999 f24">粉丝{{ item.userFans }}</view>
</view>
<view class="button fs0">
<view class="btn cancel w150" v-if="item.isAttention">取消关注</view>
<view class="btn cancel w150" v-if="item.isAttention == 0">取消关注</view>
<view class="btn focus w150" v-else>关注</view>
</view>
</view>
<view v-if="userList.data.length == 0" class="mtb20 nomore">暂无更多</view>
</view>
</view>
</template>
@ -446,38 +477,38 @@
</template>
<style lang="scss">
image {
image {
width: 100%;
height: 100%;
}
}
//
.apex {
//
.apex {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1;
background-color: #fff;
}
}
//
.search {
//
.search {
height: 60rpx;
background-color: #f1f1f1;
}
}
//
.searchList {
//
.searchList {
//
.item {
background-color: #f1f1f1;
}
}
}
//
.hotList {
//
.hotList {
.item+.item {
border-top: 1rpx solid #F6F6F6;
@ -518,10 +549,10 @@
background-image: linear-gradient(123deg, #27EFE2 0%, #A45EFF 43%, #FF004F 99%);
}
}
}
}
//
.tabList {
//
.tabList {
.item {
.line {
@ -543,10 +574,10 @@
}
}
}
}
}
//
.listBox {
//
.listBox {
min-height: 95vh;
background-color: #f8f8f8;
@ -555,5 +586,5 @@
height: 376rpx;
}
}
}
}
</style>

View File

@ -0,0 +1,9 @@
{
"version" : "1.0",
"configurations" : [
{
"playground" : "standard",
"type" : "uni-app:app-android"
}
]
}

View File

@ -6,7 +6,7 @@ const config = {
// #endif
// #ifndef H5
// host: 'http://91f.xyz:8080',
host: 'https://b433d23.r24.cpolar.top/',
host: 'https://1a880cd5.r24.cpolar.top/',
// #endif
// 支付方式配置
payType: {

View File

@ -1425,16 +1425,17 @@ const util = {
value: userinfo
})
setTimeout(() => {
util.loginTencent(userinfo)
uni.reLaunch({
url: '/pages/index/index'
})
}, 500)
},
// 登录腾讯聊天
loginTencent(userinfo) {
api.login.getIMToken({}).then(rs => {
console.log(rs);
const imSig = rs.msg
uni.$chat.login({
@ -1444,22 +1445,6 @@ const util = {
console.log('im login success', rs)
})
// // #ifdef APP
// // 音视频登录
// const loginParams = {
// SDKAppID: util.config.TChat.SDKAppID,
// userID: userinfo.id + '',
// userSig: imSig,
// }
// uni.$TUICallKit.login(loginParams, res => {
// if (res.code === 0) {
// console.log('[TUICallKit] login success.');
// } else {
// console.error('[TUICallKit] login failed, failed message = ', res.msg, params);
// }
// })
// // #endif
})
},

View File

@ -142,6 +142,10 @@ onUnload(() => {
videoContext.value.stop()
})
onUnmounted(() => {
removeListener()
})
//
function addListener() {
let onMessageReceived = function (event) {
@ -160,7 +164,7 @@ function addListener() {
//
function removeListener() {
uni.$chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED);
uni.$chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, () => { });
}
//

View File

@ -60,73 +60,66 @@ function addListener() {
//
function removeListener() {
uni.$chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED);
uni.$chat.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, () => { });
}
//
function getList() {
api.news.getMessageList({
query: {
userId: userinfo.serviceId,
}
}).then(rs => {
if (rs.code == 200) {
chatList.push(...rs.data.map(item => {
item.callbackData = JSON.parse(item.callbackJson)
if (item.callbackData.callback_json.length) {
let msgType = item.callbackData.callback_json[0].MsgType;
if (msgType == TencentCloudChat.TYPES.MSG_TEXT) {
item.chatText = item.callbackData.callback_json[0].MsgContent.Text
} else if (msgType == TencentCloudChat.TYPES.MSG_IMAGE) {
item.chatText = '[图片]'
} else if (msgType == TencentCloudChat.TYPES.MSG_AUDIO) {
item.chatText = '[语音]'
} else if (msgType == TencentCloudChat.TYPES.MSG_VIDEO) {
item.chatText = '[视频]'
} else if (msgType == TencentCloudChat.TYPES.MSG_CUSTOM) {
if (item.callbackData.callback_json[0].businessType == 'redPacket') {
item.chatText = `[红包] ${item.callbackData.blessing}`
}
}
}
return item
}))
// sdk
let isReady = uni.$chat.isReady();
if (!isReady) {
setTimeout(function () {
getList();
}, 800);
return
}
util.alert({
content: rs.msg,
showCancel: false,
uni.$chat.getConversationList().then(rs => {
let res = rs.data.conversationList
let arr = []
res.forEach(item => {
let obj = {}
obj.type = item.type;
obj.chatText = item.lastMessage.messageForShow;
obj.lastTime = handleDate(item.lastMessage.lastTime);
obj.unreadCount = item.unreadCount;
if (item.type == 'C2C') {
obj.avatar = item.userProfile.avatar;
obj.name = item.userProfile.nick;
obj.userID = item.userProfile.userID;
}
arr.push(obj)
})
chatList.data = arr;
})
// api.news.getMessageList({
// query: {
// userId: userinfo.serviceId,
// }
// }).then(rs => {
// if (rs.code == 200) {
// chatList.push(...rs.data.map(item => {
// item.callbackData = JSON.parse(item.callbackJson)
// return item
// }))
// return
// }
// util.alert({
// content: rs.msg,
// showCancel: false,
// })
// })
}
// /**
// *
// * @param {Number} item
// */
// function handleChat(item) {
// //
// }
// /**
// *
// * @param {String} url
// */
// function link(url) {
// uni.navigateTo({
// url,
// })
// }
// 退
function handleLogout() {
util.alert({
content: '确认退出登录吗?',
}).then(rs => {
if (!rs.confirm) return
util.logout(() => {
// #ifdef APP
plus.runtime.restart()
@ -135,22 +128,16 @@ function handleLogout() {
})
}
/**
* 去聊天
* @param {Object} item
*/
function handleChat(item) {
console.log(111111111, item);
let param = {
type: 'C2C',
name: `${item.callbackData.from_name}`,
msgId: `${item.callbackData.from_id}`
};
console.log(22222222, param);
util.toChat(param)
}
@ -176,7 +163,7 @@ function delMsg(item) {
return
}
let conversationId = item.groupId == null ? `C2C${item.fromId}` : `GROUP${item.groupId}`;
let conversationId = item.type == 'C2C' ? `C2C${item.userID}` : `GROUP${item.groupID}`;
uni.$chat.deleteConversation(conversationId).then(rs => {
getList()
@ -194,7 +181,7 @@ function setRead(item) {
return
}
let conversationId = item.groupId == null ? `C2C${item.fromId}` : `GROUP${item.groupId}`;
let conversationId = item.type == 'C2C' ? `C2C${item.userID}` : `GROUP${item.groupID}`;
uni.$chat.setMessageRead({
conversationID: conversationId,
}).then(rs => {
@ -229,59 +216,24 @@ function setRead(item) {
<uni-icons type="right" />
</view>
<!-- <view class="list">
<view class="item rows ptb20 plr20" v-for="(item, index) in chatList" :key="index"
@click="handleChat(item)">
<view class="avatar">
<image :src="item.avatar" class="wh80 cir" />
</view>
<view class="info f1 ml20">
<view class="rows">
<view class="name c333 f28">{{ item.name }}</view>
<view class="time c999 f22">2024.05.06 13:00</view>
</view>
<view class="rows">
<view class="content mt10 c666 f24">{{ item.lastMessage }}</view>
<view class="dot cfff f22">
<view class="content" v-if="item.dot">{{ item.dot }}</view>
</view>
</view>
</view>
</view>
</view> -->
<view class="firendBox pr">
<scroll-view scroll-y="true" class="scroll">
<uni-swipe-action ref="swipeAction">
<view class="list pb30">
<uni-swipe-action-item :right-options="rightOption" v-for="(item, index) in chatList"
<uni-swipe-action-item :right-options="rightOption" v-for="(item, index) in chatList.data"
:key="index" @click="handleMenu($event, item)">
<view class="item rows ptb20 plr30" @click="handleChat(item)">
<view class="image wh90 pr">
<template v-if="item.groupId == null">
<image class="cir wh90" :src="item.callbackJson.from_url" mode="aspectFill" />
</template>
<template v-else>
<image class="cir wh90" :src="item.groupChatDTO.groupFaceUrl"
mode="aspectFill" />
</template>
<image class="cir wh90" :src="item.avatar" mode="aspectFill" />
<view class="mark pa t0 r0 cfff f22 cir" v-if="item.unreadCount">{{ item.unreadCount
}}
</view>
</view>
<view class="col f1 ml20">
<view class="rows">
<template v-if="item.groupId == null">
<view class="name f1 thd c333 f32">{{ item.callbackJson.from_name }}</view>
</template>
<template v-else>
<view class="name f1 thd c333 f32">{{ item.groupChatDTO.name }}</view>
</template>
<view class="name f1 thd c333 f32">{{ item.name }}</view>
<view class="datetime c999 f22">
{{ util.formatTime('MM-dd HH:mm', item.createTime) }}</view>
{{ util.formatTime('MM-dd HH:mm', item.lastTime) }}</view>
</view>
<view class="desc thd mt10 c666 f24">{{ item.chatText }}</view>
</view>

View File

@ -4,7 +4,7 @@ import {
import uni from '@dcloudio/vite-plugin-uni';
// let target = 'http://91f.xyz:8080'
let target = 'https://b433d23.r24.cpolar.top/'
let target = 'https://1a880cd5.r24.cpolar.top/'
export default defineConfig({
plugins: [uni()],