Browse Source

上传代码

master
杨豪 3 years ago
parent
commit
6cf8b20993
  1. 2
      src/layout/components/Sidebar/Logo.vue
  2. 5
      src/router/routers.js
  3. 1
      src/store/getters.js
  4. 3
      src/store/modules/api.js
  5. 106
      src/views/wechat/reply/addReply.vue

2
src/layout/components/Sidebar/Logo.vue

@ -25,7 +25,7 @@ export default {
}, },
data() { data() {
return { return {
title: '禅易精舍后台管理系统', title: '禅易云生态管理系统',
logo: Logo logo: Logo
} }
} }

5
src/router/routers.js

@ -67,11 +67,12 @@ export const constantRouterMap = [
}, },
component: (resolve) => require(['@/components/editorMaterial/index'], resolve), component: (resolve) => require(['@/components/editorMaterial/index'], resolve),
hidden: true hidden: true
} },
{ path: '*', component: (resolve) => require(['@/views/home'], resolve) }
] ]
export default new Router({ export default new Router({
mode: 'hash', mode: 'history',
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRouterMap routes: constantRouterMap
}) })

1
src/store/getters.js

@ -19,6 +19,7 @@ const getters = {
uploadApi: state => state.api.uploadApi, uploadApi: state => state.api.uploadApi,
updateAvatarApi: state => state.api.updateAvatarApi, updateAvatarApi: state => state.api.updateAvatarApi,
qiNiuUploadApi: state => state.api.qiNiuUploadApi, qiNiuUploadApi: state => state.api.qiNiuUploadApi,
wechatUploadApi: state => state.api.wechatUploadApi,
sqlApi: state => state.api.sqlApi, sqlApi: state => state.api.sqlApi,
swaggerApi: state => state.api.swaggerApi swaggerApi: state => state.api.swaggerApi
} }

3
src/store/modules/api.js

