diff --git a/api/webView/webViewApi.js b/api/webView/webViewApi.js new file mode 100644 index 0000000..97ab6e5 --- /dev/null +++ b/api/webView/webViewApi.js @@ -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); + } + +} diff --git a/conf/config.js b/conf/config.js index 13aac9d..0569547 100644 --- a/conf/config.js +++ b/conf/config.js @@ -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, diff --git a/pages.json b/pages.json index 7e0a6e2..bdfb1e2 100644 --- a/pages.json +++ b/pages.json @@ -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" } } diff --git a/pages/hcWebView/hcWebView.vue b/pages/hcWebView/hcWebView.vue index ba4b5c2..a1d18f2 100644 --- a/pages/hcWebView/hcWebView.vue +++ b/pages/hcWebView/hcWebView.vue @@ -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) { diff --git a/pages/mall/mall.vue b/pages/mall/mall.vue index e22e688..b3d7009 100644 --- a/pages/mall/mall.vue +++ b/pages/mall/mall.vue @@ -1,11 +1,13 @@