|
@@ -5,6 +5,29 @@ import {
|
|
|
isWeixin
|
|
|
} from "./common.js"
|
|
|
import store from '@/store/index.js'
|
|
|
+
|
|
|
+export function webViewHref(url, pam = {}) {
|
|
|
+ var pamstr = Object.entries(pam).map(item => item.join("=")).join("&");
|
|
|
+ // #ifdef H5
|
|
|
+ if (!!~url.indexOf("?")) {
|
|
|
+ return process.env.VUE_APP_HREF + url +
|
|
|
+ `${pamstr?"&"+pamstr:""}&x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}`
|
|
|
+ } else {
|
|
|
+ return process.env.VUE_APP_HREF + url +
|
|
|
+ `?${pamstr?pamstr+"&":""}x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}`
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+ // #ifndef H5
|
|
|
+ if (!!~url.indexOf("?")) {
|
|
|
+ return process.env.VUE_APP_HREF + url +
|
|
|
+ `${pamstr?"&"+pamstr:""}&x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}&miniProgram=jsm_env`
|
|
|
+ } else {
|
|
|
+ return process.env.VUE_APP_HREF + url +
|
|
|
+ `?${pamstr?pamstr+"&":""}x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}&miniProgram=jsm_env`
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+}
|
|
|
+
|
|
|
export const navToPage = (function() {
|
|
|
var gopageid = null
|
|
|
return function(p, goToType = "navigateTo") {
|
|
@@ -15,7 +38,7 @@ export const navToPage = (function() {
|
|
|
// #ifdef H5
|
|
|
if (isWeixin()) {
|
|
|
wx.miniProgram.getEnv(res => {
|
|
|
- if (res.miniprogram && uni.getStorageSync('miniProgram') == "jsm_env") {
|
|
|
+ if (res.miniprogram) {
|
|
|
var i = 0;
|
|
|
(function goTo() {
|
|
|
if (gopageid) {
|
|
@@ -24,10 +47,19 @@ export const navToPage = (function() {
|
|
|
i++
|
|
|
if (uniWebview && uniWebview[goToType]) {
|
|
|
// h5跳转小程序
|
|
|
- uniWebview[goToType]({
|
|
|
- url: url,
|
|
|
- ...data
|
|
|
- })
|
|
|
+ if (uni.getStorageSync('miniProgram') == "jsm_env") {
|
|
|
+ // 家盛茂小程序环境
|
|
|
+ uniWebview[goToType]({
|
|
|
+ url: url,
|
|
|
+ ...data
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 第三方小程序跳转我们的h5页面处理
|
|
|
+ uniWebview[goToType]({
|
|
|
+ url: `/pagesJsm/pages/webview?webUrl=${encodeURIComponent(webViewHref(url))}`,
|
|
|
+ ...data
|
|
|
+ })
|
|
|
+ }
|
|
|
} else if (i < 10) {
|
|
|
gopageid = setTimeout(function() {
|
|
|
gopageid = null
|
|
@@ -59,28 +91,4 @@ export const navToPage = (function() {
|
|
|
})
|
|
|
// #endif
|
|
|
}
|
|
|
-})()
|
|
|
-
|
|
|
-export function webViewHref(url, pam = {}) {
|
|
|
- var pamstr = Object.entries(pam).map(item => {
|
|
|
- return item.join("=")
|
|
|
- }).join("&");
|
|
|
- // #ifdef H5
|
|
|
- if (!!~url.indexOf("?")) {
|
|
|
- return process.env.VUE_APP_HREF + url +
|
|
|
- `${pamstr?"&"+pamstr:""}&x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}`
|
|
|
- } else {
|
|
|
- return process.env.VUE_APP_HREF + url +
|
|
|
- `?${pamstr?pamstr+"&":""}x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}`
|
|
|
- }
|
|
|
- // #endif
|
|
|
- // #ifndef H5
|
|
|
- if (!!~url.indexOf("?")) {
|
|
|
- return process.env.VUE_APP_HREF + url +
|
|
|
- `${pamstr?"&"+pamstr:""}&x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}&miniProgram=jsm_env`
|
|
|
- } else {
|
|
|
- return process.env.VUE_APP_HREF + url +
|
|
|
- `?${pamstr?pamstr+"&":""}x-token=${store.state.user.token||''}&openId=${store.state.user.openId||''}&userId=${store.state.user.userId}&username=${store.state.user.name||''}&useravatar=${store.state.user.avatar||''}&miniProgram=jsm_env`
|
|
|
- }
|
|
|
- // #endif
|
|
|
-}
|
|
|
+})()
|