wxml:
<view class="phone_one" bindtap="clickPerson">
<view class="phone_personal">{{firstPerson}}</view>
<image src="../../image/v6.png" class="personal_image {{selectArea ? 'rotateRight' :''}}"></image>
</view>
<view class="person_box">
<view class="phone_select" hidden="{{selectPerson}}">
<view class="select_one" bindtap="mySelect" data-me="请选择">请选择</view>
<view class="select_one" bindtap="mySelect" data-me="微信支付">微信支付</view>
</view>
</view>
wxss:
.phone_one{
display: flex;
position: relative;
justify-content: space-between;
width:150rpx;
height:100rpx;
margin:0 auto;
float: right;
text-align: right;
}
.person_box{
position: relative;
}
.phone_select{
margin-top:100rpx;
right: 0;
z-index: 100;
position: absolute;
}
.select_one{
text-align: center;
background-color:rgb(239, 239, 239);
width:326rpx;
height:100rpx;
line-height:100rpx;
margin:0 5%;
border-bottom:2rpx solid rgb(255, 255, 255);
}
.personal_image{
z-index: 100;
position: absolute;
right:2.5%;
width: 34rpx;
height: 20rpx;
margin:40rpx 20rpx 40rpx 0;
transition: All 0.4s ease;
-webkit-transition: All 0.4s ease;
}
.rotateRight{
transform: rotate(180deg);
}
JS:
Page({
data: {
selectPerson: true,
firstPerson: '个人',
selectArea: false,
},
//点击选择类型
clickPerson: function () {
var selectPerson = this.data.selectPerson;
if (selectPerson == true) {
this.setData({
selectArea: true,
selectPerson: false,
})
} else {
this.setData({
selectArea: false,
selectPerson: true,
})
}
},
//点击切换
mySelect: function (e) {
this.setData({
firstPerson: e.target.dataset.me,
selectPerson: true,
selectArea: false,
})
},
})