接口调用

main
123456 1 month ago
parent 183ac4e9d5
commit f9b51ee29f
  1. 7
      components/dashan.vue
  2. 148
      main.js
  3. 46
      pages/dongtai/index.vue
  4. 54
      pages/index/index.vue
  5. 45
      pages/peiwan/index.vue
  6. 110
      pages/pipei/shipin/detail.nvue
  7. 168
      pages/pipei/shipin/index.vue
  8. 12
      pages/pipei/tongcheng/index.vue
  9. 48
      pages/user/index.vue
  10. 64
      pages/users/chat/index.vue
  11. 1
      pages/users/site/index.vue
  12. 35
      pages/xiaoxi/index.vue
  13. 2388
      unpackage/dist/dev/app-plus/app-service.js
  14. 291
      unpackage/dist/dev/app-plus/app-view.js
  15. 1465
      unpackage/dist/dev/app-plus/pages/pipei/shipin/detail.js

@ -119,6 +119,13 @@
message: this.content message: this.content
}) })
if(code == 200){ if(code == 200){
uni.sendSocketMessage({data:JSON.stringify({
userId: uni.getStorageSync("userInfo").id,
sellerId: this.info.userid,
type: 6,
message: this.content,
"topic":"message"
})})
this.socialConsumption(); this.socialConsumption();
uni.$emit("closeSharePopup",false) uni.$emit("closeSharePopup",false)
this.tabIndex = -1; this.tabIndex = -1;

@ -16,12 +16,12 @@ Vue.component('share', share)
Vue.component('dashan', dashan) Vue.component('dashan', dashan)
Vue.config.productionTip = false Vue.config.productionTip = false
// import ZIM from '@/js_sdk/zego-ZIMUniplugin-JS/lib/index.js';
// ZIM.create({ appID: 267111980, appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e' });
// Vue.prototype.$ZIM = ZIM.getInstance();
const bgAudioManager = uni.getBackgroundAudioManager(); const bgAudioManager = uni.getBackgroundAudioManager();
console.log(bgAudioManager)
uni.$on("playAudio",res=>{ uni.$on("playAudio",res=>{
console.log(11)
bgAudioManager.src = 'https://api.lyiyuan.cn/profile/upload/static/tishiyin.mp3'; bgAudioManager.src = 'https://api.lyiyuan.cn/profile/upload/static/tishiyin.mp3';
bgAudioManager.play(); bgAudioManager.play();
}) })
@ -45,63 +45,108 @@ uni.$on("openSocket",function(res){
uni.connectSocket({ uni.connectSocket({
url: 'wss://api.lyiyuan.cn/websocket?userId='+uni.getStorageSync('userInfo').id url: 'wss://api.lyiyuan.cn/websocket?userId='+uni.getStorageSync('userInfo').id
}); });
console.log(1111212)
uni.onSocketOpen(function (res) { uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!'); console.log('WebSocket连接已打开!');
uni.setStorageSync("isOpen",true)
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})}); uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
xintiao() xintiao()
uni.setStorageSync("isOpen",true)
}); });
uni.onSocketMessage(function (res) { uni.onSocketMessage(function (res) {
let obj = JSON.parse(res.data) const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){ if(obj.topic == 'message'){
// if(uni.getStorageSync("userInfo").id == obj.sellerid){ if(obj.type>=8){
// uni.showModal({ if(uni.getStorageSync("userInfo").id == obj.sellerId){
// title: "视频通话来了", if(obj.type == 9){
// content: "来自"+obj.from_user_data.name+"视频消息,请立即处理!", if(obj.userMsgVoice == 1){
// confirmText: "加入房间", uni.$emit("playAudio")
// success(data) { }
// if(data.confirm){ if(obj.userMsgShock == 1){
uni.vibrateLong({
// }else{ complete: function (res) {
// uni.sendSocketMessage({ console.log('success',res);
// data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0}) }
// }); });
// } }
// } uni.showModal({
// }) title: '温馨提示',
content: '来自'+obj.userNickname+"发起的视频匹配,是否同意",
// } cancelText: '拒绝',
} confirmText: '同意',
// if((res.data !="success") && (JSON.parse(res.data).event == 1)){ success: res => {
// let obj = JSON.parse(res.data) if(res.confirm){
// console.log(obj) console.log(obj, uni.getStorageSync("userInfo"))
//uni.$emit("playAudio") uni.sendSocketMessage({data:JSON.stringify({
// uni.showModal({ "userId": uni.getStorageSync("userInfo").id,
// title: "视频通话来了", sellerId: obj.userId,
// content: "来自"+obj.from_user_data.name+"视频消息,请立即处理!", type: 10,
// confirmText: "加入房间", "topic":"message"
// success(data) { })})
// if(data.confirm){ if(uni.getStorageSync("userInfo").id == obj.sellerId){
console.log("toChat",uni.getStorageSync("userInfo").id , obj.userId)
// }else{ uni.navigateTo({
// // if(uni.getStorageSync("isSocket")){ url: "/pages/pipei/shipin/detail?type=2&id="+obj.userId
})
// // uni.sendSocketMessage({ }
// // data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0}) }else{
// // }); uni.sendSocketMessage({data:JSON.stringify({
// // } "userId": uni.getStorageSync("userInfo").id,
// } sellerId: obj.userId,
type: 11,
// } "topic":"message"
// }) })})
// } }
},
fail: () => {},
complete: () => {}
});
}
if(obj.type == 8){
if(obj.userMsgVoice == 1){
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.showModal({
title: '温馨提示',
content: '来自'+obj.userNickname+"发起的语音匹配,是否同意",
cancelText: '拒绝',
confirmText: '同意',
success: res => {
if(res.confirm){
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
sellerId: data.id,
type: 10,
"topic":"message"
})})
}else{
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
sellerId: data.id,
type: 11,
"topic":"message"
})})
}
},
fail: () => {},
complete: () => {}
});
}
}
}else{
console.log("挂断了")
}
}
}); });
uni.onSocketClose(function (res) { uni.onSocketClose(function (res) {
clearInterval(timer) clearInterval(timer)
uni.closeSocket(); uni.closeSocket();
uni.removeStorageSync("isOpen",false) uni.removeStorageSync("isOpen")
console.log('WebSocket 已关闭!'); console.log('WebSocket 已关闭!');
}); });
}) })
@ -112,11 +157,12 @@ function xintiao() {
console.log("xintiao") console.log("xintiao")
uni.setStorageSync("isOpen",true) uni.setStorageSync("isOpen",true)
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})}); uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
}, 10000) }, 30000)
} }
setTimeout(()=>{ setTimeout(()=>{
console.log(1212) if(uni.getStorageSync("userInfo").id){
uni.$emit("openSocket") uni.$emit("openSocket")
}
},1000) },1000)
// #ifdef VUE3 // #ifdef VUE3

