连云港陪玩陪聊
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

279 lines
7.6 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';
3 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)
3 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="
2 months ago
Vue.prototype.$userShareUrl = "https://api.lyiyuan.cn/profile/upload/web/index.html#/pages/login/reg?id="
1 month 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
4 weeks ago
let isChat = false;
1 month ago
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):{};
4 weeks ago
// 获取当前页面的实例
const pages = getCurrentPages();
// 获取当前页面的实例
const currentPage = pages[pages.length - 1];
// 获取页面路由信息
const route = currentPage.route;
// 打印路由信息
console.log('当前页面路由是:' + route);
1 month ago
console.log(obj)
4 weeks ago
if(obj.topic == 'heart_beat'){
if(obj.hasMsg == 1){
uni.showTabBarRedDot({
index: 3
})
}else{
uni.hideTabBarRedDot({
index: 3
})
}
}
if(route == 'pages/users/chat/index'){
uni.$emit("toChatObj",res)
return ;
}
1 month ago
if(obj.topic == 'message'){
4 weeks ago
uni.showTabBarRedDot({
index: 3
})
1 month ago
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: '温馨提示',
1 month ago
content: '来自'+obj.sellerNickname+"发起的视频匹配,是否同意",
1 month 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: '温馨提示',
1 month ago
content: '来自'+obj.sellerNickname+"发起的语音匹配,是否同意",
1 month 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)
}
}
1 month ago
}else{
uni.$emit("toChatXiaoxiObj",res)
1 month 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"
})})
})
1 month ago
uni.$on("showToast",res=>{
uni.showToast({
icon: "none",
position: "bottom",
title: res?'对方已挂断':"对方已拒绝"
})
})
1 month 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()
2 months ago
// #endif
3 months ago
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif