|
|
@@ -6,57 +6,56 @@
|
|
|
:data="tableData"
|
|
|
fit
|
|
|
highlight-current-row
|
|
|
- style="width: 100%;"
|
|
|
ref="multipleTable"
|
|
|
@selection-change="handleSelectionChange"
|
|
|
>
|
|
|
- <el-table-column type="selection" width="70" align="center"></el-table-column>
|
|
|
+ <el-table-column type="selection" width="50" align="center"></el-table-column>
|
|
|
<el-table-column align="center" type="index" width="50"></el-table-column>
|
|
|
- <el-table-column :label="$t('shop.productName')" align="center" prop="GOODS_NAME">
|
|
|
+ <el-table-column :label="$t('shop.qty')" min-width="150" align="center">
|
|
|
+ <template slot-scope="{row, $index}">
|
|
|
+ <el-input-number size="mini" v-model="storeNums[$index]" :min="1" :max="Number(row.STORE_NUMS)" @change="handleInputNumber($event, row)"></el-input-number>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('shop.productName')" min-width="140" align="center" prop="GOODS_NAME">
|
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row.GOODS_NAME }}</span>
|
|
|
+ <span style="word-break: keep-all;">{{ row.GOODS_NAME }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.productPicture')" align="center" min-width="70px" prop="GOODS_NAME">
|
|
|
+ <el-table-column :label="$t('shop.productPicture')" align="center" min-width="80px" prop="GOODS_NAME">
|
|
|
<template slot-scope="{row}">
|
|
|
<el-image
|
|
|
- style="width: 70px; height: 70px"
|
|
|
+ style="width: 80px; height: 80px"
|
|
|
:src="tool.getArImage(row.COVER, '/files/')"
|
|
|
:preview-src-list="[tool.getArImage(row.COVER, '/files/')]"
|
|
|
>
|
|
|
</el-image>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.productPrice')" align="center" prop="SELL_PRICE">
|
|
|
+ <el-table-column :label="$t('shop.productPrice')" align="center" prop="SELL_PRICE" min-width="120px">
|
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row.SELL_PRICE }}</span>
|
|
|
+ <span>{{ $t('currency.sign') }} {{ row.SELL_PRICE | amountFilter }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.productBV')" align="center" prop="PRICE_PV">
|
|
|
+ <el-table-column :label="$t('shop.productBV')" align="center" prop="PRICE_PV" min-width="100px">
|
|
|
<template slot-scope="{row}">
|
|
|
<span>{{ row.PRICE_PV }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.taxRate')" align="center" prop="TAX_RATE">
|
|
|
+ <el-table-column :label="$t('shop.taxRate')" align="center" prop="TAX_RATE" min-width="100px">
|
|
|
<template slot-scope="{row}">
|
|
|
<span>{{ row.TAX_RATE / 100 }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.taxAmount')" align="center">
|
|
|
+ <el-table-column :label="$t('shop.taxAmount')" align="center" min-width="120px">
|
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row | taxAmountFilter }}</span>
|
|
|
+ <span>{{ $t('currency.sign') }} {{ row | taxAmountFilter | amountFilter }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.inventory')" align="center" prop="STORE_NUMS">
|
|
|
+ <el-table-column :label="$t('shop.inventory')" align="center" prop="STORE_NUMS" min-width="120px">
|
|
|
<template slot-scope="{row}">
|
|
|
<span>{{ row.STORE_NUMS }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column :label="$t('shop.qty')" min-width="90" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-input-number size="mini" v-model="storeNums[scope.$index]" :min="1" :max="Number(scope.row.STORE_NUMS)" @change="(val)=>{handleInputNumber(val, scope.row)}"></el-input-number>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
|
|
|
@@ -71,19 +70,162 @@
|
|
|
<div style="display: inline-block;">{{ $t('shop.taxAmount') }}:{{ $t('currency.sign') }} {{ taxSum }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- 购物车 -->
|
|
|
+ <el-dialog :title="$t('shop.productsSettlement')" :visible.sync="visibleShoppingCart" :width="screenWidth" v-loading="shoppingCartLoading" style="margin-top: -95px;">
|
|
|
+ <div v-loading="loading">
|
|
|
+ <div class="white-box">
|
|
|
+ <el-table :data="goods" style="width: 100%" show-summary :summary-method="getSummaries">
|
|
|
+ <el-table-column :label="$t('shop.productPicture')" align="center" min-width="90px">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-image
|
|
|
+ style="width: 80px; height: 80px"
|
|
|
+ :src="tool.getArImage(row.COVER, '/files/')"
|
|
|
+ :preview-src-list="[tool.getArImage(row.COVER, '/files/')]">
|
|
|
+ </el-image>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('shop.productName')" prop="GOODS_NAME" align="center" min-width="130px"></el-table-column>
|
|
|
+ <el-table-column :label="$t('shop.qty')" prop="chose_num" align="center" min-width="90px"></el-table-column >
|
|
|
+ <el-table-column :label="$t('shop.productPrice')" prop="member_price" align="center" min-width="130px">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ $t('currency.sign') }} {{ row.member_price }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('shop.totalPrice')" prop="member_price_plus" align="center" min-width="130px">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ $t('currency.sign') }} {{ row.member_price_plus }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('shop.taxRate')" prop="TAX_RATE" align="center" min-width="70px">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.TAX_RATE / 100 }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('shop.totalTaxAmount')" prop="tax_amount_plus" align="center" min-width="120px">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ $t('currency.sign') }} {{ row.tax_amount_plus }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <div class="white-box-footer" style=" padding: 15px; line-height: 15px;">
|
|
|
+ <el-row :gutter="40">
|
|
|
+ <el-col :xs="24" :sm="24" :lg="24">
|
|
|
+ <!-- 订单合计 -->
|
|
|
+ <div class="box address_box">
|
|
|
+ {{ $t('shop.totalOrders') }}:
|
|
|
+ <div class="sum">
|
|
|
+ <div class="sum_box">
|
|
|
+ <div>{{ $t('shop.paidAmount') }}</div>
|
|
|
+ <div>{{ $t('currency.sign') }} {{ payType === "cash" ? cashSum : pointsSum }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="sum_box">
|
|
|
+ <div>{{ $t('shop.freight') }}</div>
|
|
|
+ <div>{{ $t('currency.sign') }} {{ pointFreight }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 支付方式/账户余额 -->
|
|
|
+ <div class="box address_box">
|
|
|
+ {{ $t('shop.selectPayment') }}:
|
|
|
+ <el-radio-group v-model="payType" @change='chosePayType'>
|
|
|
+ <div v-for="(item, index) in payList" :key='index' class="address">
|
|
|
+ <el-radio :label="item.label" border>
|
|
|
+ {{ item.name }}<span v-if="item.label === 'cash'" style="color: tomato;">({{ cashCurrency }}: {{ $t('currency.sign') }} {{ userBalance.cash }})</span>
|
|
|
+ </el-radio>
|
|
|
+ </div>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ <!-- 收货地址 -->
|
|
|
+ <div class="box address_box">
|
|
|
+ {{ $t('shop.selectAddress') }}:
|
|
|
+ <el-radio-group v-model="addressId" @change='choseAddress'>
|
|
|
+ <div class="address">
|
|
|
+ <el-radio :label="selfPickUpAddressId" border>{{ $t('shop.selfPickUp') }}</el-radio>
|
|
|
+ </div>
|
|
|
+ <div v-for="(item, index) in shippingAddressList" :key='index' class="address">
|
|
|
+ <el-radio :label="item.ID" border>
|
|
|
+ <span>{{item.ADDRESS}}, {{item.LGA_NAME}}, {{item.PROVINCE_NAME}}</span>
|
|
|
+ <el-divider direction="vertical"></el-divider>
|
|
|
+ <span>{{item.MOBILE}}</span>
|
|
|
+ <el-divider direction="vertical"></el-divider>
|
|
|
+ <span>{{item.CONSIGNEE}}</span>
|
|
|
+ </el-radio>
|
|
|
+ </div>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="white-box-footer" >
|
|
|
+ <el-row :gutter="40">
|
|
|
+ <el-col :xs="24" :sm="24" :lg="24" align="left">
|
|
|
+ <el-button type="warning" size="small" @click="visibleShoppingCart = false">{{ $t('shop.goBack') }}</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="orderSubmit" :loading="submitButtonStat">{{ $t('shop.goPay') }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- payStack模态框 -->
|
|
|
+ <el-dialog :title="$t('shop.goPay')" :visible.sync="visible" :width="payStackScreenWidth" v-loading="payStackLoading" :before-close="handleClose">
|
|
|
+ <section>
|
|
|
+ <el-form :model="form">
|
|
|
+ <el-form-item :label="$t('user.email')" label-width="100px" required>
|
|
|
+ <el-input v-model="form.email" autocomplete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="$t('shop.amount')" label-width="100px" required>
|
|
|
+ <el-input v-model="form.amount" autocomplete="off" readonly></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </section>
|
|
|
+ <paystack
|
|
|
+ :firstname="form.firstname"
|
|
|
+ :lastname="form.lastname"
|
|
|
+ :amount="form.amount * 100"
|
|
|
+ :email="form.email"
|
|
|
+ :metadata="form.metadata"
|
|
|
+ :currency="form.currency"
|
|
|
+ :paystackkey="form.publicKey"
|
|
|
+ :reference="reference"
|
|
|
+ :channels="channels"
|
|
|
+ :callback="processPayment"
|
|
|
+ :close="handleClose"
|
|
|
+ >
|
|
|
+ <el-button type="primary" size="small">{{ $t('shop.goPay') }}</el-button>
|
|
|
+ </paystack>
|
|
|
+ <el-button type="danger" size="small" class="cancelButton" @click="handleClose" style="margin-left: 10px;">{{ $t('common.cancel') }}</el-button>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 倒计时页面 -->
|
|
|
+ <el-dialog :title="$t('common.hint')" :visible.sync="payDialog" :width="payStackScreenWidth" :show-close="false" :close="handleOrderList">
|
|
|
+ <el-card shadow="always">
|
|
|
+ <el-result icon="success" :title="$t('common.successfully')" :subTitle="$t('shop.successOrderTips')">
|
|
|
+ <template slot="extra">
|
|
|
+ <el-button type="primary" size="medium" @click="handleOrderList">{{ $t('shop.goBack') }}({{ countdown }})</el-button>
|
|
|
+ </template>
|
|
|
+ </el-result>
|
|
|
+ </el-card>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { fetchProductList, fetchProduct } from '@/api/shop'
|
|
|
+ import {fetchProductList, createApproachOrder, deleteApproachOrder, fetchShoppingCart, createOrder} from '@/api/shop'
|
|
|
import waves from '@/directive/waves'
|
|
|
- import { parseTime } from '@/utils'
|
|
|
+ import {formatAmount, getScreenWidth} from '@/utils'
|
|
|
import tool from '@/utils/tool'
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
+ import usersInfo from "@/utils/usersInfo"
|
|
|
+ import paystack from 'vue-paystack'
|
|
|
|
|
|
export default {
|
|
|
- name: 'standardProducts',
|
|
|
- components: { Pagination },
|
|
|
+ name: 'ProductsList',
|
|
|
+ components: { Pagination, paystack },
|
|
|
directives: { waves },
|
|
|
filters: {
|
|
|
priceFilter(price) {
|
|
|
@@ -99,6 +241,9 @@
|
|
|
}
|
|
|
return statusMap[status]
|
|
|
},
|
|
|
+ amountFilter(amount) {
|
|
|
+ return formatAmount(amount)
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -121,14 +266,92 @@
|
|
|
display: false,
|
|
|
currentPage: 1,
|
|
|
shoppingCartGoods: [],
|
|
|
+
|
|
|
+ shoppingCartLoading: false,
|
|
|
+ visibleShoppingCart: false,
|
|
|
+ loading: false,
|
|
|
+
|
|
|
+ goods: [],
|
|
|
+ payList: [],
|
|
|
+ cashCurrency: '',
|
|
|
+ currency: {},
|
|
|
+ pointsSum: '',
|
|
|
+ cashSum: '',
|
|
|
+ pointFreight: '',
|
|
|
+ freeShipping: '',
|
|
|
+ goodsId: '',
|
|
|
+ goodsNum: '',
|
|
|
+ payPassword: '',
|
|
|
+ submitButtonStat: false,
|
|
|
+ sn: '',
|
|
|
+ orderType: '',
|
|
|
+ payDialog: false,
|
|
|
+ countdown: 5,
|
|
|
+ visible: false,
|
|
|
+ totalAmount: 0.00,
|
|
|
+ freight: 0.00,
|
|
|
+ userBalance: {},
|
|
|
+
|
|
|
+ payType: 'cash',
|
|
|
+ payStackLoading: false,
|
|
|
+ channels: ["card", "bank", "ussd", "qr"],
|
|
|
+ form: {
|
|
|
+ publicKey: process.env.VUE_APP_BASE_PAY_STACK_PUBLIC_KEY,
|
|
|
+ currency: 'NGN',
|
|
|
+ firstname: usersInfo.userName(),
|
|
|
+ lastname: '',
|
|
|
+ email: usersInfo.userEmail(),
|
|
|
+ amount: 0,
|
|
|
+ orderSn: '',
|
|
|
+ metadata: {
|
|
|
+ cart_id: '',
|
|
|
+ custom_fields: [
|
|
|
+ {
|
|
|
+ display_name: 'orderSn',
|
|
|
+ variable_name: 'orderSn',
|
|
|
+ value: this.sn,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ display_name: 'orderType',
|
|
|
+ variable_name: 'orderType',
|
|
|
+ value: 'userOrder'
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ },
|
|
|
+ payStackScreenWidth: getScreenWidth() > 500 ? '450px' : getScreenWidth() + 'px',
|
|
|
+
|
|
|
+ regionData: tool.getRegionData(),
|
|
|
+ addressId: '',
|
|
|
+ selfPickUpAddressId: '100000000000000000',
|
|
|
+ shippingAddressList: [],
|
|
|
+
|
|
|
+ screenWidth: getScreenWidth() > 600 ? '80%' : getScreenWidth() + 'px',
|
|
|
+ labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
|
|
|
+ dialog: false,
|
|
|
+ dialogLoading: false,
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- // 商品列表查询
|
|
|
this.getList()
|
|
|
},
|
|
|
- methods: {
|
|
|
- // 商品类别
|
|
|
+ mounted() {
|
|
|
+ // 支付方式、账户信息、余额
|
|
|
+ this.getShoppingCart()
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // PayStack混淆串
|
|
|
+ reference() {
|
|
|
+ let text = ''
|
|
|
+ let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
|
+ for (let i = 0; i < 10; i++) {
|
|
|
+ text += possible.charAt(Math.floor(Math.random() * possible.length))
|
|
|
+ }
|
|
|
+ return text
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 商品列表
|
|
|
getList() {
|
|
|
this.listLoading = true
|
|
|
fetchProductList(this.listQuery).then(response => {
|
|
|
@@ -161,20 +384,18 @@
|
|
|
})
|
|
|
},
|
|
|
// 选择商品计数
|
|
|
- handleInputNumber(val, row){
|
|
|
- console.log(val, row)
|
|
|
- let pageList = this.multipleSelection[this.currentPage]
|
|
|
+ handleInputNumber(current, row){
|
|
|
+ let pageList = this.multipleSelection[this.listQuery.page]
|
|
|
let selectStatus = false
|
|
|
for (let i in pageList) {
|
|
|
- if( pageList[i].ID === row.ID ) {
|
|
|
- pageList[i].chose_num = val
|
|
|
+ if (pageList[i].ID === row.ID) {
|
|
|
+ pageList[i].chose_num = current
|
|
|
selectStatus = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- console.log('selectStatus', selectStatus)
|
|
|
if (selectStatus) {
|
|
|
- this.multipleSelection[this.currentPage] = pageList
|
|
|
+ this.multipleSelection[this.listQuery.page] = pageList
|
|
|
this.handleSureChange()
|
|
|
}
|
|
|
},
|
|
|
@@ -198,42 +419,329 @@
|
|
|
this.display = true
|
|
|
}
|
|
|
},
|
|
|
- handleSelectionChange(ele) {
|
|
|
- this.multipleSelection.length = 0
|
|
|
- if (ele.length > 0) {
|
|
|
- let idx = -1, num
|
|
|
- for (let i in this.tableData) {
|
|
|
- for (let v in ele) {
|
|
|
- if (ele[v].ID === this.tableData[i].ID) {
|
|
|
- idx = i
|
|
|
- num = this.storeNums[idx]
|
|
|
- ele[v]["chose_num"] = num
|
|
|
- break
|
|
|
- }
|
|
|
+ // 选择商品
|
|
|
+ handleSelectionChange(val) {
|
|
|
+ let idx = -1, num
|
|
|
+ for (let i in this.tableData) {
|
|
|
+ for (let v in val){
|
|
|
+ if (val[v].ID === this.tableData[i].ID) {
|
|
|
+ idx = i
|
|
|
+ num = this.storeNums[idx]
|
|
|
+ val[v]['chose_num'] = num
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
- this.multipleSelection.push(ele)
|
|
|
}
|
|
|
-
|
|
|
+ this.multipleSelection[this.listQuery.page] = val
|
|
|
// 计算统计
|
|
|
this.handleSureChange()
|
|
|
},
|
|
|
// 结算商品
|
|
|
settlement() {
|
|
|
if (this.multipleSelection.length <= 0) {
|
|
|
- this.$message.error('Please choose the products.')
|
|
|
+ this.$message.error(this.$t('shop.chooseTips'))
|
|
|
return false
|
|
|
}
|
|
|
- sessionStorage.setItem('orderGoodsQueue', JSON.stringify(this.multipleSelection))
|
|
|
- sessionStorage.setItem('categoryType', '1')
|
|
|
- this.$router.push({path: `/shop/shopping-cart`})
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- // 监听多选按钮,判断结算按钮是否可用
|
|
|
- multipleSelection: function (modern) {
|
|
|
+ // 弹出购物车
|
|
|
+ this.visibleShoppingCart = true
|
|
|
+ // 展示购物车商品数据
|
|
|
+ this.getShowCart()
|
|
|
+ },
|
|
|
+ // 设置运费
|
|
|
+ setFreight() {
|
|
|
+ // 如果地址为自提,则运费为0
|
|
|
+ this.pointFreight = (this.addressId === this.selfPickUpAddressId) ? Number(0) : Number(this.freight);
|
|
|
+ },
|
|
|
+ // 表格合并
|
|
|
+ getSummaries(param) {
|
|
|
+ const {columns, data} = param
|
|
|
+ const sums = []
|
|
|
+ columns.forEach((column, index) => {
|
|
|
+ if (index === 0) {
|
|
|
+ sums[index] = this.$t('shop.total')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const values = data.map(item => Number(item[column.property]));
|
|
|
+ if ((!values.every(value => isNaN(value))) && [2, 3, 4, 6].includes(index)) {
|
|
|
+ sums[index] = values.reduce((prev, curr) => {
|
|
|
+ const value = Number(curr)
|
|
|
+ if (!isNaN(value)) {
|
|
|
+ return Math.round((prev + curr) * 100) / 100
|
|
|
+ } else {
|
|
|
+ return Math.round(prev * 100) / 100
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ if (index !== 2) {
|
|
|
+ sums[index] = this.$t('currency.sign') + ' ' + sums[index]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ return sums
|
|
|
},
|
|
|
- },
|
|
|
+ // 支付方式、账户信息、余额
|
|
|
+ getShoppingCart() {
|
|
|
+ fetchShoppingCart({categoryType: this.listQuery.categoryType}).then(response => {
|
|
|
+ // 收货地址
|
|
|
+ this.shippingAddressList = response.data.allAddress
|
|
|
+ this.shippingAddressList.map(item => {
|
|
|
+ if (item.IS_DEFAULT === '1') {
|
|
|
+ this.addressId = item.ID
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 账户
|
|
|
+ this.userBalance = response.data.userBalance
|
|
|
+ // 支付方式处理
|
|
|
+ this.currency = response.data.payList
|
|
|
+ this.cashCurrency = response.data.payList[this.payType].name
|
|
|
+ // 支付方式
|
|
|
+ for (let item of response.data.sellType) {
|
|
|
+ if (item.id === this.listQuery.categoryType) {
|
|
|
+ this.payList = item.sell_type
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 支付方式的第一项默认选中
|
|
|
+ this.payType = Object.values(this.payList)[1]['label']
|
|
|
+ // 免运费阈值
|
|
|
+ this.freeShipping = response.data.freeShipping
|
|
|
+ // 运费
|
|
|
+ this.freight = response.data.freight
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 支付
|
|
|
+ orderSubmit() {
|
|
|
+ // 账户余额
|
|
|
+ let amountBalance = this.userBalance[this.payType]
|
|
|
+ // 账户类型提示信息
|
|
|
+ let accountType = this.currency[this.payType].name
|
|
|
+ if (amountBalance < 0 || !accountType) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t('shop.paymentError'),
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 支付方式处理
|
|
|
+ if (['cash', 'pay_stack'].includes(this.payType)) {
|
|
|
+ let payObj = this.payList.find((item) => {
|
|
|
+ return item.label === this.payType
|
|
|
+ })
|
|
|
+ accountType = (payObj.length <= 0) ? '' : payObj.name
|
|
|
+ }
|
|
|
+
|
|
|
+ // 余额是否充足
|
|
|
+ if ((this.payType !== 'pay_stack') && ((amountBalance - this.cashSum) < 0)) {
|
|
|
+ this.$message({
|
|
|
+ message: accountType + this.$t('shop.balanceNotAllow'),
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ this.submitButtonStat = false
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ this.submitButtonStat = true
|
|
|
+ this.$prompt(this.$t('shop.inputPasswordTips'), this.$t('common.hint'), {
|
|
|
+ confirmButtonText: this.$t('common.confirm'),
|
|
|
+ cancelButtonText: this.$t('common.cancel'),
|
|
|
+ customClass: 'csClass',
|
|
|
+ type: 'info',
|
|
|
+ inputType: 'password',
|
|
|
+ inputPattern: /\S+/,
|
|
|
+ inputErrorMessage: this.$t('shop.inputPasswordTips')
|
|
|
+ }).then(({value}) => {
|
|
|
+ this.payPassword = value
|
|
|
+ let params = {
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ goodsNum: this.goodsNum,
|
|
|
+ payPassword: this.payPassword,
|
|
|
+ email: this.form.email,
|
|
|
+ addressId: this.addressId,
|
|
|
+ address: this.address,
|
|
|
+ payType: this.payType,
|
|
|
+ }
|
|
|
+ if (this.payType === 'pay_stack') {
|
|
|
+ // PayStack支付
|
|
|
+ createApproachOrder(params).then(response => {
|
|
|
+ this.visibleShoppingCart = false
|
|
|
+ this.submitButtonStat = false
|
|
|
+ this.visible = true
|
|
|
+ this.form.orderSn = response.data.SN
|
|
|
+ this.form.amount = this.cashSum
|
|
|
+ this.form.metadata.cart_id = response.data.SN
|
|
|
+ this.form.metadata.custom_fields[0].value = response.data.SN
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ message: err,
|
|
|
+ type: 'error',
|
|
|
+ duration: 5 * 1000
|
|
|
+ })
|
|
|
+ this.submitButtonStat = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 非PayStack支付
|
|
|
+ createOrder(params).then(() => {
|
|
|
+ this.submitButtonStat = false
|
|
|
+ this.$message({
|
|
|
+ message: this.$t('common.successfully'),
|
|
|
+ type: 'success',
|
|
|
+ duration: 5 * 1000
|
|
|
+ })
|
|
|
+ this.$router.push({path: `/shop/order-list`})
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ message: err,
|
|
|
+ type: 'error',
|
|
|
+ duration: 5 * 1000
|
|
|
+ })
|
|
|
+ this.submitButtonStat = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.submitButtonStat = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 计算价格
|
|
|
+ getSumMoney () {
|
|
|
+ let cash_plus_sum = [];
|
|
|
+ let goodsId = [];
|
|
|
+ let goodsNum = [];
|
|
|
+ let choseNum = 0;
|
|
|
+ this.goods.map(item => {
|
|
|
+ choseNum = Number(item.chose_num);
|
|
|
+ if (choseNum > 0) {
|
|
|
+ cash_plus_sum.push(item.SELL_PRICE * choseNum * (item.DISCOUNT / 100));
|
|
|
+ goodsId.push(item.ID);
|
|
|
+ goodsNum.push(choseNum);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.goodsNum = goodsNum;
|
|
|
+ this.goodsId = goodsId;
|
|
|
+ // 增加运费
|
|
|
+ let payAmount = tool.sum(cash_plus_sum);
|
|
|
+ // 设置运费
|
|
|
+ this.setFreight();
|
|
|
+ // 商品总价大于预定值,免运费
|
|
|
+ this.pointFreight = (this.pointFreight > 0) ? ((payAmount >= this.freeShipping) ? 0 : this.freight) : 0
|
|
|
+ // 计算总价
|
|
|
+ this.pointsSum = this.cashSum = this.form.amount = tool.formatPrice(tool.sum(cash_plus_sum) + this.pointFreight) ;
|
|
|
+ },
|
|
|
+ // 展示购物车信息
|
|
|
+ getShowCart () {
|
|
|
+ let orderGoods = this.multipleSelection
|
|
|
+ let cartGoods = []
|
|
|
+ for (let i in orderGoods) {
|
|
|
+ cartGoods = orderGoods[i]
|
|
|
+ if (!cartGoods) continue
|
|
|
+
|
|
|
+ cartGoods.map(item => {
|
|
|
+ if (Number(item.chose_num) > 0) {
|
|
|
+ let discount = item.DISCOUNT / 100
|
|
|
+ item.member_price = Math.round(item.SELL_PRICE * discount * 100) / 100;
|
|
|
+ item.member_price_plus = Math.round(item.SELL_PRICE * Number(item.chose_num) * discount * 100) / 100;
|
|
|
+ item.tax_amount_plus = Math.round((item.member_price - item.member_price / (1 + item.TAX_RATE / 100)) * item.chose_num * 100) / 100;
|
|
|
+ this.goods.push(item)
|
|
|
+ this.totalAmount += item.member_price_plus
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ this.goods = cartGoods
|
|
|
+
|
|
|
+ // 计算价格
|
|
|
+ this.getSumMoney();
|
|
|
+ },
|
|
|
+ // 选择收货地址
|
|
|
+ choseAddress (addressId) {
|
|
|
+ this.addressId = addressId
|
|
|
+ // 设置运费
|
|
|
+ this.setFreight()
|
|
|
+ // 计算价格
|
|
|
+ this.getSumMoney()
|
|
|
+ },
|
|
|
+ // 切换支付方式
|
|
|
+ chosePayType(type) {
|
|
|
+ this.payType = type
|
|
|
+ },
|
|
|
+ // 关闭支付回调
|
|
|
+ handleClose() {
|
|
|
+ this.$confirm(this.$t('shop.confirmClose')).then(_ => {
|
|
|
+ deleteApproachOrder({ orderSn: this.form.orderSn }).then(() => {
|
|
|
+ // 关闭支付模态框
|
|
|
+ this.visible = false
|
|
|
+ // 关闭购物车
|
|
|
+ this.visibleShoppingCart = false
|
|
|
+ this.submitButtonStat = false
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 支付成功回调
|
|
|
+ processPayment() {
|
|
|
+ // 关闭支付页面
|
|
|
+ this.visible = false
|
|
|
+ this.payStackLoading = false
|
|
|
+ // 显示支付成功模态框
|
|
|
+ this.payDialog = true;
|
|
|
+ // 启动支付成功倒计时
|
|
|
+ this.handleCountdown()
|
|
|
+ },
|
|
|
+ // 倒计时结束跳转
|
|
|
+ handleOrderList () {
|
|
|
+ this.$router.push({path: `/shop/order-list`})
|
|
|
+ },
|
|
|
+ // 启动倒计时
|
|
|
+ handleCountdown () {
|
|
|
+ // 创建定时器
|
|
|
+ setInterval(() => {
|
|
|
+ // 每隔1秒把time的值减一,赋值给span标签
|
|
|
+ this.countdown--
|
|
|
+ if (this.countdown === 0) {
|
|
|
+ // 倒计时结束,跳转到订单列表
|
|
|
+ this.$router.push({path: `/shop/order-list`});
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ },
|
|
|
}
|
|
|
</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+.el-table--medium .el-table__cell {
|
|
|
+ padding: 3px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.csClass{
|
|
|
+ width: 360px;
|
|
|
+}
|
|
|
+
|
|
|
+.address{
|
|
|
+ line-height: 2.5rem;
|
|
|
+}
|
|
|
+.address_box{
|
|
|
+ border-bottom: 1px solid #e3e3e3;
|
|
|
+}
|
|
|
+.sum{
|
|
|
+ display: inline-block;
|
|
|
+}
|
|
|
+.box{
|
|
|
+ margin: 1rem 0;
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
+ align-items: center;
|
|
|
+ padding-bottom: 1rem;
|
|
|
+}
|
|
|
+.sum_box{
|
|
|
+ display: flex;
|
|
|
+ margin-left: 1rem;
|
|
|
+}
|
|
|
+.sum_box > div{
|
|
|
+ line-height: 2rem;
|
|
|
+}
|
|
|
+.sum_box > div:nth-child(1){
|
|
|
+ margin-right: 1rem;
|
|
|
+}
|
|
|
+.payButton {
|
|
|
+ border: none;
|
|
|
+ padding: 0;
|
|
|
+}
|
|
|
+</style>
|