Skip to content

Instantly share code, notes, and snippets.

@Manuel5cc
Created January 4, 2021 13:26
Show Gist options
  • Save Manuel5cc/366e9fff79d588f4e21308224693cd03 to your computer and use it in GitHub Desktop.
Save Manuel5cc/366e9fff79d588f4e21308224693cd03 to your computer and use it in GitHub Desktop.
Generador enlaces whatsapp
<!DOCTYPE html>
<html lang="es" >
<head>
<meta charset="UTF-8">
<title>Generador enlace whatsapp</title>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
</head>
<body>
<!-- partial:index.partial.html -->
<div class="container">
<div class="jumbotron">
<h1>Generador enlaces Whatsapp</h1>
<p>Envía mensajes de Whatsapp sin añadir el número a tu agenda</p>
</div>
<div id="app">
<form @submit.prevent="generateURLs">
<h2>Entrada</h2>
<div class="form-group">
<label for="url">Teléfono con prefijo pais (Ej: 34000000000)</label>
<input class="form-control" name="text" type="text" required v-model.trim="text">
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit">Generar</button>
</div>
</form>
<template v-if="success">
<h2>Salida</h2>
<div class="form-group">
<label for="url">Whatsapp <a :href="whaURL" target="_blank" rel="noopener noreferrer">Abrir</a></label>
<input name="url" type="url" class="form-control" v-model="whaURL">
</div>
</template>
</div>
</div>
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.min.js'></script><script src="./script.js"></script>
</body>
</html>
const app = new Vue({
el: '#app',
data: {
url: '',
text: '',
whaURL: '',
twitterURL: '',
linkedinURL: '',
success: false },
computed: {
encodedURL() {
return encodeURIComponent(this.url);
},
encodedText() {
return encodeURIComponent(this.text);
} },
methods: {
generateURLs(event) {
if (event.target.checkValidity()) {
this.success = true;
this.whaURL = 'https://api.whatsapp.com/send?phone=' + this.encodedText;
}
} } });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment