5 changed files with 224 additions and 10 deletions
@ -0,0 +1,38 @@ |
|||||
|
<template> |
||||
|
<svg fill="currentColor" :height="h" :width="w" xmlns="http://www.w3.org/2000/svg" |
||||
|
viewBox="0 0 300.005 300.005" xml:space="preserve"> |
||||
|
<g> |
||||
|
<g> |
||||
|
<g> |
||||
|
<circle cx="185.974" cy="132.664" r="8.642"/> |
||||
|
<rect x="123.419" y="94.979" width="36.3" height="15.562"/> |
||||
|
<path d="M150,0C67.159,0,0.002,67.162,0.002,150S67.159,300.005,150,300.005S300.003,232.841,300.003,150S232.841,0,150,0z |
||||
|
M230.387,174.466h-9.163c-4.23,11.415-11.433,21.504-20.967,29.417l6.863,6.863c6.105,6.105,6.105,16,0,22.1 |
||||
|
c-6.105,6.105-16.003,6.105-22.106,0l-13.925-13.925c-7.436,2.046-15.435,3.154-23.882,3.154c-6.767,0-13.243-0.721-19.385-2.057 |
||||
|
l-12.831,12.828c-6.105,6.105-16,6.105-22.103,0c-6.105-6.103-6.105-15.998,0-22.1l4.404-4.404 |
||||
|
C79.619,193.218,68.9,173.076,68.9,150.475c0-9.947,2.077-19.419,5.906-28.029c-18.01-1.245-25.259-13.622-26.572-20.342 |
||||
|
c-0.822-4.217,1.93-8.305,6.147-9.127c4.16-0.82,8.209,1.867,9.096,6.002c0.353,1.403,2.643,8.027,14.301,8.027 |
||||
|
c1.935,0,3.683,0.731,5.042,1.901c13.751-18.176,36.7-30.039,64.387-30.039c4.988,0,9.799,0.42,14.449,1.157l40.048-15.3 |
||||
|
l-8.02,27.467c12.807,8.44,22.401,20.37,27.552,34.288h9.148c6.873,0,12.447,5.571,12.447,12.447v23.094h0.003 |
||||
|
C242.832,168.893,237.262,174.466,230.387,174.466z"/> |
||||
|
</g> |
||||
|
</g> |
||||
|
</g> |
||||
|
</svg> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "PromocodeSvg", |
||||
|
props: { |
||||
|
w: { |
||||
|
type: String, |
||||
|
default: "512px" |
||||
|
}, |
||||
|
h: { |
||||
|
type: String, |
||||
|
default: "60%" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,154 @@ |
|||||
|
<template> |
||||
|
<md-dialog :md-active.sync="show" @close="show=false"> |
||||
|
<div class="md-layout md-alignment-bottom-center"> |
||||
|
<div class="md-layout-item md-size-100 md-small-size-100 md-alignment-bottom-center rounded-only"> |
||||
|
<h1 v-if="loading" style="text-align: center">Загрузка</h1> |
||||
|
<div v-else> |
||||
|
<div v-if="success.length>0"> |
||||
|
<h3 style="text-align: center">Промокод активирован</h3> |
||||
|
<h5 style="text-align: center">{{success}}</h5> |
||||
|
<md-button style="float: right" class="btn-default" v-on:click="showMe(false)">Отлично...</md-button> |
||||
|
</div> |
||||
|
<div v-else> |
||||
|
<md-field :class="promoField"> |
||||
|
<label>Введи промокод</label> |
||||
|
<md-input v-model="promocode"></md-input> |
||||
|
<span class="md-error" style="color: #FAFAFA">{{this.error}}</span> |
||||
|
</md-field> |
||||
|
<md-button style="float: left" class="btn-strange" v-on:click="activatePromo()">Активировать</md-button> |
||||
|
<md-button style="float: right" class="btn-default" v-on:click="showMe(false)">Я передумал</md-button> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!--<h5 v-else style="padding: 0% 5%; text-align: center">{{result}}</h5> |
||||
|
--> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="md-layout md-alignment-bottom-center" v-if="$API.admin.permition.z || success.length===0" style="padding-top: 5%"> |
||||
|
<div class="md-layout-item md-size-100 md-small-size-100 md-alignment-bottom-center rounded-only"> |
||||
|
<h4>Генерировать промокоды</h4> |
||||
|
<div> |
||||
|
<md-field> |
||||
|
<label for="movie">Тип промокода</label> |
||||
|
<md-select v-model="promogen_type"> |
||||
|
<md-option value="vip">VIP</md-option> |
||||
|
</md-select> |
||||
|
</md-field> |
||||
|
<md-field v-if="promogen_type === 'vip'"> |
||||
|
<label>Количество минут</label> |
||||
|
<md-input v-model="promogen_value"/> |
||||
|
</md-field> |
||||
|
<md-field> |
||||
|
<label>Событие</label> |
||||
|
<md-input v-model="promogen_append" required/> |
||||
|
</md-field> |
||||
|
<md-button class="btn-hand" v-on:click="createPromo()">Создать</md-button> |
||||
|
<md-button class="btn-boss" v-on:click="actualPromo()">Получить текущие</md-button> |
||||
|
<md-button class="btn-unusual" v-on:click="clearPromo()">Очистить</md-button> |
||||
|
<md-field v-if="promogen_result.length>0"> |
||||
|
<label>Результат</label> |
||||
|
<md-textarea readonly v-model="promogen_result"/> |
||||
|
</md-field> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</md-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import axios from "axios"; |
||||
|
import Random from "@/api/Random"; |
||||
|
|
||||
|
export default { |
||||
|
name: "PromocodeDialog", |
||||
|
data: () => ({ |
||||
|
show: false, |
||||
|
loading: false, |
||||
|
promocode: "", |
||||
|
error:"", |
||||
|
success:"", |
||||
|
/////////// |
||||
|
promogen_type:"", |
||||
|
promogen_value:60, |
||||
|
promogen_append:"GOYDA", |
||||
|
promogen_result: "" |
||||
|
}), |
||||
|
methods: { |
||||
|
showMe(action) { |
||||
|
this.show = action === undefined ? !this.show : action; |
||||
|
}, |
||||
|
clearPromo() { |
||||
|
this.promogen_result = ""; |
||||
|
}, |
||||
|
createPromo() { |
||||
|
axios.post("api/promocode?action="+this.promogen_type+":"+`${this.promogen_value*60}`+"&append="+this.promogen_append+Random.getRndWebAppend()) |
||||
|
.then(response => { |
||||
|
this.promogen_result += response.data + ` ${this.promogen_type.toUpperCase()} ${this.promogen_value} минут \n`; |
||||
|
}) |
||||
|
}, |
||||
|
actualPromo() { |
||||
|
axios.get("api/promocode" + Random.getRndWebNew()) |
||||
|
.then(response => { |
||||
|
for (const code in response.data) { |
||||
|
const a = response.data[code].split(":"); |
||||
|
this.promogen_result += code + ` ${a[0].toUpperCase()} ${Math.round(a[1]/60)} минут \n`; |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
activatePromo() { |
||||
|
this.loading = true; |
||||
|
axios.put("api/promocode?code=" + this.promocode + Random.getRndWebAppend()) |
||||
|
.then(response => { |
||||
|
console.log(response) |
||||
|
switch (response.status) { |
||||
|
case 200: { |
||||
|
this.success = "Твоя випка продлена"; |
||||
|
break; |
||||
|
} |
||||
|
case 201: { |
||||
|
this.success = "Развлекайся бро..."; |
||||
|
break; |
||||
|
} |
||||
|
case 204: { |
||||
|
this.success = "Промокод деактивирован"; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
.catch(error => { |
||||
|
console.log("error",error.response); |
||||
|
switch (error.response.status) { |
||||
|
case 404: { |
||||
|
this.error = "Промокод не найден"; |
||||
|
break; |
||||
|
} |
||||
|
case 423: { |
||||
|
this.error = "Промокод заблокирован"; |
||||
|
break; |
||||
|
} |
||||
|
case 410: { |
||||
|
this.error = "Промокод уже активирован"; |
||||
|
break; |
||||
|
} |
||||
|
case 418: { |
||||
|
this.error = "Ясно автору 7 лет"; |
||||
|
break; |
||||
|
} |
||||
|
case 409: { |
||||
|
this.error = "Стоит подождать сутки, прежде чем активировать другой промокод"; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
.finally(() => { |
||||
|
this.loading = false; |
||||
|
console.log(this.success, this.error); |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
promoField() { |
||||
|
return { 'md-invalid' : this.error.length>0} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
Loading…
Reference in new issue