From d4e6d812bf1e9fa55ea62745983f0b2a878ed8aa Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期四, 31 三月 2022 10:24:33 +0800
Subject: [PATCH] 管理中心

---
 src/views/hashrate/AlgManage/index.vue |  204 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 125 insertions(+), 79 deletions(-)

diff --git a/src/views/hashrate/AlgManage/index.vue b/src/views/hashrate/AlgManage/index.vue
index f5c226d..784f699 100644
--- a/src/views/hashrate/AlgManage/index.vue
+++ b/src/views/hashrate/AlgManage/index.vue
@@ -8,8 +8,8 @@
       <div class="label">鏀惰垂绠楁硶</div>
       <div class="payList">
         <div class="algCard" v-for="(item, index) in payAlg" :key="index">
-          <img :src="item.img" alt="" draggable="false" />
-          <div class="name">{{ item.name }}</div>
+          <img :src="item.logoUrl" alt="" draggable="false" />
+          <div class="name">{{ item.productName }}</div>
           <span class="button pay">璐拱</span>
         </div>
       </div>
@@ -26,12 +26,12 @@
           @dragend="dragAlg = null"
         >
           <img
-            :src="item.img"
+            :src="item.logoUrl"
             alt=""
             draggable="true"
             @dragstart="dragStart(item)"
           />
-          <div class="name">{{ item.name }}</div>
+          <div class="name">{{ item.productName }}</div>
           <span class="button detail">鏌ョ湅璇︽儏</span>
         </div>
       </div>
@@ -78,16 +78,19 @@
       <div class="title">閰嶇疆鎻愮ず</div>
       <div class="control">
         <div class="label">鍚敤绠楁硶浠撶鐞�</div>
-        <el-switch v-model="setting" active-color="#D4E3FA" :width="56">
+        <el-switch v-model="setting" active-color="#D4E3FA" :width="44">
         </el-switch>
       </div>
       <div class="des">鍚敤鍚庣畻娉曠鐞嗛〉闈㈤厤缃敓鏁堬紝鍚﹀垯涓嶇敓鏁�</div>
       <div class="btns">
-        <div class="cancel button" @click="closeSettingBox">鍙栨秷</div>
         <div class="confirm button" @click="closeSettingBox">纭畾</div>
       </div>
-      <span class="iconfont close" @click="closeSettingBox">&#xe60f;</span>
     </div>
+
+    <div class="setBtn iconfont" @click="showSettingBox = true">
+      &#xe652; 閰嶇疆鎻愮ず
+    </div>
+
     <!-- 閬僵灞� -->
     <div class="mask" v-if="showSettingBox"></div>
   </div>
@@ -95,62 +98,29 @@
 
 <script>
 import Card from "./components/AlgCard";
