接口调用

main
123456 1 month ago
parent 183ac4e9d5
commit f9b51ee29f
  1. 9
      components/dashan.vue
  2. 158
      main.js
  3. 46
      pages/dongtai/index.vue
  4. 58
      pages/index/index.vue
  5. 45
      pages/peiwan/index.vue
  6. 112
      pages/pipei/shipin/detail.nvue
  7. 218
      pages/pipei/shipin/index.vue
  8. 12
      pages/pipei/tongcheng/index.vue
  9. 52
      pages/user/index.vue
  10. 64
      pages/users/chat/index.vue
  11. 1
      pages/users/site/index.vue
  12. 37
      pages/xiaoxi/index.vue
  13. 2590
      unpackage/dist/dev/app-plus/app-service.js
  14. 529
      unpackage/dist/dev/app-plus/app-view.js
  15. 1465
      unpackage/dist/dev/app-plus/pages/pipei/shipin/detail.js

@ -118,7 +118,14 @@
type: 6,
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();
uni.$emit("closeSharePopup",false)
this.tabIndex = -1;

@ -16,12 +16,12 @@ Vue.component('share', share)
Vue.component('dashan', dashan)
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();
console.log(bgAudioManager)
const bgAudioManager = uni.getBackgroundAudioManager();
uni.$on("playAudio",res=>{
console.log(11)
bgAudioManager.src = 'https://api.lyiyuan.cn/profile/upload/static/tishiyin.mp3';
bgAudioManager.play();
})
@ -44,64 +44,109 @@ let timer = null;
uni.$on("openSocket",function(res){
uni.connectSocket({
url: 'wss://api.lyiyuan.cn/websocket?userId='+uni.getStorageSync('userInfo').id
});
console.log(1111212)
});
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!');
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
xintiao()
console.log('WebSocket连接已打开!');
uni.setStorageSync("isOpen",true)
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
xintiao()
});
uni.onSocketMessage(function (res) {
let obj = JSON.parse(res.data)
const obj = res.data?JSON.parse(res.data):{}
if(obj.topic == 'message'){
// if(uni.getStorageSync("userInfo").id == obj.sellerid){
// uni.showModal({
// title: "视频通话来了",
// content: "来自"+obj.from_user_data.name+"视频消息,请立即处理!",
// confirmText: "加入房间",
// success(data) {
// if(data.confirm){
// }else{
// uni.sendSocketMessage({
// data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0})
// });
// }
// }
// })
// }
}
// if((res.data !="success") && (JSON.parse(res.data).event == 1)){
// let obj = JSON.parse(res.data)
// console.log(obj)
//uni.$emit("playAudio")
// uni.showModal({
// title: "视频通话来了",
// content: "来自"+obj.from_user_data.name+"视频消息,请立即处理!",
// confirmText: "加入房间",
// success(data) {
// if(data.confirm){
// }else{
// // if(uni.getStorageSync("isSocket")){
// // uni.sendSocketMessage({
// // data: JSON.stringify({event: 3, "room_id": obj.room_id, "to_id": obj.from_user_data.fromUserId,'from_id':0})
// // });
// // }
// }
// }
// })
// }
if(obj.type>=8){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.type == 9){
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){
console.log(obj, uni.getStorageSync("userInfo"))
uni.sendSocketMessage({data:JSON.stringify({
"userId": uni.getStorageSync("userInfo").id,
sellerId: obj.userId,
type: 10,
"topic":"message"
})})
if(uni.getStorageSync("userInfo").id == obj.sellerId){
console.log("toChat",uni.getStorageSync("userInfo").id , obj.userId)
uni.navigateTo({
url: "/pages/pipei/shipin/detail?type=2&id="+obj.userId
})
}
}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) {
clearInterval(timer)
uni.closeSocket();
uni.removeStorageSync("isOpen",false)
uni.removeStorageSync("isOpen")
console.log('WebSocket 已关闭!');
});
})
@ -112,11 +157,12 @@ function xintiao() {
console.log("xintiao")
uni.setStorageSync("isOpen",true)
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
}, 10000)
}, 30000)
}
setTimeout(()=>{
console.log(1212)
uni.$emit("openSocket")
if(uni.getStorageSync("userInfo").id){
uni.$emit("openSocket")
}
},1000)
// #ifdef VUE3

