From 81995aada399b25e9415bf709c918125461c402d Mon Sep 17 00:00:00 2001
From: heyujie <516346543@qq.com>
Date: 星期二, 09 三月 2021 18:07:30 +0800
Subject: [PATCH] 窗口中升级产品接口更改

---
 src/pages/ai/index/App.vue |  171 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 116 insertions(+), 55 deletions(-)

diff --git a/src/pages/ai/index/App.vue b/src/pages/ai/index/App.vue
index de7310d..4da418a 100644
--- a/src/pages/ai/index/App.vue
+++ b/src/pages/ai/index/App.vue
@@ -150,7 +150,6 @@
                         </div>
                       </div>
                     </div>
-                    <!-- </draggable> -->
                     <div
                       class="wrap-box"
                       v-for="item in notInstalledList"
@@ -161,12 +160,28 @@
                         v-loading="downloading && downloadItem == item.id"
                       >
                         <div class="mask">
-                          <el-button
-                            type="primary"
-                            class="bot-btn"
-                            @click="donwload(item)"
-                            >瀹夎</el-button
-                          >
+                           <div class="left-top">
+                                <div v-if="item.installed">褰撳墠鐗堟湰:{{ item.version }}</div>
+                                <div v-if="item.remoteVersion">
+                                  鏈�鏂扮増鏈�:{{ item.remoteVersion }}
+                                </div>
+                              </div>
+                              <div
+                                class="info-onmask"
+                                @click="checkDetail(item, 'inactive')"
+                              >
+                                鏌ョ湅璇︽儏
+                              </div>
+                              <div class="mask-btn">
+                                <el-button
+                                 @click="donwload(item)"
+                                  type="primary"
+                                  class="bot-btn"
+                                  >瀹夎</el-button
+                                >
+                                
+                              </div>
+                  
                         </div>
                         <div class="click-download" title="涓嬭浇">
                           <span class="iconfont iconxiazai1"></span>
@@ -302,6 +317,7 @@
                             element-loading-background="rgba(0,0,0,.8)"
                           >
                             <div class="mask">
+                             
                               <el-button
                                 size="small"
                                 type="primary"
@@ -900,18 +916,21 @@
             <div class="summary">
               <div class="icon">
                 <img
-                  v-if="curCheckTarget.iconBlob"
+                  v-if="productDetail.iconBlob"
                   class="baseImg"
                   :src="
-                    curCheckTarget.iconBlob.indexOf(',') > 0
-                      ? curCheckTarget.iconBlob
-                      : `data:image/png;base64,${curCheckTarget.iconBlob}`
+                    productDetail.iconBlob.indexOf(',') > 0
+                      ? productDetail.iconBlob
+                      : `data:image/png;base64,${productDetail.iconBlob}`
                   "
                   alt
                 />
               </div>
               <div class="right-desc">
-                <div class="name">{{ productDetail.productName }}</div>
+                  
+                <div class="name"><el-tooltip class="" effect="dark" :content="productDetail.productName  " placement="right-start">
+                  <span>{{ productDetail.productName  }}</span>
+                </el-tooltip></div>
                 <div class="tags">
                   <!-- <span
                   class="tag"
@@ -920,15 +939,15 @@
                 >{{showNameById(id)}}</span> -->
                   <el-tag type="info" size="small" color="#fff" v-if="!isSDKDialog">搴旂敤</el-tag>
                   <el-tag type="info" size="small" color="#fff" v-if="isSDKDialog">绠楁硶</el-tag>
-                  <el-tag type="info"  size="small" color="#fff" v-if="!isSDKDialog">杞欢</el-tag>
+                  <!-- <el-tag type="info"  size="small" color="#fff" v-if="!isSDKDialog">杞欢</el-tag> -->
                 </div>
                 <div class="btns">
