mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-23 21:36:38 +08:00
优化业主端和商城端鉴权
This commit is contained in:
parent
9a4e9525a9
commit
88cfbe1436
71
api/webView/webViewApi.js
Normal file
71
api/webView/webViewApi.js
Normal file
@ -0,0 +1,71 @@
|
||||
import {
|
||||
request
|
||||
} from '../java110Request.js'
|
||||
import
|
||||
url
|
||||
from '../../constant/url.js'
|
||||
|
||||
import
|
||||
mapping
|
||||
from '../../constant/MappingConstant.js'
|
||||
|
||||
import {
|
||||
formatDate,
|
||||
dateTimeStringToDateString
|
||||
} from '../../utils/DateUtil.js'
|
||||
|
||||
|
||||
const ACTION_NAVIGATE_TO = "navigateTo"; // 跳转
|
||||
const ACTION_REFRESH_TOKEN = "refreshToken";
|
||||
|
||||
/**
|
||||
* 检查回话
|
||||
*/
|
||||
export function checkSession(that,url){
|
||||
checkSession().then(function() {
|
||||
//申请会话
|
||||
}, function(error) { //回话过期
|
||||
// #ifdef H5
|
||||
//先微信登录
|
||||
wechatRefreshToken();
|
||||
// #endif
|
||||
|
||||
//小程序登录
|
||||
// #ifdef MP-WEIXIN
|
||||
doLogin();
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
//查询临时钥匙
|
||||
let _key = wx.getStorageSync(mapping.OWNER_KEY);
|
||||
if (_key) {
|
||||
doLoginOwnerByKey(_key);
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/showlogin/showlogin?wAppId=' + getWAppId()
|
||||
});
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} event事件
|
||||
*/
|
||||
export function reciveMessage(event,that) {
|
||||
console.log('商城回传的参数', event);
|
||||
|
||||
let _data = event.data;
|
||||
console.log('_data', _data)
|
||||
if (_data.action == ACTION_NAVIGATE_TO) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/hcWebView/hcWebView?url=' + _data.url
|
||||
});
|
||||
return;
|
||||
} else if (_data.action == ACTION_REFRESH_TOKEN) {
|
||||
//校验是否登录,如果没有登录跳转至温馨提示页面
|
||||
checkSession(that,_data.url);
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,7 +15,9 @@ const baseUrl = '/';
|
||||
const commonBaseUrl = 'https://hc.demo.winqi.cn/';
|
||||
|
||||
//商城的url
|
||||
const mallUrl = 'http://mallapp.homecommunity.cn/#/?hcCommunityId=7020181217000001&hcCode=123456789';
|
||||
const mallUrl = 'http://mallapp.homecommunity.cn/';
|
||||
|
||||
const mallUrlIndexPage = mallUrl+'#/?hcCommunityId=7020181217000001&hcCode=123456789&mallFrom=HC';
|
||||
|
||||
// #ifndef H5
|
||||
//服务器域名 小程序 或者 app 时 后端地址
|
||||
@ -37,6 +39,7 @@ const logLevel="DEBUG"; // 日志级别
|
||||
export default{
|
||||
baseUrl:baseUrl,
|
||||
mallUrl:mallUrl,
|
||||
mallUrlIndexPage:mallUrlIndexPage,
|
||||
commonBaseUrl: commonBaseUrl,
|
||||
DEFAULT_COMMUNITY_ID:DEFAULT_COMMUNITY_ID,
|
||||
DEFAULT_COMMUNITY_NAME:DEFAULT_COMMUNITY_NAME,
|
||||
|
||||
@ -354,7 +354,8 @@
|
||||
,{
|
||||
"path" : "pages/mall/mall",
|
||||
"style" : {
|
||||
"navigationBarTitleText": "商圈"
|
||||
"navigationBarTitleText": "商圈",
|
||||
"navigationStyle":"custom"
|
||||
}
|
||||
}
|
||||
,
|
||||
@ -514,7 +515,8 @@
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": false
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle":"custom"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -12,9 +12,18 @@
|
||||
url: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// #ifdef H5
|
||||
window.addEventListener("message", this.reciveMessage);
|
||||
// #endif
|
||||
},
|
||||
onLoad(options) {
|
||||
this.url = options.url;
|
||||
|
||||
let _url = options.url;
|
||||
|
||||
this.url = conf.mallUrl + '#' + _url;
|
||||
|
||||
console.log('_hcUrl',this.url);
|
||||
|
||||
},
|
||||
methods: {
|
||||
reciveMessage: function(event) {
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
<template>
|
||||
<view class="h5-html">
|
||||
<web-view ref="webview" :src="url" @onPostMessage="reciveMessage"></web-view>
|
||||
<web-view ref="webview" :src="url" @onPostMessage="reciveMessage"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import conf from '../../conf/config.js'
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -17,39 +19,18 @@
|
||||
window.addEventListener("message",this.reciveMessage);
|
||||
// #endif
|
||||
},
|
||||
onLoad() {
|
||||
this.url = conf.mallUrl;
|
||||
|
||||
},
|
||||
// onReady() {
|
||||
// var that = this;
|
||||
// var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
|
||||
// var statusBarHeight = 0;
|
||||
// uni.getSystemInfo({
|
||||
// //成功获取的回调函数,返回值为系统信息
|
||||
// success: (sysinfo) => {
|
||||
// height = sysinfo.windowHeight - that.$navHeight - sysinfo.statusBarHeight; //自行修改,自己需要的高度
|
||||
// statusBarHeight = sysinfo.statusBarHeight;
|
||||
// },
|
||||
// complete: () => {}
|
||||
// });
|
||||
onLoad(options) {
|
||||
let _url = options.url;
|
||||
|
||||
// var pages = getCurrentPages();
|
||||
// var page = pages[pages.length - 1];
|
||||
|
||||
// var currentWebview = page.$getAppWebview(); //页面栈最顶层就是当前webview
|
||||
|
||||
// setTimeout(function() {
|
||||
// var wv = currentWebview.children()[0];
|
||||
// wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
|
||||
// top: that.$navHeight + statusBarHeight,
|
||||
// height: height
|
||||
// })
|
||||
// }, 500); //如页面初始化调用需要写延迟
|
||||
// },
|
||||
if(_url){
|
||||
this.url = conf.mallUrl + _url;
|
||||
}else{
|
||||
this.url = conf.mallUrlIndexPage;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reciveMessage: function(event) {
|
||||
console.log('商城回传的参数', event);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user