Browse Source

公众号菜单:上传微信公众号素材永久图片,图库

zhengchengwu 4 years ago
parent
commit
51d51e490b

+ 2 - 0
index.html View File

@@ -5,6 +5,8 @@
5 5
     <meta charset="utf-8">
6 6
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7 7
     <meta name="renderer" content="webkit">
8
+    <meta name=”referrer” content=”never”>
9
+    <meta name="referrer" content="no-referrer"/>
8 10
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
9 11
     <title>血透管理-酷医云</title>
10 12
   </head>

+ 9 - 0
src/api/mpwechat/material.js View File

@@ -0,0 +1,9 @@
1
+import request from '@/utils/request'
2
+
3
+export function GetMaterials(params) {
4
+    return request({
5
+        url: '/api/mpwechat/media/material',
6
+        method: 'get',
7
+        params:params
8
+    })
9
+}

+ 219 - 0
src/scrm_pages/contactBox/index.vue View File

@@ -0,0 +1,219 @@
1
+<template>
2
+    <div class="contact-box" id="contact-box">
3
+        <div class="contact-box-item msg-box" >
4
+            <div class="box-btn " @click="showMsgBox=true">
5
+                <i class="el-icon-service"></i>
6
+                <span>在线客服</span>
7
+            </div>
8
+            <div class="contact-info-box" v-show="!showMsgBox">
9
+                点击打开在线客服
10
+            </div>
11
+            <div class="contact-msg-box" v-show="showMsgBox">
12
+                <div class="msg-box-panel">
13
+                    <div class="panel-header">
14
+                        <i class="el-icon-close kf-close" @click="showMsgBox=false"></i>
15
+                        <p class="kf-h-line">酷医云在线客服</p>
16
+                        <div class="clearfix"></div>
17
+                    </div>
18
+                    <div class="panel-body">
19
+                        <ul class="msg-inner scroll-y">
20
+                            <li>1</li>
21
+                            <li>1</li>
22
+                            <li>1</li>
23
+                            <li>1</li>
24
+                            <li>1</li>
25
+                            <li>1</li>
26
+                            <li>1</li>
27
+                            <li>1</li>
28
+                            <li>1</li>
29
+                            <li>1</li>
30
+                            <li>1</li>
31
+                            <li>1</li>
32
+                            <li>1</li>
33
+                            <li>1</li>
34
+                            <li>1</li>
35
+                            <li>1</li>
36
+                            <li>1</li>
37
+                            <li>1</li>
38
+                            <li>1</li>
39
+                            <li>1</li>
40
+                            <li>1</li>
41
+                            <li>1</li>
42
+                            <li>1</li>
43
+                            <li>1</li>
44
+                            <li>1</li>
45
+                            <li>1</li>
46
+                        </ul>
47
+                    </div>
48
+                </div>
49
+            </div>
50
+        </div>
51
+        <div class="contact-box-item phone-box">
52
+            <div class="box-btn">
53
+                <i class="el-icon-phone-outline"></i>
54
+                <span>客服电话</span>
55
+            </div>
56
+            <div class="contact-phone-box">
57
+                <i class="el-icon-phone-outline"></i>
58
+                <span>0755-86526342</span>
59
+            </div>
60
+        </div>
61
+    </div>
62
+</template>
63
+<script>
64
+export default {
65
+    name:'contactBox',
66
+    data(){
67
+        return{
68
+            showMsgBox:false,
69
+        }
70
+    }
71
+
72
+}
73
+</script>
74
+
75
+<style scoped>
76
+.contact-box {
77
+    position: fixed;
78
+    right: 12px;
79
+    bottom: 10%;
80
+    margin-top: -100px;
81
+    z-index: 99999;
82
+}
83
+    
84
+.contact-box .contact-box-item{
85
+    position: relative;
86
+    margin-bottom: 6px;
87
+    border: 1px solid #999;
88
+}
89
+
90
+.contact-box .contact-box-item .box-btn {
91
+    width: 48px;
92
+    height: 48px;
93
+    text-align: center;
94
+    display: block;
95
+    position: relative;
96
+    background: #fff;
97
+    cursor: pointer;
98
+}
99
+.contact-box .contact-box-item .box-btn i{
100
+    font-size:30px; 
101
+    margin: 9px;
102
+    color: #59a3ec;
103
+    display: inline-block;
104
+}
105
+.contact-box .contact-box-item .box-btn:hover {
106
+    background: #5aa6f1;
107
+}
108
+.contact-box .box-btn span{
109
+    display: none;
110
+}
111
+
112
+.contact-box .box-btn:hover span{
113
+    display: block;
114
+    color:#fff;
115
+    padding: 8px;
116
+    font-size: 14px;
117
+}
118
+.contact-box .box-btn:hover i{
119
+    display: none;
120
+}
121
+.contact-box .contact-phone-box {
122
+    border: 1px solid #999;
123
+    position: absolute;
124
+    bottom: 0px;
125
+    right: 56px;
126
+    height: 48px;
127
+    /* display: block; */
128
+    background: #fff;
129
+    width: 230px;
130
+    display:none;
131
+    align-items: center;
132
+}
133
+.contact-box .contact-phone-box i {
134
+    color: #59a3ec;
135
+    font-size:30px; 
136
+    margin: 9px;
137
+}
138
+.contact-box .phone-box:hover .contact-phone-box{
139
+    display:flex;
140
+}
141
+
142
+.contact-box .contact-phone-box span {
143
+    font-size:20px; 
144
+    margin-left: 15px;
145
+    color: #485b6d;
146
+}
147
+
148
+.contact-box .contact-info-box {
149
+    border: 1px #e5e5e5 solid;
150
+    position: absolute;
151
+    bottom: 0px;
152
+    right: 56px;
153
+    display: none;
154
+    background: #fff;
155
+    width: 175px;
156
+    z-index: 1000000;
157
+}
158
+.contact-box .msg-box:hover .contact-info-box{
159
+    display:block;
160
+    color: #485b6d;
161
+    font-size:20px; 
162
+    padding: 5px;
163
+}
164
+
165
+.contact-box .contact-msg-box {
166
+    border: 1px #e5e5e5 solid;
167
+    position: absolute;
168
+    bottom: 0px;
169
+    right: 56px;
170
+    background: #fff;
171
+}
172
+.contact-box .msg-box-panel {
173
+    width: 408px;
174
+    background-color: #fff;
175
+    position: relative;
176
+}
177
+.contact-box .panel-header {
178
+    border-bottom: 1px #e5e5e5 solid;
179
+}
180
+.contact-box .panel-header .kf-close {
181
+    width: 30px;
182
+    height: 20px;
183
+    float: right;
184
+    cursor: pointer;
185
+    margin: 12px 0 0 0;
186
+}
187
+.contact-box .panel-header .kf-h-line {
188
+    float: left;
189
+    color: #485b6d;
190
+    font-size: 16px;
191
+    line-height: 40px;
192
+    height: 40px;
193
+    padding-left: 10px;
194
+}
195
+.contact-box .panel-body {
196
+    overflow-x: visible;
197
+    overflow-y: auto;
198
+    height: 182px;
199
+}
200
+
201
+.contact-box .msg-inner {
202
+    overflow-y: auto;
203
+    overflow-x: hidden;
204
+    height: 100%;
205
+    border-bottom: 1px #e5e5e5 solid;
206
+}
207
+.contact-box .scroll-y::-webkit-scrollbar {
208
+    width: 6px;
209
+    height: 3px;
210
+}
211
+.contact-box .scroll-y::-webkit-scrollbar-thumb {
212
+    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.1);
213
+    box-shadow: inset 0 0 6px rgba(0,0,0,.1);
214
+    border-radius: 2px;
215
+}
216
+.contact-box .scroll-y::-webkit-scrollbar-track {
217
+    border-radius: 2px;
218
+}
219
+</style>

