2023年12月14日发(作者:幼儿园安全管理制度)
小程序:通讯录列表的实现
1.效果展示
2.源代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
input title="通讯录" @onInputChange="onChange" :back="type == 1 ? fal : true" >
class="list" v-for="(items, idx) in e" :key="idx" @click="onclick(items)" >
class="checkBox" v-if="type == 3 ? true : fal" @click="choiceItem(idx)" > color="#2D84FC" style="transform: scale(0.8)" :checked="list[idx].checked" >
1
2
3
4
5
6
7
8
9
10
import Vue from "vue";
import rve from "@/mixin/";
import { personnel } from "../../pages/order/";
export default ({
name: "x-phone",
// 1
是通讯录,
2
是选择转派人员,
3
是选择协助人员
props: ["type"],
data() {
return {
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
return {
//
后台返回的数据
res: {},
//
电话列表
phoneList: [],
returnData: [],
list: [],
//
单选框
};
},
onShow() {},
onLoad() {},
mounted() {
tactsList();
},
methods: {
//
获取通讯录列表
getContactsList() {
tactsList().then((res) => {
let data = ;
ist = data;
Data = data;
for (let i = 0, length = ; i < length; i++) {
({
checked: fal,
urName: ist[i].urName,
urId: ist[i].urId,
});
}
});
},
//
搜索功能
onChange(value) {
if (value == "") {
ist = Data;
} el {
let temp;
ist = [];
for (let i = 0, length = ; i < length; i++) {
temp = Data[i].((array) =>
(value)
);
if () {
({
deptName: Data[i].deptName,
employe: temp,
});
}
}
}
},
//
拨打电话
onclick(items) {
if ( == 1) {
let e = ;
oneCall({
//
手机号
phoneNumber: e,
//
成功回调
success: (res) => {
("调用成功!");
},
//
失败回调
fail: (res) => {
("调用失败!");
},75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
},
});
} el if ( == 2) {
Staff = ;
teBack({
url: `1`,
});
}
},
//
选择协助人员
choiceItem(idx) {
[idx].checked = ![idx].checked;
},
},
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@import "@/theme";
.address-book {
position: relative;
display: flex;
width: 100vw;
height: 100vh;
background: #fbfbfb;
flex-direction: column;
.address-box {
flex: 1;
overflow: scroll;
.listWrap {
.department {
@include ba-style(100%, 40rpx);
line-height: 40rpx;
background: #f5f5f5;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
padding-left: 30rpx;
}
.list {
height: 120rpx;
padding: 24rpx 0;
border-bottom: 1px solid #e7e7e7;
display: flex;
margin-left: 30rpx;
.profile {
@include ba-style(72rpx, 72rpx);
background: #86b1fd;
border-radius: 42rpx;
display: flex;
justify-content: center;
align-items: center;
text {
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
}
}
.info {
@include ba-style(70%, 72rpx);47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@include ba-style(70%, 72rpx);
margin-left: 20rpx;
.name {
@include ba-style(70%, 32rpx);
font-size: 32rpx;
font-weight: 400;
color: #333333;
line-height: 32rpx;
}
.phone {
@include ba-style(70%, 24rpx);
font-size: 24rpx;
font-weight: 400;
color: #999999;
line-height: 24rpx;
margin-top: 12rpx;
}
}
}
}
}
.blanck {
@include ba-style(100vw, 95rpx);
}
.submit-box {
position: fixed;
@include ba-style(100vw, 184rpx);
background: #ffffff;
left: 0;
right: 0;
bottom: 0;
padding-top: 20rpx;
button {
@include ba-style(92%, 84rpx);
bottom: 56rpx;
line-height: 84rpx;
color: #ffffff;
background: #3880ff;
font-size: 36rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
}
}
}
3.我的理解
第一,在vue文件里面,首先我不知道怎么弄两次循环获取数据以及前端是怎么设置部门及人员的排序方式,后来才知道这个是后端设置好
了部门排序以及人员排序,前端需要做的就是将数据v-for循环遍历两遍展示数据。
接着把接口调通,把里面的{{ (-2) }}换成后台返回的各个数据,就可以显示出来了。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class="list" v-for="(items, idx) in e" :key="idx" @click="onclick(items)" >
第二,搜索关键词怎么做?
这一般有两种方式,一种是接口直接调用,后台已经配置好是哪个关键字,直接用就行;还有一种就是前端自己设置,这次用的关键字是根
据名字来进行搜索的,用的是模糊查询。
1
2
3
4
5
6
1
2
3
4
5
6
input title="通讯录" @onInputChange="onChange" :back="type == 1 ? fal : true" >
//
后台返回的数据
res: {},
//
电话列表
phoneList: [], //
从后台直接获取的所有数据
returnData: [], //
搜索后得到的数据
list: [],
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
搜索功能
onChange(value) {
if (value == "") {
ist = Data;
} el {
let temp;
ist = [];
for (let i = 0, length = ; i < length; i++) {
temp = Data[i].((array) =>
(value)
);
if () {
({
deptName: Data[i].deptName,
employe: temp,
});
}
}
}
},
这段代码的filter 和 match
还有vue的filter()方法很少用,要强化vue,还有它的生命周期。
本文发布于:2023-12-14 05:11:46,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/zhishi/a/1702501906121041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:小程序:通讯录列表的实现.doc
本文 PDF 下载地址:小程序:通讯录列表的实现.pdf
留言与评论(共有 0 条评论) |