Prechádzať zdrojové kódy

TBtools-单项指数转化

panyong 4 rokov pred
rodič
commit
4f0616887c

+ 29 - 2
htmldev/TBTools/src/views/modules/tools/tools-online.vue

@@ -22,7 +22,7 @@
             </el-input>
           </el-col>
           <el-col class="mt-160" :span="2" :offset="1">
-            <el-button type="primary">立即换算</el-button>
+            <el-button type="primary" :disabled="isDisabled" @click="handleExchange">立即换算</el-button>
           </el-col>
           <el-col :span="10" :offset="1">
             <div class="TT-header">
@@ -94,7 +94,7 @@ export default {
   name: 'toolsOnline',
   data () {
     return {
-      activeName: 'second',
+      activeName: 'first',
       menuData: [
         {
           title: '关键词页面指数【流量指数】',
@@ -319,6 +319,33 @@ export default {
         this.$set(this[`formData${index}`]['data'][idx], 'value', '')
       })
     },
+    handleExchange () {
+      const activeIndex = this.activeIndex * 1
+      const { title, beforeValue } = this.menuData[activeIndex]
+      let postData = {
+        number: beforeValue, // 指数值
+        type: title === '支付转化率指数' ? 7 : 1 // 指数类型(7为支付指数转化 其他都为1)
+      }
+      if (this.isDisabled) {
+        return
+      }
+      this.isDisabled = true
+      this.$http({
+        url: this.$http.adornUrl('/tb/exchange'),
+        method: 'post',
+        data: this.$http.adornData(postData)
+      }).then(({ data }) => {
+        this.isDisabled = false
+        if (data.status) {
+          const { numberData } = data.data
+          this.$set(this.menuData[activeIndex], 'afterValue', numberData)
+          return
+        }
+        this.$message.error(data.msg)
+      }).catch(() => {
+        this.isDisabled = false
+      })
+    },
     onSubmit () {
       const data = this.formData0.data
       let postData = {}