短视频优化交互细节,IM浮窗

This commit is contained in:
abu 2025-05-07 17:45:16 +08:00
parent ef29aebf9c
commit 4ab450a368
21 changed files with 646 additions and 131 deletions

View File

@ -85,6 +85,24 @@ export function vlogList(page, pageSize, userId = '', cityCode = '', search = ''
});
}
/**
* 用户删除短视频
*/
export function vlogDel({
userId,
vlogId,
status
}) {
return http.request({
url: api.vlog + "/vlog/changeVlogStatus",
method: Method.POST,
params: {
userId,
vlogId,
status
}
});
}
/**
* 短视频喜欢
*/

View File

@ -99,7 +99,7 @@
:show-fullscreen-btn="false"
:show-center-play-btn="false"
:style="boxStyle"
:object-fit="item.width >= item.height ? 'contain' : 'fill'"
:object-fit="item.width >= item.height ? 'contain' : 'cover'"
@timeupdate="timeupdate($event, i)"
:poster="item.firstFrameImg"
></video>
@ -107,8 +107,8 @@
<image
v-if="!item.playIng"
:src="item.firstFrameImg"
:mode="item.width >= item.height ? 'aspectFit' : 'scaleToFill'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 'px; position: absolute;'"
:mode="item.width >= item.height ? 'aspectFit' : 'aspectFit'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 26 + 'px; position: absolute;'"
></image>
<!--
mode: 图片裁剪、缩放的模式
@ -424,9 +424,9 @@
</template>
<script>
import storage from '@/utils/storage.js'; //缓存
import { graceNumber } from '@/utils/tools.js';
import { graceNumber, clickFeedBack } from '@/utils/tools.js';
import api from '@/config/api.js';
import { vlogFollowList, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts } from '@/api/vlog';
import { vlogFollowList, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts, vlogDetail } from '@/api/vlog';
/*
引入评论组件
*/
@ -583,21 +583,32 @@ export default {
this.refreshVlogCounts();
this.freshCommentCounts();
}
if (data.from == 'initGuanzhu') {
console.log('初始化关注视频数据');
this.init();
}
// 刷新点赞状态
if (data.from == 'refreshLike') {
// 刷新点赞状态
this.refreshLike(data.vlogId, data.flag);
// 刷新点赞数据
this.refreshVlogCounts();
}
}
};
this.platform = uni.getSystemInfoSync().platform;
var model = uni.getSystemInfoSync().model;
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
// this.deleteHeight = 32; //有 tabbar的 修改这里可以改变视频高度
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
this.deleteHeight = 0; //有 tabbar的 修改这里可以改变视频高度
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
/*
引入评论参数
*/
this.heightNum = 1.27;
} else {
// this.deleteHeight = 0;
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
this.deleteHeight = 0;
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
/*
引入评论参数
*/
@ -612,7 +623,8 @@ export default {
// 控制渲染 -- end
this.windowWidth = uni.getSystemInfoSync().screenWidth; //获取屏幕宽度
this.boxStyle.width = this.windowWidth + 'px'; //给宽度加px
this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
// this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
this.wHeight = uni.getSystemInfoSync().windowHeight; //获取屏幕可用高度
console.log(this.wHeight);
this.boxStyle.height = this.wHeight - this.deleteHeight; //改变视频高度
console.log(this.boxStyle);
@ -621,6 +633,18 @@ export default {
},
onReady() {},
methods: {
// 点赞取消点赞,后刷新点赞状态
refreshLike(vlogId, flag) {
var me = this;
var playerList = me.dataList;
// 关注以后循环当前playerList修改对应粉丝关系的doIFollowVloger改为true
for (var i = 0; i < playerList.length; i++) {
var vlog = playerList[i];
if (vlog.vlogId == vlogId) {
vlog.doILikeThisVlog = flag;
}
}
},
async refreshVlogCounts() {
// 查询当前点赞数,重新赋值给当前视频
var me = this;
@ -642,6 +666,7 @@ export default {
},
// 关注博主
async followMe(vlogerId) {
clickFeedBack();
var myUserInfo = storage.getVlogUserInfo();
if (myUserInfo == null) {
uni.navigateTo({
@ -655,6 +680,7 @@ export default {
if (result.data.status == 200) {
// 关注成功后修改当前数据的状态
this.dataList[this.k].doIFollowVloger = true;
this.reFollowPlayList(vlogerId, true);
} else {
uni.showToast({
title: result.data.msg,
@ -663,11 +689,24 @@ export default {
});
}
},
// 关注/取消关注,后刷新关注状态
reFollowPlayList(vlogerId, flag) {
var me = this;
var playerList = me.dataList;
// 关注以后循环当前playerList修改对应粉丝关系的doIFollowVloger改为true
for (var i = 0; i < playerList.length; i++) {
var vlog = playerList[i];
if (vlog.vlogerId == vlogerId) {
vlog.doIFollowVloger = flag;
}
}
},
// 把超过1000或10000的数字调整比如1.3k/6.8w
getGraceNumber(num) {
return graceNumber(num);
},
async likeOrDislikeVlog(item) {
clickFeedBack();
var info = storage.getVlogUserInfo();
if (info != null) {
this.userId = info.id;
@ -691,7 +730,8 @@ export default {
});
console.log(result);
if (result.data.status == 200) {
item.likeCounts++;
// item.likeCounts++;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
} else {
uni.showToast({
@ -708,7 +748,8 @@ export default {
vlogId: item.vlogId
});
if (result.data.status == 200) {
item.likeCounts--;
// item.likeCounts--;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
} else {
uni.showToast({

View File

@ -99,7 +99,7 @@
:show-fullscreen-btn="false"
:show-center-play-btn="false"
:style="boxStyle"
:object-fit="item.width >= item.height ? 'contain' : 'fill'"
:object-fit="item.width >= item.height ? 'contain' : 'cover'"
@timeupdate="timeupdate($event, i)"
:poster="item.firstFrameImg"
></video>
@ -107,8 +107,8 @@
<image
v-if="!item.playIng"
:src="item.firstFrameImg"
:mode="item.width >= item.height ? 'aspectFit' : 'scaleToFill'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 'px; position: absolute;'"
:mode="item.width >= item.height ? 'aspectFit' : 'aspectFit'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 26 + 'px; position: absolute;'"
></image>
<!--
mode: 图片裁剪、缩放的模式
@ -424,9 +424,9 @@
</template>
<script>
import storage from '@/utils/storage.js'; //缓存
import { graceNumber } from '@/utils/tools.js';
import { graceNumber, clickFeedBack } from '@/utils/tools.js';
import api from '@/config/api.js';
import { vlogList, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts } from '@/api/vlog';
import { vlogList, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts, vlogDetail } from '@/api/vlog';
/*
引入评论组件
*/
@ -583,21 +583,34 @@ export default {
this.refreshVlogCounts();
this.freshCommentCounts();
}
// 刷新当前视频关注的状态
if (data.from == 'refresh') {
console.log('刷新同城列表关注状态');
this.reFollowPlayList(data.vlogerId, data.flag);
}
// 刷新点赞状态
if (data.from == 'refreshLike') {
// 刷新点赞状态
this.refreshLike(data.vlogId, data.flag);
// 刷新点赞数据
this.refreshVlogCounts();
}
}
};
this.platform = uni.getSystemInfoSync().platform;
var model = uni.getSystemInfoSync().model;
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
// this.deleteHeight = 32; //有 tabbar的 修改这里可以改变视频高度
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
// this.deleteHeight = 50 + 26; //有 tabbar的 修改这里可以改变视频高度
this.deleteHeight = 0;
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
/*
引入评论参数
*/
this.heightNum = 1.27;
} else {
// this.deleteHeight = 0;
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
this.deleteHeight = 0;
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
/*
引入评论参数
*/
@ -612,7 +625,8 @@ export default {
// 控制渲染 -- end
this.windowWidth = uni.getSystemInfoSync().screenWidth; //获取屏幕宽度
this.boxStyle.width = this.windowWidth + 'px'; //给宽度加px
this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
// this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
this.wHeight = uni.getSystemInfoSync().windowHeight; //获取屏幕可用高度
console.log(this.wHeight);
this.boxStyle.height = this.wHeight - this.deleteHeight; //改变视频高度
console.log(this.boxStyle);
@ -621,6 +635,18 @@ export default {
},
onReady() {},
methods: {
// 点赞取消点赞,后刷新点赞状态
refreshLike(vlogId, flag) {
var me = this;
var playerList = me.dataList;
// 关注以后循环当前playerList修改对应粉丝关系的doIFollowVloger改为true
for (var i = 0; i < playerList.length; i++) {
var vlog = playerList[i];
if (vlog.vlogId == vlogId) {
vlog.doILikeThisVlog = flag;
}
}
},
async refreshVlogCounts() {
// 查询当前点赞数,重新赋值给当前视频
var me = this;
@ -642,6 +668,7 @@ export default {
},
// 关注博主
async followMe(vlogerId) {
clickFeedBack();
var myUserInfo = storage.getVlogUserInfo();
if (myUserInfo == null) {
uni.navigateTo({
@ -655,6 +682,11 @@ export default {
if (result.data.status == 200) {
// 关注成功后修改当前数据的状态
this.dataList[this.k].doIFollowVloger = true;
this.reFollowPlayList(vlogerId, true);
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -663,11 +695,24 @@ export default {
});
}
},
// 关注/取消关注,后刷新关注状态
reFollowPlayList(vlogerId, flag) {
var me = this;
var playerList = me.dataList;
// 关注以后循环当前playerList修改对应粉丝关系的doIFollowVloger改为true
for (var i = 0; i < playerList.length; i++) {
var vlog = playerList[i];
if (vlog.vlogerId == vlogerId) {
vlog.doIFollowVloger = flag;
}
}
},
// 把超过1000或10000的数字调整比如1.3k/6.8w
getGraceNumber(num) {
return graceNumber(num);
},
async likeOrDislikeVlog(item) {
clickFeedBack();
var info = storage.getVlogUserInfo();
if (info != null) {
this.userId = info.id;
@ -691,7 +736,8 @@ export default {
});
console.log(result);
if (result.data.status == 200) {
item.likeCounts++;
// item.likeCounts++;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
} else {
uni.showToast({
@ -708,7 +754,8 @@ export default {
vlogId: item.vlogId
});
if (result.data.status == 200) {
item.likeCounts--;
// item.likeCounts--;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
} else {
uni.showToast({

View File

@ -92,16 +92,16 @@
:show-fullscreen-btn="false"
:show-center-play-btn="false"
:style="boxStyle"
:object-fit="item.width >= item.height ? 'contain' : 'fill'"
:object-fit="item.width >= item.height ? 'contain' : 'cover'"
@timeupdate="timeupdate($event, i)"
:poster="item.firstFrameImg"
></video>
<!-- 这里是封面 -->
<!-- 这里是封面 26是进度条的高度 -->
<image
v-if="!item.playIng"
:src="item.firstFrameImg"
:mode="item.width >= item.height ? 'aspectFit' : 'scaleToFill'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 'px; position: absolute;'"
:mode="item.width >= item.height ? 'aspectFit' : 'aspectFit'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 26 + 'px; position: absolute;'"
></image>
<!--
mode: 图片裁剪、缩放的模式
@ -417,9 +417,9 @@
</template>
<script>
import storage from '@/utils/storage.js'; //缓存
import { graceNumber } from '@/utils/tools.js';
import { graceNumber, clickFeedBack } from '@/utils/tools.js';
import api from '@/config/api.js';
import { vlogList, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts } from '@/api/vlog';
import { vlogList, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts, vlogQueryDoIFollowVloger, vlogDetail } from '@/api/vlog';
/*
引入评论组件
*/
@ -571,25 +571,40 @@ export default {
this.channelComment.onmessage = (event) => {
const { type, data } = event.data;
if (type == 'comment-counts') {
// 刷新评论数据,点赞数据
if (data.from == 'tuijian') {
this.refreshVlogCounts();
this.freshCommentCounts();
}
// 刷新当前视频关注的状态
if (data.from == 'refresh') {
console.log('刷新推荐列表关注状态');
this.reFollowPlayList(data.vlogerId, data.flag);
}
// 刷新点赞状态
if (data.from == 'refreshLike') {
console.log('触发刷新点赞状态');
// 刷新点赞状态
this.refreshLike(data.vlogId, data.flag);
// 刷新点赞数据
this.refreshVlogCounts();
}
}
};
this.platform = uni.getSystemInfoSync().platform;
var model = uni.getSystemInfoSync().model;
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
// this.deleteHeight = 32; //有 tabbar的 修改这里可以改变视频高度
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
this.deleteHeight = 0; //有 tabbar的 修改这里可以改变视频高度
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10,默认50
/*
引入评论参数
*/
this.heightNum = 1.27;
} else {
// this.deleteHeight = 0;
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
// this.deleteHeight = 50 + 16;
this.deleteHeight = 0;
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
/*
引入评论参数
*/
@ -603,7 +618,9 @@ export default {
// 控制渲染 -- end
this.windowWidth = uni.getSystemInfoSync().screenWidth; //获取屏幕宽度
this.boxStyle.width = this.windowWidth + 'px'; //给宽度加px
this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
// this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
this.wHeight = uni.getSystemInfoSync().windowHeight; //获取屏幕可用高度
console.log(uni.getSystemInfoSync());
console.log(this.wHeight);
this.boxStyle.height = this.wHeight - this.deleteHeight; //改变视频高度
console.log(this.boxStyle);
@ -633,6 +650,7 @@ export default {
},
// 关注博主
async followMe(vlogerId) {
clickFeedBack();
var myUserInfo = storage.getVlogUserInfo();
if (myUserInfo == null) {
uni.navigateTo({
@ -646,6 +664,11 @@ export default {
if (result.data.status == 200) {
// 关注成功后修改当前数据的状态
this.dataList[this.k].doIFollowVloger = true;
this.reFollowPlayList(vlogerId, true);
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -654,11 +677,36 @@ export default {
});
}
},
// 关注/取消关注,后刷新关注状态
reFollowPlayList(vlogerId, flag) {
var me = this;
var playerList = me.dataList;
// 关注以后循环当前playerList修改对应粉丝关系的doIFollowVloger改为true
for (var i = 0; i < playerList.length; i++) {
var vlog = playerList[i];
if (vlog.vlogerId == vlogerId) {
vlog.doIFollowVloger = flag;
}
}
},
// 点赞取消点赞,后刷新点赞状态
refreshLike(vlogId, flag) {
var me = this;
var playerList = me.dataList;
// 关注以后循环当前playerList修改对应粉丝关系的doIFollowVloger改为true
for (var i = 0; i < playerList.length; i++) {
var vlog = playerList[i];
if (vlog.vlogId == vlogId) {
vlog.doILikeThisVlog = flag;
}
}
},
// 把超过1000或10000的数字调整比如1.3k/6.8w
getGraceNumber(num) {
return graceNumber(num);
},
async likeOrDislikeVlog(item) {
clickFeedBack();
var info = storage.getVlogUserInfo();
if (info != null) {
this.userId = info.id;
@ -682,8 +730,9 @@ export default {
});
console.log(result);
if (result.data.status == 200) {
item.likeCounts++;
// item.likeCounts++;
item.doILikeThisVlog = !item.doILikeThisVlog;
this.refreshVlogCounts();
} else {
uni.showToast({
title: result.data.msg,
@ -699,7 +748,8 @@ export default {
vlogId: item.vlogId
});
if (result.data.status == 200) {
item.likeCounts--;
// item.likeCounts--;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
} else {
uni.showToast({
@ -713,7 +763,14 @@ export default {
// --------------------
showVd() {
console.log('回到前台');
if (this.dataList.length !== 0) {
if (this.dataList.length != 0) {
// if (uni.getSystemInfoSync().platform == 'ios') {
// this.dataList[this.k].state = 'play';
// uni.createVideoContext(this.dataList[this.k].id, this).play();
// } else {
// this.dataList[this.k].state = 'play';
// uni.createVideoContext(this.dataList[this.k].id, this).play();
// }
this.dataList[this.k].state = 'play';
uni.createVideoContext(this.dataList[this.k].id, this).play();
}

View File

@ -28,6 +28,7 @@ const prod = {
common: "http://43.143.227.203:8890",
buyer: "http://43.143.227.203:8888",
vlog: "http://43.143.227.203:8099",
// vlog: "http://192.168.1.86:8099",
web: "http://43.143.227.203:8099",
seller: "http://43.143.227.203:8889",
};

View File

@ -1303,7 +1303,7 @@
}
},
"tabBar": {
"color": "#999696",
"color": "#CCCCCC",
"selectedColor": "#FFFFFF",
"borderStyle": "#1c1b1b",
"backgroundColor": "#0e0d0d",

View File

@ -20,6 +20,21 @@
scroll-y="true"
@scrolltolower="loadMore"
>
<refresh
class="refresh"
@refresh="onrefresh"
@pullingdown="onpullingdown"
:display="refreshing ? 'show' : 'hide'"
>
<loading style="background-color: #ffffff">
<view style="align-items: center; display: flex; justify-content: center">
<image
src="@/static/img/index/logins.gif"
:style="'width: 80upx; height: 40upx; margin-top: 80upx; margin-bottom: 30upx;'"
></image>
</view>
</loading>
</refresh>
<image
class="mybg"
:src="pageUserInfo.bgImg"
@ -187,9 +202,11 @@
</view>
<view class="vlog-list">
<block
<view
class="vlogBox"
@longpress="delVlog(vlog)"
v-for="(vlog, index) in vlogList"
:key="index"
:key="vlog.vlogId"
>
<image
class="vlog-cover"
@ -197,7 +214,14 @@
@click="goToVlog(vlog)"
mode="aspectFill"
></image>
</block>
<view class="rightLike">
<image
src="/static/images/icon-unlike.png"
style="width: 30rpx; height: 30rpx"
></image>
<text style="color: #ffffff">{{ getGraceNumber(vlog.likeCounts) }}</text>
</view>
</view>
</view>
<view
@ -222,9 +246,9 @@ let system = uni.getSystemInfoSync();
import * as filters from '@/utils/filters.js';
import api from '@/config/api.js';
import storage from '@/utils/storage.js'; //缓存
import { vlogUserInfo, vlogMyPublicList, vlogMyPrivateList, vlogMyLikedList, vlogMeTag } from '@/api/vlog';
import { vlogUserInfo, vlogMyPublicList, vlogMyPrivateList, vlogMyLikedList, vlogMeTag, vlogDel } from '@/api/vlog';
import { getAstro, getAnimal, dateFormat, graceNumber } from '@/utils/tools.js';
import { getAstro, getAnimal, dateFormat, graceNumber, clickFeedBack } from '@/utils/tools.js';
export default {
data() {
@ -258,7 +282,8 @@ export default {
page: 0,
toalPage: 0,
vlogList: []
vlogList: [],
refreshing: false
};
},
onLoad() {
@ -287,15 +312,56 @@ export default {
}
},
methods: {
delVlog(item) {
clickFeedBack();
let myUserInfo = storage.getVlogUserInfo();
let myUserId = myUserInfo.id;
var data = {
userId: myUserId,
vlogId: item.vlogId,
status: 5 // 5=删除 4=下架
};
uni.showModal({
title: '提示',
content: '确认删除视频吗?',
success: async (r) => {
if (r.confirm) {
var res = await vlogDel(data);
if (res.data.success) {
// 本地删除
this.vlogList = this.vlogList.filter((v) => v.vlogId !== item.vlogId);
}
}
}
});
},
async initInfo() {
let me = this;
// 判断我有没有登录
this.userIsLogin = storage.getHasLogin();
console.log(this.userIsLogin);
if (this.userIsLogin) {
this.getUinfo();
} else {
return;
}
},
onpullingdown() {
// console.log('正在下拉刷新,此时手还在触摸没有松开')
this.refreshing = true;
},
onrefresh() {
// console.log('下拉刷新完毕,此时手松开了')
this.initInfo();
setTimeout(() => {
this.refreshing = false;
}, 1000);
},
async getUinfo() {
let myUserInfo = storage.getVlogUserInfo();
let myUserId = myUserInfo.id;
uni.showLoading({
title: '正在加载!'
});
var result = await vlogUserInfo(myUserId);
uni.hideLoading();
console.log(result);
if (result.data.status == 200) {
this.pageUserInfo = result.data.data;
@ -348,7 +414,8 @@ export default {
}
},
loadMore() {
let requestArr = ['myPublicList', 'myPrivateList', 'myLikedList'];
// let requestArr = ['myPublicList', 'myPrivateList', 'myLikedList'];
let requestArr = ['myPublicList', 'myLikedList'];
if (this.page >= this.toalPage) {
return;
} else {
@ -362,7 +429,7 @@ export default {
var uinfo = storage.getVlogUserInfo();
if (uinfo == null) return;
let userId = uinfo.id;
var result = await vlogMeTag(requrl, page, 20, userId);
var result = await vlogMeTag(requrl, page, 10, userId);
if (result.data.status == 200) {
let vlogList = result.data.data.rows;
console.log(vlogList);
@ -730,6 +797,17 @@ export default {
justify-content: flex-start;
background-color: #000000;
}
.vlogBox {
position: relative;
}
.rightLike {
position: absolute;
flex-direction: row;
align-items: center;
left: 5px;
bottom: 5px;
color: #ffffff;
}
.empty-text {
color: #ffffff;
@ -759,7 +837,7 @@ export default {
flex-direction: row;
justify-content: center;
position: relative;
top: -260rpx;
top: -400rpx;
}
.isLogin-info-wrapper {

View File

@ -95,6 +95,9 @@ export default {
me.bgUrl = newBg;
//
let serverUrl = api.vlog;
uni.showLoading({
title: '上传中'
});
uni.uploadFile({
header: {
headerUserId: userId,
@ -127,6 +130,9 @@ export default {
icon: 'none'
});
}
},
complete() {
uni.hideLoading();
}
});
}

View File

@ -31,7 +31,7 @@
<text
class="operator-words"
style="color: #ef274d"
@click="followMe(f.fanId)"
@click="followMe(f)"
>
回粉
</text>
@ -43,7 +43,7 @@
<text
class="operator-words"
style="color: #ffffff"
@click="cancelFollow(f.fanId)"
@click="cancelFollow(f)"
>
互粉
</text>
@ -58,7 +58,7 @@
let system = uni.getSystemInfoSync();
import storage from '@/utils/storage.js'; //缓存
import { vlogFansCancel, vlogFansFollow, vlogQueryMyFans } from '@/api/vlog';
import { isStrEmpty } from '@/utils/tools.js';
import { isStrEmpty, clickFeedBack } from '@/utils/tools.js';
export default {
data() {
return {
@ -70,7 +70,15 @@ export default {
from: false
};
},
destroyed() {
console.log('组件销毁');
// 销毁时关闭 BroadcastChannel
if (this.channelComment) {
this.channelComment.close();
}
},
onLoad(param) {
this.channelComment = new BroadcastChannel('comment-counts');
if (!isStrEmpty(param.userId)) {
this.from = true;
this.userId = param.userId;
@ -107,17 +115,26 @@ export default {
}
me.fansList = fansList;
},
async cancelFollow(vlogerId) {
async cancelFollow(item) {
clickFeedBack();
let me = this;
let userId = me.userId;
let data = {
myId: userId,
vlogerId
vlogerId: item.fanId
};
var result = await vlogFansCancel(data);
console.log(result);
if (result.data.status == 200) {
me.reFreshList(vlogerId, 0);
me.reFreshList(item.fanId, 0);
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: false, from: 'refresh', vlogerId: item.fanId }
});
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -126,17 +143,26 @@ export default {
});
}
},
async followMe(vlogerId) {
async followMe(item) {
clickFeedBack();
let me = this;
let userId = me.userId;
let data = {
myId: userId,
vlogerId
vlogerId: item.fanId
};
var result = await vlogFansFollow(data);
console.log(result);
if (result.data.status == 200) {
me.reFreshList(vlogerId, 1);
me.reFreshList(item.fanId, 1);
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: true, from: 'refresh', vlogerId: item.fanId }
});
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,

View File

@ -31,7 +31,7 @@
<text
class="operator-words"
style="color: #ef274d"
@click="cancelFollow(f.vlogerId)"
@click="cancelFollow(f)"
>
已关注
</text>
@ -43,7 +43,7 @@
<text
class="operator-words"
style="color: #ffffff"
@click="cancelFollow(f.vlogerId)"
@click="cancelFollow(f)"
>
互关
</text>
@ -57,7 +57,7 @@
<script>
import storage from '@/utils/storage.js'; //缓存
import { vlogFansCancel, vlogFansFollow, vlogQueryMyFollows } from '@/api/vlog';
import { isStrEmpty } from '@/utils/tools.js';
import { isStrEmpty, clickFeedBack } from '@/utils/tools.js';
let system = uni.getSystemInfoSync();
export default {
data() {
@ -67,10 +67,19 @@ export default {
page: 0,
totalPage: 0,
followsList: [],
from: false
from: false,
channelComment: null
};
},
destroyed() {
console.log('组件销毁');
// 销毁时关闭 BroadcastChannel
if (this.channelComment) {
this.channelComment.close();
}
},
onLoad(param) {
this.channelComment = new BroadcastChannel('comment-counts');
if (!isStrEmpty(param.userId)) {
this.from = true;
this.userId = param.userId;
@ -106,17 +115,26 @@ export default {
}
me.followsList = followsList;
},
async cancelFollow(vlogerId) {
async cancelFollow(item) {
clickFeedBack();
let me = this;
let userId = this.userId;
var data = {
myId: userId,
vlogerId
vlogerId: item.vlogerId
};
var result = await vlogFansCancel(data);
console.log(result);
if (result.data.status == 200) {
me.reFreshList(vlogerId, 0);
me.reFreshList(item.vlogerId, 0);
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: false, from: 'refresh', vlogerId: item.vlogerId, vlogId: item.vlogId }
});
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -126,6 +144,7 @@ export default {
}
},
async followMe(vlogerId) {
clickFeedBack();
let me = this;
let userId = this.userId;
let data = {

View File

@ -2,7 +2,7 @@
<view class="container">
<view
class="mheader"
:style="{ marginTop: deleteHeight + 'px' }"
:style="{ marginTop: statusBarHeight + 'px' }"
>
<image
class="header-left"
@ -102,7 +102,7 @@
:show-fullscreen-btn="false"
:show-center-play-btn="false"
:style="boxStyle"
:object-fit="item.width >= item.height ? 'contain' : 'fill'"
:object-fit="item.width >= item.height ? 'contain' : 'cover'"
@timeupdate="timeupdate($event, i)"
:poster="item.firstFrameImg"
></video>
@ -110,8 +110,8 @@
<image
v-if="!item.playIng"
:src="item.firstFrameImg"
:mode="item.width >= item.height ? 'aspectFit' : 'scaleToFill'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 'px; position: absolute;'"
:mode="item.width >= item.height ? 'aspectFit' : 'aspectFit'"
:style="'width: ' + windowWidth + 'px; height: ' + boxStyle.height + 26 + 'px; position: absolute;'"
></image>
<!--
mode: 图片裁剪、缩放的模式
@ -149,7 +149,7 @@
v-if="!item.doIFollowVloger && userId != item.vlogerId"
src="/static/images/icon-follow.png"
class="follow-me"
@click="followMe(item.vlogerId)"
@click="followMe(item)"
></image>
</view>
<!-- 2.点赞 -->
@ -427,7 +427,7 @@
</template>
<script>
import storage from '@/utils/storage.js'; //缓存
import { graceNumber } from '@/utils/tools.js';
import { graceNumber, clickFeedBack } from '@/utils/tools.js';
import api from '@/config/api.js';
import { vlogDetail, vlogLike, vlogUnLike, vlogComment, vlogFollow, vlogTotalLikedCounts } from '@/api/vlog';
/*
@ -514,7 +514,8 @@ export default {
isPrivate: 0
},
vlogId: '',
channelComment: null
channelComment: null,
statusBarHeight: uni.getSystemInfoSync().statusBarHeight
};
},
// components: {
@ -577,6 +578,13 @@ export default {
let vlogId = option.vlogId || 1;
this.vlogId = vlogId;
},
destroyed() {
console.log('视频详情组件销毁');
// 销毁时关闭 BroadcastChannel
if (this.channelComment) {
this.channelComment.close();
}
},
// created() {
// this.channel = new BroadcastChannel('video-progress');
// },
@ -594,16 +602,16 @@ export default {
this.platform = uni.getSystemInfoSync().platform;
var model = uni.getSystemInfoSync().model;
if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')) {
// this.deleteHeight = 32; //有 tabbar的 修改这里可以改变视频高度
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
this.deleteHeight = 0; //有 tabbar的 修改这里可以改变视频高度
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 26; //进度条高度16点高度10
/*
引入评论参数
*/
this.heightNum = 1.27;
} else {
// this.deleteHeight = 0;
this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
this.deleteHeight = 0;
// this.deleteHeight = uni.getSystemInfoSync().statusBarHeight + 16; // 安卓只处理进度条高度10
/*
引入评论参数
*/
@ -617,7 +625,8 @@ export default {
// 控制渲染 -- end
this.windowWidth = uni.getSystemInfoSync().screenWidth; //获取屏幕宽度
this.boxStyle.width = this.windowWidth + 'px'; //给宽度加px
this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
// this.wHeight = uni.getSystemInfoSync().screenHeight; //获取屏幕高度
this.wHeight = uni.getSystemInfoSync().windowHeight; //获取屏幕可用高度
console.log(this.wHeight);
this.boxStyle.height = this.wHeight - this.deleteHeight; //改变视频高度
console.log(this.boxStyle);
@ -651,7 +660,8 @@ export default {
});
},
// 关注博主
async followMe(vlogerId) {
async followMe(item) {
clickFeedBack();
var myUserInfo = storage.getVlogUserInfo();
if (myUserInfo == null) {
uni.navigateTo({
@ -661,10 +671,19 @@ export default {
return;
}
var userId = myUserInfo.id;
var result = await vlogFollow(userId, vlogerId);
var result = await vlogFollow(userId, item.vlogerId);
if (result.data.status == 200) {
// 关注成功后修改当前数据的状态
this.dataList[this.k].doIFollowVloger = true;
// 同步修改视频列表数据
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: true, from: 'refresh', vlogerId: item.vlogerId, vlogId: item.vlogId }
});
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -678,6 +697,8 @@ export default {
return graceNumber(num);
},
async likeOrDislikeVlog(item) {
console.log(item);
clickFeedBack();
var info = storage.getVlogUserInfo();
if (info != null) {
this.userId = info.id;
@ -701,8 +722,19 @@ export default {
});
console.log(result);
if (result.data.status == 200) {
item.likeCounts++;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
console.log('是否执行通道');
try {
console.log(item.vlogId);
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: true, from: 'refreshLike', vlogId: item.vlogId }
});
} catch (e) {
console.log(e);
}
// item.likeCounts++;
} else {
uni.showToast({
title: result.data.msg,
@ -718,8 +750,13 @@ export default {
vlogId: item.vlogId
});
if (result.data.status == 200) {
item.likeCounts--;
// item.likeCounts--;
this.refreshVlogCounts();
item.doILikeThisVlog = !item.doILikeThisVlog;
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: false, from: 'refreshLike', vlogId: item.vlogId }
});
} else {
uni.showToast({
title: result.data.msg,

View File

@ -171,7 +171,8 @@
</view>
<view class="vlog-list">
<block
<view
class="vlogBox"
v-for="(vlog, index) in vlogList"
:key="index"
>
@ -181,7 +182,14 @@
@click="goToVlog(vlog)"
mode="aspectFill"
></image>
</block>
<view class="rightLike">
<image
src="/static/images/icon-unlike.png"
style="width: 30rpx; height: 30rpx"
></image>
<text style="color: #ffffff">{{ getGraceNumber(vlog.likeCounts) }}</text>
</view>
</view>
</view>
<view
@ -203,7 +211,7 @@
<script>
let system = uni.getSystemInfoSync();
import * as filters from '@/utils/filters.js';
import { clickFeedBack } from '@/utils/tools.js';
import api from '@/config/api.js';
import storage from '@/utils/storage.js'; //缓存
import { vlogUserInfo, vlogQueryDoIFollowVloger, vlogMyPublicList, vlogMyPrivateList, vlogMyLikedList, vlogMeTag, vlogFansCancel, vlogFansFollow } from '@/api/vlog';
@ -244,10 +252,19 @@ export default {
page: 0,
totalpage: 0,
vlogList: []
vlogList: [],
channelComment: null
};
},
destroyed() {
console.log('博主信息页面销毁');
// 销毁时关闭 BroadcastChannel
if (this.channelComment) {
this.channelComment.close();
}
},
async onLoad(params) {
this.channelComment = new BroadcastChannel('comment-counts');
this.statusBarHeight = system.statusBarHeight;
let screenHeight = system.safeArea.bottom + 50;
this.screenHeight = screenHeight;
@ -350,7 +367,8 @@ export default {
if (this.page >= this.toalPage) {
return;
} else {
this.myList(this.page);
var prop = ['myPublicList', 'myLikedList'];
this.myList(this.page, prop[this.currentTab]);
}
},
async myList(page, requrl, init = false) {
@ -358,7 +376,7 @@ export default {
page = page + 1;
me.page = page;
let userId = me.userPageId;
var result = await vlogMeTag(requrl, page, 20, userId);
var result = await vlogMeTag(requrl, page, 10, userId);
if (result.data.status == 200) {
let vlogList = result.data.data.rows;
console.log(vlogList);
@ -378,6 +396,15 @@ export default {
});
},
async cancelFollow() {
var myUserInfo = storage.getVlogUserInfo();
if (myUserInfo == null) {
uni.navigateTo({
url: '/pages/passport/login',
animationType: 'slide-in-bottom'
});
return;
}
clickFeedBack();
let me = this;
let vlogerId = me.userPageId;
let userId = storage.getVlogUserInfo().id;
@ -388,6 +415,14 @@ export default {
// 刷新当前页的粉丝数
let pendingInfo = me.pageUserInfo;
me.pageUserInfo.myFansCounts = pendingInfo.myFansCounts - 1;
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: false, from: 'refresh', vlogerId: vlogerId }
});
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -399,7 +434,14 @@ export default {
async followMe() {
let me = this;
let myUserInfo = storage.getVlogUserInfo();
if (myUserInfo == null) {
uni.navigateTo({
url: '/pages/passport/login',
animationType: 'slide-in-bottom'
});
return;
}
clickFeedBack();
let vlogerId = me.userPageId;
let userId = myUserInfo.id;
var result = await vlogFansFollow({ myId: userId, vlogerId: vlogerId });
@ -409,6 +451,14 @@ export default {
// 刷新当前页的粉丝数
let pendingInfo = me.pageUserInfo;
me.pageUserInfo.myFansCounts = pendingInfo.myFansCounts + 1;
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: true, from: 'refresh', vlogerId: vlogerId }
});
this.channelComment.postMessage({
type: 'comment-counts',
data: { from: 'initGuanzhu' }
});
} else {
uni.showToast({
title: result.data.msg,
@ -449,7 +499,7 @@ export default {
};
</script>
<style lang="scss">
<style>
.header-right-search {
width: 40rpx;
height: 40rpx;
@ -523,6 +573,7 @@ export default {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: #000000;
opacity: 0.5;
width: 130rpx;
@ -593,6 +644,7 @@ export default {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.bottom {
display: flex;
@ -683,6 +735,17 @@ export default {
justify-content: flex-start;
background-color: #000000;
}
.vlogBox {
position: relative;
}
.rightLike {
position: absolute;
flex-direction: row;
align-items: center;
left: 5px;
bottom: 5px;
color: #ffffff;
}
.empty {
background-color: #000000;
width: 750rpx;
@ -703,7 +766,7 @@ export default {
flex-direction: row;
justify-content: center;
position: relative;
top: -260rpx;
top: -400rpx;
}
.isLogin-info-wrapper {
}

View File

@ -563,6 +563,7 @@ export default {
// vlogtokenvlog
storage.setVlogToken(vlogInfo.userToken);
storage.setVlogUserInfo(vlogInfo);
storage.setRefreshVlogIndex('1');
/**
* 登录成功后获取个人信息

View File

@ -21,7 +21,8 @@
:model="searchContent"
:value="searchContent"
@input="typingContent"
@confirm=""
@confirm="doSearch"
confirm-type="search"
placeholder="请输入内容~"
maxlength="10"
class="search-input"

View File

@ -21,6 +21,8 @@
:model="searchContent"
:value="searchContent"
@input="typingContent"
@confirm="doSearch"
confirm-type="search"
placeholder="请输入内容~"
maxlength="10"
class="search-input"

View File

@ -24,8 +24,8 @@
<view class="flxbox">
<view class="bottom-info">
<u-image
width="30rpx"
height="30rpx"
width="40rpx"
height="40rpx"
:src="item.vlogerFace"
loading-icon="/static/missing-face.png"
error-icon="/static/missing-face.png"
@ -34,7 +34,7 @@
></u-image>
<view class="showOne ml">{{ item.vlogerName }}</view>
</view>
<view class="bottom-info">
<view class="bottom-info pdr">
<image
style="width: 20rpx; height: 20rpx"
src="/static/images/icon-comment-unlike.png"
@ -62,8 +62,8 @@
<view class="flxbox">
<view class="bottom-info">
<u-image
width="30rpx"
height="30rpx"
width="40rpx"
height="40rpx"
loading-icon="/static/missing-face.png"
error-icon="/static/missing-face.png"
:src="item.vlogerFace"
@ -72,7 +72,7 @@
></u-image>
<view class="showOne ml">{{ item.vlogerName }}</view>
</view>
<view class="bottom-info">
<view class="bottom-info pdr">
<image
style="width: 20rpx; height: 20rpx"
src="/static/images/icon-comment-unlike.png"
@ -179,7 +179,7 @@ export default {
clear() {
var dom = this.$refs.uWaterfall;
if (dom) {
clear();
dom.clear();
}
}
}
@ -194,7 +194,7 @@ export default {
border-radius: 8px;
margin: 5px;
background-color: #ffffff;
padding: 8px;
padding: 2px;
position: relative;
max-width: 329rpx;
width: 100%;
@ -207,7 +207,8 @@ export default {
}
.showOne {
width: 200rpx;
width: 180rpx;
font-size: 32rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
@ -240,4 +241,7 @@ export default {
display: block;
margin-left: 5px;
}
.pdr {
padding-right: 5px;
}
</style>

View File

@ -8,6 +8,7 @@
:key="i.id"
>
<u-image
@click="tozuozhe(i.id)"
:src="i.face"
class="flxleft"
width="120"
@ -18,15 +19,28 @@
style="display: flex; align-items: center"
></u-image>
<view class="flxcenter">
<view
class="flxcenter"
@click="tozuozhe(i.id)"
>
<view class="nkname">{{ i.nickname }}</view>
<!-- <view class="fans">粉丝125.2</view> -->
<view
class="fans"
v-if="i.myFansCounts"
>
粉丝{{ getGraceNumber(i.myFansCounts || 0) }}
</view>
<view
class="fans"
v-if="i.totalLikeMeCounts"
>
获赞{{ getGraceNumber(i.totalLikeMeCounts || 0) }}
</view>
</view>
<view class="flxright">
<u-button
type="error"
@click="follow(i)"
size="mini"
v-if="i.followStatus == '未关注'"
>
关注
@ -35,7 +49,6 @@
v-else
type="plain"
@click="cancelFollow(i)"
size="mini"
>
{{ i.followStatus }}
</u-button>
@ -59,7 +72,8 @@
<script>
import storage from '@/utils/storage.js'; //
import { vlogSearchUser, vlogFansFollow, vlogFansCancel } from '@/api/vlog';
import { vlogSearchUser, vlogFansFollow, vlogFansCancel, vlogQueryDoIFollowVloger } from '@/api/vlog';
import { clickFeedBack, graceNumber } from '@/utils/tools.js';
export default {
props: {
keywords: {
@ -74,13 +88,31 @@ export default {
page: 0,
totalPage: 0,
search: '',
id: ''
id: '',
channelComment: null
};
},
destroyed() {
console.log('查询用户组件销毁');
// BroadcastChannel
if (this.channelComment) {
this.channelComment.close();
}
},
created() {
this.initData();
this.channelComment = new BroadcastChannel('comment-counts');
},
methods: {
// 100010000, 1.3k/6.8w
getGraceNumber(num) {
return graceNumber(num);
},
tozuozhe(userId) {
uni.navigateTo({
url: '/pages/me/vlogerInfo?userPageId=' + userId
});
},
async getData() {
if (this.loadStatus !== 'loadmore') return;
var info = storage.getVlogUserInfo();
@ -134,6 +166,7 @@ export default {
this.getData();
},
async follow(item) {
clickFeedBack();
let userInfo = storage.getVlogUserInfo();
if (userInfo == null) {
uni.navigateTo({
@ -149,7 +182,18 @@ export default {
var result = await vlogFansFollow(data);
console.log(result);
if (result.data.status == 200) {
item.followStatus = '已关注';
var bothFrd = await vlogQueryDoIFollowVloger({ myId: item.id, vlogerId: userInfo.id });
if (bothFrd.data.data) {
item.followStatus = '互相关注';
} else {
item.followStatus = '已关注';
}
console.log(bothFrd);
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: true, from: 'refresh', vlogerId: item.id, vlogId: item.vlogId }
});
item.myFansCounts++;
} else {
uni.showToast({
title: result.data.msg,
@ -159,6 +203,7 @@ export default {
}
},
async cancelFollow(item) {
clickFeedBack();
let userInfo = storage.getVlogUserInfo();
if (userInfo == null) {
uni.navigateTo({
@ -174,7 +219,12 @@ export default {
var result = await vlogFansCancel(data);
console.log(result);
if (result.data.status == 200) {
item.doIflow = false;
item.followStatus = '未关注';
this.channelComment.postMessage({
type: 'comment-counts',
data: { flag: false, from: 'refresh', vlogerId: item.id, vlogId: item.vlogId }
});
item.myFansCounts--;
} else {
uni.showToast({
title: result.data.msg,
@ -212,11 +262,11 @@ export default {
-webkit-line-clamp: 1;
overflow: hidden;
font-weight: 500;
font-size: 26rpx;
font-size: 32rpx;
}
.fans {
font-size: 24rpx;
color: #999;
font-size: 26rpx;
color: #000;
}
.flxright {
margin-left: 10px;

View File

@ -247,6 +247,7 @@ export default {
storage.setRefreshVlogIndex('0'); //初始完数据修改状态不需要刷新
} else {
try {
console.log('index刷新子组件');
this.$refs[prop].showVd();
} catch {}
}
@ -272,14 +273,11 @@ export default {
methods: {
handleHuaWei() {
// 处理华为机型问题
const deviceInfo = uni.getSystemInfoSync();
console.log(deviceInfo.brand);
if (deviceInfo.brand === 'HUAWEI') {
// 针对华为设备,修改 Tabbar 样式
uni.setTabBarStyle({
color: '#e8e8e8'
});
}
// #ifdef APP-HARMONY
uni.setTabBarStyle({
color: '#e8e8e8'
});
// #endif
},
getLocation() {
uni.getLocation({

View File

@ -1,7 +1,12 @@
import {
getUserimInfo
} from '@/api/members';
import {
refreshTokenFn
} from "@/api/login.js";
import storage from "@/utils/storage.js";
// ---------------------------
import {
TUILogin
} from '@tencentcloud/tui-core';
@ -18,7 +23,6 @@ import {
import * as Push from '@/uni_modules/TencentCloud-Push';
import storage from "@/utils/storage.js";
// sdkStateNotReady IM断了
// onMessageReceived 收到推送的单聊、群聊、群提示、群系统通知的新消息
@ -26,11 +30,11 @@ import storage from "@/utils/storage.js";
// im断开链接时
const onSdkNotReady = function(event) {
console.log('IM断了')
var islogin = storage.getVlogUserInfo();
if (islogin != null) {
// 重新执行IM登录
loginIm()
}
// var islogin = storage.getVlogUserInfo();
// if (islogin != null) {
// // 重新执行IM登录
// loginIm()
// }
}
const onMessageReceived = function(event) {
@ -71,8 +75,23 @@ const pushMsgBack = (res) => {
export const loginIm = () => {
export const loginIm = async () => {
console.log('执行im登录')
if (storage.getRefreshToken() && storage.getHasLogin()) {
var tokenResult = await refreshTokenFn(storage.getRefreshToken())
if (tokenResult.data.result) {
var {
accessToken,
refreshToken
} = tokenResult.data.result;
storage.setAccessToken(accessToken);
storage.setRefreshToken(refreshToken);
console.log('----------IM初始化登录--------------刷新token成功')
} else {
console.log('-------------------IM初始化登录-----刷新token失败');
return;
}
}
getUserimInfo()
.then(({
data

View File

@ -205,6 +205,7 @@ http.interceptors.response.use(
(response.statusCode == 200 && !response.data.success) ||
response.statusCode == 400
) {
<<<<<<< Updated upstream
if (response.data.code == 408) {
uni.showModal({
title: '提示',
@ -227,6 +228,31 @@ http.interceptors.response.use(
icon: "none",
duration: 1500,
});
=======
if (response.data.message) {
if (response.data.code == 408) {
uni.showModal({
title: '提示',
content: response.data.message,
showCancel: false,
success() {
logout().then(() => {
cleanStorage();
});
}
})
} else if (response.data.code == 20003 || response.data.code == 20004) {
// rereshtoken也失效了=20004提示=用户已退出,请重新登录,身份凭证token过期=20003提示=用户未登录
cleanStorage();
} else {
uni.showToast({
title: response.data.message,
icon: "none",
duration: 1500,
});
}
>>>>>>> Stashed changes
}
} else if (response.data.code == 502) {
cleanStorage();

View File

@ -277,6 +277,26 @@ const dateFormat = (fmt, date) => {
return fmt;
}
const clickFeedBack = (fn) => {
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == 'ios') {
let UIImpactFeedbackGenerator = plus.ios.importClass('UIImpactFeedbackGenerator');
let impact = new UIImpactFeedbackGenerator();
impact.prepare();
impact.init(2);
impact.impactOccurred();
}
if (uni.getSystemInfoSync().platform == 'android') {
// vibrateShort
uni.vibrateLong({
success: () => {
console.log('点击震动');
}
});
}
// #endif
}
export {
getNetworkType,
@ -288,5 +308,6 @@ export {
isStrEmpty,
getAstro,
getAnimal,
dateFormat
dateFormat,
clickFeedBack
};