123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597 |
- <template>
- <div class="app-container">
- <div v-if="!isAdmin">
- <el-tabs v-model="step">
- <el-tab-pane label="首页模版配置" name="first"></el-tab-pane>
- <el-tab-pane label="商城logo配置" name="second"></el-tab-pane>
- </el-tabs>
- <div v-show="step == 'first'">
- <el-form label-width="120px" label-position="right">
- <el-form-item label="选择模版:" style="margin-bottom: 40px">
- <el-radio-group v-model="currentTemplate" @change="changeTemplate()">
- <div class="item">
- <el-radio :label="1">模版一</el-radio>
- <el-image :src="require('@/assets/template/tmp_1_thumb.png')" :preview-src-list="[require('@/assets/template/tmp_1.png')]" fit="cover"></el-image>
- </div>
- <div class="item">
- <el-radio :label="2">模版二</el-radio>
- <el-image :src="require('@/assets/template/tmp_2_thumb.png')" :preview-src-list="[require('@/assets/template/tmp_2.png')]" fit="cover"></el-image>
- </div>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="首页模块设置:" v-show="currentTemplate === 1">
- <div class="diy-table">
- <div class="item head">
- <div class="label">模块名称</div>
- <div class="value">状态</div>
- </div>
- <div class="item">
- <div class="label">分类</div>
- <div class="value">
- <el-switch v-model="switch_classify" disabled></el-switch>
- <span :class="switch_classify ? 'on':''">{{switch_classify ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">轮播图</div>
- <div class="value">
- <el-switch v-model="switch_banner"></el-switch>
- <span :class="switch_banner ? 'on':''">{{switch_banner ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">公告</div>
- <div class="value">
- <el-switch v-model="switch_notice"></el-switch>
- <span :class="switch_notice ? 'on':''">{{switch_notice ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">专属优惠券</div>
- <div class="value">
- <el-switch v-model="switch_coupon"></el-switch>
- <span :class="switch_coupon ? 'on':''">{{switch_coupon ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">客户经理</div>
- <div class="value">
- <el-switch v-model="switch_manager"></el-switch>
- <span :class="switch_manager ? 'on':''">{{switch_manager ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">秒杀专区</div>
- <div class="value">
- <el-switch v-model="switch_seckill"></el-switch>
- <span :class="switch_seckill ? 'on':''">{{switch_seckill ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">好物推荐</div>
- <div class="value">
- <el-switch v-model="switch_recom" disabled></el-switch>
- <span :class="switch_recom ? 'on':''">{{switch_recom ? '开启':'隐藏'}}</span>
- </div>
- </div>
- </div>
- </el-form-item>
- <el-form-item label="首页模块设置:" v-show="currentTemplate === 2">
- <div class="diy-table">
- <div class="item head">
- <div class="label">模块名称</div>
- <div class="value">状态</div>
- </div>
- <div class="item">
- <div class="label">首页弹窗</div>
- <div class="value">
- <el-switch v-model="switch_dialog"></el-switch>
- <span :class="switch_dialog ? 'on':''">{{switch_dialog ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">轮播图</div>
- <div class="value">
- <el-switch v-model="switch_banner"></el-switch>
- <span :class="switch_banner ? 'on':''">{{switch_banner ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">活动专区1</div>
- <div class="value">
- <el-switch v-model="switch_activity1"></el-switch>
- <span :class="switch_activity1 ? 'on':''">{{switch_activity1 ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">分类</div>
- <div class="value">
- <el-switch v-model="switch_classify" disabled></el-switch>
- <span :class="switch_classify ? 'on':''">{{switch_classify ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">活动专区2</div>
- <div class="value">
- <el-switch v-model="switch_activity2"></el-switch>
- <span :class="switch_activity2 ? 'on':''">{{switch_activity2 ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">专场专区</div>
- <div class="value">
- <el-switch v-model="switch_special"></el-switch>
- <span :class="switch_special ? 'on':''">{{switch_special ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">秒杀专区</div>
- <div class="value">
- <el-switch v-model="switch_seckill"></el-switch>
- <span :class="switch_seckill ? 'on':''">{{switch_seckill ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">专属优惠券</div>
- <div class="value">
- <el-switch v-model="switch_coupon"></el-switch>
- <span :class="switch_coupon ? 'on':''">{{switch_coupon ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">客户经理</div>
- <div class="value">
- <el-switch v-model="switch_manager"></el-switch>
- <span :class="switch_manager ? 'on':''">{{switch_manager ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">公告</div>
- <div class="value">
- <el-switch v-model="switch_notice"></el-switch>
- <span :class="switch_notice ? 'on':''">{{switch_notice ? '开启':'隐藏'}}</span>
- </div>
- </div>
- <div class="item">
- <div class="label">新维度分类专区</div>
- <div class="value">
- <el-switch v-model="switch_newclassify" disabled></el-switch>
- <span :class="switch_newclassify ? 'on':''">{{switch_newclassify ? '开启':'隐藏'}}</span>
- </div>
- </div>
- </div>
- </el-form-item>
- </el-form>
- </div>
- <div v-show="step == 'second'">
- <el-form label-width="120px" label-position="right">
- <el-upload
- class="avatar-uploader"
- :action="baseURL + 'common/upload'"
- :headers="myHeaders"
- :show-file-list="false"
- :on-success="uploadSuccess"
- :before-upload="beforeUpload">
- </el-upload>
- <el-form-item label="主logo:" prop="imgUrl">
- <div class="images">
- <div class="main-img">
- <div class="img" v-if="img1_url" @mouseover="img1_hover = true;" @mouseout="img1_hover = false;">
- <el-image ref="img1" :src="img1_url" :preview-src-list="[img1_url]" style="width: 120px; height: 120px" fit="contain"></el-image>
- <div class="mask" v-show="img1_hover">
- <i class="el-icon-zoom-in" @click="previewImage('img1')"></i>
- <i class="el-icon-upload2" @click="uploadImage('img1')"></i>
- </div>
- </div>
- <div class="add" v-else @click="uploadImage('img1')">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- </div>
- </div>
- <div class="tmp-img">
- <el-image :src="require('@/assets/template/template_1.png')" :preview-src-list="[require('@/assets/template/template_1.png')]" style="width: 120px; height: 120px; display: block" fit="contain"></el-image>
- <div class="tmp">示例图</div>
- </div>
- </div>
- <div class="tips">
- <span>建议尺寸:400*400</span>
- </div>
- </el-form-item>
- <el-form-item label="通用logo:" prop="imgUrl">
- <div class="images">
- <div class="main-img">
- <div class="img" v-if="img2_url" @mouseover="img2_hover = true;" @mouseout="img2_hover = false;">
- <el-image ref="img2" :src="img2_url" :preview-src-list="[img2_url]" style="width: 120px; height: 120px" fit="contain"></el-image>
- <div class="mask" v-show="img2_hover">
- <i class="el-icon-zoom-in" @click="previewImage('img2')"></i>
- <i class="el-icon-upload2" @click="uploadImage('img2')"></i>
- </div>
- </div>
- <div class="add" v-else @click="uploadImage('img2')">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- </div>
- </div>
- <div class="tmp-img">
- <el-image :src="require('@/assets/template/template_2.png')" :preview-src-list="[require('@/assets/template/template_2.png')]" style="width: 120px; height: 120px; display: block" fit="contain"></el-image>
- <div class="tmp">示例图</div>
- </div>
- </div>
- <div class="tips">
- <span>建议尺寸:280*60</span>
- </div>
- </el-form-item>
- <el-form-item label="头像logo:" prop="imgUrl">
- <div class="images">
- <div class="main-img">
- <div class="img" v-if="img3_url" @mouseover="img3_hover = true;" @mouseout="img3_hover = false;">
- <el-image ref="img3" :src="img3_url" :preview-src-list="[img3_url]" style="width: 120px; height: 120px" fit="contain"></el-image>
- <div class="mask" v-show="img3_hover">
- <i class="el-icon-zoom-in" @click="previewImage('img3')"></i>
- <i class="el-icon-upload2" @click="uploadImage('img3')"></i>
- </div>
- </div>
- <div class="add" v-else @click="uploadImage('img3')">
- <i class="el-icon-plus avatar-uploader-icon"></i>
- </div>
- </div>
- <div class="tmp-img">
- <el-image :src="require('@/assets/template/template_3.png')" :preview-src-list="[require('@/assets/template/template_3.png')]" style="width: 120px; height: 120px; display: block" fit="contain"></el-image>
- <div class="tmp">示例图</div>
- </div>
- </div>
- <div class="tips">
- <span>建议尺寸:400*400</span>
- </div>
- </el-form-item>
- </el-form>
- </div>
- <div class="page-footer">
- <div class="footer" :class="classObj">
- <el-button type="primary" @click="submitStep1Form" :loading="formLoading" v-if="step == 'first'">{{ formLoading ? '保存中 ...' : '保 存' }}</el-button>
- <el-button type="primary" @click="submitStep2Form" :loading="formLoading" v-if="step == 'second'">{{ formLoading ? '保存中 ...' : '保 存' }}</el-button>
- </div>
- </div>
- </div>
- <div v-else>
- <div class="nodata">超级管理员无法进行商城配置</div>
- </div>
-
- </div>
- </template>
- <script>
- import { getToken, getUserid } from '@/utils/auth';
- import { getTemplate, editAccount, editTemplate, getDetail } from "@/api/merchant";
- import { findElem } from '@/utils/util';
- import { getInfo } from '@/api/user'
- export default {
- data() {
- return {
- isAdmin: JSON.parse(localStorage.getItem("supply_user")).type === 2,
- baseURL: process.env.VUE_APP_BASE_API,
- myHeaders: {'x-token': getToken()},
- step: 'first',
- companyId: JSON.parse(localStorage.getItem("supply_user")).companyWechatId,
- currentTemplate: JSON.parse(localStorage.getItem("supply_user")).useTemplate,
- switch_dialog: true,
- switch_banner: true,
- switch_activity1: true,
- switch_classify: true,
- switch_activity2: true,
- switch_special: true,
- switch_seckill: true,
- switch_coupon: true,
- switch_manager: true,
- switch_notice: true,
- switch_newclassify: true,
- switch_recom: true,
- templateList: [],
- uploadImageType: null,
- img1_url: '',
- img1_hover: false,
- img2_url: '',
- img2_hover: false,
- img3_url: '',
- img3_hover: false,
- formLoading: false
- }
- },
- computed: {
- sidebar() {
- return this.$store.state.app.sidebar
- },
- classObj() {
- return {
- hideSidebar: !this.sidebar.opened,
- openSidebar: this.sidebar.opened
- }
- },
- },
- created() {
- if(this.isAdmin) return false;
- this.getTemplate();
- },
- watch: {
- step() {
- if(this.step === 'first') {
- this.getTemplate();
- }else {
- this.getLogoDetail();
- }
- }
- },
- methods: {
- // 获取模版列表
- getTemplate() {
- getTemplate({
- companyId: this.companyId
- }).then(res => {
- this.templateList = res.data;
- this.initHome();
- })
- },
- // 切换模版
- changeTemplate() {
- this.initHome();
- },
- // 初始化配置
- initHome() {
- let index = findElem(this.templateList, 'templateType', this.currentTemplate);
- this.switch_dialog = this.templateList[index].popupStatus;
- this.switch_banner = this.templateList[index].carouseStatus;
- this.switch_activity1 = this.templateList[index].active1Status;
- this.switch_classify = this.templateList[index].categoryStatus;
- this.switch_activity2 = this.templateList[index].active2Status;
- this.switch_special = this.templateList[index].onlyStatus;
- this.switch_seckill = this.templateList[index].killStatus;
- this.switch_coupon = this.templateList[index].couponStatus;
- this.switch_manager = this.templateList[index].customerStatus;
- this.switch_notice = this.templateList[index].notiveStatus;
- this.switch_newclassify = this.templateList[index].newsStatus;
- this.switch_recom = this.templateList[index].okStatus;
- },
-
- // 保存首页配置
- submitStep1Form() {
- let index = findElem(this.templateList, 'templateType', this.currentTemplate);
- let params = {
- companyWechatId: this.companyId,
- useTemplate: this.currentTemplate,
- companyWechatTemplatesList: [{
- companyWechatTemplateId: this.templateList[index].companyWechatTemplateId,
- templateType: this.templateList[index].templateType,
- popupStatus: this.switch_dialog,
- carouseStatus: this.switch_banner,
- active1Status: this.switch_activity1,
- categoryStatus: this.switch_classify,
- active2Status: this.switch_activity2,
- onlyStatus: this.switch_special,
- killStatus: this.switch_seckill,
- couponStatus: this.switch_coupon,
- customerStatus: this.switch_manager,
- notiveStatus: this.switch_notice,
- newsStatus: this.switch_newclassify,
- okStatus: this.switch_recom,
- }],
- }
- this.formLoading = true;
- editTemplate(params).then(res => {
- this.getTemplate();
- this.$successMsg('保存成功');
- getInfo(getUserid()).then(response => {
- localStorage.setItem("supply_user", JSON.stringify(response.data));
- })
- }).finally(res => {
- this.formLoading = false;
- })
- },
- // 获取logo信息
- getLogoDetail() {
- getDetail({adminUserId: getUserid()}).then(res => {
- this.img1_url = res.data.minLogo1;
- this.img2_url = res.data.minLogo2;
- this.img3_url = res.data.minLogo3;
- })
- },
- uploadImage(type) {
- this.uploadImageType = type;
- document.querySelector('.avatar-uploader input').click();
- },
- // 上传图片
- uploadSuccess(res, file) {
- this[this.uploadImageType + '_url'] = res.data.url;
- },
- beforeUpload(file) {
- const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
- const whiteList = ['jpg', 'jpeg', 'png'];
- if (whiteList.indexOf(fileSuffix) === -1) {
- this.$errorMsg('只支持上传jpg/jpeg/png文件!');
- return false;
- }
- },
- // 预览图片
- previewImage(type) {
- this.$refs[type].showViewer = true;
- },
- submitStep2Form() {
- if(!this.img1_url) {
- return this.$errorMsg('请上传主logo');
- }
- if(!this.img2_url) {
- return this.$errorMsg('请上传通用logo');
- }
- if(!this.img3_url) {
- return this.$errorMsg('请上传头像logo');
- }
- this.formLoading = true;
- let params = {
- companyWechatId: this.companyId,
- mainLog: this.img1_url,
- commonLog: this.img2_url,
- minLogo: this.img3_url,
- }
- editTemplate(params).then(res => {
- this.getLogoDetail();
- this.$successMsg('保存成功');
- }).finally(res => {
- this.formLoading = false;
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep .el-radio-group {
- display: flex;
- .item {
- margin-right: 20px;
- .el-radio {
- height: 40px;
- line-height: 40px;
- }
- .el-image {
- width: 120px;
- height: 200px;
- display: block;
- }
- }
- }
- .images {
- display: flex;
- flex-wrap: wrap;
- .main-img {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 120px;
- margin-right: 20px;
- .img {
- border: 1px dashed #eaeaea;
- border-radius: 5px;
- overflow: hidden;
- position: relative;
- .el-image {
- display: block;
- }
- .mask {
- position: absolute;
- left: 0;
- top: 0;
- width: 120px;
- height: 120px;
- background: rgba($color: #000000, $alpha: 0.3);
- display: flex;
- align-items: center;
- justify-content: center;
- i {
- font-size: 20px;
- color: #ffffff;
- cursor: pointer;
- margin: 0 8px;
- }
- }
- }
- .text {
- font-size: 14px;
- color: #666666;
- }
- }
- .add {
- width: 120px;
- height: 120px;
- border: 1px dashed #eaeaea;
- border-radius: 5px;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- i {
- font-size: 30px;
- color: #999;
- }
- }
- .tmp-img {
- position: relative;
- .tmp {
- position: absolute;
- left: 0;
- top: 0;
- line-height: 20px;
- padding: 0 8px;
- background: #f66460;
- border-radius: 0 0 10px 0;
- font-size: 12px;
- color: #ffffff;
- }
- }
- }
- .tips {
- margin-top: 10px;
- span {
- display: inline-block;
- width: 300px;
- text-align: center;
- line-height: 32px;
- background: #ffefef;
- font-size: 14px;
- color: #f66460;
- }
- }
- .diy-table {
- width: 400px;
- .item {
- display: flex;
- border: 1px solid #eaeaea;
- border-bottom: none;
- &.head {
- font-weight: bold;
- }
- &:last-child {
- border-bottom: 1px solid #eaeaea;
- }
- >div {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .label {
- border-right: 1px solid #eaeaea;
- }
- .value {
- span {
- margin-left: 10px;
- color: #666666;
- &.on {
- color: #409EFF;
- }
- }
- }
- }
- }
- .nodata {
- font-size: 18px;
- color: #666666;
- }
- </style>
|