+ 193 - 0
src/scrm_pages/weixinmp/components/ImageMaterialBox.vue View File

@@ -0,0 +1,193 @@
1
+<template>
2
+    <div id="image-material-box">
3
+        <el-dialog title="选择图片" :visible.sync="ImageMaterialBoxVisible" width="900px" >
4
+            <el-row>
5
+                <el-col :span="24" style="text-align: right;" >
6
+                    <el-upload
7
+                        class="media-uploader"
8
+                        :action="addMaterialUrl"
9
+                        :show-file-list="false"
10
+                        :with-credentials='true'
11
+                        :on-success="handleMediaSuccess"
12
+                        :before-upload="beforeMediaUpload"
13
+                        >
14
+                        <el-button type="primary" size="small" icon="el-icon-upload" >上传图片</el-button>
15
+                    </el-upload>
16
+                </el-col>
17
+            </el-row>
18
+            <div class="material-box">
19
+                <div class="mateial-item" v-for="(media, index) in medias" :key="index" @click="selectThis(media.media_id, media.media_url)">
20
+                    <div class="mateial-item-image" :class="selectId==media.media_id?'active':''">
21
+                        <img :src="'http://img01.store.sogou.com/net/a/04/link?appid=100520029&url='+media.media_url" alt="" srcset="">
22
+                    </div>
23
+                </div>
24
+            </div>
25
+            <el-row style="clear:both">
26
+                <el-pagination
27
+                    @size-change="handleSizeChange"
28
+                    @current-change="handleCurrentChange"
29
+                    :page-sizes="[20,50,100]"
30
+                    :page-size="20"
31
+                    :current-page="pageParams.page"
32
+                    background
33
+                    style="margin-top:20px;"
34
+                    align="right"
35
+                    layout="total, sizes, prev, pager, next, jumper"
36
+                    :total="total">
37
+                </el-pagination>
38
+            </el-row>
39
+            <div slot="footer" class="dialog-footer">
40
+                <el-button @click="ImageMaterialBoxVisible = false">取消</el-button>
41
+                <el-button
42
+                type="primary"
43
+                @click="submitSelect"
44
+                >保 存
45
+                </el-button>
46
+            </div>
47
+        </el-dialog>  
48
+    </div>
49
+</template>
50
+
51
+<script>
52
+
53
+import {GetMaterials} from "@/api/mpwechat/material";
54
+
55
+export default {
56
+    name:'imageMaterialBox',
57
+    props:{
58
+        currentMenu:{
59
+            big_type:0,
60
+            type:'',
61
+            name:'',
62
+            url:'',
63
+            appid:'',
64
+            pagepath:'',
65
+            key:'',//key规则:V_[number]_click;VC_[number]_click
66
+            message:'',
67
+            sub_button:[],
68
+            media_id:'',
69
+            media_url:'',
70
+        },
71
+    },
72
+    data(){
73
+        return {
74
+            addMaterialUrl: process.env.BASE_API + '/api/mpwechat/media/add_material',
75
+            ImageMaterialBoxVisible:false,
76
+            medias:[],
77
+            selectId:'',
78
+            selectUrl:'',
79
+            total:0,
80
+            pageParams:{
81
+                page:1,
82
+                limit:20,
83
+                media_type:'image',
84
+            },
85
+        }
86
+    },
87
+    methods:{
88
+        open:function(){
89
+            
90
+            this.pageParams={
91
+                page:1,
92
+                limit:20,
93
+                media_type:'image',
94
+            },
95
+            
96
+            this.selectId='',
97
+            this.selectUrl='',
98
+            this.GetMaterials();
99
+            this.ImageMaterialBoxVisible = true;
100
+        },
101
+        submitSelect:function(){
102
+            if (this.selectId.length==0) {
103
+                this.$message.error('未选择图片');
104
+                return false;
105
+            }
106
+            this.currentMenu.media_id = this.selectId;
107
+            this.currentMenu.media_url = 'http://img01.store.sogou.com/net/a/04/link?appid=100520029&url=' +  this.selectUrl;
108
+            this.ImageMaterialBoxVisible = false;
109
+        },
110
+        selectThis(id, url) {
111
+            this.selectId = id;
112
+            this.selectUrl = url;
113
+        },
114
+        handleSizeChange(limit) {
115
+            this.pageParams.limit = limit;
116
+            this.GetMaterials();
117
+        },
118
+        handleCurrentChange(page) {
119
+            this.pageParams.page = page;
120
+            this.GetMaterials();
121
+        },
122
+        handleMediaSuccess:function(res, file) {
123
+            if (res.state==1) {
124
+                this.$message.success('上传成功');
125
+                this.currentMenu.media_url = 'http://img01.store.sogou.com/net/a/04/link?appid=100520029&url=' + res.data.media.media_url;
126
+                this.currentMenu.media_id =  res.data.media.media_id;
127
+                this.pageParams.page = 1;
128
+                
129
+                this.selectId='',
130
+                this.selectUrl='',
131
+                this.GetMaterials();
132
+            }else {
133
+                this.$message.error(res.msg);
134
+            }
135
+        },
136
+        beforeMediaUpload:function(file) {
137
+            var allow = {"image/bmp":1,"image/png":1,"image/jpeg":1,"image/jpg":1,"image/gif":1};
138
+            // const isJPG = file.type === 'image/jpeg';
139
+            const isImg = file.type in allow;
140
+            const isLt2M = file.size / 1024 / 1024 < 2;
141
+
142
+            if (!isImg) {
143
+                this.$message.error('上传图片只能是 bmp/png/jpeg/jpg/gif 格式!');
144
+            }
145
+            if (!isLt2M) {
146
+                this.$message.error('上传图片大小不能超过 2MB!');
147
+            }
148
+            return isImg && isLt2M;
149
+        },
150
+        GetMaterials:function(){
151
+            GetMaterials(this.pageParams).then(response=>{
152
+                var res = response.data;
153
+                if (res.state==1) {
154
+                    this.medias = res.data.medias;
155
+                    this.total = res.data.total;
156
+                }
157
+            }).catch(e=>{});
158
+        }
159
+    }
160
+}
161
+</script>
162
+
163
+<style >
164
+#image-material-box .mateial-item {
165
+    float: left;
166
+    margin: 6px;
167
+}
168
+
169
+#image-material-box  .mateial-item-image {
170
+    width: 199px;
171
+    height: 90px;
172
+    position: relative;
173
+    border: none;
174
+    background: #dde1e4;
175
+    color: #58a2ec;
176
+    display: block;
177
+    padding: 4px;
178
+    line-height: 1.42857143;
179
+    background-color: #fff;
180
+    -webkit-transition: border .2s ease-in-out;
181
+    transition: border .2s ease-in-out;
182
+}
183
+
184
+#image-material-box  .mateial-item .active {
185
+    border: 1px solid rgb(68, 181, 73);
186
+}
187
+#image-material-box  .mateial-item-image img {
188
+    width: 100%;
189
+    height: 100%;
190
+    position: relative;
191
+}
192
+</style>
193
+

