This commit is contained in:
cansnow
2025-12-08 02:29:46 +08:00
parent 69a61178e1
commit 22ee59cd3d
17 changed files with 895 additions and 244 deletions
+3
View File
@@ -1,4 +1,7 @@
``` ```
n1e5a6s6m7
```
```
conversation详情 conversation详情
{ {
"conversationID": "si_100003_100004", "conversationID": "si_100003_100004",
+9 -2
View File
@@ -90,12 +90,19 @@ export const getFriendCircleNewcount = () =>{
export const getFriendCircleInfo = () =>{ export const getFriendCircleInfo = () =>{
return uni.$u?.http.get("/friendcircle/info"); return uni.$u?.http.get("/friendcircle/info");
} }
export const upload = (url,onProgress) =>{ export const upload = (files,data,onProgress) =>{
if(typeof data == 'function'){
onProgress = data;
data = {};
}
console.log(typeof files);
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
var u = uni.uploadFile({ var u = uni.uploadFile({
url: config.getRegisterUrl()+"/user/upload", // 仅为示例,非真实的接口地址 url: config.getRegisterUrl()+"/user/upload", // 仅为示例,非真实的接口地址
filePath: url, filePath: files,
//files:files.length > 1 ? files : files[0],
name: "file", name: "file",
formData:data,
header:{ header:{
token:uni.getStorageSync("BusinessToken"), token:uni.getStorageSync("BusinessToken"),
}, },
+1 -1
View File
@@ -1,5 +1,5 @@
<template> <template>
<view class="uni-searchbar"> <view class="uni-searchbar" @click="$emit('click')">
<view class="uni-searchbar__box" style="border-radius: 5px; background-color: rgb(255, 255, 255);"> <view class="uni-searchbar__box" style="border-radius: 5px; background-color: rgb(255, 255, 255);">
<view class="uni-searchbar__box-icon-search"> <view class="uni-searchbar__box-icon-search">
<uni-icons type="search" size="18" color="rgb(192, 196, 204)"></uni-icons> <uni-icons type="search" size="18" color="rgb(192, 196, 204)"></uni-icons>
+12
View File
@@ -325,6 +325,18 @@
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
},
{
"path": "pages/common/search/index",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/common/scan",
"style": {
"navigationBarTitleText": ""
}
} }
], ],
"tabBar": { "tabBar": {
+81
View File
@@ -0,0 +1,81 @@
<template>
<view class="scan_page">
<uni-nav-bar left-icon="back" fixed backgroundColor="transparent" statusBar></uni-nav-bar>
<barcode id='1' class="barcode" autostart="true" ref="barcode" background="rgb(0,0,0)" frameColor="#1C86EE" scanbarColor="#1C86EE" :filters="fil" @marked="success1" @error="fail1"></barcode>
<view class="overlay">
<button class="btn" @click="toStart">开始扫码识别</button>
<button class="btn" @click="tocancel">取消扫码识别</button>
<button class="btn" @click="toFlash">开启闪光灯</button>
<button class="btn" @click="toscan">预览</button>
</view>
</view>
</template>
<script>
export default {
onLoad() {
},
data() {
return {
fil: [0, 2, 1]
}
},
methods: {
success1(e) {
console.log("success1:" + JSON.stringify(e));
},
fail1(e) {
console.log("fail1:" + JSON.stringify(e));
},
toStart: function() {
this.$refs.barcode.start({
conserve: true,
filename: '_doc/barcode/'
});
},
tocancel:function(){
this.$refs.barcode.cancel();
},
toFlash: function() {
this.$refs.barcode.setFlash(true);
},
toscan: function() {
console.log("scan:");
const barcodeModule = uni.requireNativePlugin('barcodeScan');
barcodeModule.scan("/static/barcode1.png"
,(e)=>{
console.log("scan_error:"+JSON.stringify(e));
});
}
}
}
</script>
<style lang="scss" scoped>
.scan_page{
width: 750rpx;
height: 100vh;
position: relative;
background: #800000;
.barcode {
width: 100vw;
height: 100vh;
background-color: #808080;
}
.btn {
top: 20rpx;
width: 730rpx;
margin-left: 10rpx;
margin-top: 10rpx;
background-color: #458B00;
border-radius: 10rpx;
}
.overlay{
background: rgba(0, 0, 0, 0.1);
}
}
</style>
@@ -0,0 +1,123 @@
<template>
<view class="message-search-item" @click="handleClick">
<view class="message-content">
<view class="message-meta">
<text class="sender-name" v-if="!isSelf && !isGroup">{{ message.senderNickname }}</text>
<text class="message-time">{{ formattedTime }}</text>
</view>
<view class="message-preview">
<text class="message-text">{{ messagePreview }}</text>
</view>
</view>
</view>
</template>
<script>
import {mapGetters} from "vuex";
import MyAvatar from "@/components/MyAvatar/index.vue";
import {MessageType, SessionType} from "openim-uniapp-polyfill";
import {formatMessageTime, parseMessageByType} from "@/util/imCommon";
export default {
name: "MessageSearchItem",
components: {
MyAvatar
},
props: {
message: {
type: Object,
required: true
},
conversation: {
type: Object,
default: null
}
},
computed: {
...mapGetters([
"storeSelfInfo"
]),
isGroup() {
if(this.conversation){
return this.conversation.conversationType === SessionType.WorkingGroup || this.conversation.conversationType === 2;
}
return this.message.sessionType === SessionType.WorkingGroup || this.message.sessionType === 2;
},
isSelf() {
return this.message.sendID === this.storeSelfInfo?.userID;
},
formattedTime() {
return formatMessageTime(this.message.sendTime);
},
messagePreview() {
// 根据消息类型显示预览
switch(this.message.contentType) {
case MessageType.TextMessage:
return this.message.textElem?.content || '[文本消息]';
case MessageType.FileMessage:
return `[文件] ${this.message.fileElem?.fileName || '未知文件'}`;
case MessageType.LocationMessage:
return `[位置] ${this.message.locationElem?.description || '位置信息'}`;
case MessageType.PictureMessage:
return '[图片]';
case MessageType.VideoMessage:
return '[视频]';
case MessageType.SoundMessage:
return '[语音]';
default:
return parseMessageByType(this.message) || '[消息]';
}
}
},
methods: {
handleClick() {
this.$emit('click', {
message: this.message,
conversation: this.conversation
});
}
}
}
</script>
<style lang="scss" scoped>
.message-search-item {
background-color: #fff;
padding: 20rpx 44rpx;
border-bottom: 1px solid #f0f0f0;
&:active {
background-color: #f5f5f5;
}
.message-content {
.message-meta {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12rpx;
.sender-name {
font-size: 26rpx;
color: #1d6bed;
font-weight: 500;
}
.message-time {
font-size: 24rpx;
color: #999;
}
}
.message-preview {
.message-text {
font-size: 28rpx;
color: #666;
line-height: 1.6;
@include ellipsisWithLine(2);
}
}
}
}
</style>
+399
View File
@@ -0,0 +1,399 @@
<template>
<view style="display: flex;flex-direction: column;background-color: #ececec;">
<u-status-bar bgColor="transparent"></u-status-bar>
<uni-search-bar class="search_bar"
:focus="true"
bgColor="#fff"
cancelButton="always"
:placeholder="getPlaceholder"
v-model="searchValue"
@confirm="search"
@input="input"
@cancel="cancel"
@clear="clear">
</uni-search-bar>
<u-tabs :list="searchTypeList" :current="currentTabIndex" @change="changeSearchType"></u-tabs>
<scroll-view scroll-y="true" class="scroll-view">
<!-- 加载状态 -->
<view v-if="status === 'loading'" class="empty-container">
<u-loading-icon mode="spinner" size="40"></u-loading-icon>
<text class="empty-text">搜索中...</text>
</view>
<!-- 空状态 -->
<view v-else-if="status === 'done' && isEmpty" class="empty-container">
<text class="empty-text">暂无搜索结果</text>
</view>
<!-- 等待搜索状态 -->
<view v-else-if="status === 'wait'" class="empty-container">
<text class="empty-text">请输入关键词进行搜索</text>
</view>
<!-- 搜索结果 -->
<view v-else>
<!-- 会话搜索结果 -->
<ConversationItem
v-if="currentSearchType === 'conversation'"
:source="conversation"
:key="index"
v-for="(conversation,index) in conversationList"
></ConversationItem>
<!-- 好友搜索结果 -->
<user-item
v-if="currentSearchType === 'friend'"
@itemClick="userClick"
@updateCheck="()=>{}"
:checked="false"
:disabled="false"
:checkVisible="false"
v-for="cell in friendList"
:item="cell"
:key="cell.userID"
/>
<!-- 消息搜索结果 -->
<view v-if="['message', 'file', 'location'].includes(currentSearchType)">
<view
v-for="(resultItem, resultIndex) in messageList"
:key="resultIndex"
class="conversation-group"
>
<view class="conversation-header" @click="goToConversation(resultItem)">
<my-avatar
:src="resultItem.faceURL"
:desc="resultItem.showName"
:isGroup="resultItem.conversationType === 2"
size="36"
/>
<text class="conversation-title">{{ resultItem.showName }}</text>
<text class="message-count">{{ resultItem.messageCount }}条相关消息</text>
</view>
<message-search-item
v-for="(message, msgIndex) in resultItem.messageList"
:key="msgIndex"
:message="message"
:conversation="resultItem"
@click="messageClick"
></message-search-item>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
import {mapGetters} from "vuex";
import ConversationItem from "@/pages/conversation/conversationList/components/ConversationItem.vue";
import UserItem from "@/components/UserItem/index.vue";
import MessageSearchItem from "./components/MessageSearchItem.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
import IMSDK,{MessageType, SessionType} from "openim-uniapp-polyfill";
import {prepareConversationState, navigateToDesignatedConversation} from "@/util/imCommon";
export default {
components:{
ConversationItem,
UserItem,
MessageSearchItem,
MyAvatar
},
data() {
return {
searchValue:"",
currentSearchType:"message", // conversation, friend, message, file, location
searchTypeList:[
{
name: '会话',
value: 'conversation'
},
{
name: '好友',
value: 'friend'
},
{
name: '消息',
value: 'message'
},
{
name: '文件',
value: 'file'
},
{
name: '位置',
value: 'location'
}
],
conversationList:[],
friendList:[],
messageList:[],
status:"wait", // wait, loading, done
conversationID:"",
}
},
computed: {
...mapGetters([
"storeConversationList",
"storeFriendList",
]),
currentTabIndex() {
const index = this.searchTypeList.findIndex(item => item.value === this.currentSearchType);
return index >= 0 ? index : 2;
},
getPlaceholder() {
const placeholders = {
conversation: "搜索会话名称",
friend: "搜索好友昵称或备注",
message: "搜索消息内容",
file: "搜索文件",
location: "搜索位置"
};
return placeholders[this.currentSearchType] || "请输入您要搜索的内容";
},
isEmpty() {
if (this.currentSearchType === 'conversation') {
return this.conversationList.length === 0;
} else if (this.currentSearchType === 'friend') {
return this.friendList.length === 0;
} else if (['message', 'file', 'location'].includes(this.currentSearchType)) {
return this.messageList.length === 0;
}
return true;
}
},
onLoad(opt) {
if(opt.type){
this.currentSearchType = opt.type;
}
if(opt.conversationID){
this.conversationID = opt.conversationID;
}
},
methods: {
clear(){
this.searchValue = "";
this.status = "wait";
this.conversationList = [];
this.friendList = [];
this.messageList = [];
},
cancel(){
uni.navigateBack();
},
input(){
// 可以在这里实现实时搜索
},
async search(){
if(!this.searchValue || this.searchValue.trim() === ''){
uni.showToast({
title: '请输入搜索关键词',
icon: 'none'
});
return;
}
this.status = 'loading';
try {
if(this.currentSearchType === 'conversation'){
await this.searchConversation();
} else if(this.currentSearchType === 'friend'){
await this.searchFriend();
} else if(['message', 'file', 'location'].includes(this.currentSearchType)){
await this.searchMessage();
}
} catch(e) {
console.error('搜索失败:', e);
uni.showToast({
title: '搜索失败,请重试',
icon: 'none'
});
} finally {
this.status = 'done';
}
},
changeSearchType(e){
//console.log(e,this.searchTypeList[e]);
this.currentSearchType = e.value;//this.searchTypeList[index].value;
this.search();
// 切换类型时清空之前的搜索结果
//this.clear();
},
userClick(item){
// 跳转到用户详情或聊天页面
uni.navigateTo({
url: `/pages/common/userCard/index?sourceID=${item.userID}`
});
},
messageClick(item){
// 跳转到对应的聊天页面
const conversation = item.conversation;
if(conversation){
prepareConversationState(conversation);
}
},
goToConversation(resultItem){
// 根据会话类型跳转
const sessionType = resultItem.conversationType === 2 ? SessionType.WorkingGroup : SessionType.Single;
// 从 conversationID 中解析 sourceID,或者从 store 中获取
let sourceID = resultItem.groupID || resultItem.userID;
if(!sourceID){
// 从 conversationID 解析:si_userID1_userID2 或 g_groupID
const convID = resultItem.conversationID || '';
if(convID.startsWith('si_')) {
// 单聊:si_userID1_userID2,取第二个 userID(对方)
const parts = convID.split('_');
if(parts.length >= 3){
const selfID = this.$store.getters.storeCurrentUserID;
sourceID = parts[1] === selfID ? parts[2] : parts[1];
}
} else if(convID.startsWith('g_')) {
// 群聊:g_groupID
sourceID = convID.substring(2);
}
}
// 如果还是没有,尝试从 store 中获取
if(!sourceID){
const allConversations = this.storeConversationList || [];
const conv = allConversations.find(c => c.conversationID === resultItem.conversationID);
if(conv){
sourceID = conv.groupID || conv.userID;
}
}
if(sourceID){
navigateToDesignatedConversation(sourceID, sessionType).catch(() => {
uni.showToast({
title: '跳转失败',
icon: 'none'
});
});
} else {
uni.showToast({
title: '无法跳转,会话信息不完整',
icon: 'none'
});
}
},
// 搜索会话
searchConversation(){
const keyword = this.searchValue.toLowerCase();
const allConversations = this.storeConversationList || [];
this.conversationList = allConversations.filter(conversation => {
const showName = (conversation.showName || '').toLowerCase();
return showName.includes(keyword);
});
},
// 搜索好友
searchFriend(){
const keyword = this.searchValue.toLowerCase();
const allFriends = this.storeFriendList || [];
this.friendList = allFriends.filter(friend => {
const nickname = (friend.nickname || '').toLowerCase();
const remark = (friend.remark || '').toLowerCase();
const userID = (friend.userID || '').toLowerCase();
return nickname.includes(keyword) || remark.includes(keyword) || userID.includes(keyword);
});
},
// 搜索消息(包括文件、位置)
async searchMessage(){
const _this = this;
// 根据搜索类型确定消息类型
let messageTypeList = [];
if(this.currentSearchType === 'file'){
messageTypeList = [MessageType.FileMessage];
} else if(this.currentSearchType === 'location'){
messageTypeList = [MessageType.LocationMessage];
} else {
// 消息搜索:文本消息
messageTypeList = [MessageType.TextMessage];
}
try {
const result = await IMSDK.asyncApi('searchLocalMessages', IMSDK.uuid(), {
conversationID: _this.conversationID || '',
keywordList: [_this.searchValue],
keywordListMatchType: 0,
senderUserIDList: [],
messageTypeList: messageTypeList,
searchTimePosition: 0,
searchTimePeriod: 0,
pageIndex: 1,
count: 50,
});
if(result && result.errCode === 0 && result.data){
// 直接使用返回的 searchResultItems,它们已经包含了会话信息和消息列表
this.messageList = result.data.searchResultItems || [];
// 如果需要补充更多会话信息,可以从store中获取
const allConversations = this.storeConversationList || [];
this.messageList.forEach(item => {
const conv = allConversations.find(c => c.conversationID === item.conversationID);
if(conv){
// 补充会话信息(如果返回的数据不完整)
item.userID = item.userID || conv.userID;
item.groupID = item.groupID || conv.groupID;
}
});
} else {
this.messageList = [];
}
} catch(e) {
console.error('搜索消息失败:', e);
this.messageList = [];
throw e;
}
}
}
}
</script>
<style lang="scss" scoped>
.scroll-view{
flex: 1;
height: 0;
::v-deep .uni-scroll-view-content{
background-color: #fff;
}
}
.empty-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 0;
.empty-text {
margin-top: 24rpx;
font-size: 28rpx;
color: #999;
}
}
.conversation-group {
background-color: #fff;
margin-bottom: 20rpx;
.conversation-header {
display: flex;
align-items: center;
padding: 24rpx 44rpx;
background-color: #f5f5f5;
border-bottom: 1px solid #eee;
.conversation-title {
flex: 1;
margin-left: 24rpx;
font-size: 30rpx;
font-weight: 500;
color: #333;
}
.message-count {
font-size: 24rpx;
color: #999;
}
}
}
</style>
+6 -5
View File
@@ -9,7 +9,7 @@
backgroundColor="transparent" backgroundColor="transparent"
> >
</uni-nav-bar> </uni-nav-bar>
<SearchbarPlace>搜索</SearchbarPlace> <SearchbarPlace @click="toSearch">搜索</SearchbarPlace>
</view> </view>
<uni-list class="contact_menus"> <uni-list class="contact_menus">
<uni-list-item title="新的好友" :showBadge="storeUnHandleFriendApplicationNum>0" :badgeText="storeUnHandleFriendApplicationNum+''" badgeType="error" thumbSize="lg" to="/pages/contact/applicationList/index?applicationType=NewFriend" thumb="/static/images/contact_new_friend.png"></uni-list-item> <uni-list-item title="新的好友" :showBadge="storeUnHandleFriendApplicationNum>0" :badgeText="storeUnHandleFriendApplicationNum+''" badgeType="error" thumbSize="lg" to="/pages/contact/applicationList/index?applicationType=NewFriend" thumb="/static/images/contact_new_friend.png"></uni-list-item>
@@ -57,10 +57,11 @@
}, },
methods: { methods: {
...mapActions('contact',['getFriendList']), ...mapActions('contact',['getFriendList']),
clear(){}, toSearch(){
cancel(){}, uni.navigateTo({
input(){}, url:"/pages/common/search/index?type=friend"
search() {}, })
},
contactAddClick() { contactAddClick() {
uni.navigateTo({ uni.navigateTo({
url: "/pages/contact/contactAdd/index", url: "/pages/contact/contactAdd/index",
@@ -29,11 +29,7 @@
</view> </view>
</u-overlay> </u-overlay>
</view> </view>
<uni-search-bar @confirm="search" :focus="false" bgColor="#fff" <SearchbarPlace @click="toSearch">搜索</SearchbarPlace>
placeholder="请输入您要搜索的内容"
v-model="searchValue" @input="input"
@cancel="cancel" @clear="clear">
</uni-search-bar>
<view class="status_notice"> <view class="status_notice">
<view class="tag" v-if="storeIsSyncing"> <view class="tag" v-if="storeIsSyncing">
<img class="loading" style="height: 24rpx; width: 24rpx" src="static/images/loading.png" <img class="loading" style="height: 24rpx; width: 24rpx" src="static/images/loading.png"
@@ -86,15 +82,15 @@
import MyAvatar from "@/components/MyAvatar/index.vue"; import MyAvatar from "@/components/MyAvatar/index.vue";
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
import util from "@/util"; import util from "@/util";
import SearchbarPlace from "@/components/searchbar_place.vue";
export default { export default {
name: "ChatHeader", name: "ChatHeader",
components: { components: {
MyAvatar, MyAvatar,SearchbarPlace
}, },
props: {}, props: {},
data() { data() {
return { return {
searchValue:"",
connectStart: -2, connectStart: -2,
moreMenuVisible: false, moreMenuVisible: false,
popMenuPosition: { popMenuPosition: {
@@ -113,12 +109,11 @@
this.unsubscribeAll(); this.unsubscribeAll();
}, },
methods: { methods: {
search(){}, toSearch(){
blur(){}, uni.navigateTo({
focus(){}, url:"/pages/common/search/index"
input(){}, })
cancel(){}, },
clear(){},
setStateStart() { setStateStart() {
this.connectStart = 0; this.connectStart = 0;
}, },
@@ -69,11 +69,12 @@
//console.log(this.storeConversationList); //console.log(this.storeConversationList);
this._freshing = false; this._freshing = false;
this.triggered = true; this.triggered = true;
setTimeout(()=>{ // setTimeout(()=>{
uni.navigateTo({ // uni.navigateTo({
url:'/pages/workbench/friend-circle/friend-circle', // //url:'/pages/workbench/friend-circle/friend-circle',
}) // url:'/pages/common/scan',
},1000) // })
// },1000)
}, },
methods: { methods: {
test(){ test(){
@@ -8,7 +8,7 @@
</view> </view>
</view> --> </view> -->
<view class="member_list"> <view class="member_list">
<view class="member_item" v-for="(member, index) in groupMemberList"> <view class="member_item" v-for="(member, index) in groupMemberList" :key="member.userID">
<my-avatar :src="member.faceURL" :desc="member.nickname" :key="member.userID" size="48" /> <my-avatar :src="member.faceURL" :desc="member.nickname" :key="member.userID" size="48" />
<view class="ower" v-if="member.roleLevel === 100">群主</view> <view class="ower" v-if="member.roleLevel === 100">群主</view>
<text class="member_item_name">{{ member.nickname }}</text> <text class="member_item_name">{{ member.nickname }}</text>
@@ -1,53 +1,56 @@
<template> <template>
<view class="content-circle-box" :index="index"> <view class="content-circle-box" :index="index">
<view @tap="linkToBusinessCard(item.user_id)"> <view @tap="linkToBusinessCard(item.user_id)">
<MyAvatar :src="item.user.avatar" :desc="item.user.nickname || item.user.id" :isGroup="false" size="66"></MyAvatar> <MyAvatar :src="item.user.avatar" :desc="item.user.nickname || item.user.id" :isGroup="false" size="48"></MyAvatar>
</view> </view>
<view class="content"> <view class="content">
<view class="content-name" @tap="linkToBusinessCard(item.user_id)">{{ item.user.nickname || item.user.remark }}</view> <view class="content-name" @tap="linkToBusinessCard(item.user_id)">{{ item.user.nickname || item.user.remark }}</view>
<view class="content-desc">{{ item.body }}</view> <view class="content-desc">
<u--text :lines="5" :text="item.body" />
</view>
<!-- 图片,视频 --> <!-- 图片,视频 -->
<view class="content-img" v-if="item.files!=null&&item.files.length>0"> <view class="content-img" v-if="item.files!=null&&item.files.length>0">
<!-- //只有一张图时候 --> <!-- //只有一张图时候 -->
<view v-if="item.files.length==1&&item.releaseType==1" class="u-flex u-row-left u-col-center" <view v-if="item.files.length==1&&item.releaseType==1"
style="width:100%;min-height: 200rpx;"> class="u-flex u-row-left u-col-center"
<u-image width="280rpx" :src="cdn(item.files[0])" mode="widthFix" style="width:100%;min-height: 200rpx;">
@tap="previewImg(0, item)"> <u-image width="280rpx" :src="cdn(item.files[0])" mode="widthFix" @tap="previewImg(0)">
<u-loading slot="loading"></u-loading> <u-loading-icon slot="loading"></u-loading-icon>
<view slot="error" class="u-flex u-row-left u-col-center" <view slot="error"
style="font-size: 24rpx;width: 200rpx;height: 100rpx;margin-top: -50rpx;"> class="u-flex u-row-left u-col-center"
<u-icon name="photo" size="100" label="加载失败" label-pos="bottom"></u-icon> style="font-size: 24rpx;width: 200rpx;height: 100rpx;margin-top: -50rpx;">
</view> <u-icon name="photo" size="100" label="加载失败" label-pos="bottom"></u-icon>
</view>
</u-image>
</view>
<!-- 有多张图的时候 -->
<view v-if="item.files.length > 1&&item.releaseType==1">
<view class="content-img-more u-m-b-20">
<uni-grid :column="3" showBorder borderColor="#FFF" hover-class="none" :highlight="false">
<uni-grid-item v-for="(src, index) in item.files" :key="index" :index="index">
<view class="slot-btn">
<u-image @tap="previewImg(index)" :src="cdn(src)" width="180rpx" height="180rpx" mode="aspectFill" border-radius="10"></u-image>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
<!-- 视频 -->
<view class="u-m-b-30 u-m-t-30 u-flex u-row-left u-col-center"
v-if="item.files.length > 0&&item.releaseType==2" @tap="previewImg(0, item)">
<view v-if="vuex_OSPlat=='ios'">
<u-image width="280rpx" :src="getVideoPoster(item.files[0])" mode="widthFix">
<u-loading-icon slot="loading"></u-loading-icon>
</u-image> </u-image>
</view> </view>
<!-- 有多张图的时候 --> <view v-else class="u-flex u-row-center u-col-center"
<view v-if="item.files.length > 1&&item.releaseType==1"> style="border: 1rpx solid #36648b;width:280rpx;height:120rpx;border-radius: 16rpx;">
<view class="content-img-more u-m-b-20"> <u-icon name="play-circle" size="48" color="#36648b"
<u-grid :col="3" :border="false" hover-class="none"> label="点击查看视频" label-pos="bottom"></u-icon>
<u-grid-item v-for="(src, index) in item.files" :index="index" :custom-style="girdItemCustomStyle">
<view @tap="previewImg(index, item)" class="slot-btn">
<u-image :src="cdn(src)" width="180rpx" height="180rpx" mode="aspectFill" border-radius="10"></u-image>
</view>
</u-grid-item>
</u-grid>
</view>
</view>
<!-- 视频 -->
<view class="u-m-b-30 u-m-t-30 u-flex u-row-left u-col-center"
v-if="item.fileList.length > 0&&item.releaseType==2" @tap="previewImg(0, item)">
<view v-if="vuex_OSPlat=='ios'">
<u-image width="280rpx" :src="getVideoPoster(item.fileList[0])" mode="widthFix">
<u-loading slot="loading"></u-loading>
</u-image>
</view>
<view v-else class="u-flex u-row-center u-col-center"
style="border: 1rpx solid #36648b;width:280rpx;height:120rpx;border-radius: 16rpx;">
<u-icon name="play-circle" size="48" color="#36648b"
label="点击查看视频" label-pos="bottom"></u-icon>
</view>
</view> </view>
</view>
</view> </view>
<!-- 地点 --> <!-- 地点 -->
@@ -58,43 +61,42 @@
<!-- 相对时间 点赞按钮等 --> <!-- 相对时间 点赞按钮等 -->
<view class="relavivetime" :id="`comment-${'null'}-${index}`"> <view class="relavivetime" :id="`comment-${'null'}-${index}`">
<view class="time u-flex u-col-center"> <view class="time">
<view>{{ item.created_at }}</view> <view>{{ item.created_at }}</view>
<view @click="deleteCircle(item,index)" style="color:#36648b;margin-left: 20rpx;" v-if="item.user_id==selfInfo.userID">删除</view> <view @click="deleteCircle(item,index)" style="color:#36648b;margin-left: 20rpx;" v-if="item.user_id==selfInfo.userID">删除</view>
</view> </view>
<view class="icon-box u-flex u-row-between u-col-center"> <view class="icon-box u-flex u-row-between u-col-center">
<view @tap="clickThumb(item,index)" class="u-m-r-6 u-p-t-4"> <view @tap="clickThumb(item,index)" class="u-m-r-6 u-p-t-4">
<u-icon v-if="item.isPraise==false" size="38" name="heart" color="#36648b"></u-icon> <u-icon v-if="item.is_liked==false" size="24" name="heart" color="#36648b"></u-icon>
<u-icon v-if="item.isPraise==true" size="38" name="heart-fill" color="#36648b"></u-icon> <u-icon v-if="item.is_liked==true" size="24" name="heart-fill" color="#36648b"></u-icon>
</view> </view>
<view @tap="handleComment(item.id, null, index)" class="u-m-l-6 u-p-t-2"> <view @tap="handleComment(null, index)" class="u-m-l-6 u-p-t-2">
<u-icon size="40" name="chat" color="#36648b"></u-icon> <u-icon size="24" name="chat" color="#36648b"></u-icon>
</view> </view>
</view> </view>
</view> </view>
<!-- 点赞人 评论 --> <!-- 点赞人 评论 -->
<view class="msg-box"> <view class="msg-box">
<view class="thumbinfo u-border-bottom" v-if="item.praise!=null&&item.praise.length"> <view class="thumbinfo u-border-bottom" v-if="item.likes!=null&&item.likes.length">
<uni-icons size="30" type="heart" color="#36648b" class="u-m-r-10"></uni-icons> <uni-icons size="30" type="heart" color="#36648b" class="u-m-r-10"></uni-icons>
<text class="thumbinfo-name" v-for="(userInfo, pindex) in item.praise" :index="pindex" <text class="thumbinfo-name" v-for="(userInfo, pindex) in item.likes" :index="pindex"
:key="pindex" @tap="linkToBusinessCard(userInfo.userId)"> :key="pindex" @tap="linkToBusinessCard(userInfo.userId)">
{{ userInfo.nickame }}{{ pindex != item.praise.length - 1 ? '' : '' }} {{ userInfo.nickame }}{{ pindex != item.likes.length - 1 ? '' : '' }}
</text> </text>
</view> </view>
<view class="comment" v-if="item.comments!=null&&item.comments.length"> <view class="comment" v-if="item.comments!=null&&item.comments.length">
<view class="comment-box" v-for="(comment, commentIndex) in item.comments" :index="commentIndex" <view class="comment-box" v-for="(comment, commentIndex) in item.comments" :index="comment.id"
:key="commentIndex" hover-class="comment-hover-class" :key="comment.id" hover-class="comment-hover-class"
:id="`comment-${item.id}-${index}`" :id="`comment-${item.id}-${comment.id}`"
@tap="handleComment(item.id, comment, index)"> @tap="handleComment(comment, index)">
<text class="comment-box-name" v-if="!comment.reply_user_id">{{ comment.replyUser.nickname }}</text> <text class="comment-box-name">
<text class="comment-box-name" v-if="comment.reply_user_id"> {{ comment.user.nickname }}
{{ comment.replyUser.nickname }}
<text class="callback u-m-l-4 u-m-r-4">回复</text> <text class="callback u-m-l-4 u-m-r-4">回复</text>
</text> </text>
<text v-if="comment.reply_user_id" class="comment-box-name">{{ comment.replyUser.nickname }}</text> <text v-if="comment.reply_user_id" class="comment-box-name">{{ comment.user.nickname }}</text>
<text class="comment-box-content">{{ comment.content }}</text> <text class="comment-box-content">{{ comment.body }}</text>
</view> </view>
</view> </view>
</view> </view>
@@ -105,6 +107,7 @@
<script> <script>
import MyAvatar from "@/components/MyAvatar/index.vue"; import MyAvatar from "@/components/MyAvatar/index.vue";
import videoPlayer from '@/components/videoPlayer.vue'; import videoPlayer from '@/components/videoPlayer.vue';
import util from "@/util/index.js";
export default{ export default{
components:{videoPlayer ,MyAvatar}, components:{videoPlayer ,MyAvatar},
props:{ props:{
@@ -125,13 +128,52 @@
}, },
}, },
data(){ data(){
console.log(this.item); //console.log(this.item);
return { return {
girdItemCustomStyle:{
padding: '0',
margin:'0',
border:'1rpx solid #f2f6fc'
},
} }
}, },
methods:{ methods:{
clickThumb(item,index){
this.$emit('userEvent',{type:'clickThumb',item,index});
},
deleteCircle(item,index){
this.$emit('userEvent',{type:'deleteCircle',item,index});
},
handleComment(comment,index){
this.$emit('userEvent',{type:'handleComment',comment,index});
},
linkToBusinessCard(userID){
this.$emit('userEvent',{type:'linkToBusinessCard',userID});
},
//查看大图或者预览视频
previewImg(current) {
const data = this.item;
let that=this;
let releaseType= data.releaseType;
let fileList=[...data.files];
if(releaseType==2){
that.previewVideoSrc=fileList[0];
that.previewVideoFlag=true;
}else{
fileList=fileList.map(item=>this.cdn(item));
uni.previewImage({
current:current,
urls: fileList,
});
return;
}
},
getVideoPoster(videoSrc){
console.log("video",videoSrc);
return "http://192.168.31.125:9090/we-chat/images/friendCircle/1715421601709.mp4";
//return videoSrc;
},
cdn:util.cdn
} }
} }
</script> </script>
@@ -262,6 +304,8 @@
.time { .time {
color: $uni-text-color-grey; color: $uni-text-color-grey;
display: flex;
align-items: center;
} }
.icon-box { .icon-box {
@@ -285,5 +329,8 @@
} }
} }
} }
.content-img-more{
max-width: 100%;
}
</style> </style>
+65 -143
View File
@@ -1,7 +1,7 @@
<template> <template>
<view class="content" id="content"> <view class="content" id="content">
<u-navbar <u-navbar
@leftClick="goto('/pages/workbench/index/index')" @leftClick="leftClick"
bgColor="transparent" bgColor="transparent"
title="朋友圈" title="朋友圈"
title-size="36" title-size="36"
@@ -14,7 +14,7 @@
<u-icon name="camera" color="#fff" size="32"></u-icon> <u-icon name="camera" color="#fff" size="32"></u-icon>
</view> </view>
</u-navbar> </u-navbar>
<scroll-view :scroll-x="false" :scroll-y="true" v-show="showInput==false" class="scrollView" <scroll-view :scroll-x="false" :scroll-y="true" class="scrollView"
:scroll-with-animation="scrollWithAnimation" :scroll-top="scrollTop" @scroll="scrolling" :scroll-with-animation="scrollWithAnimation" :scroll-top="scrollTop" @scroll="scrolling"
@scrolltolower="loadMore" @scrolltolower="loadMore"
:style="'height:'+scrollViewHeight+'px'"> :style="'height:'+scrollViewHeight+'px'">
@@ -32,14 +32,14 @@
<view class="">{{ selfInfo.bio }}</view> <view class="">{{ selfInfo.bio }}</view>
</view> </view>
<view v-if="vuex_friendCircleUnreadCount>0" style="display: flex;justify-content: center;"> <view v-if="unreadCount>0" style="display: flex;justify-content: center;">
<view @click="clearUnReadCount()" <view @click="clearUnReadCount()"
style="width: 300rpx;height:70rpx;line-height:70rpx;background-color: #333333;color: #ffffff;border-radius:10rpx;display: flex;align-items: center;"> style="width: 300rpx;height:70rpx;line-height:70rpx;background-color: #333333;color: #ffffff;border-radius:10rpx;display: flex;align-items: center;">
<view style="width:80rpx;padding:0 10rpx;"> <view style="width:80rpx;padding:0 10rpx;">
<MyAvatar :src="selfInfo.faceURL" class="headimg" desc=" " size="24"/> <MyAvatar :src="selfInfo.faceURL" class="headimg" desc=" " size="24"/>
</view> </view>
<view style="flex:1;"> <view style="flex:1;">
{{vuex_friendCircleUnreadCount}}条新信息 {{unreadCount}}条新信息
</view> </view>
</view> </view>
</view> </view>
@@ -49,7 +49,7 @@
<!-- circleData是vuex变量不在本页面定义 --> <!-- circleData是vuex变量不在本页面定义 -->
<template v-if="circleData!=null&&circleData.length>0"> <template v-if="circleData!=null&&circleData.length>0">
<template v-for="(item, index) in circleData" > <template v-for="(item, index) in circleData" >
<CircleItem :key="index" :index="index" :item="item"></CircleItem> <CircleItem :key="index" :index="index" :item="item" @userEvent="onUserEvent"></CircleItem>
</template> </template>
</template> </template>
<template v-else> <template v-else>
@@ -59,92 +59,18 @@
</template> </template>
</view> </view>
</scroll-view> </scroll-view>
<!-- 为了实现模拟键盘随着内容的选择而固定位置 --> <u-overlay :show="showInput" @click="showInput = false">
<template v-if="showInput==true"> <view class="input-box" style="height: 100rpx;" @tap.stop>
<scroll-view :scroll-x="false" :scroll-y="true" :scroll-top="currentTop" @touchstart="closeInputModel" <view class="input-box-flex">
:style="'width:100%;height:'+scrollViewHeight+'px;'"> <view class="input-box-flex-grow">
<view @click="closeInputModel" class="content-circle-box"> <input :adjust-position="false" type="text" class="content" id="input" v-model="content"
<view> :confirm-type="'send'" :confirm-hold="true" placeholder-style="color:#DDD;" :cursor-spacing="6"
<MyAvatar :src="currentItem.avatar" :isGroup="false" size="66"></MyAvatar> :placeholder="placeholder" :focus="true" @confirm="sendMsg" />
</view>
<view class="content">
<view class="content-name">{{ currentItem.nickname }}</view>
<view class="content-desc">{{ currentItem.content }}</view>
<view class="content-img" v-if="currentItem.files!=null&&currentItem.files.length>0">
<view v-if="currentItem.files.length==1&&currentItem.releaseType==1"
class="u-flex u-row-left u-col-center" style="width:100%;min-height: 200rpx;">
<u-image width="280rpx" :src="currentItem.files[0]" mode="widthFix">
<u-loading slot="loading"></u-loading>
<view slot="error" class="u-flex u-row-left u-col-center"
style="font-size: 24rpx;width: 200rpx;height: 100rpx;margin-top: -50rpx;">
<u-icon name="photo" size="100" label="加载失败" label-pos="bottom"></u-icon>
</view>
</u-image>
</view>
<!-- 有多张图的时候 -->
<view v-if="currentItem.files.length > 1&&currentItem.releaseType==1">
<view class="content-img-more u-m-b-20">
<u-grid :col="3" :border="false" hover-class="none">
<u-grid-item v-for="(src, index) in currentItem.files" :index="index" :custom-style="girdItemCustomStyle">
<view class="slot-btn">
<u-image :src="src" width="180rpx" height="180rpx" mode="aspectFill" border-radius="10"></u-image>
</view>
</u-grid-item>
</u-grid>
</view>
</view>
<view v-if="currentItem.releaseType==2" class="u-m-b-20 u-m-t-20 u-flex u-row-left u-col-center">
<view class="u-flex u-row-left u-col-center" style="height: 120rpx;border-radius: 16rpx;">
<u-icon name="play-circle" size="48" color="#36648b"
label="此处不支持观看视频" label-pos="bottom" :margin-left="20" :margin-right="20"></u-icon>
</view>
</view>
</view>
<!-- 地点 -->
<view v-if="(currentItem.address&&currentItem.address.chooseFlag)==true" class="u-line-2 u-m-t-10 u-m-b-10"
style="font-size: 30rpx;color: #36648b;">
<u-icon name="map" color="#36648b" size="30" :custom-style="{marginLeft:'-4rpx'}"></u-icon>
<text> {{ currentItem.address.name}}</text>
</view>
<!-- 点赞人 评论 -->
<view class="msg-box">
<view class="thumbinfo" v-if="currentItem.praise!=null&&currentItem.praise.length>0">
<uni-icons type="heart" class="thumbinfo-icon"></uni-icons>
<text class="thumbinfo-name" v-for="(userInfo, pindex) in currentItem.praise"
:key="pindex">
{{ userInfo.nickname }}{{ pindex != currentItem.praise.length - 1 ? '' : '' }}
</text>
</view>
<view class="comment" v-if="currentItem.comments!=null&&currentItem.comments.length>0">
<view class="comment-box" v-for="(comment, cindex) in currentItem.comments" :key="cindex" :index="cindex"
hover-class="comment-hover-class">
<text class="comment-box-name" v-if="!comment.reply_user_id">{{ comment.replyUser.nickname }}</text>
<text class="comment-box-name" v-if="comment.reply_user_id">
{{ comment.replyUser.nickname }}<text class="callback u-m-l-4 u-m-r-4">回复</text>
</text>
<text v-if="comment.reply_user_id" class="comment-box-name">{{ comment.replyUser.nickname }}</text>
<text class="comment-box-content">{{ comment.body }}</text>
</view>
</view>
</view>
</view> </view>
<u-button class="btn" type="primary" size="mini" @tap.prevent.stop="sendMsg">发送</u-button>
</view> </view>
</scroll-view>
</template>
<view class="input-box" v-show="showInput" style="height: 100rpx;">
<view class="input-box-flex">
<view class="input-box-flex-grow">
<input :adjust-position="false" type="text" class="content" id="input" v-model="content"
:confirm-type="'send'" :confirm-hold="true" placeholder-style="color:#DDD;" :cursor-spacing="6"
:placeholder="placeholder" :focus="showInput" @blur="blurInput" @confirm="sendMsg" />
</view>
<button class="btn" type="primary" size="mini" @touchend.prevent="sendMsg">发送</button>
</view> </view>
</view> </u-overlay>
<!-- 视频预览 --> <!-- 视频预览 -->
<view v-if="previewVideoFlag==true"> <view v-if="previewVideoFlag==true">
@@ -180,7 +106,7 @@
circleData() { circleData() {
return this.$store.getters.storeCircleData; return this.$store.getters.storeCircleData;
}, },
vuex_friendCircleUnreadCount() { unreadCount() {
return this.$store.getters.storeCircleUnreadCount; return this.$store.getters.storeCircleUnreadCount;
}, },
last_unread_item() { last_unread_item() {
@@ -255,21 +181,22 @@
}, },
onLoad:function(){ onLoad:function(){
let that=this; let that=this;
this.platFrom= this.$u.os(); this.platFrom= this.$u.os();
console.log("onload",this.platFrom); console.log("onload",this.platFrom);
let param={ let param={
page:1, page:1,
limit:this.limit, limit:this.limit,
moreFlag:false moreFlag:false
}; };
this.$store.dispatch('circle/getFriendCircleInfo');
this.getCircleDataList(param); this.getCircleDataList(param);
uni.$on("handleFriendCircle", function(friendCircleMessage) { uni.$on("handleFriendCircle", function(friendCircleMessage) {
console.log("监听到朋友圈动态有更新",friendCircleMessage); console.log("监听到朋友圈动态有更新",friendCircleMessage);
let id= friendCircleMessage.content.id; let id= friendCircleMessage.content.id;
let newPraise= friendCircleMessage.content.praise; let newPraise= friendCircleMessage.content.likes;
const index = that.circleData.findIndex(i => i.id ==id); const index = that.circleData.findIndex(i => i.id ==id);
that.circleData[index].praise=JSON.parse(newPraise); that.circleData[index].likes=JSON.parse(newPraise);
if(friendCircleMessage.content.isPraise&&friendCircleMessage.userId!=that.selfInfo.userID){ if(friendCircleMessage.content.is_liked&&friendCircleMessage.userId!=that.selfInfo.userID){
that.$store.dispatch('circle/updateUnreadCount',1); that.$store.dispatch('circle/updateUnreadCount',1);
} }
}) })
@@ -293,7 +220,7 @@
methods: { methods: {
goto:util.goto, goto:util.goto,
clearUnReadCount(){ clearUnReadCount(){
this.$store.dispatch('circle/updateUnreadCount',0-this.vuex_friendCircleUnreadCount); this.$store.dispatch('circle/updateUnreadCount',0-this.unreadCount);
}, },
//初始化朋友圈 //初始化朋友圈
getCircleDataList:function(param){ getCircleDataList:function(param){
@@ -368,32 +295,31 @@
clickThumb(item,index) { clickThumb(item,index) {
let that=this; let that=this;
let flag=true; let flag=true;
item.isPraise = !item.isPraise; item.is_liked = !item.is_liked;
if (item.isPraise) { if (item.is_liked) {
item.praise.push({ item.likes.push({
userId: this.selfInfo.userID, userId: this.selfInfo.userID,
userName: this.selfInfo.nickname userName: this.selfInfo.nickname
}); });
} else { } else {
const index = item.praise.findIndex(i => i.userId == this.selfInfo.userID); const index = item.likes.findIndex(i => i.userId == this.selfInfo.userID);
item.praise.splice(index, 1); item.likes.splice(index, 1);
flag=false; flag=false;
} }
console.log("当前动态下标",index); console.log("当前动态下标",index);
console.log("点赞列表",item); console.log("点赞列表",item);
let param={ let param={
id:item.id, id:item.id,
praise:JSON.stringify(item.praise), likes:JSON.stringify(item.likes),
isPraise:flag is_liked:flag
}; };
friendCircleZan(param).then(res => { this.$store.dispatch('circle/like',param).then(res=>{
if(res.code==200){ console.log("点赞更新成功",res.data);
console.log("点赞更新成功",res.data); item.likes=JSON.parse(res.data.likes);
item.praise=JSON.parse(res.data.praise); that.circleData[index]=item;
that.circleData[index]=item; }).catch(e=>{
}else{ item.is_liked = !item.is_liked;
item.isPraise = !item.isPraise; console.log("评论失败",e);
}
}); });
}, },
//跳转到名片 //跳转到名片
@@ -436,12 +362,12 @@
}, },
//点击评论 唤出输入框和键盘 //点击评论 唤出输入框和键盘
handleComment(id, comment, index) { handleComment(comment, index) {
let that = this; let that = this;
this.content = ''; this.content = '';
that.currentItem = that.circleData[index]; that.currentItem = that.circleData[index];
that.currentTop = 0; that.currentTop = 0;
this.id = id; this.id = that.currentItem.id;
this.commentInfo = comment || {}; this.commentInfo = comment || {};
this.placeholder = '评论:'; this.placeholder = '评论:';
if (comment) { if (comment) {
@@ -451,7 +377,7 @@
this.placeholder = `评论:`; this.placeholder = `评论:`;
} else { } else {
// xxx评论... // xxx评论...
this.placeholder = `回复${comment.replyUser.nickname}:`; this.placeholder = `回复${comment.user.nickname}:`;
} }
} }
this.showInput = true; this.showInput = true;
@@ -463,32 +389,16 @@
return; return;
} }
let param={ let param={
reply_user_id:that.selfInfo.userID, reply_user_id:that.commentInfo?.user_id || '',
body:that.content, body:that.content,
friendCircleId:that.id id:that.currentItem.id
}; };
//如果被回复的动态发表人不是自己本人 this.$store.dispatch('circle/comment',param).then(res=>{
if(that.commentInfo.reply_user_id!=that.selfInfo.userID){ console.log("评论失败1",res);
param.reply_user_id=that.commentInfo.reply_user_id; that.closeInputModel();
param.replyUserName=that.commentInfo.replyUser.nickname; }).catch(e=>{
} console.log("评论失败",e);
console.log("新增动态的评论",param);
this.circleData.forEach(item => {
if (item.id == that.id) {
if(item.comment!=null&&item.comment.length>0){
item.comment.push(param);
}
else{
item.comment=[param];
}
that.$u.api.friendCircle.handleComment(param).then(res => {
if(res.code==200){
console.log("评论更新成功");
}
});
}
}); });
that.closeInputModel();
}, },
//查看大图或者预览视频 //查看大图或者预览视频
@@ -516,11 +426,6 @@
this.commentInfo = {}; this.commentInfo = {};
uni.hideKeyboard(); uni.hideKeyboard();
}, },
//失去焦点触发
blurInput() {
this.closeInputModel();
},
//选择发表朋友圈的方式 //选择发表朋友圈的方式
toChooseRelease: function(index) { toChooseRelease: function(index) {
@@ -584,6 +489,22 @@
return "http://192.168.31.125:9090/we-chat/images/friendCircle/1715421601709.mp4"; return "http://192.168.31.125:9090/we-chat/images/friendCircle/1715421601709.mp4";
//return videoSrc; //return videoSrc;
}, },
leftClick(e){
this.goto('/pages/workbench/index/index',"2");
},
onUserEvent(e){
switch(e.type){
case 'clickThumb':
this.clickThumb(e.item,e.index);
break;
case 'handleComment':
this.handleComment(e.comment,e.index);
break;
case 'linkToBusinessCard':
this.linkToBusinessCard(e.userID);
break;
}
},
cdn:util.cdn cdn:util.cdn
}, },
}; };
@@ -824,8 +745,9 @@
.btn { .btn {
margin-left: 20rpx; margin-left: 20rpx;
//background-color: $u-type-success; background-color: $uni-color-success;
border: none; border: none;
width: 60px;
} }
} }
} }
@@ -28,7 +28,7 @@
<view v-if="releaseType!=0" class="uploadBox"> <view v-if="releaseType!=0" class="uploadBox">
<u-grid :col="3" :border="false" hover-class="none"> <u-grid :col="3" :border="false" hover-class="none">
<template v-if="tempFilePaths.length>0"> <template v-if="tempFilePaths.length>0">
<u-grid-item v-for="(item,index) in tempFilePaths" :index="index" :custom-style="girdItemCustomStyle"> <u-grid-item v-for="(item,index) in tempFilePaths" :key="index" :index="index" :custom-style="girdItemCustomStyle">
<view @click="delTempFile(index)" <view @click="delTempFile(index)"
style="width: 200rpx; display: flex; flex-direction: row;align-items: flex-start;justify-content: flex-end;position: relative;left: 32rpx;top:32rpx; z-index: 999;"> style="width: 200rpx; display: flex; flex-direction: row;align-items: flex-start;justify-content: flex-end;position: relative;left: 32rpx;top:32rpx; z-index: 999;">
<u-icon name="close-circle" size="32" color="#fa3534"></u-icon> <u-icon name="close-circle" size="32" color="#fa3534"></u-icon>
@@ -39,7 +39,7 @@
</u-grid-item> </u-grid-item>
</template> </template>
<template v-if="(tempFilePaths.length<9&&releaseType==1)||(tempFilePaths.length<1&&releaseType==2)"> <template v-if="(tempFilePaths.length<9&&releaseType==1)||(tempFilePaths.length<1&&releaseType==2)">
<u-grid-item @click="chooseFile()" :custom-style="girdItemCustomStyle2"> <u-grid-item @click="chooseFile()" :custom-style="girdItemCustomStyle2">
<view class="slot-btn" hover-class="slot-btn__hover"> <view class="slot-btn" hover-class="slot-btn__hover">
<u-icon name="plus" size="80" :color="$u.color['lightColor']"></u-icon> <u-icon name="plus" size="80" :color="$u.color['lightColor']"></u-icon>
</view> </view>
@@ -391,18 +391,19 @@
let size= that.tempFilePaths.length; let size= that.tempFilePaths.length;
if(index==size){ if(index==size){
console.log("文件全部上传完成",files); console.log("文件全部上传完成",files);
params.fileList=JSON.stringify(files); params.files=JSON.stringify(files);
that.submitPublish(params); that.submitPublish(params);
uni.hideLoading(); uni.hideLoading();
return; return;
} }
let filePath=that.tempFilePaths[index]; let filePath=that.tempFilePaths[index];
let obj = { let obj = {
filePath:filePath, savePath: "circle" //文件存放目录
savePath: "friendCircle" //文件存放目录
} }
//批量上传
upload(filePath).then(res1=>{
//单个上传
upload(filePath,obj).then(res1=>{
if(res1.code === 0 ){ if(res1.code === 0 ){
console.log("第"+(index+1)+"个文件上传完成",res1); console.log("第"+(index+1)+"个文件上传完成",res1);
let fileUrl= res1.data[0].file_name; let fileUrl= res1.data[0].file_name;
@@ -419,7 +420,7 @@
submitPublish(param){ submitPublish(param){
let that=this; let that=this;
console.error('submitPublish'); console.error('submitPublish');
uni.$u.http.post('/friendcircle/create',param).then(res => { uni.$u.http.post('/friendcircle/create',param).then(res => {
let newCircle=res; let newCircle=res;
if(newCircle.address!=null&&newCircle.address.length>0){ if(newCircle.address!=null&&newCircle.address.length>0){
@@ -445,7 +446,7 @@
} }
let circleDataList=[...this.circleData]; let circleDataList=[...this.circleData];
circleDataList.unshift(newCircle); circleDataList.unshift(newCircle);
that.$u.vuex('circleData', circleDataList); that.$store.commit('circle/SET_LIST',circleDataList);
that.btnLoading = false; that.btnLoading = false;
uni.hideLoading(); uni.hideLoading();
uni.navigateBack(); uni.navigateBack();
@@ -492,9 +493,9 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background: rgb(244, 245, 246); //background: rgb(244, 245, 246);
border-radius: 10rpx; //border-radius: 10rpx;
border:1rpx solid $u-border-color //border:1rpx solid $u-border-color
} }
.slot-btn__hover { .slot-btn__hover {
+1 -1
View File
@@ -15,7 +15,7 @@
</uni-list> </uni-list>
<u-gap :height="10"></u-gap> <u-gap :height="10"></u-gap>
<uni-list> <uni-list>
<uni-list-item title="扫一扫" thumb="/static/images/workbench/03.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item> <uni-list-item title="扫一扫" thumb="/static/images/workbench/03.png" :thumbSize="thumbSize" to="/pages/common/scan" showArrow></uni-list-item>
<uni-list-item title="摇一摇" thumb="/static/images/workbench/05.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item> <uni-list-item title="摇一摇" thumb="/static/images/workbench/05.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item>
<uni-list-item title="看一看" thumb="/static/images/workbench/06.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item> <uni-list-item title="看一看" thumb="/static/images/workbench/06.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item>
<uni-list-item title="听一听" thumb="/static/images/workbench/06.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item> <uni-list-item title="听一听" thumb="/static/images/workbench/06.png" :thumbSize="thumbSize" to="/pages/workbench/friend-circle/friend-circle" showArrow></uni-list-item>
+54
View File
@@ -48,6 +48,60 @@ const actions = {
uni.$u.toast("获取信息失败"); uni.$u.toast("获取信息失败");
}) })
}, },
async comment({ commit, state},params) {
return new Promise((resolve,reject)=>{
uni.$u.http.post('/friendcircle/comment',params).then(data=>{
console.log("评论成功",data);
let index = -1;
for(let i=0;i<state.list.length;i++){
if(state.list[i].id==params.id){
index = i;
break;
}
}
console.log("index",index);
if(index!=-1){
state.list[index].comments.unshift(params);
resolve(data);
}else{
reject(data);
}
}).catch(e=>{
console.log("评论失败",e);
uni.$u.toast("评论失败");
reject(e);
})
})
},
async like({commit, state},params) {
return new Promise((resolve,reject)=>{
uni.$u.http.post('/friendcircle/like',params).then(data=>{
console.log("点赞成功",data);
let index = -1;
for(let i=0;i<state.list.length;i++){
if(state.list[i].id==params.id){
index = i;
break;
}
}
console.log("index",index);
if(index!=-1){
if(data.is_liked){
state.list[index].likes.push(params.user_id);
}else{
state.list[index].likes.splice(state.list[index].likes.indexOf(params.user_id),1);
}
resolve(data);
}else{
reject(data);
}
}).catch(e=>{
console.log("点赞失败",e);
uni.$u.toast("点赞失败");
reject(e);
})
})
},
async updateUnreadCount({commit,state},v) { async updateUnreadCount({commit,state},v) {
commit("SET_UNREAD_COUNT", state.unread_count+v); commit("SET_UNREAD_COUNT", state.unread_count+v);
}, },
+7 -2
View File
@@ -74,7 +74,7 @@ export default{
cdn(v){ cdn(v){
v= v || ""; v= v || "";
v = v.replace(/\\/ig,"/").replace('/\/\/ig',"/"); v = v.replace(/\\/ig,"/").replace('/\/\/ig',"/");
console.log(v); //console.log(v);
if(isString(v)){ if(isString(v)){
if(v.startsWith('blob:')){ if(v.startsWith('blob:')){
return v; return v;
@@ -88,7 +88,7 @@ export default{
return ""; return "";
}, },
goto(url,type){ goto(url,type){
console.log(url); //console.log(url);
type = type || '0'; //0 navigateTo 1 redirectTo type = type || '0'; //0 navigateTo 1 redirectTo
if(url){ if(url){
if(isInteger(url)){ if(isInteger(url)){
@@ -105,6 +105,11 @@ export default{
url:url url:url
}); });
} }
if(type == '2'){
return uni.switchTab({
url:url
});
}
uni.navigateTo({ uni.navigateTo({
url:url url:url
}) })