Просмотр исходного кода

feat: NG-91: Repeat Purchase——修改“Stockist Code”字段为必填项,并添加“*”

tyler 1 год назад
Родитель
Сommit
7859b8f72b
3 измененных файлов с 112 добавлено и 95 удалено
  1. 1 0
      src/lang/en.js
  2. 1 0
      src/lang/zh.js
  3. 110 95
      src/views/shop/standard-products.vue

+ 1 - 0
src/lang/en.js

@@ -384,6 +384,7 @@ export default {
     paymentCurrency: 'Payment Currency',
     salesPrice: 'DP',
     marketPrice: 'RP',
+      declarationCenterNumberTips: 'Please enter stockist code'
   },
 
   user: {

+ 1 - 0
src/lang/zh.js

@@ -382,6 +382,7 @@ export default {
     paymentCurrency: '支付币种',
     salesPrice: 'DP',
     marketPrice: 'RP',
+      declarationCenterNumberTips: '请输入报单中心编号'
   },
   user: {
     email: '电子邮箱',

+ 110 - 95
src/views/shop/standard-products.vue

@@ -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() {