@ -80,6 +80,10 @@
uni.$on("closeSharePopup",res=>{ uni.$on("closeSharePopup",res=>{
that.isPopup = false; that.isPopup = false;
}) })
if( uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
}, },
onShow() { onShow() {
this.getUserInfo(); this.getUserInfo();
@ -97,6 +101,48 @@
} }
}, },
methods: { methods: {
watchSocket() {
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
if(obj.type <=7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.userMsgVoice == 1){
console.log(222)
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
console.log(2233)
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.showModal({
title: "温馨提示",
content: "来自"+obj.userNickname+(obj.type==1?"语音":obj.type==2?"视频":obj.type==3?"文字":obj.type==4?"图片":obj.type==5?"礼物":"搭讪")+"消息,请立即处理!",
confirmText: "立即查看",
success(data) {
if(data.confirm){
uni.switchTab({
url: "/pages/xiaoxi/index"
})
}else{
// uni.sendSocketMessage({
// data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0})
// });
}
}
})
}
}else{
console.log("挂断了")
}
}
});
},
previewImage(index,i){ previewImage(index,i){
uni.previewImage({ uni.previewImage({
urls: this.dongtaiList[index].imgurl, urls: this.dongtaiList[index].imgurl,

@ -105,6 +105,9 @@
}, },
onPullDownRefresh() { onPullDownRefresh() {
const that = this; const that = this;
if(uni.getStorageSync("userInfo").id){
uni.$emit("openSocket");
}
setTimeout(()=>{ setTimeout(()=>{
if(that.current == 0){ if(that.current == 0){
if(that.commentList1.length <= that.total1){ if(that.commentList1.length <= that.total1){
@ -181,12 +184,17 @@
that.show=false that.show=false
} }
}) })
if(uni.getStorageSync("userInfo").id){
this.watchSocket();
}
}, },
onShow() { onShow() {
if(this.city){ if(this.city){
this.getUserInfo(); this.getUserInfo();
} }
if(!uni.getStorageSync("isOpen")&& uni.getStorageSync("userInfo").id){
uni.$emit("openSocket");
}
}, },
onReachBottom() { onReachBottom() {
const that = this; const that = this;
@ -210,6 +218,48 @@
} }
}, },
methods: { methods: {
watchSocket() {
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
if(obj.type <=7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.userMsgVoice == 1){
console.log(222)
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
console.log(2233)
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.showModal({
title: "温馨提示",
content: "来自"+obj.userNickname+(obj.type==1?"语音":obj.type==2?"视频":obj.type==3?"文字":obj.type==4?"图片":obj.type==5?"礼物":"搭讪")+"消息,请立即处理!",
confirmText: "立即查看",
success(data) {
if(data.confirm){
uni.switchTab({
url: "/pages/xiaoxi/index"
})
}else{
// uni.sendSocketMessage({
// data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0})
// });
}
}
})
}
}else{
console.log("挂断了")
}
}
});
},
// //
trackUpload(res){ trackUpload(res){
this.$api.trackUpload({ this.$api.trackUpload({
@ -442,7 +492,7 @@
}) })
}else if(index == 3){ }else if(index == 3){
uni.navigateTo({ uni.navigateTo({
url: "/pages/pipei/shipin/detail" url: "/pages/pipei/shipin/index"
}) })
}else if(index == 4){ }else if(index == 4){
uni.navigateTo({ uni.navigateTo({

@ -123,6 +123,9 @@
that.show=false that.show=false
} }
}) })
if( uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
}, },
onReachBottom() { onReachBottom() {
const that = this; const that = this;
@ -135,6 +138,48 @@
}, 1000); }, 1000);
}, },
methods: { methods: {
watchSocket() {
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
if(obj.type!=7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.userMsgVoice == 1){
console.log(222)
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
console.log(2233)
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.showModal({
title: "温馨提示",
content: "来自"+obj.userNickname+(obj.type==1?"语音":obj.type==2?"视频":obj.type==3?"文字":obj.type==4?"图片":obj.type==5?"礼物":"搭讪")+"消息,请立即处理!",
confirmText: "立即查看",
success(data) {
if(data.confirm){
uni.navigateTo({
url: "/pages/xiaoxi/index"
})
}else{
// uni.sendSocketMessage({
// data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0})
// });
}
}
})
}
}else{
console.log("挂断了")
}
}
});
},
// //
trackUpload(res){ trackUpload(res){
this.$api.trackUpload({ this.$api.trackUpload({

@ -1,28 +1,33 @@
<template> <template>
<view class="tongcheng"> <view class="tongcheng">
<!-- <zego-local-view class="video-view"></zego-local-view> <!-- #ifdef APP-PLUS -->
<zego-local-view style="height: 403.84rpx;flex: 1;"></zego-local-view>
<!-- #endif -->
<!-- #ifdef H5 -->
<video id="local_video" style="height: 403.84rpx;flex: 1;" autoplay playsinline :muted="true"></video>
<!-- #endif -->
<zego-remote-view <zego-remote-view
class="video-view" class="video-view"
:streamID="playStreamID" :streamID="playStreamID"
> >
</zego-remote-view> --> </zego-remote-view>
</view> </view>
</template> </template>
<script> <script>
// import permision from "@/js_sdk/wa-permission/permission.js" import permision from "@/js_sdk/wa-permission/permission.js"
// //导入 ZEGO Express SDK //导入 ZEGO Express SDK
// import ZegoExpressEngine from '@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/lib/ZegoExpressEngine'; import ZegoExpressEngine from '@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/lib/ZegoExpressEngine';
// const profile = {
// appID : 267111980,
// appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e',
// scenario : 0
// };
// ZegoExpressEngine.createEngineWithProfile(profile);
import ZegoRemoteView from "@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/zego-view/ZegoRemoteView"; import ZegoRemoteView from "@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/zego-view/ZegoRemoteView";
import ZegoLocalView from "@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/zego-view/ZegoLocalView"; import ZegoLocalView from "@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/zego-view/ZegoLocalView";
let roomConfig = {};
roomConfig.isUserStatusNotify = true;
const profile = {
appID : 267111980,
appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e',
scenario : 0
};
export default { export default {
components: { components: {
ZegoLocalView, ZegoLocalView,
@ -40,31 +45,68 @@
}, },
} }
}, },
onLoad(o) {
this.id = o.id;
this.type=o.type;
console.log(o)
},
onReady() { onReady() {
console.log(uni.getSystemInfoSync().platform) // // #ifdef APP-PLUS
// #ifdef APP-PLUS // if (uni.getSystemInfoSync().platform === "android") {
if (uni.getSystemInfoSync().platform === "android") { // const res = await permision.requestAndroidPermission(
const res = await permision.requestAndroidPermission( // "android.permission.RECORD_AUDIO"
"android.permission.RECORD_AUDIO" // );
); // const res1 = await permision.requestAndroidPermission(
console.log(res) // "android.permission.CAMERA"
const res1 = await permision.requestAndroidPermission( // );
"android.permission.CAMERA" // }
); // // #endif
console.log(res1) ZegoExpressEngine.createEngineWithProfile(profile);
} console.log(123565)
// #endif this.loginRoom();
// let roomConfig = {};
// // 只有传入 “isUserStatusNotify” 参数取值为 “true” 的 ZegoRoomConfig,才能收到 onRoomUserUpdate 回调。
// roomConfig.isUserStatusNotify = true;
// // 获取token传入
// roomConfig.token = "********";
// // 登录房间
// // 开始登录房间
// ZegoExpressEngine.instance().loginRoom('room1', {'userID': 'id1', 'userName': 'user1'}, roomConfig);
}, },
methods: { methods: {
async loginRoom(){
console.log("sxq",{
userId: uni.getStorageSync("userInfo").id,
sellerId: this.id
})
const res = await this.$api.findZegoToken({
userId: uni.getStorageSync("userInfo").id,
sellerId: this.id
})
console.log("sxq1",res)
return ;
if(code == 200){
// 获取token传入
roomConfig.token = data.token;
this.playStreamID = data.roomID;
console.log(data)
// 登录房间
// 开始登录房间
ZegoExpressEngine.instance().loginRoom(data.roomID, {'userID': uni.getStorageSync("userInfo").id, 'userName': uni.getStorageSync("userInfo").nickname}, roomConfig);
setTimeout(()=>{
this.toLa();
},100)
// 以下为常用的房间相关回调
ZegoExpressEngine.instance().on('roomStateUpdate', (roomID, state, errorCode, extendedData) => {
// 房间状态更新回调,登录房间后,当房间连接状态发生变更(如出现房间断开,登录认证失败等情况),SDK会通过该回调通知
}); ;
ZegoExpressEngine.instance().on('roomUserUpdate', (roomID, updateType, userList) => {
// 用户状态更新,登录房间后,当房间内有用户新增或删除时,SDK会通过该回调通知
});
ZegoExpressEngine.instance().on('roomStreamUpdate', (roomID, updateType, streamList) => {
// 流状态更新,登录房间后,当房间内有用户新推送或删除音视频流时,SDK会通过该回调通知
});
}
},
async toLa() {
await ZegoExpressEngine.instance().startPreview()
await ZegoExpressEngine.instance().startPlayingStream(this.playStreamID)
},
} }
} }
</script> </script>

@ -4,15 +4,14 @@
<u-navbar :title="title" back-icon-color="#ffffff" title-color="#ffffff" :background="background"></u-navbar> <u-navbar :title="title" back-icon-color="#ffffff" title-color="#ffffff" :background="background"></u-navbar>
</view> </view>
<view class="tongcheng-content"> <view class="tongcheng-content">
<view class="title" v-if="isSucess == false">正在寻找新朋友...</view> <view class="title" v-if="isSucess == 1">正在寻找新朋友...</view>
<view class="desc" v-if="isSucess == false">当前用户过多请耐心等待</view> <view class="desc" v-if="isSucess == 1">当前用户过多请耐心等待</view>
<view class="desc1" v-else>{{isJieshou?'':(isSucess?'你有一条新的缘分':'匹配成功马上开始这段缘分吧')}}</view> <view class="desc1" v-else>{{isSucess == 1?'你有一条新的缘分':'匹配成功马上开始这段缘分吧'}}</view>
<template v-if="isJieshou == false"> <view class="dian" v-if="isSucess == 1">
<view class="dian" v-if="isSucess == false">
<view class="user"> <view class="user">
<view class="item"> <view class="item">
<image class="avatar" src="@/static/nv.png"></image> <image class="avatar" :src="userInfo.faceImage?userInfo.faceImage:userInfo.img"></image>
<view class="txt">空白空白1</view> <view class="txt">{{userInfo.nickname}}</view>
</view> </view>
<view class="items"> <view class="items">
<image src="@/static/yuyin-xin2.png"></image> <image src="@/static/yuyin-xin2.png"></image>
@ -20,36 +19,33 @@
<view class="item"> <view class="item">
<view class="pic"> <view class="pic">
<image class="avatar1" src="@/static/nan.png"></image> <image class="avatar1" src="@/static/nan.png"></image>
<image class="avatar2" src="@/static/nan.png"></image> <image class="avatar2" src="@/static/nv.png"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="dian-on" v-else> <view class="dian-on" v-if="isSucess == 2">
<view class="info"> <view class="info">
<image src="@/static/nan.png"></image> <image :src="info.faceImage?info.faceImage:info.img"></image>
<view class="name">张美丽</view> <view class="name">{{info.nickname}}</view>
<view class="btn" v-if="isJieshou">+关注</view> <view class="txt">{{info.age}}/{{info.height}}</view>
<view class="txt">27/165cm</view>
</view> </view>
<view class="tag" v-if="isSucess == true"> <view class="tag">
<view class="titles">个性签名</view> <view class="titles">个性签名</view>
<view class="descs"> <view class="descs">
<text>们都会走上一条叫做青春的路反复并疼痛地成长着\n曾经的旧时光感动过你我\n在黎明来临的时刻我选择了将你遗忘\n思绪的风引起一阵阵叹息成了来自我心的绝唱\n用一季的花开季节见证你我的生命轮回</text> <text>{{info.declaration}}</text>
</view> </view>
</view> </view>
</view> </view>
</template>
</view> </view>
<view class="tongcheng-end" v-if="isSucess == false"> <view class="tongcheng-end" v-if="isSucess == 1">
<view class="send">茫茫人海今天和你相遇</view> <view class="send">茫茫人海今天和你相遇</view>
<view class="todo"> <view class="todo" @click="toBack()">
<image src="@/static/yuyin-cha.png"></image> <image src="@/static/yuyin-cha.png"></image>
</view> </view>
</view> </view>
<template v-else> <!-- <view class="tongcheng-start"> -->
<view class="tongcheng-start" v-if="isJieshou"> <!-- <view class="item" @click="toggleMenu(1)">
<view class="item" @click="toggleMenu(1)">
<image src="@/static/yuyin-01.png" v-if="isMakefeng"></image><image v-else src="@/static/yuyin-01-on.png"></image>麦克风{{isMakefeng?'开启':'已关'}} <image src="@/static/yuyin-01.png" v-if="isMakefeng"></image><image v-else src="@/static/yuyin-01-on.png"></image>麦克风{{isMakefeng?'开启':'已关'}}
</view> </view>
<view class="item" @click="toggleMenu(2)"> <view class="item" @click="toggleMenu(2)">
@ -57,49 +53,141 @@
</view> </view>
<view class="item" @click="toggleMenu(6)"> <view class="item" @click="toggleMenu(6)">
<image src="@/static/yuyin-04.png" v-if="isShexiangtou"></image><image v-else src="@/static/yuyin-04-on.png"></image>摄像头{{isShexiangtou?'开启':'已关'}} <image src="@/static/yuyin-04.png" v-if="isShexiangtou"></image><image v-else src="@/static/yuyin-04-on.png"></image>摄像头{{isShexiangtou?'开启':'已关'}}
</view> </view> -->
<view class="item"></view> <!-- <view class="item"></view> -->
<view class="items"> <!-- <view class="items">
<image @click="toggleMenu(4)" src="@/static/yuyin-02.png"></image> <image @click="toggleMenu(4)" src="@/static/yuyin-02.png"></image>
<image @click="toggleMenu(5)" class="off" src="@/static/yuyin-off.png"></image> <image @click="toggleMenu(5)" class="off" src="@/static/yuyin-off.png"></image>
</view> -->
<!-- <view class="item"></view> -->
<!-- </view> -->
<view class="tongcheng-start" v-if="isSucess == 2">
<view class="item" @click="toPage(1)">
<image src="@/static/yuyin-02.png"></image>换一个
</view> </view>
<view class="item"></view> <view class="item">
</view> <image src="@/static/yuyin-05.png"></image>{{isSucess == 2?'等待中':'立即进入'}}
<view class="tongcheng-start" v-else>
<view class="item" @click="toggleMenu(3)">
<image src="@/static/yuyin-02.png"></image>挂断
</view>
<view class="item" @click="toggleMenu(3)">
<image src="@/static/yuyin-05.png"></image>接受
</view> </view>
</view> </view>
</template> <!-- <view class="tongcheng-video">
<view class="tongcheng-video">
<view class="other"></view> <view class="other"></view>
<view class="content"></view> <view class="content"></view>
</view> </view> -->
</view> </view>
</template> </template>
<script> <script>
let timer = null;
export default { export default {
data() { data() {
return { return {
isJieshou: true, info: {},
count: 10,
userInfo: {},
isJieshou: false,
title: "视频速配", title: "视频速配",
isShexiangtou: true, isShexiangtou: true,
isMakefeng: true, isMakefeng: true,
isYangshengqi: true, isYangshengqi: true,
isSucess: true, isSucess: 1,
background: { background: {
// //
background: 'url(@/static/yuyin-bg.png) center top no-repeat', background: 'url(https://api.lyiyuan.cn/profile/upload/static/yuyin-bg.png) center top no-repeat',
// size // size
backgroundSize: '100 auto', backgroundSize: '100 auto',
}, },
}; };
}, },
onLoad() {
this.userInfo = uni.getStorageSync("userInfo");
this.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
this.toPage(1)
},
onReady() {
this.watchSocket();
},
methods: { methods: {
watchSocket() {
const that = this;
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
console.log("watchSocket",obj)
if(obj.topic == 'message'){
if(obj.type>= 8){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.type == 10){
that.toPage(2,obj.userId);
}else if(obj.type == 11){
that.isSucess = 1
that.toPage(1);
}
}
}else{
console.log("挂断了")
}
}
});
},
toBack() {
clearInterval(timer);
uni.navigateBack({
delta: 1
})
},
toPage(index,id){
const that = this;
if(index == 1){
that.isSucess = 1;
clearInterval(timer);
timer = setInterval(()=>{
if(that.count == 0){
clearInterval(timer);
that.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
that.userSpeedDating();
}else{
that.count --
}
},1000)
}else if(index == 2){
this.toChat(id);
}else if(index == 3){
that.isSucess = 1;
that.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
}
},
//
async toChat(id) {
console.log("toChat",uni.getStorageSync("userInfo").id , id)
uni.redirectTo({
url: "/pages/pipei/shipin/detail?type=2&id="+id
})
},
async userSpeedDating() {
const { code, data, msg } = await this.$api.userSpeedDating({
userId: uni.getStorageSync("userInfo").id,
type: 1,
lat: uni.getStorageSync("jingweiInfo").latitude,
lon: uni.getStorageSync("jingweiInfo").longitude,
city: uni.getStorageSync("jingweiInfo").new_city?uni.getStorageSync("jingweiInfo").new_city:uni.getStorageSync("jingweiInfo").city,
})
if(code == 200){
this.isSucess = 2;
this.info = data
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
sellerId: data.id,
type: 9,
"topic":"message"
})})
}else{
this.isSucess = 1;
uni.showToast({
title: msg,
position: "bottom",
icon: "none",
})
}
},
toggleMenu(index){ toggleMenu(index){
if(index == 1){ if(index == 1){
this.isMakefeng = !this.isMakefeng this.isMakefeng = !this.isMakefeng
@ -122,7 +210,7 @@
<style scoped lang="scss"> <style scoped lang="scss">
.tongcheng{ .tongcheng{
background: #0d0b15 url(@/static/yuyin-bg.png) center top no-repeat; background: #0d0b15 url(https://api.lyiyuan.cn/profile/upload/static/yuyin-bg.png) center top no-repeat;
background-size: 100% auto; background-size: 100% auto;
overflow: hidden; overflow: hidden;
min-height: 100vh; min-height: 100vh;
@ -336,6 +424,8 @@
border-radius: 50%; border-radius: 50%;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
font-size: 30rpx;
color: #FFFFFF;
} }
.items{ .items{
width: 33.3%; width: 33.3%;

@ -52,7 +52,7 @@
return { return {
isSucess: 1, isSucess: 1,
info: {}, info: {},
count: 5, count: 10,
userInfo: {}, userInfo: {},
background: { background: {
// //
@ -64,7 +64,7 @@
}, },
onLoad() { onLoad() {
this.userInfo = uni.getStorageSync("userInfo"); this.userInfo = uni.getStorageSync("userInfo");
this.count = Math.floor(Math.random() * (20 - 1 + 1)) + 1; this.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
}, },
methods: { methods: {
toPage(index){ toPage(index){
@ -74,7 +74,7 @@
timer = setInterval(()=>{ timer = setInterval(()=>{
if(that.count == 0){ if(that.count == 0){
clearInterval(timer); clearInterval(timer);
that.count = Math.floor(Math.random() * (20 - 1 + 1)) + 1; that.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
that.sameCitySpeedDating(); that.sameCitySpeedDating();
}else{ }else{
that.count -- that.count --
@ -84,19 +84,19 @@
this.toChat(); this.toChat();
}else if(index == 3){ }else if(index == 3){
that.isSucess = 1; that.isSucess = 1;
that.count = Math.floor(Math.random() * (20 - 1 + 1)) + 1; that.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
} }
}, },
// //
async toChat() { async toChat() {
const { code, data } = await this.$api.findZegoToken({ const { code, data } = await this.$api.findZegoToken({
userId: uni.getStorageSync("userInfo").id, userId: uni.getStorageSync("userInfo").id,
sellerId: this.id sellerId: this.info.id
}) })
if(code == 200){ if(code == 200){
uni.setStorageSync("chatToken",data.token); uni.setStorageSync("chatToken",data.token);
uni.navigateTo({ uni.navigateTo({
url: "/pages/users/chat/index?id="+this.id+"&roomId="+data.roomId url: "/pages/users/chat/index?id="+this.info.id+"&roomId="+data.roomId
}) })
} }
}, },

@ -198,7 +198,7 @@
poster: "" poster: ""
} }
}, },
onLoad() { onReady() {
const that = this; const that = this;
uni.$on("closeSharePopup",res=>{ uni.$on("closeSharePopup",res=>{
that.isPopup = false; that.isPopup = false;
@ -209,11 +209,57 @@
that.createPoster(); that.createPoster();
that.show = true; that.show = true;
}) })
if( uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
}, },
onShow() { onShow() {
this.getUserInfo(); this.getUserInfo();
}, },
methods: { methods: {
watchSocket() {
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
if(obj.type <= 7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.userMsgVoice == 1){
console.log(222)
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
console.log(2233)
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.showModal({
title: "温馨提示",
content: "来自"+obj.userNickname+(obj.type==1?"语音":obj.type==2?"视频":obj.type==3?"文字":obj.type==4?"图片":obj.type==5?"礼物":"搭讪")+"消息,请立即处理!",
confirmText: "立即查看",
success(data) {
if(data.confirm){
uni.navigateTo({
url: "/pages/xiaoxi/index"
})
}else{
// uni.sendSocketMessage({
// data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0})
// });
}
}
})
}
}else{
console.log("挂断了")
}
}
});
},
toCancle() { toCancle() {
this.show = false; this.show = false;
}, },

@ -184,8 +184,31 @@
innerAudioContext.onEnded(res=>{ innerAudioContext.onEnded(res=>{
that.isPlay = false that.isPlay = false
}) })
this.watchSocket();
}, },
methods: { methods: {
watchSocket() {
const that = this;
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
console.log(obj)
if(obj.type!=7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
that.page = 1;
that.getChatList();
}
if(uni.getStorageSync("userInfo").id == obj.userId){
that.page = 1;
that.getChatList();
}
}else{
}
}
});
},
scrolltoupper(e) { scrolltoupper(e) {
if(this.chatList.length <=this.total){ if(this.chatList.length <=this.total){
this.page ++; this.page ++;
@ -290,13 +313,13 @@
*/ */
} }
}, },
// // type:1. 2. 3. 4 56
async socialConsumption(type) { async socialConsumption(type) {
await this.$api.socialConsumption({ await this.$api.socialConsumption({
userId: uni.getStorageSync("userInfo").id, userId: uni.getStorageSync("userInfo").id,
sellerId: this.info.userid, sellerId: this.id,
type, type: (type == 1 || type == 2 || type == 3)?3:type,
duration: type==1?this.count: "" duration: ""
}) })
}, },
toOpen(){ toOpen(){
@ -304,9 +327,9 @@
//{"userId":"123","sellerId":"4575676878","type":3} type:1. 2. 3. 4 56 //{"userId":"123","sellerId":"4575676878","type":3} type:1. 2. 3. 4 56
// console.log(111) // console.log(111)
// console.log(JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"})) // console.log(JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"}))
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"})}); // uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,sellerId:this.id, type:3,"topic":"message"})});
return ; // return ;
// APP // APP
if(uni.getSystemInfoSync().platform == 'android') { if(uni.getSystemInfoSync().platform == 'android') {
plus.android.checkPermission( plus.android.checkPermission(
@ -529,19 +552,25 @@
message: type == 3?that.content: that.img message: type == 3?that.content: that.img
}) })
if(code == 200){ if(code == 200){
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
sellerId:that.id,
type,
num: (that.count+1),
message: (type == 3?that.content: that.img),
"topic":"message"
})})
if(type==5){ if(type==5){
this.giftGiving(); that.giftGiving();
} }
that.isOpen = false; that.isOpen = false;
that.isToggle = true; that.isToggle = true;
that.show1 = false; that.show1 = false;
this.socialConsumption(); that.socialConsumption(type);
this.getChatList(); that.userBalance();
this.userBalance(); that.content=""
this.content="" that.count = 0;
this.count = 0; that.num = 1;
this.num = 1;
} }
}, },
// //
@ -563,7 +592,11 @@
toUserId: this.id}); toUserId: this.id});
if(code == 200){ if(code == 200){
this.total= data.total; this.total= data.total;
this.chatList= that.arrayUnique([...this.chatList,...data.list],'msgId'); if(type == 1){
this.chatList= that.arrayUnique([...data.list,...this.chatList],'msgId');
}else{
this.chatList= data.list
}
if(type == 1){ if(type == 1){
return ; return ;
} }
@ -996,6 +1029,7 @@
font-size: 30rpx; font-size: 30rpx;
color: #222222; color: #222222;
line-height: 48rpx; line-height: 48rpx;
display: inline-block;
} }
} }