+ 60 - 23
src/scrm_pages/weixinmp/menus.vue View File

@@ -105,7 +105,7 @@
105 105
                               <el-row>
106 106
                                 <el-col :span="12" >
107 107
                                   <div class="mediaID-item">
108
-                                    <i class="el-icon-news"></i>
108
+                                    <i class="el-icon-news" @click="openMediaBox"></i>
109 109
                                     <span class="icon-name">从素材库选择</span>
110 110
                                   </div>
111 111
                                 </el-col>
@@ -126,6 +126,9 @@
126 126
                                   </div>
127 127
                                 </el-col>
128 128
                               </el-row>
129
+                              
130
+                            <span class="tips" id="acterrinfo"  >&nbsp;&nbsp;如果出现:此图片来自微信公众平台,未经允许不可引用!是正常情况</span>
131
+                              
129 132
                             </div>
130 133
                         </div>
131 134
                         <div class="inner  jump_page" v-show="menuType==2">
@@ -165,18 +168,22 @@
165 168
           </div>
166 169
       </div>
167 170
     </div>
171
+    <!--选择图片-->
172
+    <image-material-box ref="imageMaterialBox" :currentMenu="currentMenu"></image-material-box>
168 173
   </div>
169 174
 </template>
170 175
 
171 176
 <script>
