465 lines
9.1 KiB
Vue
Raw Normal View History

2025-03-28 15:46:11 +08:00
<style>
.page {
background-color: #000000;
opacity: 0.9;
}
.btn-cancel {
background-color: #1d1d1e;
border-color: #3a3a3d;
}
.btn-cancel-touched {
background-color: #515156;
border-color: #2b2b2f;
}
.all-box {
display: flex;
flex-direction: row;
2025-04-30 14:28:07 +08:00
/* justify-content: space-around; */
2025-03-28 15:46:11 +08:00
height: 280rpx;
}
.share-item {
display: flex;
flex-direction: column;
margin-top: 60rpx;
2025-04-30 14:28:07 +08:00
margin-left: 20rpx;
margin-right: 20rpx;
width: 120rpx;
2025-03-28 15:46:11 +08:00
}
.icon-wrapper {
width: 120rpx;
height: 120rpx;
background-color: #343437;
border-radius: 100px;
display: flex;
flex-direction: row;
justify-content: center;
opacity: 0.8;
}
.icon-image {
width: 60rpx;
height: 60rpx;
}
.icon-tag-text {
2025-04-25 18:10:54 +08:00
color: #ffffff;
2025-04-30 14:28:07 +08:00
width: 120rpx;
2025-03-28 15:46:11 +08:00
font-size: 14px;
margin-top: 10rpx;
2025-04-30 14:28:07 +08:00
lines: 1;
text-overflow: ellipsis;
text-align: center;
2025-03-28 15:46:11 +08:00
}
</style>
<template>
<view class="page">
<view class="all-box">
2025-04-25 18:10:54 +08:00
<!-- <view
class="share-item"
@click="downloadVlog()"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
class="icon-image"
src="/static/images/link.png"
style="align-self: center"
></image>
2025-03-28 15:46:11 +08:00
</view>
2025-04-25 18:10:54 +08:00
<text
class="icon-tag-text"
style="align-self: center"
>
复制口令
</text>
</view> -->
<view
2025-04-30 14:28:07 +08:00
v-if="userId == ''"
2025-04-25 18:10:54 +08:00
class="share-item"
@click="copyLink()"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
class="icon-image"
src="/static/images/link.png"
style="align-self: center"
></image>
2025-03-28 15:46:11 +08:00
</view>
2025-04-25 18:10:54 +08:00
<text
class="icon-tag-text"
style="align-self: center"
>
复制链接
</text>
2025-03-28 15:46:11 +08:00
</view>
2025-04-30 14:28:07 +08:00
<!-- 会话列表 storage.getHasLogin() -->
<scroll-view
v-if="userId != ''"
:scroll-x="true"
:show-scrollbar="false"
class="all-box"
>
<view
class="share-item"
@click="copyLink()"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
class="icon-image"
src="/static/images/link.png"
style="align-self: center"
></image>
</view>
<text
class="icon-tag-text"
style="align-self: center"
>
复制链接
</text>
</view>
<view
v-for="(i, index) in converList"
:key="index"
class="share-item"
@click="toIm(i)"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
v-if="i.type == 'C2C'"
class="icon-image"
:src="i.userProfile.avatar || ''"
style="align-self: center"
></image>
<image
v-if="i.type == 'GROUP'"
class="icon-image"
:src="i.groupProfile.avatar || ''"
style="align-self: center"
></image>
</view>
<text
v-if="i.type == 'C2C'"
class="icon-tag-text"
style="align-self: center"
>
{{ i.userProfile.nick || '' }}
</text>
<text
v-if="i.type == 'GROUP'"
class="icon-tag-text"
style="align-self: center"
>
{{ i.groupProfile.name || '' }}
</text>
</view>
</scroll-view>
2025-04-25 18:10:54 +08:00
<!-- <view
class="share-item"
@click="gotoQRCode()"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
class="icon-image"
src="/static/images/icon-qrcode.png"
style="align-self: center"
></image>
2025-03-28 15:46:11 +08:00
</view>
2025-04-25 18:10:54 +08:00
<text
class="icon-tag-text"
style="align-self: center"
>
二维码
</text>
</view> -->
2025-03-28 15:46:11 +08:00
<!-- 判断只有我自己才能显示这个按钮 -->
2025-04-25 18:10:54 +08:00
<!-- <view
v-if="thisVlogerId == userId && isPrivate == 0"
class="share-item"
@click="changeVlogToPrivate()"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
class="icon-image"
src="/static/images/icon-private.png"
style="align-self: center"
></image>
2025-03-28 15:46:11 +08:00
</view>
2025-04-25 18:10:54 +08:00
<text
class="icon-tag-text"
style="align-self: center"
>
转为私密
</text>
</view> -->
<!-- <view
v-if="thisVlogerId == userId && isPrivate == 1"
class="share-item"
@click="changeVlogToPublic()"
>
<view
class="icon-wrapper"
style="align-self: center"
>
<image
class="icon-image"
src="/static/images/icon-private.png"
style="align-self: center"
></image>
2025-03-28 15:46:11 +08:00
</view>
2025-04-25 18:10:54 +08:00
<text
class="icon-tag-text"
style="align-self: center"
>
转为公开
</text>
</view> -->
2025-03-28 15:46:11 +08:00
</view>
2025-04-25 18:10:54 +08:00
<view
class=""
style="padding: 0 20rpx"
>
2025-03-28 15:46:11 +08:00
<!-- :class="{'btn-preplay':!preplayTouched, 'btn-preplay-touched': preplayTouched}"
@click="preview"
@touchstart="touchstartPreplay"
@touchend="touchendPreplay" -->
2025-04-25 18:10:54 +08:00
<view
:class="{ 'btn-cancel': !cancelTouched, 'btn-cancel-touched': cancelTouched }"
@click="close"
2025-03-28 15:46:11 +08:00
@touchstart="touchstartCancel"
2025-04-25 18:10:54 +08:00
@touchend="touchendCancel"
style="height: 50px; display: flex; flex-direction: column; justify-content: center; border-width: 1rpx; border-radius: 10px"
>
<text
class=""
style="color: #ffffff; font-size: 16px; align-self: center; align-self: center"
>
取消
</text>
2025-03-28 15:46:11 +08:00
</view>
</view>
</view>
</template>
<script>
2025-04-25 18:10:54 +08:00
import storage from '@/utils/storage.js'; //缓存
2025-04-30 14:28:07 +08:00
import config from '@/config/config.js';
2025-04-25 18:10:54 +08:00
import { vlogChangeToPublic, vlogChangeToPrivate } from '@/api/vlog';
import { dateFormat, graceNumber, getDateBeforeNow } from '@/utils/tools.js';
2025-04-30 14:28:07 +08:00
import { conversationData, sendVlogCustomMsg } from '@/utils/handleim.js';
2025-04-25 18:10:54 +08:00
import popup from '../uni-popup/popup.js';
export default {
name: 'UniPopupShare',
mixins: [popup],
emits: ['select'],
props: {
title: {
type: String,
default: ''
2025-03-28 15:46:11 +08:00
},
2025-04-25 18:10:54 +08:00
beforeClose: {
type: Boolean,
default: false
2025-03-28 15:46:11 +08:00
},
2025-04-25 18:10:54 +08:00
thisVlogerId: {
type: String,
default: ''
2025-03-28 15:46:11 +08:00
},
2025-04-25 18:10:54 +08:00
thisVlogId: {
type: String,
default: ''
},
vlogUrl: {
type: String,
default: ''
},
isPrivate: {
type: Number,
default: 0
2025-04-30 14:28:07 +08:00
},
vlogItem: {}
2025-04-25 18:10:54 +08:00
},
data() {
return {
userId: '',
2025-04-30 14:28:07 +08:00
cancelTouched: false,
converList: [],
flag: true
2025-04-25 18:10:54 +08:00
};
},
mounted() {
console.log('挂载');
var info = storage.getVlogUserInfo();
if (info != null) {
2025-04-30 14:28:07 +08:00
console.log('登录了');
2025-04-25 18:10:54 +08:00
this.userId = info.id;
2025-04-30 14:28:07 +08:00
this.conversationList();
2025-04-25 18:10:54 +08:00
}
},
methods: {
2025-04-30 14:28:07 +08:00
// 获取会话列表
async conversationList() {
var data = await conversationData();
console.log(data);
this.converList = data.data.conversationList;
console.log(this.converList);
},
toIm(i) {
if (this.flag) {
this.flag = false;
sendVlogCustomMsg(i, this.vlogItem)
.then((res) => {
console.log('发送成功,返回结果:', res);
uni.showToast({
icon: 'success',
title: '分享成功',
duration: 3000
});
var timer = setTimeout(() => {
clearTimeout(timer);
this.flag = true;
}, 3000);
})
.catch((err) => {
this.flag = true;
console.error('发送失败了', err);
// 这里可以做失败之后的处理,比如弹个错误提示
uni.showToast({
icon: 'error',
title: '云服务异常'
});
});
} else {
uni.showToast({
icon: 'none',
title: '点太快了'
});
}
},
2025-04-25 18:10:54 +08:00
/**
* 选择内容
*/
select(item, index) {
this.$emit('select', {
item,
index
});
this.close();
},
/**
* 关闭窗口
*/
close() {
if (this.beforeClose) return;
this.popup.close();
uni.showTabBar({
animation: true
});
},
touchstartCancel() {
this.cancelTouched = true;
},
touchendCancel() {
this.cancelTouched = false;
},
downloadVlog() {
console.log('downloadVlog...thisVlogId = ' + this.vlogUrl);
uni.showLoading();
uni.downloadFile({
url: this.vlogUrl,
success: (res) => {
if (res.statusCode === 200) {
console.log('下载成功');
uni.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success: function () {
console.log('save success');
uni.hideLoading();
uni.showToast({
title: '保存成功~',
duration: 5000
});
}
});
2025-03-28 15:46:11 +08:00
}
}
2025-04-25 18:10:54 +08:00
});
},
copyLink() {
// this.thisVlogId 视频id
2025-04-30 14:28:07 +08:00
var url = config.shareLink + '/pages/me/vlog?vlogId=' + this.thisVlogId;
2025-04-25 18:10:54 +08:00
uni.setClipboardData({
2025-04-30 14:28:07 +08:00
data: url,
2025-04-25 18:10:54 +08:00
success: () => {
2025-03-28 15:46:11 +08:00
uni.showToast({
2025-04-25 18:10:54 +08:00
//提示
title: '复制成功'
});
2025-03-28 15:46:11 +08:00
}
2025-04-25 18:10:54 +08:00
});
},
gotoQRCode() {
uni.navigateTo({
url: '/pages/qrcode/qrcode?vlogId=' + this.thisVlogId
});
},
async changeVlogToPublic() {
var vlogId = this.thisVlogId;
var me = this;
var info = storage.getVlogUserInfo();
var userId = info.id;
var result = await vlogChangeToPublic(userId, vlogId);
if (result.data.status == 200) {
this.isPrivate = 0;
uni.showToast({
title: '设置完毕~'
});
}
},
async changeVlogToPrivate() {
var vlogId = this.thisVlogId;
var me = this;
var info = storage.getVlogUserInfo();
var userId = info.id;
var result = await vlogChangeToPrivate(userId, vlogId);
if (result.data.status == 200) {
this.isPrivate = 1;
uni.showToast({
title: '设置完毕~'
});
2025-03-28 15:46:11 +08:00
}
}
}
2025-04-25 18:10:54 +08:00
};
2025-03-28 15:46:11 +08:00
</script>