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.
 
 
 
 
 

368 lines
8.6 KiB

<template>
<view class="page" :style="{'background-image': 'url('+ imgfixUrls + 'dating/bd_new_bg.png' +')'}">
<view v-if="recommendList.length == 0" class="tips">{{tipsText}}</view>
<movable-area class="movable-area">
<movable-view
@touchend="touchend(index,item.id)"
:x="item.touchX"
:y="touchY"
direction="horizontal"
@change="onChange($event,index)"
out-of-bounds="true"
style="width: 560rpx;height: auto;overflow: hidden;transition: top 0.5s;"
:style="{'z-index': 999 - index}"
:class="{'first-class' : currentIndex == index}"
:disabled="currentIndex != index"
v-for="(item,index) in cRecommendList"
:key="index"
>
<view class="common-user" @click="toDetail(item.id)">
<image class="avatar" :src="item.cover_show" mode=""></image>
<view class="name">{{item.nickname}}</view>
<view class="user-info">
<view class="sex-age" :class="{'woman': item.gneder == 2,'man': item.gneder == 1}">
<view v-if="item.gneder == 2" class="iconfont icon-female"></view>
<view v-else class="iconfont icon-male"></view>
<view>{{item.age}}</view>
</view>
<view class="location">{{item.area}}</view>
<view v-if="item.is_vip == 1" class="member">VIP</view>
</view>
<view class="tags">
<view class="item" v-for="(tag,tagIndex) in item.label_list" :key="tagIndex">{{tag}}</view>
</view>
<!-- 喜欢和无感 -->
<view class="common-btn close" :style="{'opacity': item.closeOpacity}">
<image :src="imgfixUrls + 'dating/bd_close.svg'" mode=""></image>
</view>
<view class="common-btn like" :style="{'opacity': item.likeOpacity}">
<image :src="imgfixUrls + 'dating/bd_like.svg'" mode=""></image>
</view>
</view>
</movable-view>
</movable-area>
<TabBars :tabBarAct="0" pageType="16"></TabBars>
</view>
</template>
<script>
import App from '@/common/js/app.js';
import TabBars from '@/components/template/tabBar.vue';
export default {
data() {
return {
recommendList: [],
currentPage: 1,
totalPage: 1,
listlen: 1, //记录列表有多少条
tipsText: '暂无推荐',
currentIndex: 0, //当前第一条的index
percent: 0,
touchY: 0
}
},
components:{
TabBars
},
onLoad() {
let _this = this
_this.getRecommendList()
uni.getSystemInfo({
success(res) {
// 换算不同手机rpx转为px的值 ,movable-view组件用rpx有问题
_this.percent = (res.windowWidth / 750 * 850).toFixed(0)
_this.touchY = (res.windowWidth / 750 * 180).toFixed(0)
}
})
},
watch: {
// 监听剩余列表数量,当剩余1条并且还有下一页数据时请求第下一页数据
listlen(val) {
if(val == 0 && this.currentPage <= this.totalPage) {
this.getRecommendList()
console.log('请求下一页')
}else if(val == 0 && this.currentPage > this.totalPage) {
// 剩余1,且没有下一页时,重新请求第一页数据
this.currentPage = 1
this.getRecommendList()
console.log('重新请求第一页')
}
}
},
computed: {
// 加工列表数据
cRecommendList() {
if(this.recommendList.length) {
return this.recommendList.map(item => {
item.touchX = this.percent //开始显示的横向距离
// item.touchY = '180rpx' //开始显示的纵向距离
item.likeOpacity = 0 //喜欢图标显示度
item.closeOpacity = 0 //无感图标的显示度
item.lastX = 0 //最后隐藏的横向距离
item.lastY = 0 //最后隐藏的纵向的距离
console.log(item,'item值')
return item
})
}
}
},
methods: {
// 获取推荐的列表
getRecommendList() {
let _this = this
App._post_form(
`&p=dating&do=recommendMember`,
{
page: _this.currentPage
},
res => {
_this.recommendList = res.data.list
_this.currentIndex = 0
_this.listlen = _this.recommendList.length
_this.currentPage ++
_this.totalPage = res.data.total
},
false,
() => {
}
);
},
// 松开手指时
touchend(index,id) {
if(!this.cRecommendList[index]) {
return
}
// 超过滑动幅度时隐藏
if(this.cRecommendList[index].likeOpacity > 0.5 || this.cRecommendList[index].closeOpacity > 0.5) {
this.cRecommendList[index].touchX = this.cRecommendList[index].lastX
// 隐藏一条减1
this.listlen --
this.currentIndex = index + 1
// 右滑直接收藏
if(this.cRecommendList[index].likeOpacity > 0.5) {
let _this = this
App._post_form(
`&p=dating&do=collectionOperation&id=${id}`,
{
id: id,
is_cancel: 2
},
res => {
},
false,
() => {
}
);
}
}else {
// 滑动幅度过小回到原处
this.cRecommendList[index].touchX = this.cRecommendList[index].touchX == this.percent ? Number(this.percent) + Number(0.01) : this.percent
}
this.$forceUpdate()
},
// 滑动
onChange(e,index) {
if(!this.cRecommendList[index]) {
return
}
// 滑动给最终隐藏位置赋值
if(e.detail.x < this.percent) {
this.cRecommendList[index].lastX = 0
}else if(e.detail.x > this.percent) {
this.cRecommendList[index].lastX = 1400
}
// 滑动的距离
let changeNum = e.detail.x - this.percent
// 小于0左滑大于0右滑
if(changeNum < 0) {
this.cRecommendList[index].likeOpacity = 0
// 每1px增加0.05opacity值
this.cRecommendList[index].closeOpacity = (changeNum * -0.05 > 1 ? 1 : changeNum * -0.05).toFixed(2)
}else if(changeNum > 0) {
this.cRecommendList[index].closeOpacity = 0
this.cRecommendList[index].likeOpacity = (changeNum * 0.05 > 1 ? 1 : changeNum * 0.05).toFixed(2)
}else{
this.cRecommendList[index].closeOpacity = 0
this.cRecommendList[index].likeOpacity = 0
}
this.$forceUpdate()
},
// 去详情页面
toDetail(id) {
App.navigationTo({
url: `pages/subPages2/blindDate/member/detail?id=${id}`
})
},
}
}
</script>
<style lang="scss" scoped>
.page {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-size: 100% 100%;
}
.tips {
width: 100%;
height: 40rpx;
text-align: center;
line-height: 40rpx;
font-size: 36rpx;
color: #fff;
position: fixed;
top: 100rpx;
left: 0;
}
.movable-area {
width: 300vw;
height: 100vh;
position: absolute;
top: 0;
left: -100vw;
}
.first-class {
top: 20rpx;
left: 20rpx;
}
.common-user {
width: 560rpx;
height: auto;
border-radius: 20rpx;
// position: absolute;
overflow: hidden;
background-color: #fff;
position: relative;
padding-bottom: 20rpx;
.avatar {
width: 100%;
height: 558rpx;
display: block;
}
.name {
height: 70rpx;
line-height: 70rpx;
font-size: 48rpx;
color: #333;
margin: 20rpx 0 0 30rpx;
font-weight: bold;
}
.user-info {
width: 100%;
height: 30rpx;
margin: 20rpx 0 0 30rpx;
display: flex;
align-items: center;
color: #fff;
font-size: 20rpx;
.sex-age {
width: 70rpx;
height: 30rpx;
border-radius: 15rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10rpx;
.iconfont {
font-size: 20rpx;
line-height: 30rpx;
margin-right: 4rpx;
}
.icon-female {
transform: rotate(45deg);
}
}
.man {
background-color: #0084FF;
}
.woman {
background-color: #FE83AF;
}
.location {
height: 30rpx;
width: auto;
padding: 0 16rpx;
border-radius: 15rpx;
background-color: #333333;
margin-right: 10rpx;
}
.member {
width: 70rpx;
height: 30rpx;
line-height: 30rpx;
border-radius: 15rpx;
text-align: center;
background-color: #DCC083;
}
}
.tags {
width: 530rpx;
height: 110rpx;
overflow: hidden;
display: flex;
flex-wrap: wrap;
font-size: 20rpx;
color: #333;
padding: 0 0 0 30rpx;
.item {
width: auto;
height: 34rpx;
border-radius: 17rpx;
line-height: 34rpx;
text-align: center;
padding: 0 13rpx;
margin: 20rpx 20rpx 0 0;
background-color: #EEEEEE;
}
}
}
.common-btn {
width: 120rpx;
height: 120rpx;
border-radius: 60rpx;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 30rpx;
}
.close {
right: 30rpx;
background-color: #333333;
image {
width: 44rpx;
height: 44rpx;
}
}
.like {
left: 30rpx;
background-color: #FF4444;
image {
width: 78rpx;
height: 72rpx;
}
}
</style>