@ -12,6 +12,9 @@ const api = {
// 修改头像 // 修改头像
updateAvatarApi: baseUrl + '/api/users/updateAvatar', updateAvatarApi: baseUrl + '/api/users/updateAvatar',
// 上传文件到七牛云 // 上传文件到七牛云
wechatUploadApi: baseUrl + '/api/wechat/upload',
// 公众号自动回复上传图片地址
qiNiuUploadApi: baseUrl + '/api/qiNiuContent', qiNiuUploadApi: baseUrl + '/api/qiNiuContent',
uploadApi: baseUrl + '/api/upload', uploadApi: baseUrl + '/api/upload',

106
src/views/wechat/reply/addReply.vue

@ -41,7 +41,7 @@
<div class="view-item text-box clearfix" :class="{show:type=='image'}"> <div class="view-item text-box clearfix" :class="{show:type=='image'}">
<div class="avatar fl"><img src="../../../assets/wechat/head.gif"></div> <div class="avatar fl"><img src="../../../assets/wechat/head.gif"></div>
<div class="box-content fl"> <div class="box-content fl">
<img class="picbox" :src="dataGroup.image.mediaId" alt=""> <img class="picbox" :src="dataGroup.image.src" alt="">
</div> </div>
</div> </div>
@ -105,7 +105,7 @@
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<div class="group-item"> <div class="group-item">
<input v-model="key" style="position: relative;top: 1px;left: 3px;" :disabled="readonly"> <el-input v-model="key" style="position: relative;top: 1px;left: 3px;" :disabled="readonly"></el-input>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -117,10 +117,12 @@
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<div class="col-sm-10 group-item"> <div class="col-sm-10 group-item">
<select v-model="type" class="form-control m-b" name="account"> <el-select v-model="type" class=" m-b" name="account">
<option value="text">文字消息</option> <el-option value="text" label="文字消息"></el-option>
<option value="image">图片</option> <el-option value="image" label="图片"></el-option>
</select> <!-- <option value="net">地址</option> -->
<el-option value="news" label="文章"></el-option>
</el-select>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -130,15 +132,46 @@
<div class="control-item control-main-txt" :class="{show:type=='text'}"> <div class="control-item control-main-txt" :class="{show:type=='text'}">
<div class="form-group clearfix"> <div class="form-group clearfix">
<label class="col-sm-2 tips" for="">规则内容</label> <label class="col-sm-2 tips" for="">规则内容</label>
<div class="col-sm-10 group-item"> <div class="col-sm-10 group-item" style="margin-top:10px">
<textarea id="" v-model="dataGroup.text.content" name="" cols="30" rows="10" placeholder="请输入内容" /> <el-input type="textarea" v-model="dataGroup.text.content" placeholder="请输入内容"></el-input>
</div> </div>
</div> </div>
</div> </div>
<!-- 图片 --> <!-- 图片 -->
<div class="control-item control-main-picture" :class="{show:type=='image'}"> <div class="control-item control-main-picture" :class="{show:type=='image'}">
<div class="form-group clearfix"> <div class="form-group clearfix">
<pic-upload v-model="dataGroup.image.mediaId" style="width: 500px;" /> <el-upload
class="pic-uploader-component"
:action="wechatUploadApi"
:headers="headers"
:show-file-list="false"
:on-success="handleUploadSuccess"
:before-upload="beforeAvatarUpload"
>
<img v-if="dataGroup.image.src" :src="dataGroup.image.src" class="pic">
<i v-else class="el-icon-plus pic-uploader-icon" />
</el-upload>
</div>
</div>
<!-- 地址 -->
<!-- <div class="control-item control-main-txt" :class="{show:type=='net'}">
<div class="form-group clearfix">
<label class="col-sm-2 control-label tips" for="">请输入地址</label>
<input type="text" v-model="dataGroup.net.content" placeholder="请输入地址" style="position: relative;top: 1px;left: 24px;">
</div>
</div> -->
<!-- 选择文章 -->
<div class="control-item control-main-txt" :class="{show:type=='news'}">
<div class="form-group clearfix">
<label class="col-sm-2 control-label tips" for="">请选择文章</label>
<el-select v-model="dataGroup.news.articleId" clearable placeholder="请选择文章" style="position: relative;top: 1px;left: 24px;">
<el-option
v-for="item in articleList"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
</div> </div>
</div> </div>
</div> </div>
@ -161,6 +194,8 @@ import { del, add, get } from '@/api/yxWechatReply'
import eForm from './form' import eForm from './form'
import picUpload from '@/components/pic-upload' import picUpload from '@/components/pic-upload'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
export default { export default {
components: { eForm, picUpload }, components: { eForm, picUpload },
mixins: [initData], mixins: [initData],
@ -180,25 +215,41 @@ export default {
content: '' content: ''
}, },
image: { image: {
src: '' src: '',
mediaId:'',
},
article:{
}, },
voice: { voice: {
src: '' src: ''
}, },
news: [] news: {
articleId:'',
}
}, },
uploadColl: function() { uploadColl: function() {
}, },
uploadLink: '', uploadLink: '',
result: null result: null,
headers: {
'Authorization': getToken()
},
articleList:[]
} }
}, },
computed: {
...mapGetters([
'wechatUploadApi'
])
},
created() { created() {
this.$nextTick(() => { this.$nextTick(() => {
this.init() this.init()
}) })
}, },
mounted: function() { mounted: function() {
this.getArticleList()
this.key = 'subscribe' this.key = 'subscribe'
this.msg = '编辑关注回复' this.msg = '编辑关注回复'
get().then(rese => { get().then(rese => {
@ -217,8 +268,28 @@ export default {
}) })
}, },
methods: { methods: {
//
getArticleList(){
this.$http('/api/yxArticle?page=100&size=100&sort=id,desc','get').then((res)=>{
this.articleList = res.content
})
},
//
handleUploadSuccess(response, file, fileList) {
console.log(file)
this.dataGroup.image.src= file.response.url;
this.dataGroup.image.mediaId= file.response.mediaId;
},
//
beforeAvatarUpload(file) {
console.log(file)
const isLt2M = file.size / 1024 / 1024 < 2
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!')
}
return isLt2M
},
radioChange(){ radioChange(){
console.log(this.replyStatus)
if(this.replyStatus == 1){ if(this.replyStatus == 1){
this.key = 'subscribe' this.key = 'subscribe'
this.readonly = true this.readonly = true
@ -259,6 +330,7 @@ export default {
edit(data) { edit(data) {
this.isAdd = false this.isAdd = false
const _this = this.$refs.form const _this = this.$refs.form
console.log(data,'data')
_this.form = { _this.form = {
id: data.id, id: data.id,
key: data.key, key: data.key,
@ -271,9 +343,11 @@ export default {
}, },
submit: function() { submit: function() {
if (!this.check()) return false if (!this.check()) return false
console.log(this.type)
console.log(this.dataGroup[this.type])
add({ key: this.key, status: this.status, data: this.dataGroup[this.type], type: this.type }).then(function(res) { add({ key: this.key, status: this.status, data: this.dataGroup[this.type], type: this.type }).then(function(res) {
Message({ message: '设置成功', type: 'success' }) Message({ message: '设置成功', type: 'success' })
}).catch(function(err) { }).catch(function(err) {
// Message({message: err,type: 'error'}) // Message({message: err,type: 'error'})
}) })
@ -288,6 +362,10 @@ export default {
// if (dataGroup.image.src == '') { return this.returnError('') } // if (dataGroup.image.src == '') { return this.returnError('') }
if (dataGroup.image.mediaId == '') { return this.returnError('请上传图片') } if (dataGroup.image.mediaId == '') { return this.returnError('请上传图片') }
break break
case 'image':
// if (dataGroup.image.src == '') { return this.returnError('') }
if (dataGroup.image.articleId == '') { return this.returnError('请选择文章') }
break
} }
return true return true
} }

Loading…
Cancel
Save