Files
aida_front/src/component/HomePage/renew.vue

544 lines
14 KiB
Vue
Raw Normal View History

2024-12-11 16:26:36 +08:00
<template>
<div class="renew" ref="renew"></div>
<a-modal
class="generalModel"
:get-container="() => $refs.renew"
v-model:visible="renewModel"
:footer="null"
:width="pageWidth"
height="auto"
:maskClosable="false"
:centered="true"
:closable="false"
:mask="renewModelMask"
:keyboard="false"
:destroyOnClose="true"
:zIndex="1000"
>
<div class="generalModel_btn">
<div class="generalModel_closeIcon" @click.stop="cancelDsign()">
<!-- <i class="fi fi-rr-cross-small"></i> -->
<svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
2025-01-07 17:15:28 +08:00
<circle cx="23" cy="23" r="23" fill="white" fill-opacity="0.3"/>
<rect x="32.5063" y="12" width="3" height="29" rx="1.5" transform="rotate(45 32.5063 12)" fill="white"/>
<rect x="34.6274" y="32.5059" width="3" height="29" rx="1.5" transform="rotate(135 34.6274 32.5059)" fill="white"/>
</svg>
2024-12-11 16:26:36 +08:00
</div>
</div>
<div class="renewContent">
<div class="generalModelTitle">
2024-12-23 16:23:18 +08:00
{{ $t('Renew.title') }}
2024-12-11 16:26:36 +08:00
</div>
<div class="renew_detail">
2025-02-17 15:24:01 +08:00
<div class="name generalModelTitle">{{ current?.title }}</div>
2024-12-11 16:26:36 +08:00
<div class="price_box">
<div class="price">
<sub>$</sub>
2025-02-17 15:24:01 +08:00
{{ current?.price[current?.type] }} <span>{{ current?.unit[current?.type] }}</span>
2024-12-11 16:26:36 +08:00
</div>
<div class="type" v-if="current.typeList.length > 1">
<label>
<input name="pric" type="radio" value="monthly" v-model="current.type" @change="setPricType('monthly')">
2024-12-23 16:23:18 +08:00
{{ $t('Renew.Monthly') }}
2024-12-11 16:26:36 +08:00
</label>
<label>
<input name="pric" type="radio" value="year" v-model="current.type" @change="setPricType('year')">
2024-12-23 16:23:18 +08:00
{{ $t('Renew.Yearly') }}
2024-12-11 16:26:36 +08:00
</label>
</div>
2025-04-16 10:43:54 +08:00
<div class="type promotion">
<div class="text">{{ $t('Renew.promotionCode') }}:</div>
<div class="succeed" v-show="promotionData.error == 'true'">
{{promotionData.code}}
<i class="fi fi-sr-times-hexagon" @click="clearPromotionCode"></i>
</div>
<div class="input" v-show="!promotionData.error || promotionData.error == 'false'">
<input type="text" v-model="promotionData.code">
<div style="cursor: pointer;" @click="examine">{{ $t('Renew.use') }}</div>
</div>
<div class="error" v-show="promotionData.error == 'false'">{{promotionData.str}}</div>
</div>
2025-02-20 09:26:11 +08:00
<div class="type payment">
<div class="text">{{ $t('Renew.Payment') }}:</div>
<label>
<input name="payment" type="radio" value="CreditCard" v-model="current.PaymentType" @change="setPaymentType('CreditCard')">
{{ $t('Renew.CreditCard') }}
</label>
<label>
<input name="payment" type="radio" value="Alipay" v-model="current.PaymentType" @change="setPaymentType('Alipay')">
{{ $t('Renew.Alipay') }}
</label>
</div>
<!-- <div class="autoRenewal">
2025-02-17 15:24:01 +08:00
<label>
{{ current.autoRenewal.text }} :
<a-switch v-model:checked="current.autoRenewal.value" />
</label>
2025-02-20 09:26:11 +08:00
</div> -->
2025-02-17 15:24:01 +08:00
<div class="info">{{ current?.info }}</div>
2025-02-20 09:26:11 +08:00
<div class="payMethod_payAffirm_clause" ref="labelDisclaimer">
<label>
<input type="checkbox" v-model="clause">
<span class="generalModelDescription">{{ $t('upgradePlan.policy1') }}<a href="https://code-create.com.hk/aida-terms-and-conditions/" target="_blank">{{ $t('upgradePlan.policy2') }}</a>{{ $t('upgradePlan.policy3') }}<a href="https://code-create.com.hk/aida-subscription-agreement/" target="_blank">{{ $t('upgradePlan.policy4') }}</a>. *</span>
</label>
</div>
2024-12-11 16:26:36 +08:00
</div>
2024-12-23 16:23:18 +08:00
<div class="gallery_btn gallery_btn_radius" @click="payment">{{ $t('Renew.SubscribeNow') }}</div>
2024-12-11 16:26:36 +08:00
</div>
<div
class="login_footer_item_text"
@click="turnToWindow(
'https://code-create.com.hk/aida-terms-and-conditions/'
)"
>
Terms&Conditions
</div>
<div
class="login_footer_item_text"
@click="turnToWindow(
'https://code-create.com.hk/aida-subscription-agreement/'
)"
>
Privacy Policy
</div>
</div>
2025-02-20 09:26:11 +08:00
<div class="mark_loading" v-show="isShowMark_">
<a-spin size="large" />
</div>
<div class="mark_loading" v-show="isShowMark" state="true">
<div class="mark_loading_title">{{ $t('upgradePlan.completed') }}</div>
<div class="mark_loading_intro">{{ $t('upgradePlan.hint') }}</div>
<div class="mark_loading_title_box">
<div class="mark_loading_btn mark_loading_btn2" @click="setPaidBack">{{ $t('upgradePlan.Back') }}</div>
<div class="mark_loading_btn" @click="completePayment">OK</div>
</div>
</div>
2024-12-11 16:26:36 +08:00
</a-modal>
2024-12-27 14:38:21 +08:00
<payMethod ref="payMethod" @completePayment="cancelDsign" type="renew"></payMethod>
2024-12-11 16:26:36 +08:00
</template>
<script lang="ts">
2025-02-14 17:41:35 +08:00
import { defineComponent,computed,reactive,toRefs ,onMounted} from "vue";
2024-12-11 16:26:36 +08:00
import { message } from "ant-design-vue";
import payMethod from "@/component/Pay/payMethod.vue";
import { useStore } from "vuex";
2024-12-23 16:23:18 +08:00
import { useI18n } from "vue-i18n";
2025-02-20 09:26:11 +08:00
import { Https } from "@/tool/https";
2024-12-11 16:26:36 +08:00
const md5 = require("md5");
export default defineComponent({
components: {
payMethod,
},
setup(){
const store = useStore();
2024-12-23 16:23:18 +08:00
const {t} = useI18n()
2024-12-11 16:26:36 +08:00
let renew = reactive({
renewModel:false,
renewModelMask:true,
pageWidth:'50%'
})
2025-02-20 09:26:11 +08:00
let payMethodData = reactive({
clause:false,
labelDisclaimer:null,
newWindow:null as any,
isShowMark:false,
isShowMark_:false,
})
2024-12-11 16:26:36 +08:00
let renewData = reactive({
2025-04-16 10:43:54 +08:00
promotionData:{
code:'',
error:'',
str:'',
oldPrice:'',
},
2025-02-14 17:41:35 +08:00
personage:computed(()=>{
return {
title:t('Renew.PersonalVersion'),
price:{
monthly:'500',
year:'5,000',
},
unit:{
monthly:t('Renew.HKDMonth'),
year:t('Renew.HKDYear'),
},
type:'monthly',
2025-02-20 09:26:11 +08:00
PaymentType:'',
2025-02-14 17:41:35 +08:00
typeList:['monthly','year'],
info:'Tax, VAT not included.',
}
}),
firm:computed(()=>{
return {
title:'Education Edition',
price:{
year:'500',
},
unit:{
year:'HKD / Year',
},
type:'year',
2025-02-17 15:24:01 +08:00
autoRenewal:{
text:t('Renew.automatically'),
value:true,
},
2025-02-14 17:41:35 +08:00
typeList:['year'],
info:'Customised plan',
}
}),
education:computed(()=>{
return {
title:'Enterprise Edition',
2024-12-11 16:26:36 +08:00
price:{
year:'500',
},
unit:{
year:'HKD / Year',
},
type:'year',
2025-02-17 15:24:01 +08:00
autoRenewal:{
text:t('Renew.automatically'),
value:true,
2024-12-11 16:26:36 +08:00
},
typeList:['year'],
info:'Customised plan',
2025-02-14 17:41:35 +08:00
}
}),
2024-12-11 16:26:36 +08:00
current:{
} as any,
payMethod:null as any,
})
const init = ()=>{
renew.renewModel = true
renewData.current = renewData.personage
}
const cancelDsign = () => {
renew.renewModel = false
}
const setPricType=(str:any)=>{
renewData.current.type = str
}
2025-02-20 09:26:11 +08:00
const setPaymentType = (str:any)=>{
renewData.current.PaymentType = str
}
2024-12-11 16:26:36 +08:00
const payment = ()=>{
2025-02-20 09:26:11 +08:00
if(!payMethodData.clause){
let labelDisclaimer:any = payMethodData.labelDisclaimer
if(!labelDisclaimer.classList.contains('animation')){
labelDisclaimer.classList.add('animation')
setTimeout(() => {
labelDisclaimer.classList.remove('animation')
}, 1000);
}
return
}
2024-12-11 16:26:36 +08:00
let subscribeType = 'Year'
2025-02-20 09:26:11 +08:00
if(!renewData.current.PaymentType)return message.info(t('Renew.PleaseSelectPayment'))
2024-12-11 16:26:36 +08:00
if(renewData.current.type == 'monthly')subscribeType= 'Month'
2025-02-20 09:26:11 +08:00
// let data = {
// autoRenewal:renewData.current.PaymentType != 'Alipay',//one_time为不自动续费
// productName:'Subscription',
// subscribeType,//yearly为年费monthly为月费
// }
let url = window.location.origin+'/paySucceed'
2024-12-11 16:26:36 +08:00
let data = {
2025-02-20 09:26:11 +08:00
autoRenewal:renewData.current.PaymentType != 'Alipay',//false为不自动续费
2024-12-11 16:26:36 +08:00
productName:'Subscription',
2025-02-20 09:26:11 +08:00
quantity:1,
returnUrl:url,
subscribeType:subscribeType,//yearly为年费monthly为月费
wallet:'ALIPAYHK',
2025-04-16 10:43:54 +08:00
promotionCode:renewData.promotionData.code,
2024-12-11 16:26:36 +08:00
}
2025-02-20 09:26:11 +08:00
let httpsUrl = Https.httpUrls.payStripe
payMethodData.isShowMark_ = true
Https.axiosPost(httpsUrl,data).then(
(rv: any) => {
var width = 800;
var height = 600;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
payMethodData.newWindow = window.open("", "_blank", "width=" + width + ", height=" + height + ", left=" + left + ", top=" + top);
let herf = rv
if(payMethodData.newWindow){
payMethodData.newWindow.location.href = herf
}else{
// window.open(herf, '_blank');
window.location.href=herf;
}
payMethodData.newWindow = null
payMethodData.isShowMark = true
payMethodData.isShowMark_ = false
}
).catch(res=>{
payMethodData.isShowMark_ = false
});
// renewData.payMethod.init(data)
}
const setPaidBack = ()=>{
payMethod.payMethodModel = false
payMethodData.isShowMark = false
payMethodData.clause = false
}
const completePayment = ()=>{
renew.renewModel = false
setPaidBack()
2024-12-11 16:26:36 +08:00
}
2025-04-16 10:43:54 +08:00
const examine = ()=>{
// renewData.promotionData.error
let price = renewData.current?.price[renewData.current?.type]
const normalNumber = Number(price.replace(/,/g, ''));
if(!renewData.promotionData.code){
return
}
let data = {
promotionCode:renewData.promotionData.code,
price:normalNumber,
}
Https.axiosGet(Https.httpUrls.checkCoupon,{params:data}).then((rv:any)=>{
if(rv){
if(rv.status == "valid"){
renewData.promotionData.error = 'true'
renewData.promotionData.oldPrice = renewData.current?.price[renewData.current?.type]
renewData.current.price[renewData.current.type] = (Number(rv.discountedPrice)).toLocaleString()
}else{
renewData.promotionData.error = 'false'
renewData.promotionData.str = rv.message
}
}else{
}
})
}
const clearPromotionCode = ()=>{
renewData.promotionData.error = '';
renewData.promotionData.code = ''
renewData.current.price[renewData.current.type] = renewData.promotionData.oldPrice
renewData.promotionData.oldPrice = ''
}
2024-12-11 16:26:36 +08:00
return{
store,
...toRefs(renew),
...toRefs(renewData),
2025-02-20 09:26:11 +08:00
...toRefs(payMethodData),
2024-12-11 16:26:36 +08:00
init,
cancelDsign,
setPricType,
2025-02-20 09:26:11 +08:00
setPaymentType,
2024-12-11 16:26:36 +08:00
payment,
2025-02-20 09:26:11 +08:00
setPaidBack,
completePayment,
2025-04-16 10:43:54 +08:00
examine,
clearPromotionCode,
2024-12-11 16:26:36 +08:00
}
},
data() {
return {
};
},
methods: {
turnToWindow(url:any) {
window.open(url);
},
},
});
</script>
<style lang="less" scoped>
.renew {
.renewContent{
display: flex;
flex-direction: column;
align-items: center;
.generalModelTitle{
text-align: center;
}
.renew_detail{
width: 58rem;
2025-02-20 09:26:11 +08:00
height: 60rem;
// height: 53rem;
2024-12-11 16:26:36 +08:00
border-radius: 3rem;
margin-bottom: 5rem;
border: 2px solid #000;
padding: 6rem 3rem 5rem;
display: flex;
flex-direction: column;
.price_box{
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
justify-content: space-between;
margin-bottom: 3rem;
}
.price{
font-size: 6rem;
sub{
font-size: 2rem;
top: -3rem;
}
span{
font-size: 2rem;
}
}
.type{
display: flex;
2025-04-16 10:43:54 +08:00
&.promotion{
flex-wrap: wrap;
justify-content: center;
align-items: center;
> .succeed{
padding: 1rem;
display: flex;
align-items: center;
border-radius: 1rem;
background: #eee;
> i{
display: flex;
margin-left: 1rem;
cursor: pointer;
}
}
> .input{
display: flex;
align-items: center;
border-radius: 2rem;
border: 2px solid #000;
overflow: hidden;
padding: 0 1rem;
input{
border: none;
height: 3rem;
}
}
> .error{
color: red;
width: 100%;
text-align: center;
font-size: 1.2rem;
}
}
2025-02-20 09:26:11 +08:00
> .text{
margin-right: 2rem;
// font-weight: 600;
}
2024-12-11 16:26:36 +08:00
label{
display: flex;
align-items: center;
margin-right: 3rem;
input{
margin-right: 1rem;
}
}
2025-02-20 09:26:11 +08:00
&.payment{
label{
margin-right: 1rem;
input{
margin-right: .5rem;
}
}
}
2024-12-11 16:26:36 +08:00
label:last-child{
margin-right: 0rem;
}
}
}
.login_footer_item_text{
text-align: center;
margin-bottom: 1.5rem;
text-decoration: underline;
}
.login_footer_item_text:last-child{
margin-bottom: 0rem;
}
2025-02-20 09:26:11 +08:00
.payMethod_payAffirm_clause{
label{
cursor: pointer;
input{
margin-right: 1rem;
cursor: pointer;
vertical-align: middle;
}
span{
vertical-align: top;
a{
color: #000;
text-decoration: underline;
}
}
}
&.animation{
animation: shake .3s linear;
@keyframes shake {
0%{
transform: translateX(0px);
}
25%{
transform: translateX(-10px);
}
50%{
transform: translateX(10px);
}
75%{
transform: translateX(-10px);
}
100%{
transform: translateX(0px);
}
}
}
}
2024-12-11 16:26:36 +08:00
}
2025-02-20 09:26:11 +08:00
.mark_loading{
position: absolute;
z-index: 2;
background: #fff;
.mark_loading_title{
font-size: 3rem;
// text-decoration: underline;
font-weight: 600;
margin-bottom: 2rem;
// color: #fff;
}
.mark_loading_intro{
color: rgba(0, 0, 0, 0.6);
font-size: 1.4rem;
margin-bottom: 2rem;
text-align: center;
width: 80%;
}
.mark_loading_title_box{
display: flex;
}
.mark_loading_btn,.mark_loading_btn2{
// border: #000;
// color: #fff;
display: flex;
margin-top: 10px;
text-align: center;
border: 2px solid;
padding: 0 20px;
border-radius: 10px;
cursor: pointer;
padding: .3rem 4rem;
background: #39215b;
color: #fff;
border: none;
margin: 0 2rem;
align-items: center;
}
.mark_loading_btn2{
border: 2px solid #000;
color: #000;
background: rgba(0,0,0,0);
}
}
2024-12-11 16:26:36 +08:00
}
</style>