连云港陪玩陪聊
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chunwan/main.js

252 lines
7.0 KiB

3 months ago
import App from './App'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import uView from './uni_modules/vk-uview-ui';
Vue.use(uView);
3 months ago
import unverified from '@/components/unverified.vue';
import insufficient from '@/components/insufficient.vue';
3 months ago
import share from '@/components/share.vue';
2 months ago
import dashan from '@/components/dashan.vue';
3 months ago
Vue.component('unverified', unverified)
Vue.component('insufficient', insufficient)
3 months ago
Vue.component('share', share)
2 months ago
Vue.component('dashan', dashan)
3 months ago
Vue.config.productionTip = false
2 months ago
import api from '@/api/index.js'
Vue.prototype.$api = api
2 months ago
Vue.prototype.$articleShareUrl = "https://api.lyiyuan.cn/profile/upload/web/index.html#/pages/dongtai/detail?type=web&id="
1 month ago
Vue.prototype.$userShareUrl = "https://api.lyiyuan.cn/profile/upload/web/index.html#/pages/login/reg?id="
4 weeks ago
let bgAudioManager = uni.getBackgroundAudioManager();
uni.$on("playAudio",res=>{
bgAudioManager.src = 'https://api.lyiyuan.cn/profile/upload/static/tishiyin.mp3';
bgAudioManager.play();
bgAudioManager = null
})
//socket
let timer = null;
uni.$on("openSocket",function(res){
uni.connectSocket({
url: 'wss://api.lyiyuan.cn/websocket?userId='+uni.getStorageSync('userInfo').id
});
uni.onSocketOpen(function (res) {
xintiao()
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
console.log('WebSocket连接已打开!');
uni.setStorageSync("isOpen",true)
uni.$emit("watchSocket")
});
uni.$on("watchSocket",res=>{
uni.onSocketMessage(function (res) {
const obj = res.data?JSON.parse(res.data):{};
console.log(obj)
3 weeks ago
uni.$emit("toChatObj",res)
4 weeks ago
if(obj.topic == 'message'){
if(obj.type>=8){
if(uni.getStorageSync("userInfo").id == obj.sellerId){
if(obj.type == 12){
uni.$emit("watchEvent",obj)
}
if(obj.type == 20){
uni.$emit("toJieshouYinship",obj)
}
if(obj.type == 18){
if(obj.userMsgVoice == 1){
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.navigateTo({
url: "/pages/pipei/shipin/detail?type=3&id="+obj.userId+'&fid='+obj.sellerId
})
}
if(obj.type == 19){
if(obj.userMsgVoice == 1){
uni.$emit("playAudio")
}
if(obj.userMsgShock == 1){
uni.vibrateLong({
complete: function (res) {
console.log('success',res);
}
});
}
uni.navigateTo({
url: "/pages/pipei/shipin/detail?type=4&id="+obj.userId+'&fid='+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: '温馨提示',
3 weeks ago
content: '来自'+obj.sellerNickname+"发起的视频匹配,是否同意",
4 weeks ago
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: '温馨提示',
3 weeks ago
content: '来自'+obj.sellerNickname+"发起的语音匹配,是否同意",
4 weeks ago
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=1&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 == 10 || obj.type==11){
uni.$emit("jiantingTiaozhuan",obj)
}
}
3 weeks ago
}else{
uni.$emit("toChatXiaoxiObj",res)
4 weeks ago
}
}
});
})
uni.$on("duanYinship",obj=>{
uni.sendSocketMessage({data:JSON.stringify({
"userId": obj.userId,
"sellerId": obj.sellerId,
type: 12,
"topic":"message"
})})
})
uni.$on("jieshouYinship",obj=>{
uni.sendSocketMessage({data:JSON.stringify({
"userId": obj.userId,
"sellerId": obj.sellerId,
type: 20,
"topic":"message"
})})
})
3 weeks ago
uni.$on("showToast",res=>{
uni.showToast({
icon: "none",
position: "bottom",
title: res?'对方已挂断':"对方已拒绝"
})
})
4 weeks ago
uni.onSocketClose(function (res) {
clearInterval(timer)
uni.closeSocket();
uni.removeStorageSync("isOpen")
console.log('WebSocket 已关闭!');
setTimeout(()=>{
if(uni.getStorageSync("userInfo").id){
uni.$emit("openSocket")
}
},1000)
});
})
function xintiao() {
timer = setInterval(()=>{
uni.setStorageSync("isOpen",true)
uni.sendSocketMessage({data:JSON.stringify({"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"})});
}, 30000)
}
setTimeout(()=>{
if(uni.getStorageSync("userInfo").id){
uni.$emit("openSocket")
}
},1000)
2 months ago
3 months ago
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
1 month ago
// #endif
3 months ago
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif