文件

1169 行
46 KiB
HTML
可执行文件

<!DOCTYPE html>
<html>
<!--[1.5.2]-->
<head>
<meta charset="utf-8"/>
<title>{$logoinfo['name']}后台管理系统</title>
<link rel="shortcut icon" type="image/x-icon" href="{$logoinfo['icourl']}">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/paper/css/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/layui-v2.4.3/layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/home.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/goodsList.css"/>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key={$cache['tencent_key']}"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/jquery/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/layui-v2.4.3/layui/layui.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/receipt/Qrcode.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/UEditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/UEditor/ueditor.all.js"></script>
<script type="text/javascript"
src="https://api.map.baidu.com/api?v=3.0&ak=ObMZWhkHzzF0zbnNgF72Bcws8GHqnya7"></script>
<style>
.goods_title {
padding: 10px 0;
}
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar {
width: 8px;
height: 8px;
background-color: #F5F5F5;
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #F5F5F5;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, .3);
background-color: #3f4c73;
}
.menu-index-box {
display: flex;
}
.menu-index-left, .menu-index-right-title {
color: white;
}
.menu-index-left {
width: 160px;
height: 100vh;
background: #232b42;
overflow-y: auto;
}
.menu-index-left-logo > img {
width: 140px;
height: auto;
padding: 10px;
box-sizing: border-box;
}
.menu-index-right {
width: calc(100% - 160px);
height: 100vh;
}
.menu-index-right-title {
width: 100%;
height: 65px;
background: #232b42;
display: flex;
justify-content: space-between;
}
.menu-index-right-content {
box-sizing: border-box;
width: 100%;
height: calc(100vh - 65px);
/*overflow-y: auto;*/
display: flex;
padding-top: 30px;
}
.fa {
color: white !important;
font-size: 20px;
}
.menu-index-right-title-nickname {
display: flex;
align-items: center;
box-sizing: border-box;
padding: 0 20px;
}
.menu-index-right-title-nickname > img {
display: block;
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.menu-index-right-title-nickname > span {
color: white;
font-size: 14px;
display: block;
max-width: 140px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.menu-index-right-title-quit {
width: 95px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.menu-index-right-title-quit > img {
display: block;
width: 30px;
height: 30px;
}
.menu-index-list {
display: flex;
flex-direction: row;
align-items: center;
margin: 10px 0;
padding-left: 60px;
}
.menu-index-left-name {
width: 109px;
text-align: right;
font-size: 14px;
line-height: 56px;
color: #666;
margin-right: 20px;
}
.menu-index-tips {
text-align: center;
font-size: 12px;
color: #999;
line-height: 30px;
}
.menu-index-center {
text-align: center;
}
li .fa {
width: 26px;
text-align: center;
}
.menu-index-code-big-box {
margin-bottom: 20px;
}
.menu-index-code-box-con {
position: relative;
}
.menu-index-code-box {
width: 200px;
margin: 0 auto;
}
.menu-index-code-box > img {
margin: 0 auto;
}
.menu-index-code-title {
text-align: center;
padding-bottom: 20px;
font-size: 16px;
font-weight: bold;
color: #333;
}
.menu-index-code-title i {
margin-left: 10px;
color: #999;
}
.menu-index-code-timeout {
position: absolute;
top: 0;
left: 80px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
background-color: rgba(255, 255, 255, 0.8);
width: 200px;
height: 200px;
}
.menu-index-code-timeout > span {
font-weight: bold;
color: rgb(68, 68, 68);
}
.menu-index-refresh {
display: inline-block;
height: 32px;
line-height: 32px;
margin-top: 20px;
padding: 0 18px;
background-color: #4394ff;
color: #fff;
white-space: nowrap;
text-align: center;
font-size: 14px;
border: none;
border-radius: 2px;
cursor: pointer;
}
.menu-index-refresh-child-window {
position: fixed;
top: 70px;
right: 15px;
color: #666;
display: flex;
cursor: pointer;
}
.menu-index-refresh-child-window i {
font-size: 20px;
}
.menu-index-refresh-child-window span {
font-size: 14px;
}
.menu-index-refresh-child-window span::selection {
background-color: transparent;
}
.menu-index-refresh-child-window:hover {
color: #333;
}
.menu-index-refresh-child-window:active {
transform: scale(0.95);
}
#myInclude {
flex: 1 1 0%;
box-sizing: border-box;
padding: 0 20px 20px;
overflow-y: auto;
}
.menu-index-notice {
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.menu-index-notice-left {
margin-left: 20px;
display: flex;
align-items: center;
color: #fff;
}
.menu-index-notice-left > span {
font-size: 12px;
white-space: nowrap;
}
.menu-index-notice-left > img {
width: 20px;
height: 20px;
}
.menu-index-notice-right {
min-width: 230px;
height: 65px;
}
.menu-index-user-name {
color: white;
line-height: 65px;
height: 65px;
margin-left: 10px;
white-space: nowrap;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
}
.menu-index-right-list-box {
display: flex;
align-items: center;
justify-content: center;
}
.menu-index-right-list {
line-height: 65px;
font-size: 13px;
display: flex;
align-items: center;
cursor: pointer;
white-space: nowrap;
}
.menu-index-right-list-row {
flex-direction: row;
height: 65px;
}
.menu-index-right-list-column {
width: 100px;
flex-direction: column;
z-index: 999;
align-items: center;
}
.menu-index-right-list-column:before {
content: '更多操作';
color: #fff;
font-size: 13px;
line-height: 65px;
cursor: pointer;
}
.menu-index-right-list-row .menu-index-right-list {
color: white;
margin-right: 20px;
}
.menu-index-right-list-column .menu-index-right-list {
line-height: 36px;
width: 100px;
color: #fff;
padding: 0 10px;
box-sizing: border-box;
background-color: #232b42;
justify-content: center;
transition: 0.3s;
border: none;
height: 0;
}
.menu-index-right-list-column .menu-index-right-list span {
font-size: 0;
}
.menu-index-right-list-column:before:hover {
color: #4394ff;
}
.menu-index-right-list-column:hover .menu-index-right-list {
border-bottom: none;
height: 36px;
}
.menu-index-right-list-column:hover .menu-index-right-list span {
font-size: 13px;
}
.menu-index-right-list-column:hover .menu-index-right-list:nth-last-child(1) {
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.menu-index-right-list-column .menu-index-right-list:hover {
color: #4394ff;
}
.menu-index-right-list-column .menu-index-right-list i {
display: none;
}
.menu-index-right-list span {
margin-left: 5px;
}
.menu-index-right-title > div {
display: flex;
align-items: flex-start;
line-height: 65px;
position: relative;
}
.el-submenu__title i {
color: white !important;
}
.el-submenu .el-menu-item {
height: 40px !important;
line-height: 40px !important;
padding: 0 0 0 50px !important;
min-width: 152px !important;
font-size: 12px !important;
}
.el-menu-item-group__title {
padding: 0 !important;
}
.is-opened .el-menu.el-menu--inline {
background-color: rgba(255, 255, 255, 0.1) !important;
}
.el-menu-item {
background-color: transparent !important;
}
.el-submenu__title {
background-color: transparent !important;
}
.menu-index-active {
background-color: rgba(255, 255, 255, 0.2) !important;
}
.el-menu {
border-right: none !important;
}
.is-active > .el-submenu__title {
background-color: rgba(255, 255, 255, 0.2) !important;
}
.is-opened > .el-submenu__title {
background-color: rgba(255, 255, 255, 0.2) !important;
}
.is-opened .is-opened > .el-submenu__title {
background-color: rgba(255, 255, 255, 0.05) !important;
}
.is-opened .is-opened .el-menu.el-menu--inline {
background-color: #232b42 !important;
}
.is-opened .is-active > .el-submenu__title {
background-color: rgba(255, 255, 255, 0.05) !important;
}
.el-message-box__wrapper{
z-index: 20000000!important;
}
.el-dialog__wrapper{
z-index: 20000000!important;
}
.v-modal{
z-index: 19999999!important;
}
.el-select-dropdown.el-popper{
z-index: 20002230!important;
}
.el-picker-panel{
z-index: 20002233!important;
}
.el-message{
z-index: 200020002!important;
}
</style>
<script>
var MenuApp;
</script>
</head>
<body>
<include file="./Application/Admin/View/Upload/index.html"/>
<div id="MenuIndex">
<div class="menu-index-box">
<div class="menu-index-left">
<div class="menu-index-left-logo">
<img src="{$logoinfo['stageurl']}"
onerror="this.onerror=null,this.src='__PUBLIC__/Retail/images/zhihuilogo4.png'"
style="margin-left: 0px;margin-right: 0px"/>
</div>
<el-menu :default-active="String(actMenuIndex)"
@select="selectMenu"
background-color="#232b42"
text-color="#fff"
unique-opened
ref="menu"
active-text-color="#409EFF">
<template v-for="(item,index) in menuList">
<el-submenu :ref="'item'" v-if="item.list" :index="''+index+''">
<template slot="title">
<div>
<i :class="item.icon"></i>
<span>{{item.name}}</span>
</div>
</template>
<template v-for="(list,i) in item.list">
<el-menu-item-group v-if="list.path">
<el-menu-item :index="index+'-'+i">
<template slot="title">
<span style="display: block;width: 100%;height: 100%">{{list.name}}</span>
</template>
</el-menu-item>
</el-menu-item-group>
<el-submenu v-else :index="index+'-'+i">
<template slot="title">{{list.name}}</template>
<el-menu-item v-for="(li,j) in list.list" :key="j" :index="index+'-'+i+'-'+j">
{{li.name}}
</el-menu-item>
</el-submenu>
</template>
</el-submenu>
<el-menu-item :class="actMenuIndex==index?'menu-index-active':''" :ref="'item'" v-else
:index="''+index+''">
<template slot="title">
<div class="menu-index-list-con">
<i :class="item.icon"
:style="actMenuIndex==index?'color:#409EFF!important':''"></i>
<span>{{item.name}}</span>
</div>
</template>
</el-menu-item>
</template>
</el-menu>
</div>
<div ref="titleRight" class="menu-index-right">
<div class="menu-index-right-title">
<div>
<div class="menu-index-user-name">
<span>{$user['userName']}管理后台</span>
</div>
<if condition="$notice">
<div class="menu-index-notice">
<div class="menu-index-notice-left">
<span>公告:</span>
<img src="__PUBLIC__/notice/notices.png" id="photo">
</div>
<div class="menu-index-notice-right">
<marquee style="cursor: pointer;font-size: 12px;" height="65"><span
style="color: #fff;">{$notice['title']}</span>
</marquee>
</div>
</div>
</if>
</div>
<div>
<div class="menu-index-right-list-box"
:class="rightMenuRow?'menu-index-right-list-row':'menu-index-right-list-column'">
<if condition="$hardware eq 1">
<div class="menu-index-right-list"
@click="swapUrl('{:U('Agent/Hardware/commodityList')}',2)">
<i class="fa fa-question-circle"></i>
<span style="">硬件商城</span>
</div>
</if>
<!-- 删除了软件下载选项 -->
<div class="menu-index-right-list" @click="swapUrl('{:U('Super/Helps/MetInfo')}?types=1',2)">
<i class="fa fa-question-circle"></i>
<span style="">帮助中心</span>
</div>
<div class="menu-index-right-list">
<i class="fa fa-thermometer-full"></i>
<span @click="showResetPassword=true">修改密码</span>
</div>
<if condition="$openScan eq 1">
<div class="menu-index-right-list" :style="isBinding?'':'display:none;'">
<i class="fa fa-comments"></i>
<span @click="relieveWx">解绑微信</span>
</div>
<div class="menu-index-right-list" :style="isBinding?'display:none;':''">
<i class="fa fa-comments"></i>
<span @click="bindingWx">绑定微信</span>
</div>
</if>
</div>
<div class="menu-index-right-title-nickname" @click="showSetUserAvatar=true">
<img id="user_avatar" src="{$user['avatar']}"
onerror="this.onerror=null,this.src='__PUBLIC__/Retail/images/s11.png'"/>
<span>{$user['name']}</span>
</div>
<div class="menu-index-right-title-quit" @click="toClose">
<img src="__PUBLIC__/Retail/images/quit.png"/>
</div>
</div>
</div>
<div class="menu-index-right-content">
<!--右侧内容区-->
<el-tooltip class="item" effect="dark" content="点击刷新当前页面" placement="bottom-end">
<div class="menu-index-refresh-child-window" @click="refreshWindow()">
<i class="el-icon-refresh"></i>
<span>刷新</span>
</div>
</el-tooltip>
<div width="100%" height="100%" id="myInclude"
v-loading="loading"
:element-loading-text="menuLoadingText"
element-loading-spinner="el-icon-loading"></div>
</div>
</div>
</div>
<el-dialog title="修改密码" :visible.sync="showResetPassword" :width="'400px'" :close-on-click-modal="false">
<div style="padding: 0 20px">
<el-form :model="passwordForm" :rules="rules" ref="passwordForm" label-width="68px">
<el-form-item label="旧密码" prop="oldPass">
<el-input type="password" v-model="passwordForm.oldPass" auto-complete="off"
placeholder="请输入旧密码"></el-input>
</el-form-item>
<el-form-item label="新密码" prop="newPass">
<el-input type="password" v-model="passwordForm.newPass" auto-complete="off"
placeholder="请输入新密码"></el-input>
</el-form-item>
<el-form-item label="新密码" prop="newRePass">
<el-input type="password" v-model="passwordForm.newRePass" auto-complete="off"
placeholder="再次输入新密码"></el-input>
</el-form-item>
</el-form>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="showResetPassword = false">取 消</el-button>
<el-button type="primary" @click="sureResetPassword('passwordForm')">确 定</el-button>
</div>
</el-dialog>
<el-dialog title="设置头像" :visible.sync="showSetUserAvatar" :width="'400px'" :close-on-click-modal="false"
:before-close="closeAvatar">
<form id="avatar">
<div class="menu-index-list">
<label class="left_name">头像图片</label>
<label class="file_label">
<input type="hidden" name="logo_id"/>
<input @change="changeImage" type="file" name="logo" placeholder="选择图片"
accept="image/png,image/jpeg"/>
<img id="head_url" style="max-width: 200px" :src="avatar"
onerror="this.onerror=null;this.src='__PUBLIC__/paper/images/wx_add.png'">
</label>
</div>
<div class="center">
<el-button plain size="small" @click="selectImage('logo')"
icon="el-icon-upload el-icon--right">选择图库图片
</el-button>
</div>
<p class="menu-index-tips">建议大小100*100</p>
</form>
<div class="menu-index-center" style="margin-top: 50px">
<el-button type="primary" size="medium" @click="setUserAvatar">保存</el-button>
</div>
</el-dialog>
<el-dialog title="绑定微信" :visible.sync="showUserAuthCode" :width="'400px'" :close-on-click-modal="false"
:before-close="closeCode">
<div class="menu-index-code-big-box">
<div class="menu-index-code-title">
<span>{{scan_title}}<el-tooltip class="item" effect="dark" content="请在扫码之前关注该公众号"
placement="top-start">
<i class="el-icon-question"></i>
</el-tooltip></span>
</div>
<div class="menu-index-code-box-con">
<div class="menu-index-code-box" v-qrcode="{'value':code}"></div>
<div class="menu-index-code-timeout" v-if="isTimeOut">
<span>二维码过期</span>
<div class="menu-index-refresh" @click="refresh">点击刷新</div>
</div>
<div class="menu-index-code-timeout" v-if="isScanCode">
<div class="menu-index-item-suc-one-1">
<img src="__PUBLIC__/login/images/success.png" class="menu-index-item-suc-done-img">
<span style="font-weight: bold;">成功扫码,等待确认</span>
</div>
</div>
</div>
</div>
</el-dialog>
<el-dialog title="选择图片" :visible.sync="showSelectImage" custom-class="select-image-el-dialog"
:top="'10px'">
<template-select-image :can-select-num="1" @selectfile="selectFile"></template-select-image>
</el-dialog>
</div>
</body>
<script type="text/javascript">
Vue.directive('qrcode', function (el, binding) {
el.innerHTML = "";
var text = binding.value.value;
if (text) {
new QRCode(el, {
text: text,
width: 200,
height: 200,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
});
}
});
layui.use('layer', function () {
MenuApp = new Vue({
el: "#MenuIndex",
data: {
menuLoadingText: '页面加载中,请等待',
rightMenuRow: true,
menuList: {$menu},
actMenuIndex: -1,
avatar: "{$user['avatar']}",
showUserAuthCode: false,
code: '',
isTimeOut: false,
isScanCode: false,
scan_type: false,
scan_title: false,
showSetUserAvatar: false,
showSelectImage: false,
isBinding: "{$user['openid']}" ? true : false,
check_scan: null,
check_auth: null,
showResetPassword: false,
passwordForm: {
oldPass: '',
newPass: '',
newRePass: '',
},
rules: {
oldPass: [{message: '请输入原密码', required: true, trigger: 'blur'}, {
validator: function (rule, value, callback) {
var reg = /^[a-zA-Z0-9.+*-/<>?!@#$%^&*():''"";]{1,}$/;
if (!value) {
callback(new Error('请输入原密码'));
} else if (reg.test(value) == false) {
callback(new Error('只支持数字字母及字符.+*-/<>?!@#$%^&*():\'\'"";'));
} else {
callback();
}
}, trigger: 'blur'
}],
newPass: [{message: '请输入新密码', required: true, trigger: 'blur'}, {
validator: function (rule, value, callback) {
var reg = /^[a-zA-Z0-9.+*-/<>?!@#$%^&*():''"";]{1,}$/;
if (!value) {
callback(new Error('请输入新密码'));
} else if (reg.test(value) == false) {
callback(new Error('只支持数字字母及字符.+*-/<>?!@#$%^&*():\'\'"";'));
} else if (MenuApp.passwordForm.newRePass && MenuApp.passwordForm.newRePass != value) {
callback(new Error('新旧密码不一致'));
} else {
callback();
}
}, trigger: 'blur'
}],
newRePass: [{message: '请再次输入新密码', required: true, trigger: 'blur'}, {
validator: function (rule, value, callback) {
var reg = /^[a-zA-Z0-9.+*-/<>?!@#$%^&*():''"";]{1,}$/;
if (!value) {
callback(new Error('请再次输入新密码'));
} else if (reg.test(value) == false) {
callback(new Error('只支持数字字母及字符.+*-/<>?!@#$%^&*():\'\'"";'));
} else if (MenuApp.passwordForm.newPass && MenuApp.passwordForm.newPass != value) {
callback(new Error('新旧密码不一致'));
} else {
callback();
}
}, trigger: 'blur'
}],
},
openIndex: 0,
myInclude: '',
loading: false,
},
methods: {
selectMenu: function (val) {
if (this.loading) {
//如果上一次点击的菜单没有渲染完成直接return
return;
}
var arr = val.split('-');
var index = parseInt(arr[0]);
var item = this.menuList[index];
if (item.type) {
this.actMenuIndex = index;
if (item.reBack) {
$.post("{:U('reBack')}", {}, function () {
location.href = item.path;
})
} else {
location.href = item.path;
}
} else if (item.path) {
this.myInclude = item.path;
this.refreshWindow();
} else if (arr.length == 2) {
this.myInclude = item.list[parseInt(arr[1])].path;
this.refreshWindow();
} else if (arr.length == 3) {
this.myInclude = item.list[parseInt(arr[1])].list[parseInt(arr[2])].path;
this.refreshWindow();
} else {
}
this.childApp = '';// 有点击菜单栏 ,即清空内页vue实例
},
activeMenu: function (item, index, i) {
//点击菜单
if (this.loading) {
//如果上一次点击的菜单没有渲染完成直接return
return;
}
if (item.type) {
location.href = item.path;
} else if (item.path) {
if (this.actMenuIndex != index) {
this.$refs['menu'].close(this.openIndex);
$('*').removeClass('active');
this.actMenuIndex = index;
}
// console.log(item.path);
this.myInclude = item.path;
this.refreshWindow();
} else {
if (this.actMenuIndex != index) {
this.$refs['menu'].close(this.openIndex);
$('*').removeClass('active');
this.actMenuIndex = index;
this.$nextTick(function () {
$(".el-menu>li[role='menuitem']").eq(index).find('.el-submenu__title').addClass('active');
})
}
}
},
swapUrl: function (url, type) {
if (type == 1) {
this.myInclude = url;
this.refreshWindow();
} else {
window.open(url);
}
},
sureResetPassword: function (formName) {
//确认修改密码
this.$refs[formName].validate((valid) => {
if (valid) {
$.post("{:U('resetPassword')}", {
oldPass: this.passwordForm.oldPass,
newPass: this.passwordForm.newPass,
newRePass: this.passwordForm.newRePass
}, (res)=> {
if (res.status == 1) {
this.$message({
type: 'success',
message: res.msg,
duration: 1000,
onClose: ()=> {
this.showResetPassword = false;
this.passwordForm = {
oldPass: '',
newPass: '',
newRePass: '',
};
}
});
} else {
this.$message({
type: 'error',
message: res.msg,
duration: 1000
});
}
})
} else {
return false;
}
});
},
closeAvatar: function () {
this.showSetUserAvatar = false;
},
refresh: function () {
//刷新token
this.getTokenUrl();
},
closeCode: function () {
//关闭授权
clearTimeout(this.check_scan);
clearTimeout(this.check_auth);
this.showUserAuthCode = false;
},
selectFile: function (item) {
//选择文件
console.log(item);
this.showSelectImage = false;
if (item.length) {
$("input[name='logo']").val('');
$("input[name='logo_id']").val(item[0].id);
this.avatar = item[0].path;
}
},
selectImage: function () {
//将选择图片
this.showSelectImage = true;
},
changeImage: function () {
var that = this;
if (window.event.target.files.length) {
var imgObj = window.event.target.files[0];
var imgType = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'];
if (jQuery.inArray(imgObj.type, imgType) != -1) {
var reader = new FileReader();
reader.readAsDataURL(imgObj);
reader.onload = function (e) {
console.log(e);
that.avatar = this.result;
}
}
}
},
setUserAvatar: function () {
//设置头像
if (!$("input[name='logo']").val() && !$("input[name='logo_id']").val()) {
this.$message({
type: 'warning',
message: '您未修改头像',
duration: 1000
});
return;
}
var fd = new FormData(document.getElementById('avatar'));
$.ajax({
url: "{:U('setUserImage')}",
type: "post",
data: fd,
processData: false, // jQuery不要去处理发送的数据
contentType: false, // jQuery不要去设置Content-Type请求头
success: (res)=> {
if (res.status == 1) {
$('#user_avatar').attr('src', this.avatar);
this.$message({
type: 'success',
message: res.msg,
duration: 1000,
onClose: ()=> {
this.showSetUserAvatar = false;
}
});
} else {
this.$message({
type: 'error',
message: res.msg,
duration: 1000
});
}
}
})
},
relieveWx: function () {
$.post("{:U('relieveWx')}", {}, (res) =>{
if (res.status == 1) {
this.isBinding = false;
this.$message({
type: 'success',
message: res.msg,
duration: 1000
});
} else {
this.$message({
type: 'error',
message: res.msg,
duration: 1000
});
}
});
},
bindingWx: function () {
this.getTokenUrl();
},
getTokenUrl: function () {
$.post("{:U('random')}", {}, (res) =>{
if (res.status == 1) {
this.code = res.data.url;
this.scan_title = res.data.title;
this.check(res.data.token, 0);
this.showUserAuthCode = true;
this.isTimeOut = false;
this.isScanCode = false;
} else {
this.$message({
type: 'error',
message: res.msg,
duration: 1000
});
}
})
},
check: function (token, time) {
/* 判断二维码过期时间 */
if (time >= 30) {
//显示刷新按钮
this.isTimeOut = true;
clearTimeout(this.check_scan);
return false;
} else {
this.check_scan = setTimeout( ()=> {
$.post("{:U('check')}", {token: token}, (res)=> {
if (res.status == 1) {
//显示扫面成功
clearTimeout(this.check_scan);
this.isScanCode = true;
this.auth(token, 0); // 调起授权计时器
} else if (res.status == 2) {
clearTimeout(this.check_scan);
this.showUserAuthCode = false;
this.isBinding = true;
this.$message({
message: res.msg,
type: 'success',
center: true
});
} else if (res.status == 3) {
clearTimeout(this.check_scan);
this.$message({
message: res.msg,
type: 'error',
center: true
});
} else if (res.status == 4) {
this.isTimeOut = true;
clearTimeout(this.check_scan);
this.$message({
message: res.msg,
type: 'error',
center: true
});
} else {
time++;
this.check(token, time);
}
})
}, 1000)
}
},
auth: function (token, time) {
/* 判断授权过期时间 */
if (time >= 30) {
//显示刷新二维码按钮
clearTimeout(this.check_auth);
this.isTimeOut = true;
this.isScanCode = false;
return false;
} else {
this.check_auth = setTimeout( ()=> {
$.post("{:U('auth')}", {token: token}, (res)=> {
if (res.status == 1) { // 授权
//用户授权成功
clearTimeout(this.check_scan);
this.showUserAuthCode = false;
this.isBinding = true;
this.$message({
message: res.msg,
type: 'success',
center: true
});
} else if (res.status == 2) { // 取消授权
clearTimeout(this.check_scan);
this.showUserAuthCode = false;
this.$message({
message: res.msg,
type: 'error',
center: true
});
} else if (res.status == 3) {
this.isTimeOut = true;
clearTimeout(this.check_scan);
this.$message({
message: res.msg,
type: 'error',
center: true
});
} else {
time++;
this.auth(token, time);
}
})
}, 1000)
}
},
toClose: function () {
this.$confirm('确定退出登录?', '温馨提示', {
confirmButtonText: '退出',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
localStorage.removeItem('thisPath');
window.location.href = "{:U('loginOut')}";
}).catch(() => {
});
},
refreshWindow: function (path) {
//刷新子页面
this.loading = true;
if (path) {
this.myInclude = path;
}
top.layer.closeAll();
$.get(this.myInclude, (data) => {
localStorage.thisPath = this.myInclude;
$('#myInclude').html(data);
$('#myInclude').ready(() => {
this.loading = false;
});
});
},
getActMenuIndex(myInclude, menuList) {
for (let i = 0; i < menuList.length; i++) {
if (menuList[i]['list']) {
let list_i = this.getActMenuIndex(myInclude, menuList[i]['list']);
if (list_i === false) {
continue;
} else {
return i + '-' + list_i;
}
} else if (menuList[i]['path'] == myInclude) {
return i;
}
}
return false;
},
},
mounted: function () {
const thisPath = localStorage.thisPath;
if (thisPath) {
this.myInclude = thisPath;
let actMenuIndex = this.getActMenuIndex(this.myInclude, this.menuList);
if (actMenuIndex) {
this.actMenuIndex = actMenuIndex;
return this.refreshWindow();
}
}
if (!this.menuList[0].path) {
this.actMenuIndex = 0;
this.myInclude = this.menuList[0].list[0].path;
} else if (this.menuList[0].type) {
this.actMenuIndex = 1;
this.myInclude = this.menuList[1].path;
} else {
this.actMenuIndex = 0;
this.myInclude = this.menuList[0].path;
}
this.refreshWindow();
},
created: function () {
window.onload = window.onresize = ()=> {
var width = this.$refs.titleRight.offsetWidth;
// console.log(width)
if (width < 1020) {
this.rightMenuRow = false;
} else {
this.rightMenuRow = true;
}
}
}
});
})
</script>
</html>