小程序认证

wechat
ihzero 2023-11-12 16:40:46 +08:00
parent 5f3df387e7
commit 4cba12d49c
6 changed files with 345 additions and 318 deletions

View File

@ -1,3 +1,6 @@
ENV = 'development'
VUE_APP_BASE_API = 'http://lcny.sk797.cn'
# VUE_APP_BASE_API = 'http://lcny.sk797.cn'
VUE_APP_BASE_API = 'http://36.133.205.221:81'
VUE_APP_BASE_URL = 'http://36.133.205.221:91'

View File

@ -2,3 +2,5 @@ ENV = 'production'
VUE_APP_BASE_API = 'http://36.133.205.221:81'
VUE_APP_BASE_URL = 'http://36.133.205.221:91'

View File

@ -8,52 +8,44 @@
"style": {
"navigationBarTitleText": "隆昌农业大数据监控平台"
}
}
,{
"path" : "pages/login/login",
"style" :
},
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
,{
"path" : "pages/user/user",
"style" :
},
{
"path": "pages/user/user",
"style": {
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
,{
"path" : "pages/user/password-edit",
"style" :
},
// {
// "path": "pages/user/password-edit",
// "style": {
// "navigationBarTitleText": "修改密码",
// "enablePullDownRefresh": false
// }
// },
// {
// "path": "pages/system/role",
// "style": {
// "navigationBarTitleText": "角色管理",
// "enablePullDownRefresh": false
// }
// },
{
"navigationBarTitleText": "修改密码",
"enablePullDownRefresh": false
"path": "pages/webview/index",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
,{
"path" : "pages/system/role",
"style" :
{
"navigationBarTitleText": "角色管理",
"enablePullDownRefresh": false
}
},{
"path" : "pages/webview/index",
"style" :
{
"navigationBarTitleText": "webview",
"enablePullDownRefresh": false
}
}
// ,{
// "path" : "pages/index/meteorological",
@ -282,7 +274,8 @@
"selectedColor": "#1296db",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [{
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "static/tab/tab_home.png",
"selectedIconPath": "static/tab/tab_home_h.png",

View File

@ -175,7 +175,7 @@ export default {
}
},
computed: {
...mapGetters(['userInfo']),
...mapGetters(['userInfo','token']),
menus(){
return this.filterAsyncRoutes(this.menuList, this.userInfo?.permissions_slug ?? [])
@ -206,12 +206,9 @@ export default {
linknavFn(item) {
if(!item.url) return
const host = 'http://36.133.205.221:91'
// uni.navigateTo({
// url: `/pages/webview/index?url=${host}/#${item.url}`,
// })
const url = encodeURIComponent(`${item.url}`)
uni.navigateTo({
url: `/pages/webview/index?url=${host}/#/pages/login/login`,
url: `/pages/webview/index?url=${url}`,
})
},
},

View File

@ -134,10 +134,14 @@
})
},
linnavF(url){
linnavF(uri){
const url = encodeURIComponent(`${uri}`)
uni.navigateTo({
url:url
url: `/pages/webview/index?url=${url}`,
})
// uni.navigateTo({
// url:url
// })
},
loginOut(){
this.show = true;

View File

@ -1,15 +1,22 @@
<template>
<view >
<web-view :fullscreen="false" ref="webview" style="height: 500rpx;" :src="src" @onPostMessage="message"> </web-view>
<button class="button" @click="evalJs">evalJs(webview)</button>
<view>
<web-view
:fullscreen="true"
ref="webview"
style="height: 500rpx"
:src="src"
@onPostMessage="message"
>
</web-view>
</view>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
data() {
return {
src: 'https://www.baidu.com',
src: '',
webview_styles: {
progress: {
color: '#FF3333',
@ -17,23 +24,44 @@ export default {
},
}
},
computed: {
...mapGetters(['token']),
},
onLoad({ url }) {
// this.src = decodeURIComponent(url)
const host = process.env.VUE_APP_BASE_URL
const queryParams = this.queryURLParams(decodeURIComponent(url))
const query = {
...queryParams.query,
token: this.token,
appbar: 'hidden',
}
this.src = `${host}/#${queryParams.path}${uni.$u.queryParams(query)}`
},
onReady() {
this.writeToWebView()
// this.webviewContext = uni.createWebviewContext('web-view', this)
},
mounted() {
setTimeout(()=>{
console.log(this.$refs.webview);
},2000)
},
methods: {
queryURLParams(URL) {
// const url = location.search; // searchurl"?"
let url = URL.split('?')[1]
let obj = {} //
if (url) {
let arr = url.split('&') // &
for (let i = 0; i < arr.length; i++) {
let arrNew = arr[i].split('=') // "="
obj[arrNew[0]] = arrNew[1]
}
}
return {
query: obj,
path: URL.split('?')[0],
}
},
writeToWebView(data) {},
evalJs: function () {
console.log(this.$refs.webview);
console.log(this.$refs.webview)
this.$refs.webview.evalJs("document.body.style.background ='#00FF00'")
},
message(event) {