hanbaoshan
2020-09-30 bdfabf5a34092c02b5445ad50a0daafcbaa49721
应用中心商城应用激活
3个文件已修改
311 ■■■■■ 已修改文件
src/api/app.ts 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/cardWindow.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/ai/index/App.vue 294 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/app.ts
@@ -9,7 +9,7 @@
  });
};
//获取应用中心商城待激活列表
//获取应用中心商城待激活算法列表
export const getUnActivedSdk = () => {
  return request({
    url: "/data/api-v/sdk/buyList",
@@ -25,7 +25,7 @@
  })
}
//获取商城所有应用
//获取商城所有应用(已激活)
export const findAllApp = () => request({
  url: '/data/api-v/app/findAllApp',
  method: 'get'
@@ -42,4 +42,14 @@
  url: '/data/api-v/app/unInstall',
  method: 'post',
  data
})
});
//获取商城待激活的应用
export const getUnActivedApp = ()=> request({
  url:'/data/api-v/app/buyList',
  method: 'get'
});
//激活商城应用
export const actApp = (appId:String,code:String) => request({
  url:`/data/api-v/app/active?appId=${appId}&code=${code}`,
  method:'get'
});
src/components/cardWindow.vue
@@ -18,6 +18,7 @@
        :maxHeight="7000"
        :height="defaultHeight"
        :width="defaultWidth"
      >
        <div v-if="item.list.length == 1" style="height: calc(100% - 50px)">
          <model-card :data="item.list[0]"></model-card>
src/pages/ai/index/App.vue
@@ -51,13 +51,13 @@
                    </div>
                    <div class="wrap-box" v-for="(item) in installedList" :key="item.id">
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                        <div class="list-complete-item-handle">
                          <div class="svg-wrap">
                            <div class="mask flex-center" v-if="!item.isEdit">
                              <div class="info-onmask">
                                <div>当前版本:{{item.version}}</div>
                              </div>
                            </div>
                            </div>
                            <img
                              class="baseImg"
                              :src="`data:image/png;base64,${item.iconBlob}`"
@@ -113,41 +113,59 @@
                  <p class="src-title">应用软件</p>
                  <div class="flex-list">
                    <div class="wrap-box" v-for="(item) in installedApps" :key="item.id">
                        <div class="list-choose-item-left">
                          <div class="list-complete-item-handle">
                            <div class="svg-wrap" v-loading="item.unloadLoading" element-loading-text="卸载中" element-loading-background="rgba(0,0,0,.8)">
                              <div class="mask" v-if="!item.isDefault">
                                <el-button
                                  v-if="!item.isDefault"
                                  @click="unLoad(item)"
                                  type="primary"
                                  class="bot-btn"
                                >卸载</el-button>
                              </div>
                              <img class="baseImg" :src="`${item.iconBlob?'data:image/png;base64,'+item.iconBlob:item.icon}`" alt />
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                          <div
                            class="svg-wrap"
                            v-loading="item.unloadLoading"
                            element-loading-text="卸载中"
                            element-loading-background="rgba(0,0,0,.8)"
                          >
                            <div class="mask" v-if="!item.isDefault">
                              <el-button
                                v-if="!item.isDefault"
                                @click="unLoad(item)"
                                type="primary"
                                class="bot-btn"
                              >卸载</el-button>
                            </div>
                            <div class="alg-name">
                              <div style="padding:0px 10px 0px 10px;">
                                <span v-if="!item.isEdit">{{ item.name }}</span>
                                <el-input
                                  size="small"
                                  v-model="item.sdk_name"
                                  v-if="item.isEdit"
                                  v-focus
                                  :maxlength="15"
                                  @blur="inputBlur(item)"
                                ></el-input>
                              </div>
                            <img
                              class="baseImg"
                              :src="`${item.iconBlob?'data:image/png;base64,'+item.iconBlob:item.icon}`"
                              alt
                            />
                          </div>
                          <div class="alg-name">
                            <div style="padding:0px 10px 0px 10px;">
                              <span v-if="!item.isEdit">{{ item.name }}</span>
                              <el-input
                                size="small"
                                v-model="item.sdk_name"
                                v-if="item.isEdit"
                                v-focus
                                :maxlength="15"
                                @blur="inputBlur(item)"
                              ></el-input>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="wrap-box" v-for="item in storeApps" :key="item.id">
                      <div class="list-choose-item-left ">
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle uninstall">
                          <div class="svg-wrap" v-loading="item.installLoading" element-loading-text="安装中" element-loading-background="rgba(0,0,0,.8)">
                          <div
                            class="svg-wrap"
                            v-loading="item.installLoading"
                            element-loading-text="安装中"
                            element-loading-background="rgba(0,0,0,.8)"
                          >
                            <div class="mask">
                              <el-button type="primary" class="bot-btn" @click="downloadApp(item)">安装</el-button>
                              <el-button
                                type="primary"
                                class="bot-btn"
                                @click="downloadApp(item)"
                              >安装</el-button>
                            </div>
                            <img
                              class="baseImg"
