Commit 1ebf7390 by xinlaa

企业微信登录完善,登陆背景,首页替换等

1 parent c14d8076
......@@ -52,3 +52,13 @@ export function wxQrLogin(auth_code) {
},
});
}
/**
* 获取扫码登陆相关参数
*/
export function findWxQrLoginInfo() {
return request({
url: '/findWxQrLoginInfo',
method: 'get',
});
}
// 对象克隆
export function clone(obj) {
var o;
// 如果 他是对象object的话 , 因为null,object,array 也是'object';
if (typeof obj === 'object') {
// 如果 他是空的话
if (obj === null) {
o = null;
}
else {
// 如果 他是数组arr的话
if (obj instanceof Array) {
o = [];
for (var i = 0, len = obj.length; i < len; i++) {
o.push(clone(obj[ i ]));
}
}
// 如果 他是对象object的话
else {
o = {};
for (var j in obj) {
o[ j ] = clone(obj[ j ]);
}
}
}
}
else {
o = obj;
}
return o;
};
//判断obj是否有空值---校验 arr为不检验的参数
export function isEmpty(obj,arr){
if(!arr){arr =[]}
console.log(arr,arr.length)
let flag = true;
for(var key in obj){  //遍历对象的所有属性,包括原型链上的所有属性
      if(obj.hasOwnProperty(key)){ //判断是否是对象自身的属性,而不包含继承自原型链上的属性
if(arr.indexOf(key)!= -1){
}else if(!obj[key]){
flag=false;
}
      }
    }
return flag
};
//obj为初始化的对象 arr为obj内不必初始化的值
export function initObj(obj,arr){
let flag = true;
for(var key in obj){ 
      if(obj.hasOwnProperty(key)){ 
if(arr && arr.indexOf(key)!= -1){
}else{
obj[key] = '';
}
      }
    }
return obj
};
// newObj为待复制的对象 copyobj为给newobj赋值的obj
export function objCopy(newObj,copyObj){
for(var key in copyObj){  //遍历对象的所有属性,包括原型链上的所有属性
      if(copyObj.hasOwnProperty(key)){ //判断是否是对象自身的属性,而不包含继承自原型链上的属性
for(var newkey in newObj){  
      if(newObj.hasOwnProperty(newkey)){ 
if(key == newkey){
newObj[newkey] = copyObj[key]
}
      }
    }
      }
    }
return newObj
};
<script>
import { wxQrLogin } from '@/api/login';
import { setToken } from '@/utils/auth';
import { wxQrLogin } from '@/api/login'
import { setToken } from '@/utils/auth'
export default {
components: {},
props: {},
data() {
return {};
return {}
},
watch: {},
computed: {},
beforeCreate() {
// http://106.13.201.219/?auth_code=xxx#/authWehatCallback
// console.log('routerbeforeCreate', this.$route);
let auth_code = location.search.slice(1).split('=')[1];
let auth_code = location.search.slice(1).split('=')[1]
if (!auth_code) {
this.msgError('授权失败');
this.$router.push({ path: '/login' });
return;
this.msgError('未获得授权')
location.href = '/'
return
}
wxQrLogin(auth_code).then((res) => {
setToken(res.token);
this.$store.commit('SET_TOKEN', res.token);
this.$router.push({ path: '/' });
});
setToken(res.token)
this.$store.commit('SET_TOKEN', res.token)
location.href = '/'
})
},
mounted() {},
methods: {},
};
}
</script>
<template>
......
<style lang="scss" scoped>
</style>
<script>
import * as api from '@/api/enterpriseId'
// import clipboard from "clipboard";
export default {
components: {},
props: {},
data() {
return {
query: {
pageNum: 1,
pageSize: 10,
companyName: '',
},
total: 0,
form: {},
list: [],
dialogVisible: false,
disabled: false,
loading: false,
rules: Object.freeze({
companyName: [{ required: true, message: '必填项', trigger: 'blur' }],
corpId: [{ required: true, message: '必填项', trigger: 'blur' }],
corpSecret: [{ required: true, message: '必填项', trigger: 'blur' }],
contactSecret: [{ required: true, message: '必填项', trigger: 'blur' }],
}),
status: ['正常', '停用'],
}
},
watch: {},
computed: {},
created() {
this.getList()
},
mounted() {
// new clipboard(".copy-btn");
},
methods: {
getList(page) {
page && (this.query.pageNum = page)
this.loading = true
api
.getList(this.query)
.then(({ rows, total }) => {
this.list = rows
this.total = +total
this.loading = false
})
.catch(() => {
this.loading = false
})
},
edit(data, type) {
this.form = Object.assign({}, data || {})
this.dialogVisible = true
type || !data ? (this.disabled = false) : (this.disabled = true)
},
submit() {
this.$refs['form'].validate((valid) => {
if (valid) {
api[this.form.id ? 'update' : 'add'](this.form)
.then(() => {
this.msgSuccess('操作成功')
this.dialogVisible = false
this.getList(!this.form.id && 1)
})
.catch(() => {
this.dialogVisible = false
})
}
})
},
start(corpId) {
api.start(corpId).then(({ rows, total }) => {
this.msgSuccess('操作成功')
this.getList()
})
},
},
}
</script>
<template>
<div>
......@@ -7,7 +86,10 @@
<div class="top-search">
<el-form inline label-position="right" :model="form" label-width="80px">
<el-form-item label="企业名称">
<el-input v-model="query.companyName" placeholder="请输入"></el-input>
<el-input
v-model="query.companyName"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label>
<el-button
......@@ -16,7 +98,8 @@
icon="el-icon-search"
size="mini"
@click="getList(1)"
>查询</el-button>
>查询</el-button
>
</el-form-item>
</el-form>
</div>
......@@ -26,7 +109,8 @@
icon="el-icon-plus"
size="mini"
@click="edit()"
>添加</el-button>
>添加</el-button
>
</div>
<!-- <el-card shadow="never" :body-style="{padding: '20px 0 0'}">
</el-card>-->
......@@ -39,13 +123,33 @@
prop="companyName"
:show-overflow-tooltip="true"
/>
<el-table-column label="企业ID" align="center" prop="corpId" :show-overflow-tooltip="true" />
<el-table-column label="应用秘钥" align="center" prop="corpSecret" :show-overflow-tooltip="true" />
<el-table-column label="绑定时间" align="center" prop="createTime" width="160"></el-table-column>
<el-table-column
label="企业ID"
align="center"
prop="corpId"
:show-overflow-tooltip="true"
/>
<el-table-column
label="应用秘钥"
align="center"
prop="corpSecret"
:show-overflow-tooltip="true"
/>
<el-table-column
label="绑定时间"
align="center"
prop="createTime"
width="160"
></el-table-column>
<el-table-column label="状态" align="center" prop="status" width="160">
<template slot-scope="scope">{{status[scope.row.status]}}</template>
<template slot-scope="scope">{{ status[scope.row.status] }}</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
width="180"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
v-hasPermi="['enterpriseWechat:view']"
......@@ -53,27 +157,30 @@
type="text"
icon="el-icon-view"
@click="edit(scope.row, 0)"
>查看</el-button>
>查看</el-button
>
<el-button
v-hasPermi="['enterpriseWechat:edit']"
size="mini"
type="text"
icon="el-icon-edit"
@click="edit(scope.row, 1)"
>编辑</el-button>
>编辑</el-button
>
<el-button
v-hasPermi="['enterpriseWechat:forbidden']"
size="mini"
type="text"
icon="el-icon-key"
@click="start(scope.row.corpId)"
>启用</el-button>
>启用</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
......@@ -109,6 +216,10 @@
<el-input disabled id="copy-input1" v-model="form.companyName"></el-input>
<el-button type="primary" class="copy-btn" data-clipboard-target="#copy-input1">复制</el-button>
</el-form-item>-->
<el-form-item label="服务商secret" prop="providerSecret">
<el-input v-model="form.providerSecret" style="width: 80%"></el-input>
<el-link class="fr" type="primary">如何获取?</el-link>
</el-form-item>
<el-form-item label="通讯录管理secret" prop="corpSecret">
<el-input v-model="form.corpSecret" style="width: 80%"></el-input>
<el-link class="fr" type="primary">如何获取?</el-link>
......@@ -130,93 +241,19 @@
</el-radio-group>
<div>开启后,可以将企业客户的添加、编辑以及主动删除客户和被动被客户删除实时的同步到塬微SCRM,无需手动更新同步。</div>
</el-form-item>-->
<el-form-item
label="企业微信扫码登陆回调地址"
prop="wxQrLoginRedirectUri"
>
<el-input v-model="form.wxQrLoginRedirectUri"></el-input>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submit" v-show="!disabled">确 定</el-button>
<el-button type="primary" @click="submit" v-show="!disabled"
>确 定</el-button
>
</div>
</el-dialog>
</div>
</template>
<script>
import * as api from "@/api/enterpriseId";
// import clipboard from "clipboard";
export default {
components: {},
props: {},
data() {
return {
query: {
pageNum: 1,
pageSize: 10,
companyName: "",
},
total: 0,
form: {},
list: [],
dialogVisible: false,
disabled: false,
loading: false,
rules: Object.freeze({
companyName: [{ required: true, message: "必填项", trigger: "blur" }],
corpId: [{ required: true, message: "必填项", trigger: "blur" }],
corpSecret: [{ required: true, message: "必填项", trigger: "blur" }],
contactSecret: [{ required: true, message: "必填项", trigger: "blur" }],
}),
status: ["正常", "停用"],
};
},
watch: {},
computed: {},
created() {
this.getList();
},
mounted() {
// new clipboard(".copy-btn");
},
methods: {
getList(page) {
page && (this.query.pageNum = page);
this.loading = true;
api
.getList(this.query)
.then(({ rows, total }) => {
this.list = rows;
this.total = +total;
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
edit(data, type) {
this.form = Object.assign({}, data || {});
this.dialogVisible = true;
type || !data ? (this.disabled = false) : (this.disabled = true);
},
submit() {
this.$refs["form"].validate((valid) => {
if (valid) {
api[this.form.id ? "update" : "add"](this.form)
.then(() => {
this.msgSuccess("操作成功");
this.dialogVisible = false;
this.getList(!this.form.id && 1);
})
.catch(() => {
this.dialogVisible = false;
});
}
});
},
start(corpId) {
api.start(corpId).then(({ rows, total }) => {
this.msgSuccess("操作成功");
this.getList();
});
},
},
};
</script>
<template>
<div class="dashboard-editor-container">
<panel-group @handleSetLineChartData="handleSetLineChartData" />
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
<line-chart :chart-data="lineChartData" />
</el-row>
<el-row :gutter="32">
<el-col :xs="24" :sm="24" :lg="8">
<div class="chart-wrapper">
<raddar-chart />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="8">
<div class="chart-wrapper">
<pie-chart />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="8">
<div class="chart-wrapper">
<bar-chart />
</div>
</el-col>
</el-row>
<div>
<img class="img" src="@/assets/image/index.png" alt="" />
<div class="button" @click="goWeb"></div>
</div>
</template>
<script>
import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import RaddarChart from './dashboard/RaddarChart'
import PieChart from './dashboard/PieChart'
import BarChart from './dashboard/BarChart'
const lineChartData = {
newVisitis: {
expectedData: [100, 120, 161, 134, 105, 160, 165],
actualData: [120, 82, 91, 154, 162, 140, 145]
},
messages: {
expectedData: [200, 192, 120, 144, 160, 130, 140],
actualData: [180, 160, 151, 106, 145, 150, 130]
},
purchases: {
expectedData: [80, 100, 121, 104, 105, 90, 100],
actualData: [120, 90, 100, 138, 142, 130, 130]
},
shoppings: {
expectedData: [130, 140, 141, 142, 145, 150, 160],
actualData: [120, 82, 91, 154, 162, 140, 130]
}
}
export default {
name: 'Index',
components: {
PanelGroup,
LineChart,
RaddarChart,
PieChart,
BarChart
},
components: {},
data() {
return {
lineChartData: lineChartData.newVisitis
}
return {}
},
methods: {
handleSetLineChartData(type) {
this.lineChartData = lineChartData[type]
}
}
goWeb() {
window.open('https://gitee.com/LinkWeChat/link-wechat')
},
},
}
</script>
<style lang="scss" scoped>
.dashboard-editor-container {
padding: 32px;
background-color: rgb(240, 242, 245);
.page {
position: relative;
.chart-wrapper {
background: #fff;
padding: 16px 16px 0;
margin-bottom: 32px;
}
padding: 0;
}
@media (max-width:1024px) {
.chart-wrapper {
padding: 8px;
}
.img {
width: 100%;
}
.button {
position: absolute;
top: 58%;
left: 11%;
width: 12%;
height: 8%;
cursor: pointer;
}
</style>
......@@ -71,7 +71,7 @@
<span v-else>登 录 中...</span>
</el-button>
</el-form-item>
<el-form-item class="ac">
<el-form-item class="ac" v-if="authLink">
<a :href="authLink">
<img
src="//wwcdn.weixin.qq.com/node/wwopen/wwopenmng/style/images/independent/brand/300x40_white$4dab5411.png"
......@@ -119,10 +119,10 @@
</template>
<script>
import axios from 'axios';
import { getCodeImg } from '@/api/login';
import Cookies from 'js-cookie';
import { encrypt, decrypt } from '@/utils/jsencrypt';
import axios from 'axios'
import { getCodeImg, findWxQrLoginInfo } from '@/api/login'
import Cookies from 'js-cookie'
import { encrypt, decrypt } from '@/utils/jsencrypt'
export default {
name: 'Login',
......@@ -152,82 +152,83 @@ export default {
redirect: undefined,
authLink: '',
dialogVisible: true,
};
}
},
watch: {
$route: {
handler: function(route) {
this.redirect = route.query && route.query.redirect;
this.redirect = route.query && route.query.redirect
},
immediate: true,
},
},
created() {
let authParams = {
appid: 'ww24262ce93851488f', // * 服务商的CorpID
redirect_uri: encodeURIComponent(
process.env.VUE_APP_BASE_API + '/#/authCallback'
), // * 授权登录之后目的跳转网址,需要做urlencode处理。所在域名需要与授权完成回调域名一致
state: '', // ? 用于企业或服务商自行校验session,防止跨域攻击
usertype: 'admin', // ? 支持登录的类型。admin代表管理员登录(使用微信扫码),member代表成员登录(使用企业微信扫码),默认为admin
};
this.authLink = `https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=${authParams.appid}&redirect_uri=${authParams.redirect_uri}&state=${authParams.state}&usertype=${authParams.usertype}`;
// data.wxQrLoginRedirectUri http://192.168.0.101/#/authCallback
findWxQrLoginInfo().then(({ data }) => {
let authParams = {
appid: data.corpId, // * 服务商的CorpID
redirect_uri: encodeURIComponent(data.wxQrLoginRedirectUri), // * 授权登录之后目的跳转网址,需要做urlencode处理。所在域名需要与授权完成回调域名一致
state: '', // ? 用于企业或服务商自行校验session,防止跨域攻击
usertype: 'admin', // ? 支持登录的类型。admin代表管理员登录(使用微信扫码),member代表成员登录(使用企业微信扫码),默认为admin
}
this.authLink = `https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=${authParams.appid}&redirect_uri=${authParams.redirect_uri}&state=${authParams.state}&usertype=${authParams.usertype}`
})
this.getCode();
this.getCookie();
this.getCode()
this.getCookie()
},
methods: {
getCode() {
getCodeImg().then((res) => {
this.codeUrl = 'data:image/gif;base64,' + res.img;
this.loginForm.uuid = res.uuid;
});
this.codeUrl = 'data:image/gif;base64,' + res.img
this.loginForm.uuid = res.uuid
})
},
getCookie() {
const username = Cookies.get('username');
const password = Cookies.get('password');
const rememberMe = Cookies.get('rememberMe');
const username = Cookies.get('username')
const password = Cookies.get('password')
const rememberMe = Cookies.get('rememberMe')
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
password:
password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
};
}
},
handleLogin() {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.loading = true;
this.loading = true
if (this.loginForm.rememberMe) {
Cookies.set('username', this.loginForm.username, { expires: 30 });
Cookies.set('username', this.loginForm.username, { expires: 30 })
Cookies.set('password', encrypt(this.loginForm.password), {
expires: 30,
});
})
Cookies.set('rememberMe', this.loginForm.rememberMe, {
expires: 30,
});
})
} else {
Cookies.remove('username');
Cookies.remove('password');
Cookies.remove('rememberMe');
Cookies.remove('username')
Cookies.remove('password')
Cookies.remove('rememberMe')
}
this.$store
.dispatch('Login', this.loginForm)
.then(() => {
this.$router.push({ path: this.redirect || '/' });
this.$router.push({ path: this.redirect || '/' })
})
.catch(() => {
this.loading = false;
this.getCode();
});
this.loading = false
this.getCode()
})
}
});
})
},
goVote() {
window.open('https://www.oschina.net/p/linkwechat');
window.open('https://www.oschina.net/p/linkwechat')
},
},
};
}
</script>
<style rel="stylesheet/scss" lang="scss">
......@@ -236,7 +237,7 @@ export default {
justify-content: center;
align-items: center;
height: 100%;
background-image: url('../assets/image/login-background.jpg');
background-image: url('../assets/image/login-background.png');
background-size: cover;
}
.title {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!