123456 1 month ago
commit 76db167e91
  1. 16
      api/index.js
  2. 3
      api/request.js
  3. 75
      main.js
  4. 3
      pages/index/city.vue
  5. 1
      pages/index/citySearch.vue
  6. 76
      pages/index/index.vue
  7. 29
      pages/login/index.vue
  8. 57
      pages/login/mima.vue
  9. 10
      pages/user/index.vue
  10. 259
      pages/users/chat/index.vue
  11. 2
      pages/users/yuyin/index.vue
  12. BIN
      static/chat-05.png
  13. 6
      unpackage/cache/wgt/__UNI__7C06BEE/app-service.js
  14. 2
      unpackage/cache/wgt/__UNI__7C06BEE/app-view.js
  15. BIN
      unpackage/debug/android_debug.apk
  16. 6
      unpackage/dist/build/app-plus/app-service.js
  17. 2
      unpackage/dist/build/app-plus/app-view.js
  18. 4984
      unpackage/dist/dev/app-plus/app-service.js
  19. 8298
      unpackage/dist/dev/app-plus/app-view.js

@ -1,5 +1,21 @@
import { request } from './request'
const api = {
//海报
createPoster(data) {
return request({
url: 'api/user/createPoster',
method: 'post',
data
})
},
//微信登录
wxAppOneKeyLogin(data) {
return request({
url: 'api/wxpublic/wxAppOneKeyLogin',
method: 'post',
data
})
},
//获取当前用户得聊天记录
findChatList(data) {
return request({

@ -5,7 +5,6 @@ Vue.prototype.$baseUrl = baseUrl;
export function request(prams) {
return new Promise((resolve, reject) => {
let url = baseUrl+"/prod-api/"+prams.url;
console.log(prams)
uni.request({
url,
data: prams.data,
@ -17,6 +16,8 @@ export function request(prams) {
},
success: (res) => {
if (res.data.code == 200){
console.log(prams)
console.log("返回结果:"+JSON.stringify(res.data))
resolve(res.data);
}else if(res.data.code == 401){
uni.showModal({

@ -16,18 +16,15 @@ Vue.component('share', share)
Vue.component('dashan', dashan)
Vue.config.productionTip = false
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
// };
const profile = {
appID : 267111980,
// AppSign 仅满足简单的鉴权需求,如果需要升级为更加安全的鉴权方式,请参考[如何从 AppSign 鉴权升级为 Token 鉴权](https://doc-zh.zego.im/faq/token_upgrade?product=ExpressVideo&platform=all)
// AppSign 可通过[控制台](https://console.zego.im/dashboard)获取,格式为 @"39011cbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e',
scenario : 0
};
ZegoExpressEngine.createEngineWithProfile(profile);
Vue.prototype.$ZegoExpressEngine = ZegoExpressEngine;
// ZegoExpressEngine.createEngineWithProfile(profile);
// Vue.prototype.$ZegoExpressEngine = ZegoExpressEngine;
@ -43,6 +40,62 @@ const app = new Vue({
app.$mount()
// #endif
let timer = null;
//socket
uni.$on("openSocket",function(res){
uni.connectSocket({
url: 'wss://api.lyiyuan.cn/websocket?userId='+uni.getStorageSync('userInfo').id
});
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!');
uni.sendSocketMessage({
data: {"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"}
});
xintiao()
});
uni.onSocketMessage(function (res) {
console.log(res)
// if((res.data !="success") && (JSON.parse(res.data).event == 1)){
// let obj = JSON.parse(res.data)
// console.log(obj)
// 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})
// // });
// // }
// }
// }
// })
// }
});
uni.onSocketClose(function (res) {
clearInterval(timer)
uni.closeSocket();
console.log('WebSocket 已关闭!');
});
})
function xintiao() {
clearInterval(timer)
timer = setInterval(()=>{
console.log("xintiao")
uni.sendSocketMessage({
data: {"userId": uni.getStorageSync("userInfo").id,"topic":"heart_beat"}
});
}, 10000)
}
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {

@ -29,6 +29,7 @@
that.city = this.jingweiInfo.city;
console.log(uni.getStorageSync("jingweiInfo"))
uni.$on("clickTap", res=>{
console.log(res)
that.jingweiInfo.formatted = res.name
that.jingweiInfo.latitude = res.latitude
that.jingweiInfo.longitude = res.longitude
@ -36,6 +37,7 @@
});
uni.$on("watchCity", res=>{
that.city = res.name
uni.setStorageSync("jingweiInfo",that.jingweiInfo)
});
},
methods: {
@ -51,7 +53,6 @@
url,
success(res) {
console.log("地址解析")
console.log(res)
if(res.data.regeocode.addressComponent){
let city = res.data.regeocode.addressComponent.city.length==0?res.data.regeocode.addressComponent.province:res.data.regeocode.addressComponent.city
that.city = that.city = res.data.regeocode.formatted_address.split(res.data.regeocode.addressComponent.township)[1]

@ -45,6 +45,7 @@
changeInput(e) {
const that = this;
that.keyword = e.detail.value
console.log('https://restapi.amap.com/v3/assistant/inputtips?datatype=all&type=分类代码&city='+that.city+'&key=4a6e2ba8eac3864f0d88f9b5abd026e6&keywords='+that.keyword)
uni.request({
url: 'https://restapi.amap.com/v3/assistant/inputtips?datatype=all&type=分类代码&city='+that.city+'&key=4a6e2ba8eac3864f0d88f9b5abd026e6&keywords='+that.keyword,
success(res) {

@ -167,7 +167,6 @@
}
});
uni.$on("closeSharePopup",res=>{
console.log(11)
that.isPopup = false;
that.isDashan= false;
that.isCoins= false;
@ -181,6 +180,7 @@
that.show=false
}
})
},
onShow() {
if(this.city){
@ -250,6 +250,7 @@
nickname: "",
startAge: "",
endAge: "",
city: this.city,
lat: uni.getStorageSync("jingweiInfo").latitude,
lon: uni.getStorageSync("jingweiInfo").longitude,
page: this.page2,
@ -276,6 +277,7 @@
nickname: "",
startAge: "",
endAge: "",
city: this.city,
page: this.page1,
limit: 20
});
@ -319,12 +321,84 @@
},
getLocation() {
const that = this;
const res1={
"type": "gcj02",
"altitude": 0,
"latitude": 32.04097,
"longitude": 118.637902,
"speed": 0,
"accuracy": 38,
"errMsg": "getLocation:ok"
}
const res={
data: {
"status": "1",
"regeocode": {
"addressComponent": {
"city": "南京市",
"province": "江苏省",
"adcode": "320111",
"district": "浦口区",
"towncode": "320111004000",
"streetNumber": {
"number": "77号",
"location": "118.637348,32.040819",
"direction": "西",
"distance": "54.838",
"street": "团结路"
},
"country": "中国",
"township": "江浦街道",
"businessAreas": [
{
"location": "118.630698,32.063288",
"name": "江浦",
"id": "320111"
}
],
"building": {
"name": [],
"type": []
},
"neighborhood": {
"name": [],
"type": []
},
"citycode": "025"
},
"formatted_address": "江苏省南京市浦口区江浦街道星河时代5栋"
},
"info": "OK",
"infocode": "10000"
}
}
that.trackUpload(res1)
uni.$emit("openSocket")
if(res.data.regeocode.addressComponent){
let city = res.data.regeocode.addressComponent.city.length==0?res.data.regeocode.addressComponent.province:res.data.regeocode.addressComponent.city
that.city = res.data.regeocode.formatted_address.split(res.data.regeocode.addressComponent.township)[1]
uni.setStorageSync("jingweiInfo",{...res1,...res.data.regeocode.addressComponent,formatted: that.city});
that.show = false
if(that.current == 0){
that.page1 = 1;
that.commentList1 = [];
that.customerRecommendList();
}else{
that.page2 = 1;
that.commentList2 = [];
that.nearbyCustomerList();
}
}
return ;
uni.getLocation({
type: 'gcj02',
isHighAccuracy: true,
success(res1) {
console.log(res1)
that.trackUpload(res1)
uni.$emit("openSocket",res=>{
})
let latitude = res1.latitude,longitude = res1.longitude;
let url = `https://restapi.amap.com/v3/geocode/regeo?output=json&location=${longitude},${latitude}&key=4a6e2ba8eac3864f0d88f9b5abd026e6&radius=1000`
uni.request({

@ -83,6 +83,7 @@
onlyAuthorize: true,
success: function(loginRes) {
console.log(loginRes.code)
that.toWxAppOneKeyLogin(loginRes.code);
},
fail(error) {
console.log(error)
@ -95,6 +96,34 @@
}
});
},
async toWxAppOneKeyLogin(code1) {
const { code, data, msg } = await this.$api.wxAppOneKeyLogin({code: code1,accessToken: uni.getStorageSync("accessToken")?uni.getStorageSync("accessToken"):""});
if(code == 200){
uni.setStorageSync("userInfo", data);
uni.setStorageSync("accessToken",data.accessToken)
if(data.sex){
uni.showToast({
title: "登录成功"
})
setTimeout(()=>{
uni.switchTab({
url: "/pages/user/index"
})
},2000)
}else{
uni.navigateTo({
url: "/pages/login/sex"
})
}
}else{
uni.showToast({
icon: "none",
position: "bottom",
title: msg
})
}
},
openPage(index) {
if(index == 2){
uni.navigateTo({

@ -51,6 +51,63 @@
uni.setStorageSync("deviceSn",uni.getSystemInfoSync().deviceId)
},
methods: {
// App
wxLogin() {
const that = this;
if(that.isCheck){
uni.showToast({
icon: "none",
position: "bottom",
title: "请勾选用户协议",
})
return
}
uni.login({
provider: 'weixin',
onlyAuthorize: true,
success: function(loginRes) {
console.log(loginRes.code)
that.toWxAppOneKeyLogin(loginRes.code);
},
fail(error) {
console.log(error)
uni.showToast({
title: '登录失败',
icon: 'error',
position: "bottom",
duration: 2000
})
}
});
},
async toWxAppOneKeyLogin(code1) {
const { code, data, msg } = await this.$api.wxAppOneKeyLogin({code: code1,accessToken: uni.getStorageSync("accessToken")?uni.getStorageSync("accessToken"):""});
if(code == 200){
uni.setStorageSync("userInfo", data);
uni.setStorageSync("accessToken",data.accessToken)
if(data.sex){
uni.showToast({
title: "登录成功"
})
setTimeout(()=>{
uni.switchTab({
url: "/pages/user/index"
})
},2000)
}else{
uni.navigateTo({
url: "/pages/login/sex"
})
}
}else{
uni.showToast({
icon: "none",
position: "bottom",
title: msg
})
}
},
openPage(index) {
if(index == 2){
uni.navigateTo({

@ -202,6 +202,7 @@
that.baseUrl = that.$baseUrl;
})
uni.$on("openHaibaoPopup",res=>{
that.createPoster();
that.show = true;
})
},
@ -212,6 +213,15 @@
toCancle() {
this.show = false;
},
//
async createPoster() {
const that = this;
const {code, data} = await that.$api.createPoster({userId: uni.getStorageSync("userInfo").id});
if(code == 200){
that.poster = data
}
},
toSave() {
uni.showLoading({
title: "正在保存"

@ -8,106 +8,263 @@
</u-navbar>
</view>
<view class="chat-hd" v-if="list.length>0">
<u-notice-bar :volume-icon="false" mode="horizontal" :list="list"></u-notice-bar>
<u-notice-bar style="width: 100%;" :volume-icon="false" mode="horizontal" :list="list"></u-notice-bar>
</view>
<scroll-view class="chat-bd" scroll-y :class="list.length==0?(isOpen?'chat-bd-active1':'chat-bd-active'):(isOpen?'chat-bd-on':'')">
<view class="item">
<view class="fl"><image src="@/static/nv.png"></image></view>
<view class="item" :class="userId != a.rightUserId?'item-on':''" v-for="(a,index) in chatList" :key="index">
<template v-if="userId != a.rightUserId">
<view class="fr">
<view class="desc">{{a.message}}</view>
</view>
<view class="fl"><image :src="a.leftFaceImage"></image></view>
</template>
<template v-else>
<view class="fl"><image :src="a.rightFaceImage"></image></view>
<view class="fr">
<view class="name">李大花<text>陪玩师</text></view>
<view class="desc">世间无敌舍我其谁霸气长存风云变色</view>
<view class="gift">送出礼物<image mode="widthFix" src="/static/logo.png"></image>棒棒糖<text>X3</text></view>
<view class="yinping">
<view class="desc" v-if="a.type == 6 || a.type==3">{{a.message}}</view>
<view class="gift" v-if="a.type == 5">送出礼物<image mode="widthFix" src="/static/logo.png"></image>棒棒糖<text>X3</text></view>
<view class="yinping" v-if="a.type == 1">
<image src="@/static/chat-03.png"></image> 8
</view>
<view class="video">
<view class="video" v-if="a.type == 2">
<video src=""></video>
</view>
<view class="img">
<view class="img" v-if="a.type == 4">
<image src="/static/pic.jpg"></image>
</view>
</view>
</view>
<view class="item item-on">
<view class="fr">
<view class="desc">天天忙的要死好久没联系了哈你最近咋样啊</view>
</view>
<view class="fl"><image src="@/static/nv.png"></image></view>
</template>
</view>
</scroll-view>
<view class="chat-fd">
<view class="a">
<view class="luyin">
<image src="/static/chat-01.png"></image>
<view class="luyin" @click="toToggle()">
<image v-if="isToggle" src="/static/chat-01.png"></image>
<image v-else src="/static/chat-05.png"></image>
</view>
<view class="input">
<!-- <editor placeholder="单行输入" @input="inputValue"></editor> -->
<input type="text" v-model="keyword" placeholder="单行输入" />
<view class="input" v-if="isToggle">
<input type="text" v-model="content" placeholder="单行输入" />
<view class="more" @click="isOpen = !isOpen">
<u-icon name="more-dot-fill" color="#000000" size="30"></u-icon>
</view>
</view>
<view class="btn">
<view class="input" v-else>
<view class="star" v-if="isPlay">开始录音</view>
<view class="star" v-else>停止录音</view>
</view>
<view class="btn" @click="toSend()">
发送
</view>
</view>
<view class="b" v-if="isOpen">
<image src="@/static/chat-zhaopian.png"></image>
<image src="@/static/chat-xiangji.png"></image>
<image @click="uploadImg()" src="@/static/chat-zhaopian.png"></image>
<image @click="uploadVideo()" src="@/static/chat-xiangji.png"></image>
<image src="@/static/chat-yinshipin.png"></image>
<image src="@/static/chat-liwu.png"></image>
<image @click="openGift()" src="@/static/chat-liwu.png"></image>
</view>
</view>
<u-popup v-model="show" mode="top" :mask-close-able='false' :zIndex="5">
<view class="permissions_box">
当您使用APP时为了使用录音的功能我们需要申请麦克风权限
</view>
</u-popup>
</view>
</template>
<script>
import ZIM from '@/js_sdk/zego-ZIMUniplugin-JS/lib/index.js';
ZIM.create({ appID: 267111980, appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e' });
const zim = ZIM.getInstance();
import permision from "@/js_sdk/wa-permission/permission.js"
const recorderManager = uni.getRecorderManager();
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
let timer = 0;
// import ZIM from '@/js_sdk/zego-ZIMUniplugin-JS/lib/index.js';
// ZIM.create({ appID: 267111980, appSign: 'afcaa90a7750ee556e450ca62287c5f9a362e9ed711789717cda0e18f088858e' });
// const zim = ZIM.getInstance();
export default {
data() {
return {
id: "",
isToggle: true,
isOpen: false,
title: "",
keyword: "",
content: "",
userInfo: {},
list: [],
itemList: [],
chatList: []
chatList: [],
userId: "",
img: "",
show: false,
isPlay: true,
};
},
onLoad(o) {
this.userId = uni.getStorageSync("userInfo").id;
this.id = o.id;
this.getUserInfo();
this.getChatList();
},
onReady() {
const that = this;
this.toImLogin()
//
zim.on('receivePeerMessage', function (zim, { messageList, fromConversationID }) {
console.log('receivePeerMessage', messageList, fromConversationID);
recorderManager.onStop(function (res) {
that.uploadVideo(res.tempFilePath);
clearInterval(timer);
});
innerAudioContext.onEnded(res=>{
that.isPlay = false
})
//
// zim.on('receivePeerMessage', function (zim, { messageList, fromConversationID }) {
// console.log('receivePeerMessage', messageList, fromConversationID);
// });
},
methods: {
toImLogin() {
zim.login(uni.getStorageSync("userInfo").id, {
userName: uni.getStorageSync("userInfo").nickname,
token: uni.getStorageSync("chatToken"),
})
.then(function (res) {
//
console.log(res,"登录成功")
toToggle() {
this.isToggle = !this.isToggle
},
toOpen(){
// APP
if(uni.getSystemInfoSync().platform == 'android') {
plus.android.checkPermission(
'android.permission.RECORD_AUDIO',
granted => {
if (granted.checkResult==-1){
that.show=true
}else{
that.show=false
if(that.isPlay){
innerAudioContext.pause();
that.isPlay = false
}
}
},
error => {
console.error('Error checking permission:', error.message);
}
);
that.requestAndroidPermission('android.permission.RECORD_AUDIO')
return ;
}
},
recorderAuthModal: function () {
const that = this;
uni.showModal({
title: '温馨提示',
content: '为了麦克风的功能,我们需要申请麦克风权限,请您确认授权,否则无法使用该功能~',
cancelText: '关闭',
confirmText: '去授权',
success(res) {
that.show=false
if (res.confirm) {
permision.gotoAppPermissionSetting()
}
}
})
.catch(function (err) {
//
},
async requestAndroidPermission(permisionID) {
const that = this;
var result = await permision.requestAndroidPermission(permisionID);
if(result != 1){
that.recorderAuthModal();
}else{
that.show =false
}
},
//
uploadVideo(filePath) {
const that = this
uni.uploadFile({
name: 'file',
url: that.$baseUrl+'/prod-api/common/upload',
filePath,
success: (res) => {
const {code, fileName, url, msg} = JSON.parse(res.data);
if(code == 200){
that.img = url
}
},
fail: (err) => {
console.log(err)
}
});
},
//
uploadVideo() {
const that = this
uni.chooseVideo({
count: 1,
sourceType: ["album", "camera"],
success: (res1) => {
console.log(res1)
uni.uploadFile({
name: 'file',
url: that.$baseUrl+'/prod-api/common/upload',
filePath: res1.tempFilePath,
success: (res) => {
const {code, fileName, url, msg} = JSON.parse(res.data);
if(code == 200){
that.img = url
}
},
fail: (err) => {
console.log(err)
}
});
},
fail(err){
console.log("fail",err)
}
});
},
//
uploadImg() {
const that = this
uni.chooseImage({
count: 1,
sizeType: ["original"], //
sourceType: ["album", "camera"],
success: (res1) => {
console.log(res1)
uni.uploadFile({
name: 'file',
url: that.$baseUrl+'/prod-api/common/upload',
filePath: res1.tempFilePath,
success: (res) => {
const {code, fileName, url, msg} = JSON.parse(res.data);
if(code == 200){
that.img = url
}
},
fail: (err) => {
console.log(err)
}
});
},
fail(err){
console.log("fail",err)
}
});
},
toSend() {},
//
toImLogin() {
// zim.login(uni.getStorageSync("userInfo").id, {
// userName: uni.getStorageSync("userInfo").nickname,
// token: uni.getStorageSync("chatToken"),
// })
// .then(function (res) {
// //
// console.log(res,"")
// })
// .catch(function (err) {
// //
// console.log(err)
// });
},
async getChatList(){
const { code, data , msg } = await this.$api.findChatList({formUserId: uni.getStorageSync("userInfo").id,toUserId: this.id});
if(code == 200){
@ -119,7 +276,7 @@
if(code == 200){
this.userInfo = data;
this.itemList = ["查看TA的主页", (data.isCare == 0?"关注":"取消关注"), "举报", (data.isBlack == 0?"加入黑名单":"移除黑名单")];
this.title = data.nickname;
this.title = data.nickname+(data.isOnline == 1?"_(在线)":"_(离线)");
this.getConfigData();
}else{
uni.showToast({
@ -133,9 +290,7 @@
async getConfigData() {
const that = this;
let res1 = await that.$api.getConfigData({dictType: 'CONFIG_MESSAGE_NOTICE'});
if(res1.data && res1.data.length > 0){
}
that.list = [res1.data.content]
},
//
async toYichu(type) {
@ -174,6 +329,7 @@
<style scoped lang="scss">
.chat{
&-navbar{
width: 100%;
.slot-wrap{
margin-right: 30rpx;
}
@ -356,6 +512,13 @@
justify-content: space-between;
margin-left: 20rpx;
margin-right: 20rpx;
font-size: 30rpx;
.star{
flex: 1;
line-height: 80rpx;
text-align: center;
background: #FFFFFF;
}
editor,input{
flex: 1;
height: 50rpx;

@ -57,8 +57,8 @@
const that = this;
that.yuyinInfo = uni.getStorageSync("yuyinInfo");
console.log(that.yuyinInfo)
that.yuyinInfo.voiceTime = that.formatFun(that.yuyinInfo.voiceTime);
that.baseUrl = that.$baseUrl;
that.yuyinInfo.voiceTime = that.formatFun(that.yuyinInfo.voiceTime);
recorderManager.onStop(function (res) {
that.yuyinInfo.voice = res.tempFilePath;
that.isPlays = false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

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

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