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,感謝您對本站的認可!
本文鏈接:http://www.newhan.cn/zhishi/a/1702501906121041.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:小程序:通訊錄列表的實現.doc
本文 PDF 下載地址:小程序:通訊錄列表的實現.pdf
| 留言與評論(共有 0 條評論) |