-                  <el-button size="small" type="warning"  v-if="needToUpgradeInWin" @click="upgradeSDKinWin" >{{
+                  <el-button size="small" type="warning"  v-if="needToUpgradeInWin||productDetail.isUpgrade" @click="upgradeSDKinWin" >{{
                     isUpgrading ? "鍗囩骇涓�.." : "鍗囩骇"
                   }}</el-button>
                   <el-button size="small" type="primary" v-if="isActive" @click="unloadSDKinWin">鍗歌浇</el-button>
                   <el-button size="small" type="primary" v-if="!isActive" @click="showInputCode=!showInputCode">涓嬭浇婵�娲�</el-button>
-                  <el-button size="small" type="success" v-if="!isSDKDialog" @click="openApp">鎵撳紑</el-button>
+                  <el-button size="small" type="success" v-if="!isSDKDialog&&isActive" @click="openApp">鎵撳紑</el-button>
                 </div>
                
               </div>
@@ -1261,7 +1280,7 @@
       }
         this.needToUpgradeInWin = item.isUpgrade?true:false
       this.resetStack()
-      this.curCheckTarget = item;
+      // this.productDetail = item;
       if (item.sdk_type===undefined) {
        this.isSDKDialog=false
       }else{
@@ -1272,6 +1291,9 @@
       let _this = this;
       getAppDetail({ id: item.id }).then((res) => {
         _this.productDetail = res.data.detail;
+        _this.productDetail.isUpgrade = item.isUpgrade
+        _this.productDetail.iconBlob = item.iconBlob
+
         _this.otherProducts = res.data.randoms;
 
       });
@@ -1284,14 +1306,14 @@
 
     },
     checkInWindow(item){
-      this.backStack.push([this.productDetail,this.otherProducts])
+      this.backStack.push([this.productDetail, this.otherProducts])
       // debugger
       this.backDisable = false
-      this.curCheckTarget = item;
-      // this.productDetailVisible = true;
+
       let _this = this;
       getAppDetail({ id: item.id }).then((res) => {
         _this.productDetail = res.data.detail;
+        _this.productDetail.iconBlob = item.iconBlob
         this.actId = _this.productDetail.productBaseId
         let flag=false
        const allNeedToNew = [...this.hasNewVersionSdk,...this.hasNewVersionApp]
@@ -1301,7 +1323,9 @@
             flag=true
           }
         }
-        this.needToUpgradeInWin = true
+        this.needToUpgradeInWin = flag
+          _this.productDetail.isUpgrade = flag
+
         _this.otherProducts = res.data.randoms;
       });
     },
@@ -1389,16 +1413,8 @@
             setTimeout(() => {
               if (action == "upgrade") {
                 app.upgradeLoading = false;
-                // _this.$notify({
-                //   type: 'success',
-                //   message: '鍗囩骇鎴愬姛'
-                // });
               } else {
                 app.installLoading = false;
-                // _this.$notify({
-                //   type: 'success',
-                //   message: '瀹夎鎴愬姛'
-                // });
               }
               // _this.getAllApps();
               window.parent.postMessage(
@@ -1408,10 +1424,16 @@
                 "*"
               );
             }, 3000);
