先看效果图

代码参考


<template>
<div>
<!-- 公众号设置 -->
<el-col :span="24" style=" margin-top: 10px;">
<h2 style="font-weight: 300; margin-left: 20px; font-size: 22px;">公众号设置</h2>
<!-- 预览功能 --> <div class="flex" v-if="openpreview"></div>
<div class="preview" v-if="openpreview">
<div class="previewcon">
<img class="previewimg" :src="previewimg" />
<div class="previewtextbot">
<div class="previewli"
:class="{'previewlione':list.length == 1,'previewlitwo':list.length == 2}"
v-for="(item,indx) in list" :key="indx" >
<div class="previewtianjia" v-if="previewtext == indx">
<a class="previewaddadd"
v-for="(item,index) in item.list"
:href="item.http" target="view_window"
:key="index">{{item.name}}</a>
<div class="previewarrow" v-if="item.list.length > 0"></div>
</div>
<div class="previewtext" v-if="item.list.length > 0" @click="preview(item,indx)">{{item.name}}</div>
<a class="previewtext" v-if="item.list.length == 0"
:href="item.http" target="view_window"
@click="preview(item,indx)">{{item.name}}</a>
</div>
</div>
</div>
<el-button type="primary" style="display: block;margin: 10px auto;" @click="out">退出预览</el-button>
</div> <!-- <el-col :span="12" :offset="6">
<div class="grid-content bg-purple warning">
<p>
<i class="el-icon-warning tips"></i>温馨提示:
<span class="on">立即授权</span>
</p>
<p>微信公众号提现需要特约商户签约,材料交给我们代为提交。签约费用500元</p>
</div>
</el-col> -->
<el-col :span="24" style=" margin-top: 30px;">
<el-col :span="5" class="left">
<img class="top" :src="top" />
<img class="bottom" :src="bottom" />
<div style="background: #F4F5F9; min-height: 438px; position: absolute;
         top: 63px; width: 320px; ">
