|
@@ -3,33 +3,43 @@
|
|
|
<div class="ptc-block">
|
|
|
<div class="ptc-inner">
|
|
|
<p class="ptc-label">Choose a version</p>
|
|
|
- <PtcRadioGroup v-model="state.product" style="display: flex">
|
|
|
- <PtcRadio class="version" value="lite">
|
|
|
- <i class="icon-lite"></i>
|
|
|
- <span class="mt18">Lite</span>
|
|
|
- </PtcRadio>
|
|
|
- <PtcRadio class="version" value="pro">
|
|
|
- <i class="icon-pro"></i>
|
|
|
- <span class="mt18">Pro</span>
|
|
|
+ <PtcRadioGroup v-model="state.form.product_id" style="display: flex">
|
|
|
+ <PtcRadio
|
|
|
+ v-for="product of state.productList"
|
|
|
+ :key="product.id"
|
|
|
+ class="version"
|
|
|
+ :value="product.id"
|
|
|
+ >
|
|
|
+ <i :class="`icon-${1 ? 'lite' : 'pro'}`"></i>
|
|
|
+ <span class="mt18">{{ product.name }}</span>
|
|
|
</PtcRadio>
|
|
|
</PtcRadioGroup>
|
|
|
- <div class="version-desc" :class="{ pro: state.product === 'pro' }">
|
|
|
- Introduction of member products,Introduction of member products
|
|
|
+ <div
|
|
|
+ class="version-desc"
|
|
|
+ :class="{ pro: state.form.product_id === 'pro' }"
|
|
|
+ >
|
|
|
+ {{ selectedProduct.remark }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="ptc-block">
|
|
|
<div class="ptc-inner">
|
|
|
<p class="ptc-label">Choose a subscription method</p>
|
|
|
- <PtcRadioGroup v-model="state.type">
|
|
|
- <PtcRadio class="method" :value="1">
|
|
|
- <span class="cost">$99</span>
|
|
|
+ <PtcRadioGroup v-model="state.form.subscribe_type">
|
|
|
+ <PtcRadio class="method" value="year">
|
|
|
+ <span class="cost">${{ selectedProduct.amount_year }}</span>
|
|
|
<span class="name">Annual</span>
|
|
|
- <span class="ptc-tag">-25% OFF</span>
|
|
|
+ <span class="ptc-tag"
|
|
|
+ >-{{ selectedProduct.better_than_monthly * 100 }}% OFF</span
|
|
|
+ >
|
|
|
</PtcRadio>
|
|
|
- <PtcRadio class="method" :value="2">
|
|
|
- <span class="cost">$12.5</span>
|
|
|
- <span class="name"> Monthly Activation fee $20</span>
|
|
|
+ <PtcRadio class="method" value="month">
|
|
|
+ <span class="cost">${{ selectedProduct.amount_month }}</span>
|
|
|
+ <span class="name">
|
|
|
+ Monthly Activation fee ${{
|
|
|
+ selectedProduct.amount_month_open
|
|
|
+ }}</span
|
|
|
+ >
|
|
|
</PtcRadio>
|
|
|
</PtcRadioGroup>
|
|
|
</div>
|
|
@@ -39,11 +49,11 @@
|
|
|
<p class="ptc-label">Do you have a discount code?</p>
|
|
|
<div v-if="!showCoupon" class="input-wrap pr">
|
|
|
<input
|
|
|
- v-model="state.couponCode"
|
|
|
+ v-model="state.form.discount_code"
|
|
|
class="ptc-input"
|
|
|
placeholder="Enter promotional code"
|
|
|
/>
|
|
|
- <button class="input-btn" @click="showCoupon = true">sbumit</button>
|
|
|
+ <button class="input-btn" @click="checkDiscount">sbumit</button>
|
|
|
</div>
|
|
|
<div v-else class="coupon-wrap">
|
|
|
<div class="coupon">
|
|
@@ -52,8 +62,8 @@
|
|
|
<p class="p3">- $10</p>
|
|
|
</div>
|
|
|
<div class="action">
|
|
|
- <span class="code">87889122</span>
|
|
|
- <span class="primary" @click="showCoupon = false">Revise</span>
|
|
|
+ <span class="code">{{ state.form.discount_code }}</span>
|
|
|
+ <span class="primary" @click="reviseDiscount">Revise</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -61,28 +71,66 @@
|
|
|
|
|
|
<div class="total">
|
|
|
<div class="ptc-inner">
|
|
|
- <p>total<strong>$99</strong></p>
|
|
|
+ <p>
|
|
|
+ total<strong>${{ cost }}</strong>
|
|
|
+ </p>
|
|
|
<p class="highlight">($10 discounted)</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="ptc-button-group">
|
|
|
<div class="ptc-inner">
|
|
|
- <button class="ptc-button" @click="$emit('next')">NEXT</button>
|
|
|
+ <button class="ptc-button" @click="next">NEXT</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref } from 'vue'
|
|
|
+import { ref, computed } from 'vue'
|
|
|
import { PtcRadioGroup, PtcRadio } from '@/components/radio'
|
|
|
-import { state } from './store'
|
|
|
+import { state, getBrandList } from './store'
|
|
|
+import * as api from '@/service/order'
|
|
|
+import Toast from '@/components/toast'
|
|
|
|
|
|
-defineEmits<{
|
|
|
+const emit = defineEmits<{
|
|
|
(e: 'next'): 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
|
|
|
+ default:
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+async function checkDiscount() {
|
|
|
+ if (!state.form.discount_code) return Toast('Please enter promotional code')
|
|
|
+ try {
|
|
|
+ const { results } = await api.checkDiscount(state.form.discount_code)
|
|
|
+ showCoupon.value = true
|
|
|
+ } catch {
|
|
|
+ state.form.discount_code = ''
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function reviseDiscount() {
|
|
|
+ showCoupon.value = false
|
|
|
+ state.form.discount_code = ''
|
|
|
+}
|
|
|
+
|
|
|
+async function next() {
|
|
|
+ if (!state.brandList.length) await getBrandList()
|
|
|
+ emit('next')
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|