contactService.vue
2.5 KB
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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
<view class="contact_service">
<!-- 留言 -->
<view class="leaving_message">
<view class="">
留言:
</view>
<textarea @input="getMsg()" v-model="msg" maxlength="200" placeholder="请输入您的留言" />
<view class="word_num">({{number}}/200)</view>
</view>
<!-- 客服热线 -->
<view class="service_single">
<view class="service_number" @click="callPhone()">客服热线:<text>{{phoneNum}}</text></view>
</view>
<!-- 发送留言 -->
<view class="send_btn" @click="sendMsg()">
发送留言
</view>
</view>
</template>
<script>
import App from "../../App.vue"
export default {
data() {
return {
// 文本框
msg:"",
// 字数
number:0,
// 客服电话
phoneNum:"",
// 防连点
isClick:false
}
},
methods: {
// 输入字数
getMsg(){
this.number = this.msg.length
},
// 拨打电话
callPhone(){
uni.makePhoneCall({
phoneNumber: this.phoneNum,
});
},
// 获取客服热线
getPhone(){
let url = "/api/member/service";
App.post(url)
.then(res=>{
this.phoneNum = res.content
})
},
// 发送留言
sendMsg(){
if(!this.isClick){
this.isClick = true
let url = "/api/member/comment";
let params = {
content:this.msg
};
App.post(url,params)
.then(res=>{
uni.showToast({
title:"反馈成功",
icon:'success',
duration:1500
})
setTimeout(function(){
uni.navigateBack({
delta:1
})
},1500)
})
.catch(err=>{
this.isClick = false
})
}
},
},
onLoad() {
this.getPhone();
}
}
</script>
<style>
page{
background-color: #f9f9f9;
}
/* 留言 */
.leaving_message{
padding: 28upx 20upx;
background-color: #fff;
margin-top: 20upx;
position: relative;
font-size: 28upx;
}
textarea{
width: 100%;
padding: 20upx 0;
box-sizing: border-box;
}
.word_num{
position: absolute;
bottom: 20upx;
right: 28upx;
color: #999;
font-size: 24upx;
}
/* 客服热线 */
.service_single{
padding: 34upx 24upx;
background-color: #fff;
margin-top: 20upx;
}
.service_number{
color: #06121E;
font-size: 28upx;
}
.service_number text{
color: #3D444D;
}
/* 发送留言 */
.send_btn{
width: 100%;
height: 88upx;
line-height: 88upx;
text-align: center;
color: #fff;
background-color: #0083FB;
font-size: 30upx;
position: absolute;
bottom: 0;
left: 0;
}
</style>