172
-import axios from 'axios';
173 177
 import BreadCrumb from "../components/bread-crumb";
178
+import ImageMaterialBox from "./components/ImageMaterialBox";
174 179
 import {GetAuthorizationInfo} from "@/api/mpwechat/mpwechat";
175 180
 import {GetMenus,SaveMenus,DeleteMenu} from "@/api/mpwechat/mpmenus";
181
+
176 182
 export default {
177 183
   name: "menus",
178 184
   components: {
179 185
     BreadCrumb,
186
+    ImageMaterialBox,
180 187
   },
181 188
   data() {
182 189
     return {
@@ -262,23 +269,32 @@ export default {
262 269
         }
263 270
       }).catch(e=>{});
264 271
     },
265
-     handleMediaSuccess:function(res, file) {
266
-       console.log(res, file);
267
-      },
268
-      beforeMediaUpload:function(file) {
269
-        var allow = {"image/bmp":1,"image/png":1,"image/jpeg":1,"image/jpg":1,"image/gif":1};
270
-        // const isJPG = file.type === 'image/jpeg';
271
-        const isImg = file.type in allow;
272
-        const isLt2M = file.size / 1024 / 1024 < 2;
272
+    openMediaBox:function(){
273
+      this.$refs.imageMaterialBox.open();
274
+    },
275
+    handleMediaSuccess:function(res, file) {
276
+      if (res.state==1) {
277
+        this.$message.success('上传成功');
278
+        this.currentMenu.media_url = 'http://img01.store.sogou.com/net/a/04/link?appid=100520029&url=' + res.data.media.media_url;
279
+        this.currentMenu.media_id =  res.data.media.media_id;
280
+      }else {
281
+        this.$message.error(res.msg);
282
+      }
283
+    },
284
+    beforeMediaUpload:function(file) {
285
+      var allow = {"image/bmp":1,"image/png":1,"image/jpeg":1,"image/jpg":1,"image/gif":1};
286
+      // const isJPG = file.type === 'image/jpeg';
287
+      const isImg = file.type in allow;
288
+      const isLt2M = file.size / 1024 / 1024 < 2;
273 289
 
274
-        if (!isImg) {
275
-          this.$message.error('上传图片只能是 bmp/png/jpeg/jpg/gif 格式!');
276
-        }
277
-        if (!isLt2M) {
278
-          this.$message.error('上传图片大小不能超过 2MB!');
279
-        }
280
-        return isImg && isLt2M;
281
-      },
290
+      if (!isImg) {
291
+        this.$message.error('上传图片只能是 bmp/png/jpeg/jpg/gif 格式!');
292
+      }
293
+      if (!isLt2M) {
294
+        this.$message.error('上传图片大小不能超过 2MB!');
295
+      }
296
+      return isImg && isLt2M;
297
+    },
282 298
     deleteMenus:function(){
283 299
       this.$confirm('删除后,公众号的菜单也将被删除', '删除提示', {
284 300
         dangerouslyUseHTMLString:true,
@@ -729,6 +745,20 @@ export default {
729 745
       }
730 746
       this.CheckPagePathError();
731 747
     },  
748
+    'currentMenu.media_id':function(){
749
+      if (this.currentPatient>=0&&this.currentChild>=0) {
750
+        this.menus.button[this.currentPatient].sub_button[this.currentChild].media_id = this.currentMenu.media_id;
751
+      } else if (this.currentPatient>=0){
752
+        this.menus.button[this.currentPatient].media_id = this.currentMenu.media_id;
753
+      }
754
+    },
755
+    'currentMenu.media_url':function(){
756
+      if (this.currentPatient>=0&&this.currentChild>=0) {
757
+        this.menus.button[this.currentPatient].sub_button[this.currentChild].media_url = this.currentMenu.media_url;
758
+      } else if (this.currentPatient>=0){
759
+        this.menus.button[this.currentPatient].media_url = this.currentMenu.media_url;
760
+      }
761
+    },
732 762
     'currentMenu.message':function(){
733 763
       var len = $.trim(this.currentMenu.message+'').length; 
734 764
       var mt = 600-len;
@@ -1111,11 +1141,18 @@ export default {
1111 1141
     /* cursor: pointer; */
1112 1142
 }
1113 1143
 
1144
+#winxin-menus-box .mediaID-item .el-icon-news{
1145
+  
1146
+    cursor: pointer;
1147
+}
1148
+
1114 1149
 /* #winxin-menus-box .mediaID-item:hover {
1115 1150
   background:#c0c8d4;
1116 1151
 }  */
1117 1152
 #winxin-menus-box .mediaID-item i {
1118 1153
   display: block;
1154
+    width: 80px;
1155
+    margin: 0 auto;
1119 1156
 }
1120 1157
 #winxin-menus-box .mediaID-item .el-icon-news {
1121 1158
   font-size: 80px;
@@ -1134,14 +1171,14 @@ export default {
1134 1171
 #winxin-menus-box .mediaID-item .media-uploader-icon {
1135 1172
   font-size: 28px;
1136 1173
   color: #8c939d;
1137
-  width: 55px;
1138
-  height: 55px;
1139
-  line-height: 55px;
1174
+  width: 155px;
1175
+  height: 70px;
1176
+  line-height: 70px;
1140 1177
   text-align: center;
1141 1178
 }
1142 1179
 #winxin-menus-box .mediaID-item  .media {
1143
-  width: 55px;
1144
-  height: 55px;
1180
+  width: 155px;
1181
+  height: 70px;
1145 1182
   display: block;
1146 1183
 }
1147 1184
 

+ 4 - 1
src/views/layout/Layout.vue View File

@@ -8,6 +8,7 @@
8 8
     <div class="main-container">
9 9
       <tags-view></tags-view>
10 10
       <app-main></app-main>
11
+      <contact-box></contact-box>
11 12
     </div>
12 13
    </div>
13 14
   </div>
@@ -15,6 +16,7 @@
15 16
 
16 17
 <script>
17 18
 import { Navbar, Sidebar, AppMain, TagsView } from './components'
19
+import ContactBox from '@/scrm_pages/contactBox';
18 20
 import ResizeMixin from './mixin/ResizeHandler'
19 21
 
20 22
 export default {
@@ -23,7 +25,8 @@ export default {
23 25
     Navbar,
24 26
     Sidebar,
25 27
     AppMain,
26
-    TagsView
28
+    TagsView,
29
+    ContactBox,
27 30
   },
28 31
   mixins: [ResizeMixin],
29 32
   computed: {