</div>
<div class="textbot">
<div class="li" v-for="(item,indx) in list" :key="indx" >
<div v-if="activeClass == indx">
<div class="add" @click="add(indx)">
<i class="el-icon-plus"></i>
<div class="arrow"></div>
</div>
<div class="tianjia">
<div class="addadd" v-for="(item,index) in item.list" :key="index"
:class="addindex == index ? 'active':''" @click="gettem(item,index)">{{item.name}}</div>
</div>
</div>
<div class="text" :class="activeClass == indx ? 'active':''" @click="getItem(item,indx)">{{item.name}}</div>
</div>
<div class="li" v-if="list.length < 3">
<div class="text" @click="addtext"><i class="el-icon-plus"></i></div>
</div>
</div>
</el-col> <el-col :span="15" style=" padding-left: 20px;">
<el-card class="box-card right">
<div slot="header" class="clearfix">
<span>{{input}}</span>
<el-button style="float: right; padding: 3px 0" type="text" @click="delet">删除子菜单</el-button>
</div>
<div style="display: flex;">
<label style="line-height: 34px; width:80px;">菜单名称</label>
<el-input v-model="input" placeholder="请输入内容" style="width:70%;" ></el-input>
</div>
<p style="color: #9A8D8D;margin-left: 80px;">仅支持中英文和数字,字数不超过4个汉字或8个字母</p>
<div style="display: flex;">
<label style="line-height: 34px; width:80px;">菜单内容</label>
<el-radio-group v-model="radio" style="line-height: 45px;">
<el-radio :label="1">平台模板</el-radio>
<el-radio :label="2">跳转的网页</el-radio>
</el-radio-group>
</div>
<div style="background: #fff;padding:10px 0;" v-if="radio == 1">
<el-radio-group v-model="radiobottom" style="padding:0 30px;">
<p style="margin: 8px 0;" v-for="(item,index) in listlist" :key="index">
<el-radio :label="index">{{item.name}}{{item.http}}</el-radio>
</p>
</el-radio-group>
</div>
<div style="background: #fff;padding:10px 0;" v-if="radio == 2">
<p style="color: #9A8D8D;margin-left: 30px;">订阅者点击该子菜单会跳到以下链接</p>
<div style="display: flex; padding:0 30px;">
<label style="line-height: 34px; width:65px;">页面地址</label>
<el-input v-model="inputhttp" placeholder="请输入内容" style="width:70%;"></el-input>
</div>
</div>
</el-card>
</el-col>
<el-col :span="24">
<el-button style="display: block;margin: 10px auto;" @click="open">打开预览</el-button>
<el-button type="primary" style="display: block;margin: 10px auto;">保存并发布</el-button>
</el-col>
</el-col>
</el-col>
</div>
</template>
<script>
export default {
data () {
return {
previewimg: '../static/img/previewimg.png',
previewtext: 0,
openpreview: false,
top: '../static/img/top.png',
bottom: '../static/img/bottom.png',
activeClass: 0,
addindex: -1,
input: '',
inputhttp: '',
radio: 1,
radiobottom: 0,
shu: 6,
id: 1, list: [
{ name: '菜单一', http: 'https://www.baidu.com/', id: 1, list: [{ 'name': '我是1', http: 'https://www.baidu.com/', id: 4 }] },
{ name: '菜单二', http: 'https://www.baidu.com/', id: 2, list: [{ 'name': '我是2', http: 'https://www.baidu.com/', id: 5 }] },
{ name: '菜单三', http: 'https://www.baidu.com/', id: 3, list: [{ 'name': '我是3', http: 'https://www.baidu.com/', id: 6 }] }
],
listlist: []
}
},
mounted () {
this.rech()
this.input = this.list[0].name
this.inputhttp = this.list[0].http
},
watch: {
// 如果 `input` 发生改变,这个函数就会运行
input: function () {
for (var i = 0; i < this.list.length; i++) {
for (var j = 0; j < this.list[i].list.length; j++) {
if (this.list[i].list[j].id === this.id) {
this.list[i].list[j].name = this.input
}
}
if (this.list[i].id === this.id) {
this.list[i].name = this.input
}
}
this.rech()
// 限制名字个数
var temp = 0
for (var k = 0; k < this.input.length; k++) {
if (/[\u4e00-\u9fa5]/.test(this.input[k])) {
temp += 2
} else {
temp++
}
if (temp > 8) {
this.input = this.input.substr(0, k)
this.$message({
message: '仅支持中英文和数字,字数不超过4个汉字或8个字母',
type: 'warning'
})
}
}
},
inputhttp: function () {
for (var i = 0; i < this.list.length; i++) {
for (var j = 0; j < this.list[i].list.length; j++) {
if (this.list[i].list[j].id === this.id) {
this.list[i].list[j].http = this.inputhttp
}
}
if (this.list[i].id === this.id) {
this.list[i].http = this.inputhttp
}
}
this.rech()
}
},
methods: {
out () {
this.openpreview = false
},
open () {
this.openpreview = true
},
preview (item, index) {
this.previewtext = index
},
// 父元素
getItem (item, index) {
this.addindex = -1
this.activeClass = index // 把当前点击元素的index,赋值给activeClass
this.input = item.name
this.inputhttp = item.http
this.id = item.id
this.rech()
},
// 子元素
gettem (item, index) {
this.addindex = index
console.log(item)
this.input = item.name
this.inputhttp = item.http
this.id = item.id
this.rech()
},
// 增加
add (index) {
this.shu++
this.list[index].list.push({
'name': '子菜单' + this.shu, http: 'https://www.baidu.com/', id: this.shu
})
this.rech()
},
addtext () {
this.shu++
this.list.push({
'name': '菜单' + this.shu, http: 'https://www.baidu.com/', id: this.shu, list: []
})
this.rech()
},
// 删除
delet () {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
for (var i = 0; i < this.list.length; i++) {
for (var j = 0; j < this.list[i].list.length; j++) {
if (this.list[i].list[j].id === this.id) {
this.list[i].list.splice(j, 1)
this.addindex = -1
this.rech()
this.$message({
type: 'success',
message: '删除成功!'
})
}
}
if (this.list[i].id === this.id) {
this.list.splice(i, 1)
this.activeClass = -1
this.rech()
this.$message({
type: 'success',
message: '删除成功!'
})
}
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
rech () {
this.listlist = []
this.list.forEach(item => {
this.listlist.push({
name: item.name,
http: item.http
})
item.list.forEach(item => {
this.listlist.push({
name: item.name,
http: item.http
})
})
})
for (var i = 0; i < this.listlist.length; i++) {
if (this.listlist[i].name === this.input) {
this.radiobottom = i
}
}
}
}
}
</script> <style lang="scss" scoped>
*{
// css页面点击文字出现蓝色底色去掉方法
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
}
.flex{
position: fixed;
background: #000000;
opacity: 0.5;
top: 0px;
left: 0px;
width: 100%;
  height: 100%;
z-index: 99;
} .preview{
position: fixed;
top: 15%;
left: 45%;
z-index: 99;
}
.previewcon{
position: relative;
}
.previewtextbot {
position: absolute;
bottom: 93px;
left: 65px;
width: 100%;
}
.previewtext{
height: 36px;
display: block;
text-decoration:none; //去掉默认下滑线
color:#999; //设置默认颜色
}
.previewli {
float: left;
width: 78px;
line-height: 36px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
text-align: center;
cursor: pointer;
color: #999;
position: relative;
}
.previewlione{
width: 233px !important;
}
.previewlitwo{
width: 117px !important;
}
.previewtianjia {
position: absolute;
bottom: 55px;
width: 100%;
line-height: 36px;
background: #FAFAFA;
} .previewaddadd {
width: 100%;
line-height: 36px;
border: 1px solid #E7E7EB;
background: #fff;
height: 36px;
display: block;
text-decoration:none; //去掉默认下滑线
color:#999; //设置默认颜色
}
.previewarrow{
position: absolute;
bottom: -15px;
left: 44%;
/* 圆角的位置需要细心调试哦 */
width: 0;
height: 0;
font-size: 0;
border: solid 8px;
border-color:#fff #E6E6E6 #E6E6E6 #E6E6E6;
}
.warning {
border: 1px solid #91d5ff;
background-color: #e6f7ff;
padding: 5px 20px;
} .on {
text-align: right;
float: right;
color: #1890ff;
} .tips {
color: #1890ff;
font-size: 20px;
margin-right: 10px;
} .left {
min-width: 390px;
min-height: 550px;
position: relative;
padding-left: 40px;
} .top {
position: absolute;
top: 0px;
} .bottom {
position: absolute;
bottom: 0px;
} .textbot {
position: absolute;
bottom: 0px;
left: 82px;
width: 100%;
} .active {
border: 1px solid #44B549 !important;
color: #44B549 !important;
} .li {
float: left;
width: 93px;
line-height: 48px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
text-align: center;
cursor: pointer;
color: #999;
position: relative;
}
.text{
height: 50px;
}
.text:hover {
color: #000;
} .add {
position: absolute;
bottom: 65px;
width: 100%;
line-height: 48px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
}
.arrow {
position: absolute;
bottom: -16px;
left: 36px;
/* 圆角的位置需要细心调试哦 */
width: 0;
height: 0;
font-size: 0;
border: solid 8px;
border-color:#fff #F4F5F9 #F4F5F9 #F4F5F9;
}
.tianjia {
position: absolute;
bottom: 115px;
width: 100%;
line-height: 48px;
background: #FAFAFA;
} .addadd {
width: 100%;
line-height: 48px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
height: 48px;
} .right {
background: #F4F5F9;
min-height: 550px;
 
}
</style>

vue 仿写微信公众号自定义菜单的更多相关文章

  1. 微信公众号自定义菜单中添加emoji表情

    做微信公众号开发,可能会遇到如何加入emoji表情的问题.今天在“海南旅游小管家”公众号的菜单中加入了emoji表情,特此记录备忘. 1.登录微信公众号,在左侧找到[开发者工具]菜单,点击进入,找到[ ...

  2. C#微信公众号——自定义菜单

    自定义菜单最多包括3个一级菜单,每个一级菜单最多包含5个二级菜单.一级菜单最多4个汉字,二级菜单最多7个汉字,多出来的部分将会以“...”代替.自定义菜单的介绍,可以看官方开发文档http://mp. ...

  3. .net mvc 微信公众号 自定义菜单

    官方文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN ...

  4. 通过微信公众号API复制公众号自定义菜单同时增加子菜单方法

    主要的原因是再不破坏公众号以前的菜单的基础上增加自定义菜单,主要步骤如下: 1.通过微信提供的微信公众平台接口调试工具获取公众号的所有自定义菜单 网址:https://mp.weixin.qq.com ...

  5. 微信公众平台自定义菜单新增扫一扫、发图片、发位置 LBS运作更便捷

    今天微信公众平台发布更新,自定义菜单新增扫一扫.发图片.发送位置等功能,这对于有意挖掘微信LBS服务的运营者来说更便捷了,订阅号不用返回微信界面就能扫图.发送图片.调用地理位置,用户体验更友好,自然也 ...

  6. 微信公众平台自定义菜单PHP开发

    微信公众平台自定义菜单PHP开发,微信公众平台自定义菜单是如何实现的呢?其实很简单,首先在微信公众平台升级为服务号,获取appid和appsecret,然后根据这2个参数获取access_token, ...

  7. java版微信公众平台自定义菜单创建代码实现

    微信公众平台自定义菜单创建代码实现—java版 搞了两天的自定义菜单,终于搞定了,现在分享下心得,以便后来者少走弯路...... 好了,先看先微信官方的API 官方写的很详细,但是我看完后很茫然,不知 ...

  8. 微信公众平台自定义菜单及高级接口PHP SDK(转)

    本文介绍介绍微信公众平台自定义菜单及高级接口的PHP SDK及使用方法. 作者 方倍工作室 修正记录: 2014.05.03 v1.0 方倍工作室 http://www.cnblogs.com/txw ...

  9. 微信公众平台自定义菜单及高级接口PHP SDK

    本文介绍介绍微信公众平台自定义菜单及高级接口的PHP SDK及使用方法. 作者 方倍工作室 修正记录: 2014.05.03 v1.0 方倍工作室 http://www.cnblogs.com/txw ...

随机推荐

  1. 洛谷 P2312 解方程 题解

    P2312 解方程 题目描述 已知多项式方程: \[a_0+a_1x+a_2x^2+\cdots+a_nx^n=0\] 求这个方程在 [1,m][1,m] 内的整数解(\(n\) 和 \(m\) 均为 ...

  2. 【后缀数组】【SP1811】 LCS - Longest Common Substring

    题目链接 题意翻译 输入2 个长度不大于250000的字符串,输出这2 个字符串的最长公共子串.如果没有公共子串则输出0 . 思路 求两个串的最长公共子串 代码 #include<iostrea ...

  3. C语言第一篇博客

    你对网络专业或者计算机专业了解是怎样? 进行网络安全,防止信息泄露. 你了解C语言么?C语言主要应用有哪些? C语言简言之就是一门计算机的编程语言. C语言主要应用于应用软件,服务器端开发,系统软件和 ...

  4. Nova官方资料入口处

    Nova官方资料地址: https://www.openstack.org/software/releases/queens/components/nova --> https://wiki.o ...

  5. Dependency Parsing

    句子的依赖结构表现在哪些单词依赖哪些单词.单词之间的这种关系及可以表示为优先级之间的关系等. Dependency Parsing 通常情况下,对于一个输入句子:\(S=w_{0} w_{1} \do ...

  6. 第07组 Beta冲刺(4/5)

    队名:摇光 队长:杨明哲 组长博客:求戳 作业博客:求再戳 队长:杨明哲 过去两天完成了哪些任务 文字/口头描述:已经完成代码编辑器,暂时没有其他任务 展示GitHub当日代码/文档签入记录:(组内共 ...

  7. tensorflow build failed on Centos with Error: suffix or operands invalid for ""

    在redhat6.5的机器上编译tensorflow1.10,局部环境配好gcc4.8.2后,发现了如题的错误.这是关于AVX指令集识别问题.虽然gcc版本足够高,能够编出使用AVX的汇编代码,但是b ...

  8. Windows10环境下 Nginx+ffmpeg自搭服务器制作RTMP直播流

    Windows10环境下 Nginx+ffmpeg自搭服务器制作RTMP直播流学习笔记 所需条件: nginx-rtmp-module(带rtmp模块) ,链接:https://link.jiansh ...

  9. thinkphp---404错误页面

    在用thinkphp开发项目的时候,会额外的处理404错误页面,但是我们很多的开发人员,在处理404错误页面的时候,处理方式都是不对的. 普通处理404的操作是通过 $this->error() ...

  10. 微信小程序开发——base64位图片显示问题

    前言: 目前小程序项目需要后端借口提供验证码图片,后端是以base64位返回的,按照H5的做法,前边拼上 data:image/png;base64, 应该就可以了,关键代码如下: H5: <i ...