alipay-emulator/components/call-log/list/list.vue

878 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="call-list" :class="['call-list-'+type]">
<view v-for="(item,index) in list" :key="index" class="item"
@touchstart="touchStart($event, index)"
@touchmove="touchMove($event, index)"
@touchend="touchEnd($event, index)"
:style="{'transform': 'translateX(' + swiperList[index] + 'px)', 'transition': swiperList[index] == 0 ? 'all 0.3s' : ''}">
<view class="avatar" v-if="type!='xiaomi'">
<image v-if="type=='ios'" :src="'/static/image/call/iosAvatar.png'||item.avatar" mode=""></image>
<image v-else-if="type=='oppo'" :src="`/static/image/call/${type}StatusIcon${item.status}.png`" mode="widthFix">
</image>
<image v-else-if="type=='huawei'" :src="`/static/image/call/${type}StatusIcon${item.status}.png`"
mode="widthFix"></image>
<image v-else-if="type=='vivo'" :src="`/static/image/call/${type}StatusIcon${item.status}.png`" mode="widthFix">
</image>
</view>
<view class="infoBox">
<view class="left-box">
<view class="leftInfo">
<view class="title" :class="{'title-red':item.status==0}">
<!-- ios -->
<view class="notes" v-if="type=='ios'">
{{item.name||item.phone}}
</view>
<!-- xiaomi -->
<view class="notes" v-else-if="type=='xiaomi'">
{{item.name||item.notes||item.phone}}
<text v-if="!item.name&&item.notes">{{item.phone}}</text>
</view>
<view class="notes" v-else-if="type=='oppo'">
{{item.name||item.phone}}
</view>
<view class="notes" v-else-if="type=='huawei'">
{{item.name||item.phone}}
</view>
<view class="notes" v-else-if="type=='vivo'">
{{item.name||item.phone}}
</view>
</view>
<view class="info">
<!-- 电话 -->
<view class="phone" v-if="type=='vivo'">
{{item.notes||item.phone}}
</view>
<!-- 卡几 -->
<view class="kj" v-if="type=='oppo'||type=='huawei'">
<image :src="`/static/image/call/${type}KJ${item.kj}.png`" mode=""></image>
</view>
<!-- 时间 -->
<view class="time" v-if="type=='xiaomi'">
{{item.time}}
</view>
<!-- icon -->
<view class="status-icon" v-if="type=='ios'">
<image src="/static/image/call/iosStatusIcon.png" mode=""></image>
</view>
<!-- 地址 -->
<view class="address" v-if="type!='ios'">
{{item.address}}
</view>
<!-- 运营商 -->
<view class="yys">
{{item.yys}}
</view>
<!-- 电话 -->
<view class="phone" v-if="type=='ios'">
{{item.phone}}
</view>
<!-- 备注 -->
<view class="notes" v-if="type=='oppo'||type=='huawei'">
{{item.notes}}
</view>
</view>
</view>
</view>
<view class="right-box">
<!-- 时间 -->
<view class="time" v-if="type!='xiaomi'">
{{item.time}}
</view>
<!-- 图标 -->
<view class="icon">
<image :src="`/static/image/call/${type}RightIcon.png`" mode=""></image>
</view>
</view>
</view>
<!-- 删除按钮 -->
<view class="delete-btn" @click="deleteItem(index)">
<text class="delete-text">删除</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive, onMounted, watch } from 'vue';
const props = defineProps({
isHuise: {
type: Boolean,
default: true
},
type: {
type: String,
default: 'ios'
}
});
const list = ref([
{
"avatar": "/static/avatar/1.png",
"title": "13912345678",
"name": "李强",
"phone": "13912345678",
"phoneNotes": "电话",
"yys": "移动",
"kj": "3",
"address": "北京",
"time": "星期一",
"icon": "/static/icon/call.png",
"status": 1,
"notes": "工作往来"
},
{
"avatar": "/static/avatar/2.png",
"title": "15887654321",
"name": "王芳",
"phone": "15887654321",
"phoneNotes": "电话",
"yys": "联通",
"kj": "2",
"address": "上海",
"time": "星期二",
"icon": "/static/icon/call.png",
"status": 4,
"notes": "老朋友"
},
{
"avatar": "/static/logo.png",
"title": "18711223344",
"name": "张伟",
"phone": "18711223344",
"phoneNotes": "电话",
"yys": "移动",
"kj": "1",
"address": "广州",
"time": "星期三",
"icon": "/static/logo.png",
"status": 0,
"notes": "推销电话"
},
{
"avatar": "/static/avatar/4.png",
"title": "13644556677",
"name": "刘洋",
"phone": "13644556677",
"phoneNotes": "电话",
"yys": "电信",
"kj": "5",
"address": "深圳",
"time": "星期四",
"icon": "/static/icon/call.png",
"status": 2,
"notes": "快递小哥"
},
{
"avatar": "/static/avatar/5.png",
"title": "17788889999",
"name": "陈静",
"phone": "17788889999",
"phoneNotes": "电话",
"yys": "联通",
"kj": "2",
"address": "杭州",
"time": "星期五",
"icon": "/static/icon/call.png",
"status": 3,
"notes": "大学同学"
},
{
"avatar": "/static/logo.png",
"title": "15133334444",
"name": "赵雷",
"phone": "15133334444",
"phoneNotes": "电话",
"yys": "移动",
"kj": "4",
"address": "成都",
"time": "星期一",
"icon": "/static/logo.png",
"status": 5,
"notes": "骚扰电话"
},
{
"avatar": "/static/avatar/7.png",
"title": "18966667777",
"name": "孙丽",
"phone": "18966667777",
"phoneNotes": "电话",
"yys": "电信",
"kj": "3",
"address": "武汉",
"time": "星期二",
"icon": "/static/icon/call.png",
"status": 1,
"notes": "客户"
},
{
"avatar": "/static/avatar/8.png",
"title": "15555558888",
"name": "周涛",
"phone": "15555558888",
"phoneNotes": "电话",
"yys": "联通",
"kj": "1",
"address": "西安",
"time": "星期三",
"icon": "/static/icon/call.png",
"status": 4,
"notes": "家人"
},
{
"avatar": "/static/logo.png",
"title": "13011112222",
"name": "吴杰",
"phone": "13011112222",
"phoneNotes": "电话",
"yys": "电信",
"kj": "5",
"address": "南京",
"time": "星期四",
"icon": "/static/logo.png",
"status": 0,
"notes": "广告推销"
},
{
"avatar": "/static/avatar/10.png",
"title": "18899990000",
"name": "郑爽",
"phone": "18899990000",
"phoneNotes": "电话",
"yys": "移动",
"kj": "2",
"address": "长沙",
"time": "星期五",
"icon": "/static/icon/call.png",
"status": 2,
"notes": "同事"
},
{
"avatar": "/static/logo.png",
"title": "15712345678",
"name": "王磊",
"phone": "15712345678",
"phoneNotes": "电话",
"yys": "移动",
"kj": "3",
"address": "天津",
"time": "星期一",
"icon": "/static/logo.png",
"status": 3,
"notes": "未知号码"
},
{
"avatar": "/static/avatar/12.png",
"title": "15287654321",
"name": "李娜",
"phone": "15287654321",
"phoneNotes": "电话",
"yys": "联通",
"kj": "4",
"address": "苏州",
"time": "星期二",
"icon": "/static/icon/call.png",
"status": 5,
"notes": "健身房"
},
{
"avatar": "/static/avatar/13.png",
"title": "18799887766",
"name": "张敏",
"phone": "18799887766",
"phoneNotes": "电话",
"yys": "移动",
"kj": "1",
"address": "青岛",
"time": "星期三",
"icon": "/static/icon/call.png",
"status": 1,
"notes": "学校老师"
},
{
"avatar": "/static/logo.png",
"title": "13655443322",
"name": "刘东",
"phone": "13655443322",
"phoneNotes": "电话",
"yys": "电信",
"kj": "5",
"address": "大连",
"time": "星期四",
"icon": "/static/logo.png",
"status": 4,
"notes": "保险推销"
},
{
"avatar": "/static/avatar/15.png",
"title": "17722334455",
"name": "陈龙",
"phone": "17722334455",
"phoneNotes": "电话",
"yys": "联通",
"kj": "2",
"address": "厦门",
"time": "星期五",
"icon": "/static/icon/call.png",
"status": 0,
"notes": "外卖"
},
{
"avatar": "/static/avatar/16.png",
"title": "15166778899",
"name": "赵雅",
"phone": "15166778899",
"phoneNotes": "电话",
"yys": "移动",
"kj": "3",
"address": "宁波",
"time": "星期一",
"icon": "/static/icon/call.png",
"status": 2,
"notes": "亲戚"
},
{
"avatar": "/static/logo.png",
"title": "18911223344",
"name": "孙浩",
"phone": "18911223344",
"phoneNotes": "电话",
"yys": "电信",
"kj": "4",
"address": "郑州",
"time": "星期二",
"icon": "/static/logo.png",
"status": 3,
"notes": "房产中介"
},
{
"avatar": "/static/avatar/18.png",
"title": "15544332211",
"name": "周梅",
"phone": "15544332211",
"phoneNotes": "电话",
"yys": "联通",
"kj": "1",
"address": "沈阳",
"time": "星期三",
"icon": "/static/icon/call.png",
"status": 5,
"notes": "银行客服"
},
{
"avatar": "/static/avatar/19.png",
"title": "13099887766",
"name": "吴刚",
"phone": "13099887766",
"phoneNotes": "电话",
"yys": "电信",
"kj": "2",
"address": "济南",
"time": "星期四",
"icon": "/static/icon/call.png",
"status": 1,
"notes": "合作伙伴"
},
{
"avatar": "/static/logo.png",
"title": "18818818818",
"name": "郑丽",
"phone": "18818818818",
"phoneNotes": "电话",
"yys": "移动",
"kj": "5",
"address": "重庆",
"time": "星期五",
"icon": "/static/logo.png",
"status": 4,
"notes": "骚扰电话"
}
]);
const swiperList = ref([]); // 存储每个item的滑动距离
const startX = ref(0); // 触摸开始X坐标
const startY = ref(0); // 触摸开始Y坐标
const deleteWidth = ref(70); // 删除按钮宽度
onMounted(() => {
// 初始化swiperList数组
swiperList.value = new Array(list.value.length).fill(0);
});
watch(() => props.isHuise, (newValue, oldValue) => {
console.log(newValue);
});
// 触摸开始
const touchStart = (e, index) => {
startX.value = e.changedTouches[0].clientX;
startY.value = e.changedTouches[0].clientY;
// 关闭其他item的滑动
swiperList.value.forEach((item, i) => {
if (i !== index) {
swiperList.value[i] = 0;
}
});
};
// 触摸移动
const touchMove = (e, index) => {
const moveX = e.changedTouches[0].clientX;
const moveY = e.changedTouches[0].clientY;
const disX = moveX - startX.value;
const disY = moveY - startY.value;
// 判断是否为左右滑动
if (Math.abs(disX) > Math.abs(disY)) {
// 阻止默认事件,防止页面滚动
e.preventDefault();
// 计算滑动距离限制在0到-deleteWidth之间
let distance = Math.max(-deleteWidth.value, Math.min(0, disX));
swiperList.value[index] = distance;
}
};
// 触摸结束
const touchEnd = (e, index) => {
const endX = e.changedTouches[0].clientX;
const disX = endX - startX.value;
// 判断是否滑动超过一半
if (disX < -deleteWidth.value / 2) {
swiperList.value[index] = -deleteWidth.value;
} else {
swiperList.value[index] = 0;
}
};
// 删除item
const deleteItem = (index) => {
// 显示确认弹窗
uni.showModal({
title: '确认删除',
content: '确定要删除这条通话记录吗?',
confirmText: '删除',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
// 删除item
list.value.splice(index, 1);
// 更新swiperList
swiperList.value.splice(index, 1);
}
}
});
};
</script>
<style lang="scss" scoped>
.call-list {
width: 100vw;
overflow: hidden;
box-sizing: border-box;
background-color: #fff;
.item {
display: flex;
position: relative;
width: 100%;
.avatar {
width: 80rpx;
height: 80rpx;
image {
width: 100% !important;
height: 100% !important;
}
}
.infoBox {
width: calc(100% - 80rpx);
display: flex;
justify-content: space-between;
align-items: center;
background-color: #fff;
.left-box {
display: flex;
justify-content: flex-start;
align-items: center;
.leftInfo {
.title {
font-size: 32rpx;
color: #333;
margin-bottom: 10rpx;
}
.info {
display: flex;
font-size: 28rpx;
color: #666;
view {
margin-right: 10rpx;
}
.kj {
line-height: 0;
width: 22rpx;
height: 22rpx;
image {
width: 100%;
height: 100%;
}
}
.status-icon {
line-height: 0;
width: 22rpx;
height: 22rpx;
image {
width: 100%;
height: 100%;
}
}
}
}
}
.right-box {
display: flex;
justify-content: flex-end;
align-items: center;
.time {
font-size: 28rpx;
color: #666;
}
.icon {
width: 40rpx;
height: 40rpx;
overflow: hidden;
margin-left: 20rpx;
image {
width: 100%;
height: 100%;
}
}
}
}
// 删除按钮
.delete-btn {
position: absolute;
top: 0;
right: -160rpx;
width: 160rpx;
height: 100%;
background-color: #FF3B30;
display: flex;
justify-content: center;
align-items: center;
.delete-text {
color: #fff;
font-size: 32rpx;
}
}
}
}
.call-list-ios {
.delete-btn{
right: -140rpx !important;
width: 140rpx !important;
height: 100% !important;
background-color: #FF3B30;
}
.item {
align-items: center;
justify-content: space-between;
height: 132rpx;
}
.avatar {
width: 84rpx;
height: 84rpx;
border-radius: 50%;
margin-left: 32rpx;
}
.infoBox {
width: calc(100% - 136rpx) !important;
padding: 24rpx 32rpx 24rpx 0;
height: 100%;
box-sizing: border-box;
box-shadow: inset 0 -0.3px 0 0 #C2C2C2;
.left-box {
.title {
font-weight: 400;
font-size: 16px;
color: #1A1A1A;
line-height: 16px;
}
.title-red {
color: #FC3E30 !important;
}
.info {
align-items: center;
}
.info .phone {
font-weight: 400;
font-size: 14px;
color: #838383;
line-height: 20px;
}
.info .yys {
height: 12px;
background: #C7C7C7;
border-radius: 2px 2px 2px 2px;
padding: 0 4rpx;
font-weight: 400;
font-size: 10px;
color: #FFFFFF;
line-height: 10px;
text-align: center;
}
}
.right-box {
.time {
font-weight: 400;
font-size: 14px;
color: #838383;
line-height: 14px;
}
.icon {
width: 40rpx;
height: 40rpx;
overflow: hidden;
margin-left: 14rpx;
image {
width: 100%;
height: 100%;
}
}
}
}
}
.call-list-xiaomi {
.item {
height: 140rpx;
}
.infoBox {
width: 100% !important;
padding: 34rpx 56rpx 28rpx 56rpx;
height: 100%;
box-sizing: border-box;
.title {
font-weight: 400;
font-size: 16px;
color: #1A1A1A;
text {
font-size: 13px !important;
color: #767676 !important;
}
}
.title-red {
color: #EE0115 !important;
}
.info {
view {
font-size: 13px;
color: #767676;
}
}
}
}
.call-list-oppo {
.item {
padding: 32rpx 36rpx 0 36rpx !important;
justify-content: space-between;
height: 140rpx;
}
.infoBox {
width: calc(100% - 46rpx) !important;
padding-bottom: 36rpx;
height: 100%;
box-sizing: border-box;
box-shadow: inset 0 -0.3px 0 0 #C2C2C2;
.title {
font-weight: 400;
font-size: 16px;
color: #1A1A1A;
}
.title-red {
color: #DB2C22 !important;
}
.info {
view {
font-size: 13px;
color: #767676;
}
.notes {
color: #F17A30;
}
}
.right-box {
.time {
color: #767676;
font-size: 13px;
}
}
}
.avatar {
width: 26rpx !important;
height: 26rpx !important;
border-radius: 0 !important;
image {
width: 100% !important;
height: 100% !important;
}
}
.info {
display: flex;
align-items: center;
}
}
.call-list-vivo {
.item {
padding: 36rpx 52rpx 0 36rpx !important;
justify-content: space-between;
height: 140rpx;
.infoBox {
width: calc(100% - 52rpx) !important;
padding-bottom: 32rpx;
height: 100%;
box-sizing: border-box;
box-shadow: inset 0 -0.3px 0 0 #C2C2C2;
.title {
font-weight: 400;
font-size: 16px;
color: #1A1A1A;
}
.title-red {
color: #F04E51 !important;
}
.info {
view {
font-size: 12px;
color: #8C8C8C;
}
}
.right-box {
.time {
color: #8C8C8C;
font-size: 14px;
}
}
}
}
.avatar {
width: 32rpx !important;
height: 32rpx !important;
border-radius: 0 !important;
image {
width: 100% !important;
height: 100% !important;
}
}
}
.call-list-huawei {
.item {
padding: 24rpx 32rpx 0 32rpx !important;
justify-content: space-between;
height: 120rpx;
}
.infoBox {
width: calc(100% - 52rpx) !important;
padding-bottom: 24rpx;
height: 100%;
box-sizing: border-box;
box-shadow: inset 0 -0.3px 0 0 #C2C2C2;
.title {
font-weight: 400;
font-size: 16px;
color: #1A1A1A;
}
.title-red {
color: #E83F28 !important;
}
.info {
view {
font-size: 13px;
color: #696969;
}
}
.right-box {
.time {
color: #696969;
font-size: 13px;
}
}
}
.avatar {
width: 32rpx !important;
height: 32rpx !important;
border-radius: 0 !important;
image {
width: 100% !important;
height: 100% !important;
}
}
.info {
display: flex;
align-items: center;
}
}
</style>