+          }else {
+        
           }
         })
         .catch((e) => {
-          console.log(e);
+            _this.$notify({
+              title: "瀹夎澶辫触",
+              message: e.data,
+              type: "warning",
+            });
           if (action == "upgrade") {
             app.upgradeLoading = false;
           } else {
@@ -1450,11 +1472,13 @@
       this.hasNewVersionApp = nArry;
     },
 
-    //鍗歌浇搴旂敤
+    //鍗歌浇
     unLoad(app) {
       let _this = this;
       this.$confirm("纭畾瑕佸嵏杞借搴旂敤鍚�?", "鎻愮ず")
         .then(() => {
+      _this.productDetailVisible = false
+
           app.unloadLoading = true;
           removeApp({ appId: app.id })
             .then((res) => {
@@ -1651,29 +1675,27 @@
       this.hasNewVersionSdk = hasNewVersionList;
     },
     unloadSDKinWin(){
-      let _this = this;
-      this.$confirm("纭畾瑕佸嵏杞借绠楁硶涔堬紵", "鎻愮ず").then(()=>{
-        _this.productDetailVisible = false
-        removeSdk({sdkId:this.productDetail.productBaseId}).then((res)=>{
-          _this.getAllSdk();
-          window.parent.postMessage(
-            {
-              msg: "AppUpdate",
-            },
-            "*"
-          );
-        }).catch((err)=>{
-           console.log(err);
+
+      let appToUnload
+      let sdkToUnload
+      if (this.productDetail.productTypeName=="搴旂敤") {
+        appToUnload= this.installedApps.find((item)=>{
+          return item.id == this.productDetail.productBaseId
         })
-      }).catch(()=>{
-        
-      })
+        this.unLoad(appToUnload)
+      }else{
+          sdkToUnload= this.installedList.find((item)=>{
+          return item.id == this.productDetail.productBaseId
+        })
+        this.unLoadSdk(sdkToUnload)
+      }
     },
     //鍗歌浇绠楁硶
     unLoadSdk(sdk) {
       let _this = this;
       this.$confirm("纭畾瑕佸嵏杞借绠楁硶鍚�?", "鎻愮ず")
         .then(() => {
+      _this.productDetailVisible = false
           sdk.unloadLoading = true;
           removeSdk({ sdkId: sdk.id })
             .then((res) => {
@@ -1701,12 +1723,42 @@
 
       this.isUpgrading = !this.isUpgrading;
 
-      downloadSdk({path:this.productDetail.productBaseId}).then((res)=>{
+      let _this = this;
+      if (this.productDetail.productTypeName=="搴旂敤") {
+      installApp({ path: this.productDetail.productBaseId})
+        .then((res) => {
+          if (res && res.success) {
+         this.$notify({
+          title: "鎴愬姛",
+          message: "鍗囩骇瀹屾垚",
+          type: "success",
+        });
+        this.needToUpgradeInWin=false
+        this.productDetail.isUpgrade = false
+        this.isUpgrading = !this.isUpgrading;
+        
+          }
+        })
+        .catch((e) => {
+            _this.$notify({
+              title: "鍗囩骇澶辫触",
+              message: e.data,
+              type: "warning",
+            });
+             this.isUpgrading = !this.isUpgrading;
+        });
+
+      // 寮�鍚嚜鍔ㄥ埛鏂�
+      this.appUpgreading = true;
+      }else{
+        downloadSdk({path:this.productDetail.productBaseId}).then((res)=>{
         this.$notify({
           title: "鎴愬姛",
           message: "鍗囩骇瀹屾垚",
           type: "success",
         });
+        this.needToUpgradeInWin=false
+        this.productDetail.isUpgrade = false
         this.isUpgrading = !this.isUpgrading;
       }).catch((err)=>{
         this.$notify({
@@ -1717,6 +1769,10 @@
         this.isUpgrading = !this.isUpgrading;
       })
       this.sdkUpgreading = true;
+      }
+
+
+      
     },
 
     donwload(item) {
@@ -1916,12 +1972,15 @@
             .right-desc {
               float: left;
               position: absolute;
-             left: 145px;
+                 left: 140px;
               .name {
                     font-size: 28px;
 
-                // font-weight: bold;
                 margin-bottom: 5px;
+                text-overflow: ellipsis;
+          white-space: nowrap;
+          overflow: hidden;
+          width: 250px;
               }
               .tags {
                 margin-bottom: 10px;
@@ -2076,11 +2135,11 @@
                 position: absolute;
                 top: 61%;
                    left: 12%;
-    width: 100px;
-    text-overflow: ellipsis;
-    white-space: nowrap;
-    overflow: hidden;
-        font-size: 13px;
+            width: 100px;
+            text-overflow: ellipsis;
+            white-space: nowrap;
+            overflow: hidden;
+              font-size: 13px;
 
                 }
               }
@@ -2249,7 +2308,8 @@
             max-width: 200px;
             .mask {
               width: 100%;
-
+              
+            
               .el-button + .el-button {
                 margin-left: 0 !important;
               }
@@ -2498,6 +2558,7 @@
         flex-wrap: wrap;
         justify-content: center;
         top: 0;
+       
         .bot-btn {
           flex: 1;
         }

--
Gitblit v1.8.0