|
|
@@ -105,9 +105,9 @@
|
|
|
</el-row>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
- <el-form>
|
|
|
- <el-form-item :label="$t('shop.declarationCenterNumber')">
|
|
|
- <el-input v-model="recUserName" :disabled="isDec == '1'" />
|
|
|
+ <el-form :rules="rules" ref="payForm" :model="payForm">
|
|
|
+ <el-form-item :label="$t('shop.declarationCenterNumber')" prop="recUserName">
|
|
|
+ <el-input v-model="payForm.recUserName" :disabled="isDec == '1'" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
@@ -361,7 +361,15 @@ export default {
|
|
|
// recUserName:usersInfo.userName(),
|
|
|
recUserName:null,
|
|
|
isDec:null,
|
|
|
- currencyUnitCode: ""
|
|
|
+ currencyUnitCode: "",
|
|
|
+ rules: {
|
|
|
+ recUserName: [
|
|
|
+ {required: true, message: this.$t('shop.declarationCenterNumberTips'), trigger: 'blur'},
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ payForm: {
|
|
|
+ recUserName: null
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -379,7 +387,7 @@ export default {
|
|
|
isDec: {
|
|
|
handler(newValue, old) {
|
|
|
if (newValue == '1') {
|
|
|
- this.recUserName = usersInfo.userName();
|
|
|
+ this.payForm.recUserName = usersInfo.userName();
|
|
|
}
|
|
|
},
|
|
|
}
|
|
|
@@ -557,96 +565,103 @@ export default {
|
|
|
},
|
|
|
// 支付
|
|
|
orderSubmit() {
|
|
|
- // 账户余额
|
|
|
- const 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)) {
|
|
|
- const 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
|
|
|
- const params = {
|
|
|
- goodsId: this.goodsId,
|
|
|
- goodsNum: this.goodsNum,
|
|
|
- payPassword: this.payPassword,
|
|
|
- email: this.form.email,
|
|
|
- addressId: this.addressId,
|
|
|
- address: this.address,
|
|
|
- payType: this.payType,
|
|
|
- userName:this.recUserName
|
|
|
- }
|
|
|
- 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/own-order` })
|
|
|
- }).catch(err => {
|
|
|
- this.$message({
|
|
|
- message: err,
|
|
|
- type: 'warning',
|
|
|
- duration: 5 * 1000
|
|
|
- })
|
|
|
- this.submitButtonStat = false
|
|
|
- })
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- this.submitButtonStat = false
|
|
|
- })
|
|
|
+ this.$refs['payForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // 账户余额
|
|
|
+ const 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)) {
|
|
|
+ const 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
|
|
|
+ const params = {
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ goodsNum: this.goodsNum,
|
|
|
+ payPassword: this.payPassword,
|
|
|
+ email: this.form.email,
|
|
|
+ addressId: this.addressId,
|
|
|
+ address: this.address,
|
|
|
+ payType: this.payType,
|
|
|
+ userName: this.payForm.recUserName
|
|
|
+ }
|
|
|
+ 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/own-order`})
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ message: err,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 5 * 1000
|
|
|
+ })
|
|
|
+ this.submitButtonStat = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.submitButtonStat = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
// 计算价格
|
|
|
getSumMoney() {
|