From ccd7b3c5b24fa115a732ea915e2e586de717ea1c Mon Sep 17 00:00:00 2001
From: “dzb” <2632970487@qq.com>
Date: 星期一, 26 九月 2022 21:39:43 +0800
Subject: [PATCH] 完成logo管理

---
 src/views/systemSetting/platform/portalSetting/index.vue |  179 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 127 insertions(+), 52 deletions(-)

diff --git a/src/views/systemSetting/platform/portalSetting/index.vue b/src/views/systemSetting/platform/portalSetting/index.vue
index 3f9217c..3bac3e2 100644
--- a/src/views/systemSetting/platform/portalSetting/index.vue
+++ b/src/views/systemSetting/platform/portalSetting/index.vue
@@ -11,30 +11,23 @@
                 <li>
                     <div class="desc">浜у搧鍥炬爣锛氫富瑕佺敤浜庣綉椤靛ご閮�</div>
                     <div class="upload">
-                        <div class="uploadBtn">
-                            <i class="el-icon-plus"></i>
-                            <span>涓婁紶鍥剧墖</span>
-                        </div>
+                        <MyUpload @getPicUrl="setPicUrl" mykey="chromeLinkUrl" :picUrl="icon.chromeLinkUrl"></MyUpload>
                         <div class="uploadTip"><span>鍙厑璁镐笂浼爅pg,jpeg,png,svg鏍煎紡鐨勫浘鐗囷紝寤鸿灏哄涓�105px*105px</span></div>
                     </div>
                 </li>
                 <li>
                     <div class="desc">缃戠珯鍥炬爣锛氫富瑕佺敤浜庢祻瑙堝櫒鏍囩椤�</div>
                     <div class="upload">
-                        <div class="uploadBtn">
-                            <i class="el-icon-plus"></i>
-                            <span>涓婁紶鍥剧墖</span>
-                        </div>
+                        <MyUpload @getPicUrl="setPicUrl" mykey="websiteHeadUrl" :picUrl="icon.websiteHeadUrl">
+                        </MyUpload>
                         <div class="uploadTip"><span>鍙厑璁镐笂浼爅pg,jpeg,png,svg鏍煎紡鐨勫浘鐗囷紝寤鸿灏哄涓�105px*105px</span></div>
                     </div>
                 </li>
                 <li>
                     <div class="desc">鐧诲綍椤靛浘鏍囷細涓昏鐢ㄤ簬鐧诲綍椤�</div>
                     <div class="upload">
-                        <div class="uploadBtn">
-                            <i class="el-icon-plus"></i>
-                            <span>涓婁紶鍥剧墖</span>
-                        </div>
+                        <MyUpload @getPicUrl="setPicUrl" mykey="loginPageIconUrl" :picUrl="icon.loginPageIconUrl">
+                        </MyUpload>
                         <div class="uploadTip"><span>鍙厑璁镐笂浼爅pg,jpeg,png,svg鏍煎紡鐨勫浘鐗囷紝寤鸿灏哄涓�105px*105px</span></div>
                     </div>
                 </li>
@@ -44,28 +37,117 @@
             <div class="webTitle">
                 <div class="text">缃戠珯鏍囬:</div>
                 <div class="inner">
-                    <el-input type="text" placeholder="閬傛槍鎵ф硶灞�" v-model="title"></el-input>
+                    <el-input type="text" placeholder="閬傛槍鎵ф硶灞�" v-model="icon.title"></el-input>
                 </div>
             </div>
             <div class="footerBtn">
                 <el-button class="cancel">杩斿洖</el-button>
-                <el-button type="primary">鎻愪氦</el-button>
+                <el-button type="primary" @click="changeLogo">鎻愪氦</el-button>
             </div>
         </footer>
     </div>
 </template>
 <script>