@ -116,6 +116,7 @@
uni.showToast({ uni.showToast({
title: "退出成功" title: "退出成功"
}) })
uni.closeSocket();
setTimeout(()=>{ setTimeout(()=>{
uni.reLaunch({ uni.reLaunch({
url: "/pages/login/index" url: "/pages/login/index"

@ -53,6 +53,7 @@
<view class="desc" v-if="a.type==2">你有一条新的视频</view> <view class="desc" v-if="a.type==2">你有一条新的视频</view>
<view class="desc" v-if="a.type==4">你有一张新的图片</view> <view class="desc" v-if="a.type==4">你有一张新的图片</view>
<view class="desc" v-if="a.type==5">你有一个新的礼物</view> <view class="desc" v-if="a.type==5">你有一个新的礼物</view>
<view class="desc" v-if="a.type==6">{{a.message}}</view>
</view> </view>
</view> </view>
</u-swipe-action> </u-swipe-action>
@ -69,7 +70,7 @@
list:[{'name': '消息'},{'name': '好友'}], list:[{'name': '消息'},{'name': '好友'}],
activeStyle:{'fontSize': '35rpx'}, activeStyle:{'fontSize': '35rpx'},
frindList: [], frindList: [],
type: -1, type: 0,
count: 0, count: 0,
xiaoxiinfo: {}, xiaoxiinfo: {},
options: [ options: [
@ -86,8 +87,36 @@
this.getList(); this.getList();
this.dashaCount(); this.dashaCount();
this.getXiaoxiList(); this.getXiaoxiList();
if(uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
}, },
methods: { methods: {
watchSocket() {
const that = this;
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
if(obj.type <= 7){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.userMsgVoice == 1){
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
that.getList()
}
}else{
console.log("挂断了")
}
}
});
},
// //
async toChat(a) { async toChat(a) {
const { code, data } = await this.$api.findZegoToken({ const { code, data } = await this.$api.findZegoToken({
@ -97,7 +126,7 @@
if(code == 200){ if(code == 200){
uni.setStorageSync("chatToken",data.token); uni.setStorageSync("chatToken",data.token);
uni.navigateTo({ uni.navigateTo({
url: "/pages/users/chat/index?id="+this.id+"&roomId="+data.roomId url: "/pages/users/chat/index?id="+a.userid+"&roomId="+data.roomId
}) })
} }
}, },
@ -187,7 +216,7 @@
changeTabs(index){ changeTabs(index){
this.current = index this.current = index
if(index==0){ if(index==0){
this.type = -1 this.type = 0
this.getList(); this.getList();
}else{ }else{
this.type = 5 this.type = 5

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save