Merge branch 'lr' of http://1.94.221.165:3000/sx/jiuyiUniapp
# Conflicts: # jiuyi2/common/js/config.js # jiuyi2/vite.config.js
This commit is contained in:
commit
0a930aa170
|
@ -2,3 +2,4 @@
|
|||
/jiuyi/unpackage
|
||||
/jiuyi2/.hbuilderx
|
||||
/jiuyi/.hbuilderx
|
||||
unpackage
|
||||
|
|
|
@ -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',
|
||||
})
|
||||
},
|
||||
|
|
|
@ -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 = {}
|
||||
|
|
|
@ -1,265 +1,286 @@
|
|||
<script setup>
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
getCurrentInstance,
|
||||
computed,
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onPullDownRefresh,
|
||||
onReachBottom
|
||||
} from '@dcloudio/uni-app'
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
getCurrentInstance,
|
||||
computed,
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onPullDownRefresh,
|
||||
onReachBottom
|
||||
} 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 {
|
||||
proxy
|
||||
} = getCurrentInstance()
|
||||
// 搜索状态
|
||||
const searchState = ref(false)
|
||||
// 搜索记录
|
||||
const searchLog = reactive([])
|
||||
const {
|
||||
proxy
|
||||
} = 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({
|
||||
data: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
})
|
||||
// 用户列表
|
||||
const userList = reactive({
|
||||
data: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
// 用户信息
|
||||
const userinfo = computed(() => {
|
||||
let resuilt = uni.$store.state.userinfo
|
||||
return resuilt
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
// 获取用户搜索记录
|
||||
getSearchLog()
|
||||
// 获取热点视频
|
||||
getHotVideo()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
// 获取更多列表
|
||||
if (searchState.value) tabList[tabIndex.value].getMoreList()
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
if (!searchState.value) {
|
||||
uni.stopPullDownRefresh()
|
||||
return
|
||||
}
|
||||
// 刷新
|
||||
tabList[tabIndex.value].refreshList()
|
||||
})
|
||||
|
||||
// 获取用户搜索记录
|
||||
function getSearchLog() {
|
||||
let searchList = uni.getStorageSync('searchLog');
|
||||
if (searchList) {
|
||||
searchList = Array.from(new Set(searchList))
|
||||
searchLog.push(...searchList)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取热点视频
|
||||
function getHotVideo() {
|
||||
// 热点视频
|
||||
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({
|
||||
data: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
})
|
||||
// 用户列表
|
||||
const userList = reactive({
|
||||
data: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
// 获取用户搜索记录
|
||||
getSearchLog()
|
||||
// 获取热点视频
|
||||
getHotVideo()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
// 获取更多列表
|
||||
if (searchState.value) tabList[tabIndex.value].getMoreList()
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
if (!searchState.value) {
|
||||
uni.stopPullDownRefresh()
|
||||
api.video.hotVideos().then(rs => {
|
||||
if (rs.code == 200) {
|
||||
hotVideoList.push(...rs.data)
|
||||
return
|
||||
}
|
||||
// 刷新
|
||||
tabList[tabIndex.value].refreshList()
|
||||
util.alert({
|
||||
contuent: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 获取用户搜索记录
|
||||
function getSearchLog() {
|
||||
//
|
||||
api.video.videoSearchLog().then(rs => {
|
||||
if (rs.code == 200) {
|
||||
searchLog.push(...rs.data)
|
||||
return
|
||||
}
|
||||
util.alert({
|
||||
content: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
// tab下标
|
||||
function handleTabIndex(index) {
|
||||
if (tabIndex.value === index) return
|
||||
tabIndex.value = index
|
||||
// 重载
|
||||
tabList[tabIndex.value].refreshList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看用户主页
|
||||
* @param {Object} item
|
||||
*/
|
||||
function handleUser(item) {
|
||||
uni.navigateTo({
|
||||
url: util.setUrl('/pages/index/videoHome', {
|
||||
userId: item.userId
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
if (!keyword.value) {
|
||||
searchState.value = false
|
||||
return
|
||||
} else searchState.value = true
|
||||
|
||||
// 获取列表
|
||||
tabList[tabIndex.value].getList()
|
||||
|
||||
|
||||
// 缓存搜索历史
|
||||
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() {
|
||||
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 getHotVideo() {
|
||||
// 热点视频
|
||||
api.video.hotVideos().then(rs => {
|
||||
if (rs.code == 200) {
|
||||
hotVideoList.push(...rs.data)
|
||||
return
|
||||
}
|
||||
util.alert({
|
||||
contuent: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
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.avatar, 'img')
|
||||
item.format_imageUrl = util.format_url(item.coverUrl, 'img')
|
||||
return item
|
||||
}))
|
||||
// 视频列表
|
||||
videoList.total = rs.total
|
||||
// console.log('videoList', videoList.data)
|
||||
return
|
||||
}
|
||||
util.alert({
|
||||
content: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}).finally(() => {
|
||||
uni.stopPullDownRefresh()
|
||||
})
|
||||
}
|
||||
|
||||
// tab下标
|
||||
function handleTabIndex(index) {
|
||||
if (tabIndex.value === index) return
|
||||
tabIndex.value = index
|
||||
// 重载
|
||||
tabList[tabIndex.value].refreshList()
|
||||
}
|
||||
// 重载朋友列表
|
||||
function refreshFriendList() {
|
||||
userList.pageNum = 1
|
||||
userList.total = 0
|
||||
getFriendList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看用户主页
|
||||
* @param {Object} item
|
||||
*/
|
||||
function handleUser(item) {
|
||||
uni.navigateTo({
|
||||
url: util.setUrl('/pages/index/videoHome', {
|
||||
userId: item.userId
|
||||
})
|
||||
// 获取更多朋友列表
|
||||
function getMoreFriendList() {
|
||||
if (userList.data.length >= userList.total) return
|
||||
userList.pageNum++
|
||||
getFriendList()
|
||||
}
|
||||
|
||||
// 获取朋友列表
|
||||
function getFriendList() {
|
||||
let obj = {
|
||||
content: keyword.value,
|
||||
type: +tabIndex.value + 1,
|
||||
userId: userinfo.value.id,
|
||||
}
|
||||
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.userId = item.id
|
||||
item.format_userPortrait = util.format_url(item.avatar, 'img')
|
||||
return item
|
||||
}))
|
||||
// 视频列表
|
||||
userList.total = rs.total
|
||||
return
|
||||
}
|
||||
util.alert({
|
||||
content: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
}).finally(() => {
|
||||
uni.stopPullDownRefresh()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击当前元素搜索
|
||||
* @param {Object} item 被点击的元素
|
||||
* @param {String} key 键
|
||||
*/
|
||||
function handleItemSearch(item, key) {
|
||||
if (key == 'search') {
|
||||
keyword.value = item
|
||||
} else if (key == 'title') {
|
||||
keyword.value = item.topic
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function handleSearch() {
|
||||
if (!keyword.value) {
|
||||
searchState.value = false
|
||||
return
|
||||
} else searchState.value = true
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 获取列表
|
||||
tabList[tabIndex.value].getList()
|
||||
}
|
||||
|
||||
// 重载视频列表
|
||||
function refreshVideoList() {
|
||||
videoList.pageNum = 1
|
||||
videoList.total = 0
|
||||
getVideoList()
|
||||
}
|
||||
|
||||
// 获取更多视频列表
|
||||
function getMoreVideoList() {
|
||||
if (videoList.data.length >= videoList.total) return
|
||||
videoList.pageNum++
|
||||
getVideoList()
|
||||
}
|
||||
|
||||
// 获取视频列表
|
||||
function getVideoList() {
|
||||
api.video.videoSearch({
|
||||
query: {
|
||||
// 搜索
|
||||
search: keyword.value,
|
||||
pageNum: videoList.pageNum,
|
||||
pageSize: videoList.pageSize,
|
||||
}
|
||||
}).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')
|
||||
return item
|
||||
}))
|
||||
// 视频列表
|
||||
videoList.total = rs.total
|
||||
console.log('videoList', videoList.data)
|
||||
return
|
||||
}
|
||||
util.alert({
|
||||
content: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
}).finally(() => {
|
||||
uni.stopPullDownRefresh()
|
||||
// 跳转视频
|
||||
function handleVideo(item) {
|
||||
uni.navigateTo({
|
||||
url: util.setUrl('/pages/index/videoDetail', {
|
||||
videoId: item.id
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 重载朋友列表
|
||||
function refreshFriendList() {
|
||||
userList.pageNum = 1
|
||||
userList.total = 0
|
||||
getFriendList()
|
||||
}
|
||||
|
||||
// 获取更多朋友列表
|
||||
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,
|
||||
}
|
||||
}).then(rs => {
|
||||
console.log(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')
|
||||
return item
|
||||
}))
|
||||
// 视频列表
|
||||
userList.total = rs.total
|
||||
return
|
||||
}
|
||||
util.alert({
|
||||
content: rs.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
}).finally(() => {
|
||||
uni.stopPullDownRefresh()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击当前元素搜索
|
||||
* @param {Object} item 被点击的元素
|
||||
* @param {String} key 键
|
||||
*/
|
||||
function handleItemSearch(item, key) {
|
||||
keyword.value = item[key]
|
||||
|
||||
// 搜索
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// 跳转视频
|
||||
function handleVideo(item) {
|
||||
console.log('handleVideo', item)
|
||||
//
|
||||
uni.navigateTo({
|
||||
url: util.setUrl('/pages/index/videoDetail', {
|
||||
videoId: item.videoId
|
||||
})
|
||||
})
|
||||
}
|
||||
// 删除历史记录
|
||||
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,114 +477,114 @@
|
|||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// 顶部
|
||||
.apex {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
background-color: #fff;
|
||||
}
|
||||
// 顶部
|
||||
.apex {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
//
|
||||
.search {
|
||||
height: 60rpx;
|
||||
//
|
||||
.search {
|
||||
height: 60rpx;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
// 搜索列表
|
||||
.searchList {
|
||||
|
||||
// 单项
|
||||
.item {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索列表
|
||||
.searchList {
|
||||
// 热搜列表
|
||||
.hotList {
|
||||
|
||||
// 单项
|
||||
.item {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
.item+.item {
|
||||
border-top: 1rpx solid #F6F6F6;
|
||||
}
|
||||
|
||||
// 热搜列表
|
||||
.hotList {
|
||||
|
||||
.item+.item {
|
||||
border-top: 1rpx solid #F6F6F6;
|
||||
}
|
||||
|
||||
.item:nth-child(1) .number {
|
||||
color: #FF0F2E;
|
||||
}
|
||||
|
||||
.item:nth-child(2) .number {
|
||||
color: #FF370F;
|
||||
}
|
||||
|
||||
.item:nth-child(3) .number {
|
||||
color: #FF630F;
|
||||
}
|
||||
|
||||
// 热度
|
||||
.number {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
// 标签
|
||||
.label {
|
||||
margin-left: 20rpx;
|
||||
padding: 2rpx 10rpx;
|
||||
font-size: 20rpx;
|
||||
color: #fff;
|
||||
border-radius: 50rpx 50rpx 50rpx 2rpx;
|
||||
|
||||
// 热
|
||||
&.hot {
|
||||
background-color: #FF0F2E;
|
||||
}
|
||||
|
||||
// 新
|
||||
&.new {
|
||||
background-image: linear-gradient(123deg, #27EFE2 0%, #A45EFF 43%, #FF004F 99%);
|
||||
}
|
||||
}
|
||||
.item:nth-child(1) .number {
|
||||
color: #FF0F2E;
|
||||
}
|
||||
|
||||
// 分栏列表
|
||||
.tabList {
|
||||
.item:nth-child(2) .number {
|
||||
color: #FF370F;
|
||||
}
|
||||
|
||||
.item:nth-child(3) .number {
|
||||
color: #FF630F;
|
||||
}
|
||||
|
||||
// 热度
|
||||
.number {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
// 标签
|
||||
.label {
|
||||
margin-left: 20rpx;
|
||||
padding: 2rpx 10rpx;
|
||||
font-size: 20rpx;
|
||||
color: #fff;
|
||||
border-radius: 50rpx 50rpx 50rpx 2rpx;
|
||||
|
||||
// 热
|
||||
&.hot {
|
||||
background-color: #FF0F2E;
|
||||
}
|
||||
|
||||
// 新
|
||||
&.new {
|
||||
background-image: linear-gradient(123deg, #27EFE2 0%, #A45EFF 43%, #FF004F 99%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 分栏列表
|
||||
.tabList {
|
||||
|
||||
.item {
|
||||
.line {
|
||||
background-color: #333;
|
||||
width: 0;
|
||||
height: 10rpx;
|
||||
border-radius: 100rpx;
|
||||
}
|
||||
|
||||
// 激活的
|
||||
&.active {
|
||||
|
||||
.txt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.item {
|
||||
.line {
|
||||
background-color: #333;
|
||||
width: 0;
|
||||
height: 10rpx;
|
||||
border-radius: 100rpx;
|
||||
}
|
||||
|
||||
// 激活的
|
||||
&.active {
|
||||
|
||||
.txt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 30rpx;
|
||||
}
|
||||
width: 30rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 列表容器
|
||||
.listBox {
|
||||
min-height: 95vh;
|
||||
background-color: #f8f8f8;
|
||||
// 列表容器
|
||||
.listBox {
|
||||
min-height: 95vh;
|
||||
background-color: #f8f8f8;
|
||||
|
||||
.videoList {
|
||||
.coverImg {
|
||||
height: 376rpx;
|
||||
}
|
||||
.videoList {
|
||||
.coverImg {
|
||||
height: 376rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"version" : "1.0",
|
||||
"configurations" : [
|
||||
{
|
||||
"playground" : "standard",
|
||||
"type" : "uni-app:app-android"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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: {
|
||||
|
|
|
@ -1425,16 +1425,17 @@ const util = {
|
|||
value: userinfo
|
||||
})
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
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
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -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, () => { });
|
||||
}
|
||||
|
||||
// 获取更多消息记录
|
||||
|
|
|
@ -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)
|
||||
// 验证sdk是否准备完毕
|
||||
let isReady = uni.$chat.isReady();
|
||||
if (!isReady) {
|
||||
setTimeout(function () {
|
||||
getList();
|
||||
}, 800);
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
}))
|
||||
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>
|
||||
|
|
|
@ -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()],
|
||||
|
|
Loading…
Reference in New Issue