1
This commit is contained in:
parent
ab431485db
commit
f6b35cc074
16
api/login.js
16
api/login.js
@ -1,5 +1,21 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 微信登录授权
|
||||||
|
export function wxLogin(code, encryptedIv, encryptedData) {
|
||||||
|
const data = {
|
||||||
|
code,
|
||||||
|
encryptedIv,
|
||||||
|
encryptedData
|
||||||
|
}
|
||||||
|
return request({
|
||||||
|
'url': '/wxLogin',
|
||||||
|
headers: {
|
||||||
|
isToken: false
|
||||||
|
},
|
||||||
|
'method': 'post',
|
||||||
|
'data': data
|
||||||
|
})
|
||||||
|
}
|
||||||
// 登录方法
|
// 登录方法
|
||||||
export function login(username, password, code, uuid) {
|
export function login(username, password, code, uuid) {
|
||||||
const data = {
|
const data = {
|
||||||
|
12
api/system/config.js
Normal file
12
api/system/config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
|
||||||
|
// 查询站点配置
|
||||||
|
export function getSiteConfig(params) {
|
||||||
|
return request({
|
||||||
|
url: '/base/config/getConfigByCode',
|
||||||
|
method: 'get',
|
||||||
|
params:params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
// 应用全局配置
|
// 应用全局配置
|
||||||
module.exports = {
|
module.exports = {
|
||||||
baseUrl: 'http://127.0.0.1/dev-api',
|
baseUrl: 'http://192.168.1.17:8080',
|
||||||
// baseUrl: 'http://localhost:8080',
|
// baseUrl: 'http://localhost:8080',
|
||||||
// 应用信息
|
// 应用信息
|
||||||
appInfo: {
|
appInfo: {
|
||||||
@ -12,12 +12,12 @@ module.exports = {
|
|||||||
logo: "/static/logo.png",
|
logo: "/static/logo.png",
|
||||||
// 政策协议
|
// 政策协议
|
||||||
agreements: [{
|
agreements: [{
|
||||||
title: "隐私政策",
|
title: "隐私协议",
|
||||||
url: "https://ruoyi.vip/protocol.html"
|
code: "privacy_agreement"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "用户服务协议",
|
title: "用户服务协议",
|
||||||
url: "https://ruoyi.vip/protocol.html"
|
code: "privacy_agreement"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
1
main.js
1
main.js
@ -7,7 +7,6 @@ Vue.use(plugins)
|
|||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.prototype.$store = store
|
Vue.prototype.$store = store
|
||||||
|
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "若依移动端",
|
"name" : "多点通告",
|
||||||
"appid" : "__UNI__25A9D80",
|
"appid" : "__UNI__5491739",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.1.0",
|
"versionName" : "1.1.0",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
@ -41,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "wxccd7e2a0911b3397",
|
"appid" : "wxd8ef44a8268672e4",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : false,
|
"urlCheck" : false,
|
||||||
"es6" : false,
|
"es6" : false,
|
||||||
|
8
package.json
Normal file
8
package.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"rich-text-parser": "^1.0.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"rich-text-parser": "^1.0.2"
|
||||||
|
}
|
||||||
|
}
|
17
pages.json
17
pages.json
@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"pages": [{
|
"pages": [{
|
||||||
|
"path": "pages/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "首页",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
"path": "pages/login",
|
"path": "pages/login",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "登录"
|
"navigationBarTitleText": "登录"
|
||||||
@ -9,12 +15,6 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "注册"
|
"navigationBarTitleText": "注册"
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
"path": "pages/index",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "若依移动端框架",
|
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
"path": "pages/work/index",
|
"path": "pages/work/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -70,6 +70,11 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "浏览文本"
|
"navigationBarTitleText": "浏览文本"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"path": "pages/common/richview/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "浏览富文本"
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
"color": "#000000",
|
"color": "#000000",
|
||||||
|
62
pages/common/richview/index.vue
Normal file
62
pages/common/richview/index.vue
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<div class="body">
|
||||||
|
<rich-text style="width: 100%" :nodes="richTextHtml" />
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getSiteConfig } from '@/api/system/config'
|
||||||
|
import parser from 'rich-text-parser'
|
||||||
|
export default {
|
||||||
|
filters: {
|
||||||
|
formatRichText(html) { // 控制小程序中图片大小
|
||||||
|
// console.log(html)
|
||||||
|
const nodes = parser.getRichTextJson(html)
|
||||||
|
return nodes.children
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
richTextHtml: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
uni.setNavigationBarTitle({
|
||||||
|
title: options.title
|
||||||
|
})
|
||||||
|
this.getRichTextHtml(options.code)
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
async getRichTextHtml(code){
|
||||||
|
let that = this
|
||||||
|
getSiteConfig({code:code}).then(res => {
|
||||||
|
let json = JSON.parse(res.data)
|
||||||
|
that.richTextHtml = json[0].value
|
||||||
|
}).catch((e) => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000,
|
||||||
|
title: e
|
||||||
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.container {
|
||||||
|
height: 100%;
|
||||||
|
padding: 20rpx;
|
||||||
|
background: white;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
.body{
|
||||||
|
flex: 1;
|
||||||
|
height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
135
pages/login.vue
135
pages/login.vue
@ -1,37 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="normal-login-container">
|
<view class="normal-login-container">
|
||||||
<view class="logo-content align-center justify-center flex">
|
<view class="logo-content align-center justify-center flex">
|
||||||
<image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
|
<!-- <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">-->
|
||||||
</image>
|
<!-- </image>-->
|
||||||
<text class="title">若依移动端登录</text>
|
<text class="title">请登录</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="login-form-content">
|
<view class="login-form-content">
|
||||||
<view class="input-item flex align-center">
|
<!-- <view class="input-item flex align-center">-->
|
||||||
<view class="iconfont icon-user icon"></view>
|
<!-- <view class="iconfont icon-user icon"></view>-->
|
||||||
<input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
|
<!-- <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />-->
|
||||||
</view>
|
<!-- </view>-->
|
||||||
<view class="input-item flex align-center">
|
<!-- <view class="input-item flex align-center">-->
|
||||||
<view class="iconfont icon-password icon"></view>
|
<!-- <view class="iconfont icon-password icon"></view>-->
|
||||||
<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
|
<!-- <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />-->
|
||||||
</view>
|
<!-- </view>-->
|
||||||
<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
|
<!-- <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">-->
|
||||||
<view class="iconfont icon-code icon"></view>
|
<!-- <view class="iconfont icon-code icon"></view>-->
|
||||||
<input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
|
<!-- <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />-->
|
||||||
<view class="login-code">
|
<!-- <view class="login-code"> -->
|
||||||
<image :src="codeUrl" @click="getCode" class="login-code-img"></image>
|
<!-- <image :src="codeUrl" @click="getCode" class="login-code-img"></image>-->
|
||||||
</view>
|
<!-- </view>-->
|
||||||
</view>
|
<!-- </view>-->
|
||||||
<view class="action-btn">
|
<view class="action-btn">
|
||||||
<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
|
<button open-type="getPhoneNumber" @getphonenumber="getPhone" class="login-btn cu-btn block bg-blue lg round">手机号快捷登录</button>
|
||||||
</view>
|
<!-- <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>-->
|
||||||
<view class="reg text-center" v-if="register">
|
<!-- <u-button open-type='getPhoneNumber' text="手机号快捷登录" @getphonenumber="wxHandleLogin" class="login-btn cu-btn block bg-green lg round"></u-button>-->
|
||||||
<text class="text-grey1">没有账号?</text>
|
|
||||||
<text @click="handleUserRegister" class="text-blue">立即注册</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
<!-- <view class="reg text-center" v-if="register">-->
|
||||||
|
<!-- <text class="text-grey1">没有账号?</text>-->
|
||||||
|
<!-- <text @click="handleUserRegister" class="text-blue">立即注册</text>-->
|
||||||
|
<!-- </view>-->
|
||||||
<view class="xieyi text-center">
|
<view class="xieyi text-center">
|
||||||
<text class="text-grey1">登录即代表同意</text>
|
<text class="text-grey1">登录即代表同意</text>
|
||||||
<text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
|
<text @click="handleUserAgrement(globalConfig.appInfo.agreements[0])" class="text-blue">《{{globalConfig.appInfo.agreements[0].title}}》</text>
|
||||||
<text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
|
<text @click="handleUserAgrement(globalConfig.appInfo.agreements[1])" class="text-blue">《{{ globalConfig.appInfo.agreements[1].title }}》</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -54,26 +56,27 @@
|
|||||||
password: "admin123",
|
password: "admin123",
|
||||||
code: "",
|
code: "",
|
||||||
uuid: ''
|
uuid: ''
|
||||||
|
},
|
||||||
|
//微信登录
|
||||||
|
wxLoginForm: {
|
||||||
|
code: "",
|
||||||
|
encryptedIv: "",
|
||||||
|
encryptedData: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getCode()
|
this.getCode()
|
||||||
|
this.wxLogin()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 用户注册
|
// 用户注册
|
||||||
handleUserRegister() {
|
handleUserRegister() {
|
||||||
this.$tab.redirectTo(`/pages/register`)
|
this.$tab.redirectTo(`/pages/register`)
|
||||||
},
|
},
|
||||||
// 隐私协议
|
// 查看相关协议
|
||||||
handlePrivacy() {
|
handleUserAgrement(site) {
|
||||||
let site = this.globalConfig.appInfo.agreements[0]
|
this.$tab.navigateTo(`/pages/common/richview/index?title=${site.title}&code=${site.code}`)
|
||||||
this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
|
|
||||||
},
|
|
||||||
// 用户协议
|
|
||||||
handleUserAgrement() {
|
|
||||||
let site = this.globalConfig.appInfo.agreements[1]
|
|
||||||
this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
|
|
||||||
},
|
},
|
||||||
// 获取图形验证码
|
// 获取图形验证码
|
||||||
getCode() {
|
getCode() {
|
||||||
@ -85,6 +88,55 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
wxLogin() {
|
||||||
|
let that = this
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin',
|
||||||
|
success(res) {
|
||||||
|
console.log(543, res);
|
||||||
|
if (res.code) {
|
||||||
|
that.wxLoginForm.code= res.code
|
||||||
|
} else {
|
||||||
|
console.log('登录失败!' + res.errMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//微信授权登录
|
||||||
|
getPhone(e) {
|
||||||
|
console.log("微信小程序发起授权登录")
|
||||||
|
this.$modal.loading("登录中...")
|
||||||
|
uni.checkSession({
|
||||||
|
success: () => {
|
||||||
|
this.wxLoginForm.encryptedIv = e.detail.iv
|
||||||
|
this.wxLoginForm.encryptedData = e.detail.encryptedData
|
||||||
|
this.sendWxLoginFormToLocalService()
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000,
|
||||||
|
title: "登录状态过期,重新登录"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//向后端发起登录请求
|
||||||
|
sendWxLoginFormToLocalService(){
|
||||||
|
this.$store.dispatch('WxLogin', this.wxLoginForm).then(() => {
|
||||||
|
this.$modal.closeLoading()
|
||||||
|
this.loginSuccess()
|
||||||
|
}).catch((e) => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000,
|
||||||
|
title: e
|
||||||
|
});
|
||||||
|
// if (this.captchaEnabled) {
|
||||||
|
// // this.getCode()
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
},
|
||||||
// 登录方法
|
// 登录方法
|
||||||
async handleLogin() {
|
async handleLogin() {
|
||||||
if (this.loginForm.username === "") {
|
if (this.loginForm.username === "") {
|
||||||
@ -94,7 +146,7 @@
|
|||||||
} else if (this.loginForm.code === "" && this.captchaEnabled) {
|
} else if (this.loginForm.code === "" && this.captchaEnabled) {
|
||||||
this.$modal.msgError("请输入验证码")
|
this.$modal.msgError("请输入验证码")
|
||||||
} else {
|
} else {
|
||||||
this.$modal.loading("登录中,请耐心等待...")
|
this.$modal.loading("登录中...")
|
||||||
this.pwdLogin()
|
this.pwdLogin()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -124,7 +176,18 @@
|
|||||||
page {
|
page {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
|
.dl{
|
||||||
|
width: 90%;
|
||||||
|
height: 44px;
|
||||||
|
background-color: #0D2E8D;
|
||||||
|
border-radius: 50px;
|
||||||
|
margin: 0 auto;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #FFFFFF;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
.normal-login-container {
|
.normal-login-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ const loginPage = "/pages/login"
|
|||||||
|
|
||||||
// 页面白名单
|
// 页面白名单
|
||||||
const whiteList = [
|
const whiteList = [
|
||||||
'/pages/login', '/pages/register', '/pages/common/webview/index'
|
'/pages/login', '/pages/register', '/pages/common/webview/index','/pages/common/richview/index'
|
||||||
]
|
]
|
||||||
|
|
||||||
// 检查地址白名单
|
// 检查地址白名单
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import storage from '@/utils/storage'
|
import storage from '@/utils/storage'
|
||||||
import constant from '@/utils/constant'
|
import constant from '@/utils/constant'
|
||||||
import { login, logout, getInfo } from '@/api/login'
|
import { login,wxLogin, logout, getInfo } from '@/api/login'
|
||||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||||
|
|
||||||
const baseUrl = config.baseUrl
|
const baseUrl = config.baseUrl
|
||||||
@ -38,6 +38,21 @@ const user = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
// 微信登录
|
||||||
|
WxLogin({ commit }, wxUserInfo) {
|
||||||
|
const code = wxUserInfo.code
|
||||||
|
const encryptedIv = wxUserInfo.encryptedIv
|
||||||
|
const encryptedData = wxUserInfo.encryptedData
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wxLogin(code, encryptedIv, encryptedData).then(res => {
|
||||||
|
setToken(res.token)
|
||||||
|
commit('SET_TOKEN', res.token)
|
||||||
|
resolve()
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
// 登录
|
// 登录
|
||||||
Login({ commit }, userInfo) {
|
Login({ commit }, userInfo) {
|
||||||
const username = userInfo.username.trim()
|
const username = userInfo.username.trim()
|
||||||
|
@ -48,10 +48,10 @@ const request = config => {
|
|||||||
reject('无效的会话,或者会话已过期,请重新登录。')
|
reject('无效的会话,或者会话已过期,请重新登录。')
|
||||||
} else if (code === 500) {
|
} else if (code === 500) {
|
||||||
toast(msg)
|
toast(msg)
|
||||||
reject('500')
|
reject(msg)
|
||||||
} else if (code !== 200) {
|
} else if (code !== 200) {
|
||||||
toast(msg)
|
toast(msg)
|
||||||
reject(code)
|
reject(msg)
|
||||||
}
|
}
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user