Skip to content

Commit 14297c1

Browse files
committed
Changed the button to the link button
1 parent 54fa94b commit 14297c1

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

projects/whatsapp_direct/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949

5050
<button type="button" class="btn btn-block btn-outline-primary" v-on:click="clearMessage()">Очистить текст сообщения</button>
5151

52-
<button type="button" class="btn btn-block btn-success" v-on:click="send">
53-
Открыть в WhatsApp
54-
</button>
52+
<a v-bind:href="whatsapp_link" class="btn btn-block btn-success" role="button">Открыть в WhatsApp</a>
5553
</div>
5654
</div>
5755
</div>
@@ -64,6 +62,9 @@
6462
<mark>0</mark>, то телефонному номеру автоматически присваивается код страны
6563
<mark>+66</mark>.
6664
</p>
65+
<p>
66+
При нажатии на кнопку "Открыть в WhatsApp", осуществляется переход по генерируемой ссылке. Эта ссылка доступна для копирования.
67+
</p>
6768
</div>
6869
</div>
6970
</div>

projects/whatsapp_direct/script.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ var app = new Vue({
66
},
77
computed: {
88
tel_numeric: function () {
9-
var numbers = this.tel.replace(/\D/g,'')
10-
9+
var numbers = this.tel.replace(/\D/g, '')
10+
1111
if (numbers.charAt(0) == "0")
1212
numbers = numbers.replace("0", "66")
1313

1414
return numbers
1515
},
1616
message_encoded: function () {
1717
return encodeURI(this.message).replace(/%5B/g, '[').replace(/%5D/g, ']')
18+
},
19+
whatsapp_link: function () {
20+
return 'https://api.whatsapp.com/send?phone=' + this.tel_numeric + '&text=' + this.message_encoded
1821
}
1922
},
2023
methods: {
21-
send: function () {
22-
window.location.href = 'https://api.whatsapp.com/send?phone=' + this.tel_numeric + '&text=' + this.message_encoded
23-
},
24-
saveTel: function() {
24+
saveTel: function () {
2525
localStorage.setItem('tel', this.tel)
2626
},
27-
saveMessage: function() {
27+
saveMessage: function () {
2828
localStorage.setItem('message', this.message)
2929
},
3030
clearTel: function () {

0 commit comments

Comments
 (0)