|
|
@@ -0,0 +1,444 @@
|
|
|
+<template>
|
|
|
+ <div class="order-item" @click="viewOrder">
|
|
|
+ <div class="id">
|
|
|
+ <div class="id-no">订单号:{{order.id}}</div>
|
|
|
+ <div class="status" :style="{color:status.color}">{{status.name}}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="divider"></div>
|
|
|
+ <div class="content">
|
|
|
+ <img class="cover" mode="aspectFill"
|
|
|
+ :src="order.product?order.product.banner[0]:''" />
|
|
|
+ <div class="info">
|
|
|
+ <div class="name">{{order.product?order.product.name:''}}</div>
|
|
|
+ <div class="spec">{{order.product?order.productSpec.name:''}}
|
|
|
+ </div>
|
|
|
+ <div class="price">
|
|
|
+ <price-tag :money="price" :coin="coin" :size="[11,14]"
|
|
|
+ color="#000000" long></price-tag>
|
|
|
+ <span class="amount">×{{order.amount}}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="real-pay-wrapper" v-if="showRealPay">
|
|
|
+ <div class="real-pay">
|
|
|
+ <span class="label">实际支付:</span>
|
|
|
+ <price-tag :money="order.money" :coin="order.coin"
|
|
|
+ :size="[11,14]" color="#FF7700"></price-tag>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="height:10px" v-if="!showRealPay"></div>
|
|
|
+ <div class="divider" v-if="btns.length"></div>
|
|
|
+ <div class="btns" v-if="btns.length">
|
|
|
+ <button v-for="item in btns" :class="['btn', item.class]"
|
|
|
+ :key="item.title" @click.stop.prevent="btnClick(item.title)">
|
|
|
+ {{item.title}}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Constants from '../../Constants';
|
|
|
+import PriceTag from '@/components/PriceTag';
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ order: {},
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ status: {
|
|
|
+ name: '',
|
|
|
+ },
|
|
|
+ price: 0,
|
|
|
+ coin: 0,
|
|
|
+ btns: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ console.log('created');
|
|
|
+ let status = {
|
|
|
+ name: '',
|
|
|
+ };
|
|
|
+ let btns = [];
|
|
|
+ switch (this.order.status) {
|
|
|
+ case Constants.OrderStatus.NOT_PAID:
|
|
|
+ status.name = '待支付';
|
|
|
+ btns = [
|
|
|
+ {
|
|
|
+ class: 'sec',
|
|
|
+ title: '取消订单',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ class: 'prim',
|
|
|
+ title: '立即支付',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case Constants.OrderStatus.PAID:
|
|
|
+ status.name = '已支付';
|
|
|
+ btns = [
|
|
|
+ {
|
|
|
+ class: 'border',
|
|
|
+ title: '查看订单',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case Constants.OrderStatus.DELIVERING:
|
|
|
+ status.name = '待收货';
|
|
|
+ btns = [
|
|
|
+ {
|
|
|
+ class: 'border',
|
|
|
+ title: '查看物流',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ class: 'prim',
|
|
|
+ title: '确认收货',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case Constants.OrderStatus.NOT_RATED:
|
|
|
+ status.name = '待评价';
|
|
|
+ btns = [
|
|
|
+ {
|
|
|
+ class: 'border',
|
|
|
+ title: '再次购买',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ class: 'prim',
|
|
|
+ title: '评价',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case Constants.OrderStatus.RATED:
|
|
|
+ status.name = '交易成功';
|
|
|
+ btns = [
|
|
|
+ {
|
|
|
+ class: 'border',
|
|
|
+ title: '再次购买',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case Constants.OrderStatus.CANCELED:
|
|
|
+ status.name = '已取消';
|
|
|
+ status.color = '#989898';
|
|
|
+ btns = [
|
|
|
+ {
|
|
|
+ class: 'sec',
|
|
|
+ title: '删除订单',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ this.status = status;
|
|
|
+ this.btns = btns;
|
|
|
+ if (this.order.payMode == Constants.PayMode.DISCOUNT) {
|
|
|
+ this.price = this.order.productSpec.discountPrice;
|
|
|
+ } else if (this.order.payMode == Constants.PayMode.ORIGINAL) {
|
|
|
+ this.price = this.order.productSpec.originalPrice;
|
|
|
+ }
|
|
|
+ if (this.order.payMode !== Constants.PayMode.DISCOUNT) {
|
|
|
+ this.coin = this.order.productSpec.coin;
|
|
|
+ } else {
|
|
|
+ this.coin = 0;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ showRealPay() {
|
|
|
+ return this.order.status !== Constants.OrderStatus.CANCELED && this.order.status !== Constants.OrderStatus.NOT_PAID;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ btnClick(title) {
|
|
|
+ console.log(title);
|
|
|
+ switch (title) {
|
|
|
+ case '立即支付':
|
|
|
+ this.payOrder();
|
|
|
+ break;
|
|
|
+ case '取消订单':
|
|
|
+ this.cancelOrder();
|
|
|
+ break;
|
|
|
+ case '查看订单':
|
|
|
+ this.viewOrder();
|
|
|
+ break;
|
|
|
+ case '删除订单':
|
|
|
+ this.deleteOrder();
|
|
|
+ break;
|
|
|
+ case '再次购买':
|
|
|
+ this.buyMore();
|
|
|
+ break;
|
|
|
+ case '确认收货':
|
|
|
+ this.confirmReceipt();
|
|
|
+ break;
|
|
|
+ case '评价':
|
|
|
+ this.comment();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ viewOrder() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/orderDetail/orderDetail?id=${this.order.id}`,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async cancelOrder() {
|
|
|
+ let { confirm } = await this.$wx.showModal({
|
|
|
+ content: '确认取消?',
|
|
|
+ });
|
|
|
+ if (!confirm) return;
|
|
|
+ wx.showLoading({
|
|
|
+ title: '取消订单',
|
|
|
+ mask: true,
|
|
|
+ });
|
|
|
+ this.$http
|
|
|
+ .post('/order/cancel', { id: this.order.id })
|
|
|
+ .then(res => {
|
|
|
+ wx.hideLoading();
|
|
|
+ if (!res.success) {
|
|
|
+ wx.shoToast({
|
|
|
+ title: res.error,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.$emit('refresh');
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ payOrder() {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '提交订单',
|
|
|
+ mask: true,
|
|
|
+ });
|
|
|
+ this.$http
|
|
|
+ .post('/order/pay', {
|
|
|
+ id: this.order.id,
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(res);
|
|
|
+ if (res.success) {
|
|
|
+ res.data.package = res.data.packageValue;
|
|
|
+ this.$wx
|
|
|
+ .requestPayment(res.data)
|
|
|
+ .then(res => {
|
|
|
+ console.log(res);
|
|
|
+ this.$emit('refresh');
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log(e);
|
|
|
+ this.$emit('refresh');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async deleteOrder() {
|
|
|
+ let { confirm } = await this.$wx.showModal({
|
|
|
+ content: '确认删除?',
|
|
|
+ });
|
|
|
+ if (!confirm) return;
|
|
|
+ wx.showLoading({
|
|
|
+ title: '删除订单',
|
|
|
+ mask: true,
|
|
|
+ });
|
|
|
+ this.$http
|
|
|
+ .post('/order/del', {
|
|
|
+ id: this.order.id,
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ wx.hideLoading();
|
|
|
+ if (res.success) {
|
|
|
+ this.$emit('refresh');
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.error,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ buyMore() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/productDetail/productDetail?id=${this.order.productId}`,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ confirmReceipt() {
|
|
|
+ this.$wx
|
|
|
+ .showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '是否确认收货?',
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '确认收货',
|
|
|
+ mask: true,
|
|
|
+ });
|
|
|
+ this.$http
|
|
|
+ .post('/order/confirmReceipt', {
|
|
|
+ id: this.order.id,
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ wx.hideLoading();
|
|
|
+ if (res.success) {
|
|
|
+ this.$emit('refresh');
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.error,
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ comment() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/productComment/productComment?orderId=${this.order.id}&productId=${this.order.productId}&pic=${this.order.product.banner[0]}`,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ order() {
|
|
|
+ console.log('updated');
|
|
|
+ },
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ PriceTag,
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.order-item {
|
|
|
+ margin: 0 15px 10px 15px;
|
|
|
+ padding: 0 15px;
|
|
|
+ background: white;
|
|
|
+ border-radius: 6px;
|
|
|
+ .id {
|
|
|
+ height: 43px;
|
|
|
+ .flex();
|
|
|
+ .id-no {
|
|
|
+ flex-grow: 1;
|
|
|
+ font-size: 13px;
|
|
|
+ color: @textColorPrimaryDark;
|
|
|
+ }
|
|
|
+ .status {
|
|
|
+ font-size: 13px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: @primaryColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .divider {
|
|
|
+ width: 100%;
|
|
|
+ height: 1px;
|
|
|
+ background: @bgColor;
|
|
|
+ }
|
|
|
+ .content {
|
|
|
+ .flex();
|
|
|
+ width: 100%;
|
|
|
+ height: 80px;
|
|
|
+ align-items: flex-start;
|
|
|
+ margin-top: 15px;
|
|
|
+ .cover {
|
|
|
+ width: 80px;
|
|
|
+ height: 80px;
|
|
|
+ min-width: 80px;
|
|
|
+ border-radius: 4px;
|
|
|
+ }
|
|
|
+ .info {
|
|
|
+ height: 80px;
|
|
|
+ .flex-col();
|
|
|
+ align-items: flex-start;
|
|
|
+ justify-content: space-between;
|
|
|
+ flex-grow: 1;
|
|
|
+ margin-left: 10px;
|
|
|
+ .name {
|
|
|
+ font-size: 14px;
|
|
|
+ color: @textColorPrimaryDark;
|
|
|
+ word-break: break-all;
|
|
|
+ .ellipsisLn(2);
|
|
|
+ }
|
|
|
+ .spec {
|
|
|
+ color: @disableColor;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ .price {
|
|
|
+ .flex();
|
|
|
+ width: 100%;
|
|
|
+ align-items: baseline;
|
|
|
+ font-size: 11px;
|
|
|
+ color: @textColorPrimaryDark;
|
|
|
+ font-weight: bold;
|
|
|
+ .amount {
|
|
|
+ color: @disableColor;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: normal;
|
|
|
+ flex-grow: 1;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .real-pay-wrapper {
|
|
|
+ .flex();
|
|
|
+ height: 40px;
|
|
|
+ width: 100%;
|
|
|
+ justify-content: flex-end;
|
|
|
+ .real-pay {
|
|
|
+ .flex();
|
|
|
+ align-items: baseline;
|
|
|
+ font-size: 11px;
|
|
|
+ color: @highlightColor;
|
|
|
+ justify-content: flex-end;
|
|
|
+ .label {
|
|
|
+ color: #666666;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: normal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .btns {
|
|
|
+ height: 58px;
|
|
|
+ width: 100%;
|
|
|
+ .flex();
|
|
|
+ justify-content: flex-end;
|
|
|
+ .btn {
|
|
|
+ height: 28px;
|
|
|
+ width: 76px;
|
|
|
+ .flex();
|
|
|
+ justify-content: center;
|
|
|
+ border-radius: 14px;
|
|
|
+ font-size: 12px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ margin-left: 10px;
|
|
|
+ &.prim {
|
|
|
+ background: linear-gradient(90deg, rgba(42, 123, 255, 1) 0%, rgba(122, 70, 255, 1) 100%);
|
|
|
+ color: white;
|
|
|
+ }
|
|
|
+ &.border {
|
|
|
+ border: 1px solid @primaryColor;
|
|
|
+ color: @primaryColor;
|
|
|
+ }
|
|
|
+ &.sec {
|
|
|
+ border: 1px solid @disableColor;
|
|
|
+ color: @disableColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|