@ -80,6 +80,10 @@
uni.$on("closeSharePopup",res=>{
that.isPopup = false;
})
if( uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
},
onShow() {
this.getUserInfo();
@ -97,6 +101,48 @@
}
},
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){
uni.previewImage({
urls: this.dongtaiList[index].imgurl,

@ -104,7 +104,10 @@
}
},
onPullDownRefresh() {
const that = this;
const that = this;
if(uni.getStorageSync("userInfo").id){
uni.$emit("openSocket");
}
setTimeout(()=>{
if(that.current == 0){
if(that.commentList1.length <= that.total1){
@ -181,11 +184,16 @@
that.show=false
}
})
if(uni.getStorageSync("userInfo").id){
this.watchSocket();
}
},
onShow() {
if(this.city){
this.getUserInfo();
}
if(!uni.getStorageSync("isOpen")&& uni.getStorageSync("userInfo").id){
uni.$emit("openSocket");
}
},
onReachBottom() {
@ -209,7 +217,49 @@
}
}
},
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){
this.$api.trackUpload({
@ -442,7 +492,7 @@
})
}else if(index == 3){
uni.navigateTo({
url: "/pages/pipei/shipin/detail"
url: "/pages/pipei/shipin/index"
})
}else if(index == 4){
uni.navigateTo({

@ -123,6 +123,9 @@
that.show=false
}
})
if( uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
},
onReachBottom() {
const that = this;
@ -135,6 +138,48 @@
}, 1000);
},
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){
this.$api.trackUpload({

@ -1,28 +1,33 @@
<template>
<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
class="video-view"
:streamID="playStreamID"
>
</zego-remote-view> -->
</zego-remote-view>
</view>
</template>
<script>
// import permision from "@/js_sdk/wa-permission/permission.js"
// //导入 ZEGO Express SDK
// 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 permision from "@/js_sdk/wa-permission/permission.js"
//导入 ZEGO Express SDK
import ZegoExpressEngine from '@/uni_modules/zego-ZegoExpressUniApp-JS/components/zego-ZegoExpressUniApp-JS/lib/ZegoExpressEngine';
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";
let roomConfig = {};
roomConfig.isUserStatusNotify = true;
const profile = {
appID : 267111980,
appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e',
scenario : 0
};
export default {
components: {
ZegoLocalView,
@ -40,31 +45,68 @@
},
}
},
onLoad(o) {
this.id = o.id;
this.type=o.type;
console.log(o)
},
onReady() {
console.log(uni.getSystemInfoSync().platform)
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform === "android") {
const res = await permision.requestAndroidPermission(
"android.permission.RECORD_AUDIO"
);
console.log(res)
const res1 = await permision.requestAndroidPermission(
"android.permission.CAMERA"
);
console.log(res1)
}
// #endif
// let roomConfig = {};
// // 只有传入 “isUserStatusNotify” 参数取值为 “true” 的 ZegoRoomConfig,才能收到 onRoomUserUpdate 回调。
// roomConfig.isUserStatusNotify = true;
// // 获取token传入
// roomConfig.token = "********";
// // 登录房间
// // 开始登录房间
// ZegoExpressEngine.instance().loginRoom('room1', {'userID': 'id1', 'userName': 'user1'}, roomConfig);
// // #ifdef APP-PLUS
// if (uni.getSystemInfoSync().platform === "android") {
// const res = await permision.requestAndroidPermission(
// "android.permission.RECORD_AUDIO"
// );
// const res1 = await permision.requestAndroidPermission(
// "android.permission.CAMERA"
// );
// }
// // #endif
ZegoExpressEngine.createEngineWithProfile(profile);
console.log(123565)
this.loginRoom();
},
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>

@ -4,102 +4,190 @@
<u-navbar :title="title" back-icon-color="#ffffff" title-color="#ffffff" :background="background"></u-navbar>
</view>
<view class="tongcheng-content">
<view class="title" v-if="isSucess == false">正在寻找新朋友...</view>
<view class="desc" v-if="isSucess == false">当前用户过多请耐心等待</view>
<view class="desc1" v-else>{{isJieshou?'':(isSucess?'你有一条新的缘分':'匹配成功马上开始这段缘分吧')}}</view>
<template v-if="isJieshou == false">
<view class="dian" v-if="isSucess == false">
<view class="user">
<view class="item">
<image class="avatar" src="@/static/nv.png"></image>
<view class="txt">空白空白1</view>
</view>
<view class="items">
<image src="@/static/yuyin-xin2.png"></image>
</view>
<view class="item">
<view class="pic">
<image class="avatar1" src="@/static/nan.png"></image>
<image class="avatar2" src="@/static/nan.png"></image>
</view>
</view>
<view class="title" v-if="isSucess == 1">正在寻找新朋友...</view>
<view class="desc" v-if="isSucess == 1">当前用户过多请耐心等待</view>
<view class="desc1" v-else>{{isSucess == 1?'你有一条新的缘分':'匹配成功马上开始这段缘分吧'}}</view>
<view class="dian" v-if="isSucess == 1">
<view class="user">
<view class="item">
<image class="avatar" :src="userInfo.faceImage?userInfo.faceImage:userInfo.img"></image>
<view class="txt">{{userInfo.nickname}}</view>
</view>
</view>
<view class="dian-on" v-else>
<view class="info">
<image src="@/static/nan.png"></image>
<view class="name">张美丽</view>
<view class="btn" v-if="isJieshou">+关注</view>
<view class="txt">27/165cm</view>
<view class="items">
<image src="@/static/yuyin-xin2.png"></image>
</view>
<view class="tag" v-if="isSucess == true">
<view class="titles">个性签名</view>
<view class="descs">
<text>们都会走上一条叫做青春的路反复并疼痛地成长着\n曾经的旧时光感动过你我\n在黎明来临的时刻我选择了将你遗忘\n思绪的风引起一阵阵叹息成了来自我心的绝唱\n用一季的花开季节见证你我的生命轮回</text>
<view class="item">
<view class="pic">
<image class="avatar1" src="@/static/nan.png"></image>
<image class="avatar2" src="@/static/nv.png"></image>
</view>
</view>
</view>
</template>
</view>
<view class="dian-on" v-if="isSucess == 2">
<view class="info">
<image :src="info.faceImage?info.faceImage:info.img"></image>
<view class="name">{{info.nickname}}</view>
<view class="txt">{{info.age}}/{{info.height}}</view>
</view>
<view class="tag">
<view class="titles">个性签名</view>
<view class="descs">
<text>{{info.declaration}}</text>
</view>
</view>
</view>
</view>
<view class="tongcheng-end" v-if="isSucess == false">
<view class="tongcheng-end" v-if="isSucess == 1">
<view class="send">茫茫人海今天和你相遇</view>
<view class="todo">
<view class="todo" @click="toBack()">
<image src="@/static/yuyin-cha.png"></image>
</view>
</view>
<template v-else>
<view class="tongcheng-start" v-if="isJieshou">
<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?'开启':'已关'}}
</view>
<view class="item" @click="toggleMenu(2)">
<image src="@/static/yuyin-03.png" v-if="isYangshengqi"></image><image v-else src="@/static/yuyin-03-on.png"></image>扬声器{{isYangshengqi?'开启':'已关'}}
</view>
<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?'开启':'已关'}}
</view>
<view class="item"></view>
<view class="items">
<image @click="toggleMenu(4)" src="@/static/yuyin-02.png"></image>
<image @click="toggleMenu(5)" class="off" src="@/static/yuyin-off.png"></image>
</view>
<view class="item"></view>
<!-- <view class="tongcheng-start"> -->
<!-- <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?'开启':'已关'}}
</view>
<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 class="item" @click="toggleMenu(2)">
<image src="@/static/yuyin-03.png" v-if="isYangshengqi"></image><image v-else src="@/static/yuyin-03-on.png"></image>扬声器{{isYangshengqi?'开启':'已关'}}
</view>
</template>
<view class="tongcheng-video">
<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?'开启':'已关'}}
</view> -->
<!-- <view class="item"></view> -->
<!-- <view class="items">
<image @click="toggleMenu(4)" src="@/static/yuyin-02.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 class="item">
<image src="@/static/yuyin-05.png"></image>{{isSucess == 2?'等待中':'立即进入'}}
</view>
</view>
<!-- <view class="tongcheng-video">
<view class="other"></view>
<view class="content"></view>
</view>
</view> -->
</view>
</template>
<script>
let timer = null;
export default {
data() {
return {
isJieshou: true,
info: {},
count: 10,
userInfo: {},
isJieshou: false,
title: "视频速配",
isShexiangtou: true,
isMakefeng: true,
isYangshengqi: true,
isSucess: true,
isSucess: 1,
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
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: {
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){
if(index == 1){
this.isMakefeng = !this.isMakefeng
@ -122,7 +210,7 @@
<style scoped lang="scss">
.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;
overflow: hidden;
min-height: 100vh;
@ -336,6 +424,8 @@
border-radius: 50%;
margin-bottom: 20rpx;
}
font-size: 30rpx;
color: #FFFFFF;
}
.items{
width: 33.3%;

@ -52,7 +52,7 @@
return {
isSucess: 1,
info: {},
count: 5,
count: 10,
userInfo: {},
background: {
//
@ -64,7 +64,7 @@
},
onLoad() {
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: {
toPage(index){
@ -74,7 +74,7 @@
timer = setInterval(()=>{
if(that.count == 0){
clearInterval(timer);
that.count = Math.floor(Math.random() * (20 - 1 + 1)) + 1;
that.count = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
that.sameCitySpeedDating();
}else{
that.count --
@ -84,19 +84,19 @@
this.toChat();
}else if(index == 3){
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() {
const { code, data } = await this.$api.findZegoToken({
userId: uni.getStorageSync("userInfo").id,
sellerId: this.id
sellerId: this.info.id
})
if(code == 200){
uni.setStorageSync("chatToken",data.token);
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: ""
}
},
onLoad() {
onReady() {
const that = this;
uni.$on("closeSharePopup",res=>{
that.isPopup = false;
@ -208,12 +208,58 @@
uni.$on("openHaibaoPopup",res=>{
that.createPoster();
that.show = true;
})
})
if( uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
},
onShow() {
this.getUserInfo();
this.getUserInfo();
},
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() {
this.show = false;
},

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

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

@ -53,6 +53,7 @@
<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==5">你有一个新的礼物</view>
<view class="desc" v-if="a.type==6">{{a.message}}</view>
</view>
</view>
</u-swipe-action>
@ -69,7 +70,7 @@
list:[{'name': '消息'},{'name': '好友'}],
activeStyle:{'fontSize': '35rpx'},
frindList: [],
type: -1,
type: 0,
count: 0,
xiaoxiinfo: {},
options: [
@ -85,9 +86,37 @@
onShow() {
this.getList();
this.dashaCount();
this.getXiaoxiList();
this.getXiaoxiList();
if(uni.getStorageSync("isOpen") && uni.getStorageSync("userInfo").id){
this.watchSocket();
}
},
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) {
const { code, data } = await this.$api.findZegoToken({
@ -97,7 +126,7 @@
if(code == 200){
uni.setStorageSync("chatToken",data.token);
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){
this.current = index
if(index==0){
this.type = -1
this.type = 0
this.getList();
}else{
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