Jelajahi Sumber

web 专业版注册商户

changhaoning 1 tahun lalu
induk
melakukan
e5773c8bb2
3 mengubah file dengan 153 tambahan dan 14 penghapusan
  1. 10 0
      src/api/pages/outh/Trade.js
  2. 11 0
      src/api/pages/outh/companyService.js
  3. 132 14
      src/view/login/register.vue

+ 10 - 0
src/api/pages/outh/Trade.js

@@ -0,0 +1,10 @@
+/**
+ * @desc   : 交易记录
+ * @author : 常皓宁
+ * @date   : 2024/8/8 9:41
+ */
+export default {
+  tradeService: {
+    prefix: 'oauth-server/trade/',
+  },
+}

+ 11 - 0
src/api/pages/outh/companyService.js

@@ -0,0 +1,11 @@
+/**
+* @desc   : 商户服务
+* @author : 常皓宁
+* @date   : 2024/8/8 9:41
+*/
+export default {
+  companyService: {
+    prefix: 'oauth-server/company/',
+    webRegisterCompany:'web_register_company',
+  },
+}

+ 132 - 14
src/view/login/register.vue

@@ -21,11 +21,11 @@
             <InputPop ref="cpPhone" v-model="formData.cpPhone" :telephone="true"/>
           </DkFormItem>
           <!--结束日期-->
-          <DkFormItem prop="endDate" :required="true" :data-type="$config.dataType.date">
-            <DatePickerPop v-model="formData.endDate" transfer
-                           :placeholder="$t('inputWords',{'search-name':$t('endDate')})"
-                           type="date" :short-cut-flag="true"/>
-          </DkFormItem>
+          <!--          <DkFormItem prop="endDate" :required="true" :data-type="$config.dataType.date">-->
+          <!--            <DatePickerPop v-model="formData.endDate" transfer-->
+          <!--                           :placeholder="$t('inputWords',{'search-name':$t('endDate')})"-->
+          <!--                           type="date" :short-cut-flag="true"/>-->
+          <!--          </DkFormItem>-->
           <!--公司规模-->
           <DkFormItem prop="cpSize">
             <InputNumberPop ref="cpSize" v-model="formData.cpSize"/>
@@ -44,11 +44,12 @@
     <!--    套餐信息-->
     <DkCollapse @on-change="changeCollapse" ref="activity">
       <DkPanel prop="activityInformation">
-        <DkForm slot="content" ref="formInline" v-model="activityTableForm">
+        <DkForm slot="content" ref="formInline1" v-model="activityTableForm">
           <!--套餐-->
           <div style="width: 100%;height: auto;margin-bottom: 15px;margin-top: 15px; margin-left: 20px;">
             <div style="display:flex;flex-wrap: wrap;">
               <div :class="(curentAdItem && curentAdItem.itemId == item.itemId)?'func-card-selected':'func-card'"
+                   ref="activityData"
                    v-for="(item, index) in activityTable" :key="item.itemId" @click="chooseAdItem(item)">
                 <!-- 标题 -->
                 <div class="card-title">{{ item.activityItemName }}</div>
@@ -132,6 +133,18 @@
 
     <!--      下部分按钮区域-->
     <DkSaveButton ref="saveButton" :loading="loading" @save="save" @close="close"></DkSaveButton>
+
+    <!--扫码支付-->
+    <el-dialog
+      width="400px"
+      title="扫码支付"
+      :visible.sync="qrCodeVisible"
+      append-to-body
+      :center="true"
+      @close="closeQrCode"
+    >
+      <div id="qrcode" style="height: 200px"></div>
+    </el-dialog>
   </div>
 </template>
 
