|
@@ -10,15 +10,22 @@
|
|
|
class="version"
|
|
|
:value="product.id"
|
|
|
>
|
|
|
- <i :class="`icon-${1 ? 'lite' : 'pro'}`"></i>
|
|
|
+ <i
|
|
|
+ class="version-icon"
|
|
|
+ :style="{ backgroundImage: `url(${product.image})` }"
|
|
|
+ ></i>
|
|
|
<span class="mt18">{{ product.name }}</span>
|
|
|
</PtcRadio>
|
|
|
</PtcRadioGroup>
|
|
|
<div
|
|
|
class="version-desc"
|
|
|
- :class="{ second: state.form.product_id === 'pro' }"
|
|
|
+ :class="{
|
|
|
+ second:
|
|
|
+ state.productList[1] &&
|
|
|
+ state.form.product_id === state.productList[1].id,
|
|
|
+ }"
|
|
|
>
|
|
|
- {{ selectedProduct.remark }}
|
|
|
+ {{ getters.selectedProduct.remark }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -27,18 +34,20 @@
|
|
|
<p class="ptc-label">Choose a subscription method</p>
|
|
|
<PtcRadioGroup v-model="state.form.subscribe_type">
|
|
|
<PtcRadio class="method" value="year">
|
|
|
- <span class="cost">${{ selectedProduct.amount_year }}</span>
|
|
|
+ <span class="cost">${{ getters.selectedProduct.amount_year }}</span>
|
|
|
<span class="name">Annual</span>
|
|
|
<span class="ptc-tag"
|
|
|
- >-{{ selectedProduct.better_than_monthly }}% OFF</span
|
|
|
+ >-{{ getters.selectedProduct.better_than_monthly }}% OFF</span
|
|
|
>
|
|
|
</PtcRadio>
|
|
|
<PtcRadio class="method" value="month">
|
|
|
- <span class="cost">${{ selectedProduct.amount_month }}</span>
|
|
|
+ <span class="cost"
|
|
|
+ >${{ getters.selectedProduct.amount_month }}</span
|
|
|
+ >
|
|
|
<span class="name">
|
|
|
- Monthly<template v-if="+selectedProduct.amount_month_open"
|
|
|
+ Monthly<template v-if="+getters.selectedProduct.amount_month_open"
|
|
|
> Activation fee ${{
|
|
|
- selectedProduct.amount_month_open
|
|
|
+ getters.selectedProduct.amount_month_open
|
|
|
}}</template
|
|
|
></span
|
|
|
>
|
|
@@ -49,7 +58,7 @@
|
|
|
<div class="ptc-block">
|
|
|
<div class="ptc-inner">
|
|
|
<p class="ptc-label">Do you have a discount code?</p>
|
|
|
- <div v-if="!showCoupon" class="input-wrap pr">
|
|
|
+ <div v-if="!state.discount" class="input-wrap pr">
|
|
|
<input
|
|
|
v-model="state.form.discount_code"
|
|
|
class="ptc-input"
|
|
@@ -60,8 +69,8 @@
|
|
|
<div v-else class="coupon-wrap">
|
|
|
<div class="coupon">
|
|
|
<p class="p1">PTC CARE PLUS</p>
|
|
|
- <p class="p2">NEWCOMER DISCOUNT</p>
|
|
|
- <p class="p3">- $10</p>
|
|
|
+ <p class="p2">{{ state.discount.name }}</p>
|
|
|
+ <p class="p3">- ${{ state.discount.discount_amount }}</p>
|
|
|
</div>
|
|
|
<div class="action">
|
|
|
<span class="code">{{ state.form.discount_code }}</span>
|
|
@@ -72,11 +81,13 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="total">
|
|
|
- <div v-if="cost" class="ptc-inner">
|
|
|
+ <div v-if="getters.cost" class="ptc-inner">
|
|
|
<p>
|
|
|
- total<strong>${{ cost }}</strong>
|
|
|
+ total<strong>${{ getters.cost }}</strong>
|
|
|
+ </p>
|
|
|
+ <p v-if="state.discount" class="highlight">
|
|
|
+ (${{ state.discount.discount_amount }} discounted)
|
|
|
</p>
|
|
|
- <p class="highlight">($10 discounted)</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="ptc-button-group">
|
|
@@ -88,32 +99,15 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, computed } from 'vue'
|
|
|
import { PtcRadioGroup, PtcRadio } from '@/components/radio'
|
|
|
-import { state, getBrandList } from './store'
|
|
|
+import { state, getters, getBrandList } from './store'
|
|
|
import * as api from '@/service/order'
|
|
|
import Toast from '@/components/toast'
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
- (e: 'next'): void
|
|
|
+ (e: 'go', delta?: number): void
|
|
|
}>()
|
|
|
|
|
|
-const showCoupon = ref(false)
|
|
|
-const selectedProduct = computed(() =>
|
|
|
- state.productList.find(item => item.id === state.form.product_id)
|
|
|
-)
|
|
|
-const cost = computed(() => {
|
|
|
- const { amount_year, amount_month, amount_month_open } = selectedProduct.value
|
|
|
- switch (state.form.subscribe_type) {
|
|
|
- case 'year':
|
|
|
- return amount_year
|
|
|
- case 'month':
|
|
|
- return (+amount_month + +amount_month_open).toFixed(2)
|
|
|
- default:
|
|
|
- return ''
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
async function checkDiscount() {
|
|
|
if (!state.form.discount_code) return Toast('Please enter promotional code')
|
|
|
try {
|
|
@@ -121,20 +115,21 @@ async function checkDiscount() {
|
|
|
state.form.discount_code
|
|
|
)
|
|
|
Toast(message)
|
|
|
- showCoupon.value = true
|
|
|
+ state.discount = results
|
|
|
} catch {
|
|
|
state.form.discount_code = ''
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function reviseDiscount() {
|
|
|
- showCoupon.value = false
|
|
|
+ state.discount = null
|
|
|
state.form.discount_code = ''
|
|
|
}
|
|
|
|
|
|
async function next() {
|
|
|
if (!state.brandList.length) await getBrandList()
|
|
|
- emit('next')
|
|
|
+ emit('go')
|
|
|
+ if (!state.discount) state.form.discount_code = ''
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -150,6 +145,12 @@ async function next() {
|
|
|
font-size: 56px;
|
|
|
font-weight: bold;
|
|
|
|
|
|
+ &-icon {
|
|
|
+ width: 36px;
|
|
|
+ height: 36px;
|
|
|
+ background-size: contain;
|
|
|
+ }
|
|
|
+
|
|
|
.mt18 {
|
|
|
margin-top: 18px;
|
|
|
}
|