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.
714 lines
18 KiB
714 lines
18 KiB
<template>
|
|
<view class="home">
|
|
<view class="home-navbar">
|
|
<u-navbar :is-back="false">
|
|
<view class="slot-wrap">
|
|
<view class="address" @click="openPage(5)">
|
|
<image src="@/static/dingwei.png"></image>{{city}}
|
|
</view>
|
|
<view class="search" @click="openPage(4)">
|
|
<image src="@/static/icon-search.png"></image>
|
|
请输入名称搜索
|
|
</view>
|
|
</view>
|
|
</u-navbar>
|
|
</view>
|
|
<view class="home-menu">
|
|
<view class="item" @click="openPage(1)">
|
|
<image src="@/static/1.png"></image>
|
|
<view class="txt">同城速配</view>
|
|
</view>
|
|
<view class="item" @click="openPage(2)">
|
|
<image src="@/static/2.png"></image>
|
|
<view class="txt">语音速配</view>
|
|
</view>
|
|
<view class="item" @click="openPage(3)">
|
|
<image src="@/static/3.png"></image>
|
|
<view class="txt">视频速配</view>
|
|
</view>
|
|
</view>
|
|
<view class="home-tab">
|
|
<view class="tab">
|
|
<u-tabs :list="list" bg-color="transparent" :is-scroll="false" active-color="#222222" inactive-color="#666666" font-size="30" :active-item-style="activeStyle" bar-height="10" bar-width="60" v-model="current" @change="changeTabs"></u-tabs>
|
|
</view>
|
|
</view>
|
|
<view class="home-list" v-if="current==0">
|
|
<view class="item" v-for="(a,i) in commentList1" :key="i">
|
|
<view class="pic" @click="openPage(6,a.id)">
|
|
<image :src="a.faceImage?a.faceImage:a.img"></image>
|
|
</view>
|
|
<view class="info" @click="openPage(6,a.id)">
|
|
<view class="name">{{a.nickname}}<view class="vip" v-if="a.memberflag>=1">VIP{{a.memberflag}}</view></view>
|
|
<view class="desc">{{a.age}}岁/{{a.height}}cm</view>
|
|
</view>
|
|
<view class="chat" @click="openPage(7,a)">
|
|
<image src="@/static/xin.png"></image>
|
|
搭讪
|
|
</view>
|
|
</view>
|
|
<view class="empty" v-if="total1 == 0 ">
|
|
<image src="@/static/empty.png"></image>
|
|
<view class="txt">暂无数据</view>
|
|
</view>
|
|
</view>
|
|
<view class="home-list" v-else>
|
|
<view class="item" v-for="(a,i) in commentList2" :key="i">
|
|
<view class="pic" @click="openPage(6,a.id)">
|
|
<image :src="a.faceImage?a.faceImage:a.img"></image>
|
|
</view>
|
|
<view class="info" @click="openPage(6,a.id)">
|
|
<view class="name">{{a.nickname}}<view class="vip" v-if="a.memberflag>=1">VIP{{a.memberflag}}</view></view>
|
|
<view class="desc">{{a.age}}岁/{{a.height}}cm</view>
|
|
</view>
|
|
<view class="chat" @click="openPage(7,a)">
|
|
<image src="@/static/xin.png"></image>
|
|
搭讪
|
|
</view>
|
|
</view>
|
|
<view class="empty" v-if="total2 == 0 ">
|
|
<image src="@/static/empty.png"></image>
|
|
<view class="txt">暂无数据</view>
|
|
</view>
|
|
</view>
|
|
<u-popup v-model="show" mode="top" :mask-close-able='false' :zIndex="5">
|
|
<view class="permissions_box">
|
|
当您使用APP时,应用程序可以提供基于位置的服务、定位导航、附近搜索等功能。
|
|
</view>
|
|
</u-popup>
|
|
<unverified :isPopup="isPopup" />
|
|
<insufficient :isCoins="isCoins" />
|
|
<dashan :isDashan="isDashan" :info="info"></dashan>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
info: {},
|
|
commentList1: [],
|
|
commentList2: [],
|
|
isCoins: false,
|
|
isDashan: false,
|
|
isPopup: false,
|
|
current: 0,
|
|
city: "",
|
|
page1: 1,
|
|
page2: 1,
|
|
total1: 1,
|
|
total2: 1,
|
|
show: false,
|
|
list:[{'name': '热门'},{'name': '附近'}],
|
|
activeStyle:{'fontSize': '35rpx'},
|
|
userInfo: {}
|
|
}
|
|
},
|
|
onPullDownRefresh() {
|
|
const that = this;
|
|
if(uni.getStorageSync("userInfo").id){
|
|
uni.$emit("openSocket");
|
|
}
|
|
setTimeout(()=>{
|
|
if(that.current == 0){
|
|
if(that.commentList1.length <= that.total1){
|
|
that.page1 ++;
|
|
setTimeout(function() {
|
|
that.customerRecommendList(1);
|
|
}, 1000);
|
|
}
|
|
}else{
|
|
if(that.commentList2.length <= that.total2){
|
|
that.page2 ++;
|
|
setTimeout(function() {
|
|
that.nearbyCustomerList(1);
|
|
}, 1000);
|
|
}
|
|
}
|
|
uni.stopPullDownRefresh();
|
|
},2000)
|
|
},
|
|
onLoad() {
|
|
const that = this;
|
|
// APP检查权限
|
|
if(uni.getSystemInfoSync().platform == 'android') {
|
|
plus.android.checkPermission(
|
|
'android.permission.ACCESS_FINE_LOCATION',
|
|
granted => {
|
|
if (granted.checkResult==-1){
|
|
that.show = true
|
|
that.getLocation();
|
|
}else{
|
|
that.show=false
|
|
console.log(2)
|
|
// 此为uView的跳转方法,详见"文档-JS"部分,也可以用uni的uni.navigateTo
|
|
that.getLocation();
|
|
}
|
|
},
|
|
error => {
|
|
console.error('Error checking permission:', error.message);
|
|
}
|
|
);
|
|
that.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
|
|
return ;
|
|
}else{
|
|
that.getLocation();
|
|
}
|
|
|
|
},
|
|
onReady() {
|
|
const that = this;
|
|
uni.$on("clickTap", res=>{
|
|
console.log(res)
|
|
that.city = res.name;
|
|
if(that.current == 0){
|
|
that.page1 = 1;
|
|
that.commentList1 = [];
|
|
that.customerRecommendList();
|
|
}else{
|
|
that.page2 = 1;
|
|
that.commentList2 = [];
|
|
that.nearbyCustomerList();
|
|
}
|
|
});
|
|
uni.$on("closeSharePopup",res=>{
|
|
that.isPopup = false;
|
|
that.isDashan= false;
|
|
that.isCoins= false;
|
|
})
|
|
|
|
uni.$on("openCoinsPopup",res=>{
|
|
that.isCoins = res
|
|
})
|
|
uni.$on("onPopup",res=>{
|
|
if(res == 1){
|
|
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() {
|
|
const that = this;
|
|
uni.showLoading({
|
|
title: "加载中"
|
|
})
|
|
if(that.current == 0){
|
|
if(that.commentList1.length <= that.total1){
|
|
that.page1 ++;
|
|
setTimeout(function() {
|
|
that.customerRecommendList(1);
|
|
}, 1000);
|
|
}
|
|
}else{
|
|
if(that.commentList2.length <= that.total2){
|
|
that.page2 ++;
|
|
setTimeout(function() {
|
|
that.nearbyCustomerList(1);
|
|
}, 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.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{
|
|
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//实时上传轨迹
|
|
trackUpload(res){
|
|
this.$api.trackUpload({
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
lat: res.latitude,
|
|
lon: res.longitude,
|
|
});
|
|
|
|
},
|
|
recorderAuthModal: function () {
|
|
const that = this;
|
|
uni.showModal({
|
|
title: '定位权限说明',
|
|
content: '便于您使用该功能在当前位置查询所在门店,请您确认授权,否则无法使用该功能。',
|
|
cancelText: '关闭',
|
|
confirmText: '去授权',
|
|
success(res) {
|
|
that.show=false
|
|
if (res.confirm) {
|
|
permision.gotoAppPermissionSetting()
|
|
}
|
|
}
|
|
})
|
|
},
|
|
async requestAndroidPermission(permisionID) {
|
|
const that = this;
|
|
var result = await permision.requestAndroidPermission(permisionID);
|
|
if(result != 1){
|
|
that.recorderAuthModal();
|
|
}else{
|
|
that.show=false
|
|
// 此为uView的跳转方法,详见"文档-JS"部分,也可以用uni的uni.navigateTo
|
|
that.getLocation();
|
|
}
|
|
},
|
|
//首页附近
|
|
async nearbyCustomerList(type){
|
|
console.log(uni.getStorageSync("jingweiInfo").new_city)
|
|
const { code, data , msg } = await this.$api.nearbyCustomerList({
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
nickname: "",
|
|
startAge: "",
|
|
endAge: "",
|
|
city: uni.getStorageSync("jingweiInfo").new_city?uni.getStorageSync("jingweiInfo").new_city:uni.getStorageSync("jingweiInfo").city,
|
|
lat: uni.getStorageSync("jingweiInfo").latitude,
|
|
lon: uni.getStorageSync("jingweiInfo").longitude,
|
|
page: this.page2,
|
|
limit: 20
|
|
});
|
|
if(type == 1){
|
|
uni.hideLoading()
|
|
}
|
|
if(code == 200){
|
|
this.total2 = data.total;
|
|
this.commentList2 = this.arrayUnique([...this.commentList2,...data.list],'id')
|
|
}else{
|
|
uni.showToast({
|
|
title: msg,
|
|
position: "bottom",
|
|
icon: "none",
|
|
})
|
|
}
|
|
},
|
|
//首页推荐
|
|
async customerRecommendList(type){
|
|
const { code, data , msg } = await this.$api.customerRecommendList({
|
|
userId: uni.getStorageSync("userInfo").id,
|
|
nickname: "",
|
|
startAge: "",
|
|
endAge: "",
|
|
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,
|
|
page: this.page1,
|
|
limit: 20
|
|
});
|
|
if(type == 1){
|
|
uni.hideLoading()
|
|
}
|
|
if(code == 200){
|
|
this.total1 = data.total;
|
|
this.commentList1 = this.arrayUnique([...this.commentList1,...data.list],'id')
|
|
}else{
|
|
uni.showToast({
|
|
title: msg,
|
|
position: "bottom",
|
|
icon: "none",
|
|
})
|
|
}
|
|
},
|
|
//数组对象去重
|
|
arrayUnique (arr, name) {
|
|
var hash = {};
|
|
return arr.reduce(function (item, next) {
|
|
hash[next[name]]
|
|
? ""
|
|
: (hash[next[name]] = true && item.push(next));
|
|
return item;
|
|
}, []);
|
|
},
|
|
//获取用户信息
|
|
async getUserInfo() {
|
|
const { code, data , msg } = await this.$api.findUserInfo({userId: uni.getStorageSync("userInfo").id});
|
|
if(code == 200){
|
|
this.userInfo = data;
|
|
uni.setStorageSync("userInfo",data);
|
|
}else{
|
|
uni.showToast({
|
|
title: msg,
|
|
position: "bottom",
|
|
icon: "none",
|
|
})
|
|
}
|
|
},
|
|
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)
|
|
|
|
|
|
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({
|
|
url,
|
|
success(res) {
|
|
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 = 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();
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
openPage(index,id){
|
|
if(index == 1){
|
|
uni.navigateTo({
|
|
url: "/pages/pipei/tongcheng/index"
|
|
})
|
|
}else if(index == 2){
|
|
uni.navigateTo({
|
|
url: "/pages/pipei/yuyin/index"
|
|
})
|
|
}else if(index == 3){
|
|
uni.navigateTo({
|
|
url: "/pages/pipei/shipin/index"
|
|
})
|
|
}else if(index == 4){
|
|
uni.navigateTo({
|
|
url: "/pages/index/search?type=1"
|
|
})
|
|
}else if(index == 5){
|
|
uni.navigateTo({
|
|
url: "/pages/index/city"
|
|
})
|
|
}else if(index == 6){
|
|
uni.navigateTo({
|
|
url: "/pages/peiwan/detail?id="+id
|
|
})
|
|
}else if(index == 7){
|
|
if(this.userInfo.realnameFlag == 0){
|
|
this.isPopup = true
|
|
return ;
|
|
}
|
|
this.info = id
|
|
this.info.userid = id.id
|
|
this.isDashan = true;
|
|
}
|
|
},
|
|
changeTabs(index){
|
|
this.current = index;
|
|
this.commentList1 = []
|
|
this.page1 = 1
|
|
this.page2 = 1
|
|
this.commentList1 = []
|
|
this.commentList2 = []
|
|
if(index == 0){
|
|
this.customerRecommendList();
|
|
}else{
|
|
this.nearbyCustomerList();
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.home{
|
|
overflow: hidden;
|
|
.permissions_box{
|
|
padding-top: 180rpx;
|
|
}
|
|
.empty{
|
|
padding: 150rpx 0;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 28rpx;
|
|
color: #222222;
|
|
image{
|
|
display: block;
|
|
width: 460rpx;
|
|
height: 400rpx;
|
|
margin: 0 auto;
|
|
}
|
|
}
|
|
&-navbar{
|
|
width: 100%;
|
|
overflow: hidden;
|
|
.slot-wrap{
|
|
width: 100%;
|
|
padding: 0 25rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
box-sizing: border-box;
|
|
.address{
|
|
font-weight: 400;
|
|
font-size: 30rpx;
|
|
white-space: nowrap;
|
|
color: #222222;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
max-width: 250rpx;
|
|
image{
|
|
width: 30rpx;
|
|
height: 30rpx;
|
|
margin-right: 7rpx;
|
|
position: relative;
|
|
top: 5rpx;
|
|
}
|
|
}
|
|
.search{
|
|
width: 436rpx;
|
|
height: 70rpx;
|
|
background: #F5F5F5;
|
|
border-radius: 70rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
font-weight: 500;
|
|
font-size: 26rpx;
|
|
color: #999999;
|
|
image{
|
|
width: 30rpx;
|
|
height: 30rpx;
|
|
margin-right: 7rpx;
|
|
margin-left: 25rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
&-menu{
|
|
padding: 0 25rpx;
|
|
overflow: hidden;
|
|
margin-top: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
.item{
|
|
width: 220rpx;
|
|
height: 140rpx;
|
|
position: relative;
|
|
image{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
.txt{
|
|
position: absolute;
|
|
left: 18rpx;
|
|
top: 55rpx;
|
|
z-index: 2;
|
|
font-weight: 500;
|
|
font-size: 30rpx;
|
|
color: #FFFFFF;
|
|
}
|
|
}
|
|
}
|
|
&-tab{
|
|
display: flex;
|
|
margin-top: 10rpx;
|
|
overflow: hidden;
|
|
.tab{
|
|
width: 250rpx;
|
|
}
|
|
}
|
|
&-list{
|
|
padding: 0 25rpx 25rpx;
|
|
overflow: hidden;
|
|
.item{
|
|
width: 100%;
|
|
height: 200rpx;
|
|
background: #FFFFFF;
|
|
box-shadow: 0px 4rpx 10rpx 0px rgba(0,0,0,0.06);
|
|
border-radius: 20rpx;
|
|
padding: 30rpx;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-top: 20rpx;
|
|
.pic{
|
|
width: 140rpx;
|
|
height: 140rpx;
|
|
border-radius: 10rpx;
|
|
overflow: hidden;
|
|
margin-right: 20rpx;
|
|
image{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
.info{
|
|
flex: 1;
|
|
.name{
|
|
font-weight: 500;
|
|
font-size: 32rpx;
|
|
color: #222222;
|
|
display: flex;
|
|
align-items: center;
|
|
.vip{
|
|
width: 60rpx;
|
|
line-height: 32rpx;
|
|
background: url(@/static/vip-bg.png) center top no-repeat;
|
|
background-size: contain;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 20rpx;
|
|
color: #FFFFFF;
|
|
overflow: hidden;
|
|
margin-left: 20rpx;
|
|
}
|
|
}
|
|
.desc{
|
|
width: 180rpx;
|
|
line-height: 40rpx;
|
|
background: #F2F2F2;
|
|
border-radius: 40rpx;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #000000;
|
|
text-align: center;
|
|
margin-top: 20rpx;
|
|
}
|
|
}
|
|
.chat{
|
|
width: 150rpx;
|
|
height: 90rpx;
|
|
background: linear-gradient(0deg, #000000, #3D3B38);
|
|
box-shadow: 0px 4rpx 18rpx 0px rgba(42,41,39,0.34);
|
|
border-radius: 90rpx;
|
|
margin-left: 20rpx;
|
|
text-align: center;
|
|
font-weight: 500;
|
|
font-size: 24rpx;
|
|
color: #FFFFFF;
|
|
image{
|
|
width: 65rpx;
|
|
height: 32rpx;
|
|
display: block;
|
|
margin: 15rpx auto 5rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|