+import {
+  getAllCenterProduct,
+  getSdkConfigInfo,
+  saveSdkConfig,
+  findAllSdk,
+  downloadOrUpgrade,
+  unInstall,
+} from "@/api/algorithm";
 export default {
   components: {
     Card,
   },
+  created() {
+    this.getConfig();
+    this.getProduct();
+    this.getEquipment();
+  },
   data() {
     return {
-      showSettingBox: true,
-      setting: true,
-      payAlg: [
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-      ],
-      freeAlg: [
-        {
-          img: "/images/index/1浠板崸妫�娴�.png",
-          name: "浠板崸妫�娴�",
-        },
-        {
-          img: "/images/index/11婊炵暀.png",
-          name: "婊炵暀",
-        },
-        {
-          img: "/images/index/15鎴村彛缃�.png",
-          name: "鎴村彛缃�",
-        },
-      ],
+      showSettingBox: false,
+      setting: false,
+      payAlg: [],
+      freeAlg: [],
       equipmentArr: [
         {
           name: "璁惧1",
@@ -297,6 +267,50 @@
     };
   },
   methods: {
+    //鑾峰彇绠楁硶绠$悊璁剧疆
+    async getConfig() {
+      let user = JSON.parse(sessionStorage.getItem("userInfo"));
+      const res = await getSdkConfigInfo({
+        userId: user.id,
+        variable: "sdkManageConfig",
+      });
+      if (res && res.success) {
+        if (res.data.value === "") {
+          this.showSettingBox = true;
+        } else {
+          this.setting = res.data.value === "on" ? true : false;
+        }
+      }
+    },
+
+    //鑾峰彇宸︿晶浜у搧鍒楄〃
+    async getProduct() {
+      const res = await getAllCenterProduct({
+        page: 1,
+        size: 100000,
+        inputText: "",
+        archType: "",
+        gpuType: "",
+        publishStatus: 1,
+        productLabelId: "d0aabaee-8edd-492d-8f43-6b0e0bb6e2dd",
+      });
+
+      if (res && res.success) {
+        res.data.list.forEach((item) => {
+          item.logoUrl = "/httpImage/" + item.logoUrl;
+          if (item.priceBase === 0) {
+            this.freeAlg.push(item);
+          } else {
+            this.payAlg.push(item);
+          }
+        });
+      }
+    },
+
+    //鑾峰彇鍙充晶璁惧鍒楄〃
+    async getEquipment() {
+      const res = await findAllSdk();
+    },
     //鎷栨嫿寮�濮�
     dragStart(alg) {
       this.dragAlg = alg;
@@ -316,8 +330,23 @@
       });
       this.dragAlg = null;
     },
-    closeSettingBox() {
-      this.showSettingBox = false;
+    async closeSettingBox() {
+      let user = JSON.parse(sessionStorage.getItem("userInfo"));
+      const res = await saveSdkConfig({
+        userId: user.id,
+        variable: "sdkManageConfig",
+        value: this.setting ? "on" : "off",
+      }).catch(() => {
+        this.$notify.error({
+          message: "閰嶇疆澶辫触",
+        });
+      });
+      if (res && res.success) {
+        this.$notify.success({
+          message: "閰嶇疆鎴愬姛",
+        });
+        this.showSettingBox = false;
+      }
     },
   },
 };
@@ -327,6 +356,20 @@
 .AlgManage {
   display: flex;
   margin-bottom: 60px;
+
+  .setBtn {
+    position: absolute;
+    top: 161px;
+    right: 44px;
+    width: 112px;
+    height: 32px;
+    line-height: 32px;
+    border-radius: 3px;
+    border: 1px solid #0064ff;
+    color: #0064ff;
+    text-align: center;
+    cursor: pointer;
+  }
 
   .leftMenu {
     align-self: stretch;
@@ -490,10 +533,10 @@
     z-index: 2;
     top: 50%;
     left: 50%;
-    margin-top: -112px;
+    margin-top: -108px;
     margin-left: -180px;
     width: 360px;
-    height: 224px;
+    height: 216px;
     background-color: #fff;
 
     .title {
@@ -519,20 +562,30 @@
 
       .el-switch ::v-deep {
         height: 24px;
-
         .el-switch__core {
-          border-radius: 16px;
           height: 24px;
-
-          &::after {
-            top: 3px;
-            background: #0065ff;
-          }
+          border-radius: 16px;
+        }
+        .el-switch__core::after {
+          width: 20px;
+          height: 20px;
+          background-color: #999999;
+        }
+      }
+      .el-switch.is-checked ::v-deep {
+        .el-switch__core {
+          background-color: #d4e3fa;
+          border-color: #d4e3fa;
+        }
+        .el-switch__core::after {
+          margin-left: -22px;
+          background-color: #0065ff;
         }
       }
     }
 
     .des {
+      margin-top: 10px;
       margin-left: 20px;
       font-size: 12px;
       color: #0065ff;
@@ -544,22 +597,15 @@
       bottom: 20px;
       right: 20px;
       text-align: center;
-      line-height: 40px;
-
-      .cancel {
-        margin-right: 10px;
-        width: 104px;
-        height: 40px;
-        border: 1px solid #0065ff;
-        color: #0065ff;
-      }
+      line-height: 32px;
 
       .confirm {
-        width: 104px;
-        height: 40px;
+        width: 60px;
+        height: 32px;
         border: 1px solid #0065ff;
         background-color: #0065ff;
         color: #fff;
+        border-radius: 3px;
       }
     }
 

--
Gitblit v1.8.0