@@ -145,6 +158,8 @@ export default {
 
   data() {
     return {
+      checkStatus: null,
+      qrCodeVisible: false,
       activityTableForm: {},
       activityTable: [],//功能
       proFlag: false,
@@ -155,9 +170,8 @@ export default {
         webMaxNum: 0,
         wxMaxNum: 0
       },
-      buyBeginDate: null,
+      buyBeginDate: new Date().getTime(),
       formData: {
-        cpId: null,
         cpName: null,
         cpManager: null,
         cpPhone: null,
@@ -166,12 +180,32 @@ export default {
         feedback: null,
         webMaxNum: null,
         wxMaxNum: null,
-        endDate: null,
       },
     }
   },
   methods: {
     /**
+     * @desc   : 关闭二维码
+     * @author : 常皓宁
+     * @date   : 2024/8/9 10:17
+     */
+    closeQrCode() {
+      this.qrCodeVisible = false
+      clearInterval(this.checkStatus)
+    },
+
+    /**
+     * @desc   : 随机生成单号
+     * @author : 常皓宁
+     * @date   : 2024/8/8 9:43
+     */
+    generateRandomNo() {
+      let timestamp = new Date().getTime().toString() // 当前时间戳
+      let randomPart = Math.random().toString(36).substring(2, 10) // 随机字符串
+      return timestamp + randomPart
+    },
+
+    /**
      * @desc   : 参数赋值
      * @author : 常皓宁
      * @date   : 2024/8/7 10:09
@@ -179,18 +213,102 @@ export default {
     setParams() {
       this.formData.gradeCode = 'PRO'
       this.params = {...this.formData}
-      if (this.formData.endDate) {
-        this.params.endDate = this.formData.endDate.format('yyyy-MM-dd')
-      }
+      let summaryInfo = this.summaryInfo
+      let curentAdItem = this.curentAdItem
+      this.params.webMaxNum = summaryInfo.webMaxNum
+      this.params.wxMaxNum = summaryInfo.wxMaxNum
+      this.params.endDate = summaryInfo.endDate
+      this.params.tradeNo = this.generateRandomNo();
+      this.params.tradeAmount = summaryInfo.amount
+      this.params.buyBeginDate = summaryInfo.buyBeginDate;
+      this.params.buyEndDate = summaryInfo.endDate
+      this.params.extendDays = summaryInfo.extendDays;
+      this.params.buyLong = curentAdItem.activityItemName
+    },
+
+    /**
+     * @desc   : 二维码展示
+     * @author : 常皓宁
+     * @date   : 2024/8/8 14:25
+     */
+    codeUrl(url) {
+      document.getElementById('qrcode').innerHTML = ''
+      new QRCode('qrcode', {
+        width: 200, // 二维码宽度,单位像素
+        height: 200, // 二维码高度,单位像素
+        text: url // 生成二维码的链接
+      })
     },
 
     /**
-     * @desc   : desc
+     * @desc   : 注册商户
      * @author : 常皓宁
      * @date   : 2024/4/30 14:17
      */
     saveData() {
-      return this.excute(this.$service.companyService, this.$service.companyService.insertCompany, this.params)
+      this.loading = false
+      if(!this.summaryInfo.amountInfo){
+        this.$message.warning('请选择套餐')
+        return;
+      }
+      let tradeNo = this.params.tradeNo
+      this.excute(this.$service.companyService, this.$service.companyService.webRegisterCompany, this.params).then(res => {
+        if (res.code === this.$config.SUCCESS_CODE) {
+          this.qrCodeVisible = true
+          setTimeout(() => {
+            this.codeUrl(res.data.codeURL)
+          }, 500)
+          var times = 0
+          var checkStatus = window.setInterval(() => {
+            this.checkStatus = checkStatus
+            times++
+            let param = {
+              tradeNo: tradeNo,
+            }
+            this.excute(this.$service.tradeService, this.$service.tradeService.selectByCond, param).then(res => {
+              if (res.code === this.$config.SUCCESS_CODE) {
+                if (res.data) {
+                  let data = res.data[0]
+                  if (data.tradeStatus === '交易状态-生效') {
+                    this.$Message.success('支付成功')
+                    this.qrCodeVisible = false
+                    clearInterval(checkStatus)
+                    this.clear()
+                  }
+                }
+              }
+              if (times >= 100) {
+                clearInterval(checkStatus)
+              }
+            })
+              .catch((error) => {
+              })
+          }, 3000)
+        } else {
+          this.$Message.warning(res.message)
+        }
+      })
+    },
+
+    /**
+     * @desc   : 成功之后清空数据
+     * @author : 常皓宁
+     * @date   : 2024/8/9 9:43
+     */
+    clear() {
+      this.formData.cpName = null
+      this.formData.cpManager = null
+      this.formData.cpPhone = null
+      this.formData.cpSize = null
+      this.formData.shopSize = null
+      this.formData.feedback = null
+      this.formData.webMaxNum = null
+      this.formData.wxMaxNum = null
+      this.staffCount.maxNum = 1
+      this.staffCount.webMaxNum = 0
+      this.staffCount.wxMaxNum = 0
+      this.summaryInfo = {}
+      this.curentAdItem = {}
     },
 
     /**