|
@@ -1,65 +1,131 @@
|
|
|
<template>
|
|
|
<div class="p-my-order">
|
|
|
<h3 class="ptc-title">My Order</h3>
|
|
|
- <div class="ptc-block wrapper" :class="{ pb24: 1 }">
|
|
|
- <div>
|
|
|
+ <div
|
|
|
+ v-for="item of list"
|
|
|
+ :key="item.id"
|
|
|
+ class="ptc-block wrapper"
|
|
|
+ :class="{ pb24: item.status !== 1 }"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ class="pointer"
|
|
|
+ @click="item.status === 1 && $router.push(`/order/${item.id}`)"
|
|
|
+ >
|
|
|
<div class="cell-group border-bottom">
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Order Status</span>
|
|
|
<span class="cell__value">
|
|
|
<span
|
|
|
class="ptc-tag"
|
|
|
- :class="{ 'not-paid': 1, paid: 0, canceled: 0 }"
|
|
|
- >Not Paid</span
|
|
|
+ :class="{
|
|
|
+ 'not-paid': item.status === 0,
|
|
|
+ paid: item.status === 1,
|
|
|
+ canceled: item.stauts > 1,
|
|
|
+ }"
|
|
|
+ >{{
|
|
|
+ item.status === 0
|
|
|
+ ? 'Not Paid'
|
|
|
+ : item.status === 1
|
|
|
+ ? 'Paid'
|
|
|
+ : 'Canceled'
|
|
|
+ }}</span
|
|
|
>
|
|
|
</span>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Order Number</span>
|
|
|
- <span class="cell__value">12345678910</span>
|
|
|
+ <span class="cell__value">{{ item.contract_no }}</span>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Order Time</span>
|
|
|
- <span class="cell__value">2021/08/20 12:34</span>
|
|
|
+ <span class="cell__value">{{ item.created_at }}</span>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Phone brand</span>
|
|
|
- <span class="cell__value">Apple iphone 12</span>
|
|
|
+ <span class="cell__value">{{ item.phone_info }}</span>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Version</span>
|
|
|
- <span class="cell__value">Lite(2022/7/31 Expires)</span>
|
|
|
+ <span class="cell__value"
|
|
|
+ >{{ item.product_name }}({{ item.end_time }} Expires)</span
|
|
|
+ >
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cell-group cell-group--compact">
|
|
|
- <template v-if="1">
|
|
|
+ <template v-if="item.status < 2">
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Activation fee</span>
|
|
|
- <span class="cell__value">$20.00</span>
|
|
|
+ <span class="cell__value">${{ item.payment_open }}</span>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Membership fee</span>
|
|
|
- <span class="cell__value">$8.95</span>
|
|
|
+ <span class="cell__value">${{ item.payment_product }}</span>
|
|
|
</div>
|
|
|
<div class="cell">
|
|
|
<span class="cell__label">Discount</span>
|
|
|
- <span class="cell__value highlight">-$10.00</span>
|
|
|
+ <span class="cell__value highlight"
|
|
|
+ >-${{ item.discount_amount }}</span
|
|
|
+ >
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="cell" :class="{ mt48: 1 }">
|
|
|
<span class="cell__label">Cost</span>
|
|
|
- <span class="cell__value bold">$18.95</span>
|
|
|
+ <span class="cell__value bold">${{ item.payment_amount }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="button-group">
|
|
|
- <button class="ptc-button">Pay 14:40</button>
|
|
|
- <button class="ptc-button ptc-button--stroke">Cancel</button>
|
|
|
+ <div v-if="item.status !== 1" class="button-group">
|
|
|
+ <template v-if="item.status === 0">
|
|
|
+ <button class="ptc-button">Pay 14:40</button>
|
|
|
+ <button
|
|
|
+ class="ptc-button ptc-button--stroke"
|
|
|
+ @click="cancelOrder(item)"
|
|
|
+ >
|
|
|
+ Cancel
|
|
|
+ </button>
|
|
|
+ </template>
|
|
|
+ <button
|
|
|
+ v-else
|
|
|
+ class="ptc-button ptc-button--stroke"
|
|
|
+ @click="deleteOrder(item)"
|
|
|
+ >
|
|
|
+ Delete
|
|
|
+ </button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
+<script>
|
|
|
+import { defineComponent } from 'vue'
|
|
|
+import * as api from '@/service/order'
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'OrderList',
|
|
|
+ async beforeRouteEnter(to, from, next) {
|
|
|
+ const { results } = await api.getOrderList()
|
|
|
+ next(vm => (vm.list = results))
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ /** @type {any[]} */
|
|
|
+ list: [],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async cancelOrder(item) {
|
|
|
+ await api.cancelOrder(item.id)
|
|
|
+ item.status = 2
|
|
|
+ },
|
|
|
+
|
|
|
+ async deleteOrder(item) {
|
|
|
+ await api.deleteOrder(item.id)
|
|
|
+ this.list.splice(this.list.indexOf(item), 1)
|
|
|
+ },
|
|
|
+ },
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
<style lang="scss">
|
|
|
.p-my-order {
|
|
|
background: #f7f7f7;
|