@@ -202,7 +220,7 @@
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                          <div class="alg-icon svg-wrap">
                            <div class="mask" @click="actSdk(item.id)">
                            <div class="mask" @click="actSdkOrApp(item.id)">
                              <span
                                class="iconfont iconyunxiazai"
                                style="color:#ff6a00;font-size:20px;position:absolute;top:45%;left:45%"
@@ -233,9 +251,39 @@
                  </div>
                  <p class="src-title">应用软件</p>
                  <div class="app-list flex-list">
                    <div class="wrap-box" v-for="item in unActivedAppList" :key="item.id">
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                          <div class="alg-icon svg-wrap">
                            <div class="mask" @click="actSdkOrApp(item.id,'app')">
                              <span
                                class="iconfont iconyunxiazai"
                                style="color:#ff6a00;font-size:20px;position:absolute;top:45%;left:45%"
                              ></span>
                            </div>
                            <img
                              class="baseImg"
                              :src="item.iconBlob.indexOf(',')>0? item.iconBlob:`data:image/png;base64,${item.iconBlob}`"
                              alt
                            />
                          </div>
                          <div class="alg-name">
                            <div style="padding:0px 10px 0px 10px;">
                              <span v-if="!item.isEdit">{{ item.sdk_name }}</span>
                              <el-input
                                size="small"
                                v-model="item.sdk_name"
                                v-if="item.isEdit"
                                v-focus
                                :maxlength="15"
                                @blur="inputBlur(item)"
                              ></el-input>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <el-drawer title="下载" :visible.sync="actDrawerShow" :direction="direction">
                  <div class="drawer-content">
@@ -263,23 +311,23 @@
                      <ul class="desc">
                        <li>
                          <label>激活码:</label>
                          <span>{{activedSdk.activateCode}}</span>
                          <span>{{activedSdkOrApp.activateCode}}</span>
                        </li>
                        <li>
                          <label>产品名称:</label>
                          <span>{{activedSdk.productName}}</span>
                          <span>{{activedSdkOrApp.productName}}</span>
                        </li>
                        <li>
                          <label>配置详情:</label>
                          <span>{{activedSdk.setting}}</span>
                          <span>{{activedSdkOrApp.setting}}</span>
                        </li>
                        <li>
                          <label>服务到期日:</label>
                          <span>{{activedSdk.expireTime}}</span>
                          <span>{{activedSdkOrApp.expireTime}}</span>
                        </li>
                        <li>
                          <label>许可证:</label>
                          <span>{{activedSdk.licence}}</span>
                          <span>{{activedSdkOrApp.licence}}</span>
                        </li>
                        <!-- <li>
                          <label>设备ID:</label>