+import MyUpload from '@/components/Upload'
 export default {
+    components: {
+        MyUpload,
+    },
     data() {
         return {
-            title:'',
-            icon:{
-                login:'',
-                website:'',
-                product:'',
-            }
+            icon: {
+                loginPageIconUrl: '',
+                websiteHeadUrl: '',
+                chromeLinkUrl: '',
+                title: '',
+            },
         }
-    }
+
+    },
+    methods: {
+        setPicUrl({obj, value}) {
+            const { icon } = this;
+            const baseUrl = 'http://140.143.152.226:8410/';
+            for (let key in icon) {
+                if (key === value) {
+                    icon[key] = baseUrl + obj.url1;
+                }
+            }
+            this.icon = icon;
+        },
+        // 鏇存敼logo鍏ュ彛
+        async changeLogo() {
+            const {icon} = this;
+            console.log(icon);
+            const preIcon = await this.getIcon();
+            if (preIcon.length === 0) {
+                this.handleChangeLogo();
+                return;
+            }
+            for(let key in icon){
+                if(icon[key]!==''){
+                    preIcon[key] = icon[key];
+                }
+            }
+            this.handleChangeLogo(preIcon);
+        },
+        // 鑾峰彇鏇存敼鍓嶇殑logo
+        async getIcon() {
+            let result;
+            await this.$axios({
+                method: 'get',
+                url: 'sccg/system/portal/logo/search',
+            }).then(res => {
+                result = res.data;
+            })
+            return result;
+        },
+        // 鎵ц鏇存敼logo鎿嶄綔
+        handleChangeLogo(obj = null) {
+            if (obj === null) {
+                const { icon } = this;
+                for (let key in icon) {
+                    if (icon[key] === '') {
+                        delete icon[key];
+                    }
+                }
+                let length = Object.keys(icon).length;
+                if (length !== 0) {
+                    // 鍙戦�佽姹�
+                    this.$axios({
+                        method: 'post',
+                        url: 'sccg/system/portal/logo/add',
+                        data: icon
+                    }).then(res => {
+                        console.log(res);
+                        if (res.code == 200) {
+                            this.$message({
+                                message: res.message,
+                                type: 'success'
+                            })
+                        }
+                    })
+                }
+            } else {
+                console.log(obj);
+                // 鍙戦�佽姹�
+                this.$axios({
+                    method: 'put',
+                    url: 'sccg/system/portal/logo/update',
+                    data: obj
+                }).then(res => {
+                    console.log(res);
+                    this.$message({
+                        message: res.message,
+                        type: 'success'
+                    })
+                })
+            }
+            localStorage.removeItem('pic');
+            window.location.href='';
+
+        }
+    },
 }
 </script>
 <style lang="scss" scoped>
@@ -98,6 +180,7 @@
 
             li {
                 margin-top: 30px;
+
                 .desc {
                     line-height: 22px;
                 }
@@ -107,31 +190,13 @@
                     line-height: 100px;
                     margin-top: 15px;
 
-                    .uploadBtn {
-                        width: 120px;
-                        height: 120px;
-                        background-color:rgba(249, 249, 249, 1);
-                        display: flex;
-                        flex-direction: column;
-                        justify-content: center;
-                        align-items: center;
-                        border-radius: 4px;
-                        i {
-                            font-size: 30px;
-                            font-weight: 650;
-                        }
-
-                        span {
-                            line-height: 22px;
-                        }
-                    }
-
                     .uploadTip {
                         display: flex;
                         align-items: flex-end;
                         margin-left: 20px;
                         font-size: 14px;
-                        span{
+
+                        span {
                             line-height: 22px;
                         }
                     }
@@ -139,34 +204,44 @@
             }
         }
     }
-    footer{
+
+    footer {
         padding: 0 20px;
-        .webTitle{
+
+        .webTitle {
             display: flex;
             line-height: 40px;
-            margin:30px 0;
-            .text{
+            margin: 30px 0;
+
+            .text {
                 flex: 1;
             }
-            .inner{
+
+            .inner {
                 flex: 13;
-                .el-input{
+
+                .el-input {
                     width: 496px;
                 }
-                &::v-deep .el-input__inner{
+
+                &::v-deep .el-input__inner {
                     background-color: #09152f;
-                    border: 1px solid #17324c;;
+                    border: 1px solid #17324c;
+                    ;
                 }
             }
         }
-        .footerBtn{
+
+        .footerBtn {
             display: flex;
             justify-content: center;
-            &::v-deep .el-button{
+
+            &::v-deep .el-button {
                 padding: 12px 40px;
                 font-weight: 600;
             }
-            .cancel{
+
+            .cancel {
                 border: 2px solid #0079fe;
                 color: #0079fe;
             }

--
Gitblit v1.8.0