|
@@ -0,0 +1,419 @@
|
|
|
+<template>
|
|
|
+ <div class="create-order">
|
|
|
+ <div class="hui-flex">
|
|
|
+ <div class="hui-flex-box">
|
|
|
+ <div class="order-box">
|
|
|
+ <div class="title">订单详情</div>
|
|
|
+ <div class="content">
|
|
|
+ <el-table :data="tableData">
|
|
|
+ <el-table-column label="商品名称" prop="name"></el-table-column>
|
|
|
+ <el-table-column label="数量" width="100">
|
|
|
+ <template>x1</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="价格" prop="price" width="100">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span class="color-danger">{{scope.row.totalFee}}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="order-box">
|
|
|
+ <div class="title" style="border: none;">优惠券</div>
|
|
|
+ <div class="content contents" v-if="coupon.length>0">
|
|
|
+ <div :class="returnCouponClass(item) ?'coupon-card' :'coupon-card disabled'"
|
|
|
+ v-for="(item,index) in coupon" :key="index" @click="checkCoupon(item)">
|
|
|
+ <div
|
|
|
+ :class="couponChecked.findIndex(node=>node.id === item.id) > -1 ? 'coupon-card-box active' :'coupon-card-box'">
|
|
|
+ <div class="price">
|
|
|
+ <div v-if="item.type === 1">
|
|
|
+ <span class="symbol">¥</span>
|
|
|
+ <span>{{item.couponAmount}}</span>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <span>{{item.discount*100}}</span>
|
|
|
+ <span class="symbol">折</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="center-describe">
|
|
|
+ <div class="product">{{item.title}}</div>
|
|
|
+ <div class="sub-title">
|
|
|
+ <span>{{item.type === 1?`满${item.threshold}减${item.couponAmount}`:`满${item.threshold}可用,最高抵扣${item.mostConstraint}`}}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="icon-check">
|
|
|
+ <i class="el-icon-check"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="content contents" v-else>
|
|
|
+ <div style="text-align: center;width: 100%; margin-top: 15px; color: #6d6d6d;">暂无优惠券</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="create-order-submit">
|
|
|
+ <div class="create-order-price">
|
|
|
+ <div v-if="isCount" class="color-danger">
|
|
|
+ 正在计算...
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <div>
|
|
|
+ <span>应付费用:</span>
|
|
|
+ <span class="color-danger">¥</span>
|
|
|
+ <span class="color-danger">{{countPriceData.totalFee}}</span>
|
|
|
+ </div>
|
|
|
+ <div class="discount-num">
|
|
|
+ <span class="color-danger">减 ¥ <span>{{minus}}</span></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-button type="primary" size="medium" :disabled="isCount || isCreate" @click="submit"
|
|
|
+ :loading="loading">
|
|
|
+ 立即支付
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-dialog :close-on-click-modal="false" title="支付订单" :visible.sync="dialogVisible" width="600px"
|
|
|
+ :append-to-body="true">
|
|
|
+ <pay-order v-if="dialogVisible" :orderNo="order.orderNo" @callback="callback"></pay-order>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ countProcessPriceAPI,
|
|
|
+ createProcessOrder
|
|
|
+ } from '@/api/serve'
|
|
|
+ import {
|
|
|
+ getCouponListByQuery
|
|
|
+ } from '@/api/discount'
|
|
|
+ import {
|
|
|
+ getProcessDataById
|
|
|
+ } from '@/api/system'
|
|
|
+ const payOrder = () => import('@/components/website/payOrder');
|
|
|
+ export default {
|
|
|
+ props: ['serveId'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData: [],
|
|
|
+ coupon: [],
|
|
|
+ couponChecked: [],
|
|
|
+ isCount: false,
|
|
|
+ countPriceData: {
|
|
|
+ productCoupon: [],
|
|
|
+ totalFee: 0
|
|
|
+ },
|
|
|
+ processData: {},
|
|
|
+ loading: false,
|
|
|
+ isStacking: false,
|
|
|
+ order: {},
|
|
|
+ dialogVisible: false,
|
|
|
+ isCreate: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ minus() {
|
|
|
+ let data = this.countPriceData.productCoupon || [];
|
|
|
+ let num = 0;
|
|
|
+ for (var i = 0; i < data.length; i++) {
|
|
|
+ num += data[i].minus
|
|
|
+ }
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ payOrder
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ getProcessDataById(this.serveId).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ let data = res.data;
|
|
|
+ this.processData = data;
|
|
|
+ this.tableData = [data];
|
|
|
+ this.countPrice();
|
|
|
+ getCouponListByQuery({
|
|
|
+ userId: this.$store.getters.user.userId,
|
|
|
+ productLevelId: data.productLevelId,
|
|
|
+ state: 1
|
|
|
+ }).then(node => {
|
|
|
+ if (node.state) {
|
|
|
+ this.coupon = node.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ returnCouponClass(item) {
|
|
|
+ if (item.threshold > this.processData.totalFee) return false; //大于满减。
|
|
|
+ if (this.couponChecked.findIndex(node => node.id === item.id) > -1) return true; //已选择的返回true
|
|
|
+ if (this.couponChecked.length === 0) return true; //未选择优惠券时都能选择。
|
|
|
+ if (this.isStacking && item.overlayUse === 0) return false; //叠加时不能选择不能叠加优惠券。
|
|
|
+ if (this.isStacking && item.overlayUse === 1) return true; //叠加时能选择叠加优惠券。
|
|
|
+ },
|
|
|
+ checkCoupon(item) {
|
|
|
+ if (!this.returnCouponClass(item)) return;
|
|
|
+ let index = this.couponChecked.findIndex(node => node.id === item.id);
|
|
|
+ if (index === -1) {
|
|
|
+ this.couponChecked.push(item);
|
|
|
+ } else {
|
|
|
+ this.couponChecked.splice(index, 1);
|
|
|
+ }
|
|
|
+ this.isStacking = this.couponChecked.length > 0 ? this.couponChecked[0].overlayUse === 1 : false; //是否可叠加
|
|
|
+ this.countPrice();
|
|
|
+ },
|
|
|
+ countPrice() {
|
|
|
+ this.isCount = true;
|
|
|
+ let couponIds = this.couponChecked.map(node => node.id).join(',') || -1;
|
|
|
+ countProcessPriceAPI(this.processData.id, couponIds).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ this.countPriceData = res.data;
|
|
|
+ }
|
|
|
+ this.isCount = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ this.loading = true;
|
|
|
+ let couponIds = this.couponChecked.map(node => node.id).join(',') || -1;
|
|
|
+ createProcessOrder(this.processData.id, this.$store.getters.organization.id, couponIds).then(res => {
|
|
|
+ this.loading = false;
|
|
|
+ if (res.state) {
|
|
|
+ this.order = res.data;
|
|
|
+ this.isCreate = true;
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.$emit('callback', 'reload');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ callback(type, operationType) {
|
|
|
+ this.$emit('callback', type, operationType);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+ .create-order {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background: $--background-color-base;
|
|
|
+ padding: 15px;
|
|
|
+
|
|
|
+ .pay-list {
|
|
|
+ display: flex;
|
|
|
+ margin-bottom: 20px;
|
|
|
+
|
|
|
+ .pay-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ border: 1px solid $--border-color-light;
|
|
|
+ padding: 5px 20px 5px 10px;
|
|
|
+ background: $--color-white;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .el-icon-check {
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-check {
|
|
|
+ color: #fff;
|
|
|
+ white-space: nowrap;
|
|
|
+ transform: rotate(45deg);
|
|
|
+ position: absolute;
|
|
|
+ top: -6px;
|
|
|
+ right: -15px;
|
|
|
+ background: #165dff;
|
|
|
+ width: 40px;
|
|
|
+ text-align: center;
|
|
|
+ height: 20px;
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-end;
|
|
|
+ justify-content: center;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ border-color: $--color-primary;
|
|
|
+ }
|
|
|
+
|
|
|
+ .huifont-weixinzhifu {
|
|
|
+ color: #57b050;
|
|
|
+ font-size: 30px;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .label {
|
|
|
+ font-weight: bold;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .pay-button {
|
|
|
+ .el-button:first-child {
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .extra-box {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .create-order-submit {
|
|
|
+ background: #fff;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: end;
|
|
|
+ padding: 15px;
|
|
|
+
|
|
|
+ .create-order-price {
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .discount-num {
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-card {
|
|
|
+ width: 50%;
|
|
|
+ margin-top: 10px;
|
|
|
+
|
|
|
+ &:nth-child(2n) {
|
|
|
+ padding-left: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:nth-child(2n-1) {
|
|
|
+ padding-right: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.disabled {
|
|
|
+ .coupon-card-box {
|
|
|
+ opacity: 0.6;
|
|
|
+ cursor: unset;
|
|
|
+
|
|
|
+ &:hover,
|
|
|
+ &.active {
|
|
|
+ border-color: $--border-color-lighter;
|
|
|
+
|
|
|
+ .icon-check {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .coupon-card-box {
|
|
|
+ background: #fff;
|
|
|
+ padding: 15px;
|
|
|
+ align-items: center;
|
|
|
+ display: flex;
|
|
|
+ position: relative;
|
|
|
+ cursor: pointer;
|
|
|
+ border: 1px solid $--border-color-lighter;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ border-color: $--color-primary;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ border-color: $--color-primary;
|
|
|
+
|
|
|
+ .icon-check {
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .price {
|
|
|
+ color: $--color-danger;
|
|
|
+ font-size: 24px;
|
|
|
+ font-weight: 500;
|
|
|
+ line-height: 24px;
|
|
|
+ text-align: center;
|
|
|
+ width: 100px;
|
|
|
+
|
|
|
+ .symbol {
|
|
|
+ margin: 0 3px;
|
|
|
+ font-size: $--font-size-base;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .center-describe {
|
|
|
+ display: inline-block;
|
|
|
+ margin-right: auto;
|
|
|
+ padding-left: 20px;
|
|
|
+ text-align: left;
|
|
|
+
|
|
|
+ .product {
|
|
|
+ color: $--color-text-primary;
|
|
|
+ font-size: $--font-size-large;
|
|
|
+ font-weight: 550;
|
|
|
+ line-height: 14px;
|
|
|
+ padding-bottom: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-check {
|
|
|
+ color: #fff;
|
|
|
+ white-space: nowrap;
|
|
|
+ transform: rotate(45deg);
|
|
|
+ position: absolute;
|
|
|
+ top: -8px;
|
|
|
+ right: -15px;
|
|
|
+ background: #165dff;
|
|
|
+ width: 40px;
|
|
|
+ text-align: center;
|
|
|
+ height: 26px;
|
|
|
+ display: none;
|
|
|
+ align-items: flex-end;
|
|
|
+ justify-content: center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-table__header {
|
|
|
+
|
|
|
+ th {
|
|
|
+ color: #606266;
|
|
|
+ background: #f4f4f5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cell {
|
|
|
+ font-weight: 700;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .order-box {
|
|
|
+ background: #fff;
|
|
|
+ margin-bottom: 15px;
|
|
|
+
|
|
|
+ .title {
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 22px;
|
|
|
+ padding: 12px 24px;
|
|
|
+ border-bottom: 1px solid $--border-color-light;
|
|
|
+ }
|
|
|
+
|
|
|
+ .content {
|
|
|
+ padding: 15px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .contents {
|
|
|
+ background: $--background-color-base;
|
|
|
+ padding: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|