@@ -321,8 +369,8 @@
  downloadSdk,
  installSdk
} from "./api";
import { getApps,installApp,removeApp } from "@/api/app";
import { getUnActivedSdk, actPageAlg } from "@/api/app";
import { getApps, installApp, removeApp, getUnActivedSdk, actPageAlg, getUnActivedApp, actApp } from "@/api/app";
import FileUploader from "@/components/subComponents/FileUpload/index";
import TaskManage from "@/Pool/TaskMange";
import VideoManageData from "@/Pool/VideoManageData";
@@ -420,8 +468,11 @@
      isInstall: false,
      installPercentage: 0,
      unActivedSDKList: [],
      actSdkId: '',
      activedSdk: {
      unActivedAppList: [],
      //actSdkId: '',
      actType: '',
      actId: '',
      activedSdkOrApp: {
        activateCode: '',
        productName: '',
        setting: '',
@@ -431,8 +482,8 @@
      },
      // unloadLoading: false,
      // installLoading: false,
      installedApps:[],
      storeApps:[]
      installedApps: [],
      storeApps: []
    }
  },
  watch: {
@@ -466,73 +517,82 @@
    this.findAll();
    this.getUser();
    this.getUnActivedList();
    this.getUnActivedAppList();
    // this.TaskMange.findAllSdk();
    // this.TaskMange.findByType();
    this.VideoManageData.init();
  },
  methods: {
    downloadApp(app){
    downloadApp (app) {
      app.installLoading = true;
      let _this = this;
      installApp(app).then(res=>{
        if(res && res.success){
          setTimeout(()=>{
      installApp(app).then(res => {
        if (res && res.success) {
          setTimeout(() => {
            app.installLoading = false;
            _this.getAllApps();
            window.parent.postMessage({
              msg: "AppUpdate"
            }, '*')
          },3000);
          }, 3000);
        }
      })
    },
    getAllApps(){
    getAllApps () {
      let _this = this;
      _this.installedApps = [];
      _this.storeApps = [];
      getApps().then(res=>{
        if(res && res.success){
      getApps().then(res => {
        if (res && res.success) {
          //_this.storeApps = res.data;
          res.data.forEach(item=>{
            if(item.installed){
              let obj = Object.assign({unloadLoading:false},item)
          res.data.forEach(item => {
            if (item.installed) {
              let obj = Object.assign({ unloadLoading: false }, item)
              _this.installedApps.push(obj)
            }else{
              let obj = Object.assign({installLoading:false},item)
            } else {
              let obj = Object.assign({ installLoading: false }, item)
              _this.storeApps.push(obj)
            }
          });
          console.log('_this.installedApps',_this.installedApps);
          console.log('_this.storeApps',_this.storeApps);
          console.log('_this.installedApps', _this.installedApps);
          console.log('_this.storeApps', _this.storeApps);
        }
      })
    },
    //卸载应用
    unLoad(app){
    unLoad (app) {
      app.unloadLoading = true;
      let _this = this;
      removeApp({appId:app.id}).then(res=>{
        if(res && res.success){
          setTimeout(()=>{
      removeApp({ appId: app.id }).then(res => {
        if (res && res.success) {
          setTimeout(() => {
            app.unloadLoading = false;
            _this.getAllApps();
            window.parent.postMessage({
              msg: "AppUpdate"
            }, '*')
          },3000);
          }, 3000);
        }
      })
    },
    actSdk (id) {
      this.actSdkId = id;
    // actSdk (id) {
    //   this.actSdkId = id;
    //   this.actDrawerShow = true;
    //   this.actStep = 0;
    //   this.activeCode = '';
    //   this.activedSdkOrApp = this.newActInfo()
    // },
    actSdkOrApp (id, type = 'sdk') {
      this.actType = type;
      this.actId = id;
      this.actDrawerShow = true;
      this.actStep = 0;
      this.activeCode = '';
      this.activedSdk = this.newActInfo()
      this.activedSdkOrApp = this.newActInfo()
    },
    newActInfo(){
    newActInfo () {
      return {
        activateCode: '',
        productName: '',
@@ -550,26 +610,54 @@
      })
    },
    getUnActivedAppList () {
      getUnActivedApp().then(res => {
        if (res.code == 200) {
          this.unActivedAppList = res.data;
        }
      });
    },
    installFormat (percentage) {
      return percentage === 100 ? '安装成功' : `${percentage}%`;
    },
    actived () {
      let _this = this;
      actPageAlg(this.actSdkId, this.activeCode).then(res => {
        if (res.data.isSuccess) {
          _this.activedSdk = res.data.successMsg;
          _this.actStep++;
          _this.getUnActivedList();
          _this.findAllSdk();
        }else{
          _this.$notify({
            type:'error',
            message:res.data.failMsg.failMsg
          });
        }
      }).catch(e => {
        console.log(e)
      })
      if (this.actType == 'sdk') {
        //激活算法
        actPageAlg(this.actId, this.activeCode).then(res => {
          if (res.data.isSuccess) {
            _this.activedSdkOrApp = res.data.successMsg;
            _this.actStep++;
            _this.getUnActivedList();
            _this.findAllSdk();
          } else {
            _this.$notify({
              type: 'error',
              message: res.data.failMsg.failMsg
            });
          }
        }).catch(e => {
          console.log(e)
        });
      } else if (this.actType == 'app') {
        //激活应用
        actApp(this.actId, this.activeCode).then(res => {
          if (res.data.isSuccess) {
            _this.activedSdkOrApp = res.data.successMsg;
            _this.actStep++;
            _this.getUnActivedAppList();
            _this.getAllApps();
          } else {
            _this.$notify({
              type: 'error',
              message: res.data.failMsg.failMsg
            });
          }
        }).catch(e => {
          console.log(e)
        });
      }
    },
    getCodeDetail () { },
    checkMyAlgorith () {
@@ -627,7 +715,7 @@
        //安装
        installSdk(file).then(res => {
          if (res.success) {
            this.isInstall = false;
            //this.$refs['progressBar'].style.width = 100%
            //this.installPercentage = 100%
@@ -1341,23 +1429,23 @@
  color: #606266;
  cursor: pointer;
}
.el-loading-mask .el-loading-spinner{
  top: 40px!important;
.el-loading-mask .el-loading-spinner {
  top: 40px !important;
}
.el-loading-mask .el-loading-spinner svg{
  transform: none!important;
  top: 20px!important;
  left: 40%!important;
.el-loading-mask .el-loading-spinner svg {
  transform: none !important;
  top: 20px !important;
  left: 40% !important;
}
.el-loading-mask .el-loading-spinner p.el-loading-text{
  display: block!important;
  text-align: center!important;
  bottom: 10px!important;
  top: 80px!important;
.el-loading-mask .el-loading-spinner p.el-loading-text {
  display: block !important;
  text-align: center !important;
  bottom: 10px !important;
  top: 80px !important;
  right: 0 !important;
  color: #78adf7;
}
.el-loading-mask .el-loading-spinner .path{
.el-loading-mask .el-loading-spinner .path {
  stroke: #78adf7;
}
.installInfo {
@@ -1647,7 +1735,8 @@
          }
        }
      }
      .store-list,.app-list {
      .store-list,
      .app-list {
        display: flex;
        flex-wrap: wrap;
        .wrap-box {
@@ -1801,7 +1890,7 @@
      z-index: 1;
      border-radius: 3px;
      display: none;
      .info-onmask{
      .info-onmask {
        color: #8ecaff;
      }
      i {
@@ -1893,12 +1982,11 @@
        .bot-btn {
          flex: 1;
        }
        &.flex-center{
        &.flex-center {
          align-items: center;
          justify-content: center;
        }
      }
    }
    .list-choose-item-left-uninstal {
      color: darkgray;
@@ -2073,11 +2161,11 @@
          max-height: 106px;
        }
      }
      &.uninstall{
        .svg-wrap{
      &.uninstall {
        .svg-wrap {
          background-color: #ddd;
        }
        .alg-name{
        .alg-name {
          color: darkgray;
        }
      }