Commit 7010d758 by 程默

全局跳转

parent 0fd2aaa7
...@@ -63,6 +63,12 @@ Component({ ...@@ -63,6 +63,12 @@ Component({
}) })
} }
} }
// ----------webview 变化
console.log('启动1111')
app.webviewCallBack = function (state,params) {
console.log('webview变化',state,params)
}
}, },
methods: { methods: {
init() { init() {
...@@ -80,7 +86,7 @@ Component({ ...@@ -80,7 +86,7 @@ Component({
app.globalData.tabBarPageLink=this.data.list[index].link.link app.globalData.tabBarPageLink=this.data.list[index].link.link
console.log(app,'aaaa') console.log(app,'aaaa')
this.toPage(this.data.list[index].link) this.toPage(this.data.list[index].link,index)
// return // return
// app.$themeToLink(this.data.list[index].link) // app.$themeToLink(this.data.list[index].link)
...@@ -88,12 +94,21 @@ Component({ ...@@ -88,12 +94,21 @@ Component({
// selected: index // selected: index
// }) // })
}, },
toPage(data){ toPage(data,index){
console.log('index98',index)
// 跳转 // 跳转
if (data.link=='/') {
wx.switchTab({ wx.switchTab({
url: '/pages/index/main', url: '/pages/home/main',
}) })
}else{
wx.switchTab({
url: `/pages/tabBar${index}/main`,
})
// ?from=tabbar&backpath=${
// data.link
// }
}
} }
} }
}) })
...@@ -4,6 +4,7 @@ import Store from './store/index' ...@@ -4,6 +4,7 @@ import Store from './store/index'
import "../static/nicon/iconfont.css" import "../static/nicon/iconfont.css"
import goodsApi from "./api/goods" import goodsApi from "./api/goods"
import { DFSImg } from "@/utils/index"; import { DFSImg } from "@/utils/index";
import { $themeToLink } from "@/utils/mayi"
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
...@@ -26,7 +27,7 @@ app.$mount() ...@@ -26,7 +27,7 @@ app.$mount()
// glob挂载到 // glob挂载到
let mpApp = getApp(); let mpApp = getApp();
Vue.prototype.mpApp = mpApp Vue.prototype.mpApp = mpApp
// 定义数据回调函数 // 数据异步回调函数
// 商城 // 商城
mpApp.shopCallBack = function () { } mpApp.shopCallBack = function () { }
// 多主题页面 // 多主题页面
...@@ -38,99 +39,8 @@ mpApp.webviewCallBack = function () { } ...@@ -38,99 +39,8 @@ mpApp.webviewCallBack = function () { }
console.log('3555555', wx) console.log('3555555', wx)
// 全局跳转 data为link对象 // 全局跳转 data为link对象
mpApp.$themeToLink = function name(data) { mpApp.$themeToLink = $themeToLink
debugger
console.log('393939')
let type = data.type;
if (type == undefined || type == 'undefined') {
if (data.length > 0) {
// this.$nuxt.$router.push(data);
}
return
}
if (type == 0) {//无链接
return
} else if (type == 1) {//h5页面
//兼容
if (data.link.substring(0, 1) == "/") {
// this.$nuxt.$router.push(data.link);
toPage(data.link)
} else {
if (data.link.startsWith('http') || data.link.startsWith('https')) {
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
wx.miniProgram.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
// } else {
// window.location = data.link
// }
} else {
window.location.href = data.link;
}
}
} else if (type == 1.1) {//小程序页面 可能增加登录态拦截
if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
wx.miniProgram.navigateTo({ url: data.link });
} else {
// Toast("暂不支持");
}
} else if (type == 1.2) { //第三方链接 // api
if (data.link == 'outerChain:businessCenter') {
// 进入商家中心外链
let url = `${config.GUIDE_URL}/login?mixid=${this.$nuxt.$route.query.mixid}&back=${encodeURIComponent(window.location.href)}`;
window.location.href = url;
return
}
if (data.link.substring(0, 1) == "/") {
// this.$nuxt.$router.push(data.link);
toPage(data.link)
} else {
if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
$mp.miniProgram.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
} else {
window.location.href = data.link
}
}
} else if (type == 2) {//功能
let featureType = data.feature.type;
if (featureType == 'themeCouponClick' || featureType == 0) {//优惠券
this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
} else if (featureType == 1) {//分享
console.log('是分享了。。。。', cb);
// if (data.type == 2 && data.feature.type == 1) {
// //分享
// this.$nuxt.$SHARE({
// itemList: data.feature.value
// });
// }
} else if (featureType == "themeMemberCardClick" || featureType == 2) { //会员卡
// this.$themeMemberCardClick(data.feature.value);
}
} else if (type == 3) { //小程序跳转到小程序
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
// if (this.$store.getters['sceneModule/flushbonadingVisible']) {
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/toMini?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// return
// }
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/main?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// } else {
// Toast("暂不支持");
// }
} else {
//向后兼容
if (data.length > 0) {
this.$nuxt.$router.push(data.link);
}
}
}
function toPage(backPath, backParams) {
wx.reLaunch({
url: `../index/main?from=home&backpath=${backPath}&params=${encodeURIComponent(backParams)}`
});
}
mpApp.goodsApi = goodsApi; mpApp.goodsApi = goodsApi;
mpApp.DFSImg = DFSImg; mpApp.DFSImg = DFSImg;
<template> <template>
<div> <div>
{{withoutScene}}
<web-view v-if="withoutScene" :src="pageUrl" @message="getMessage" @error="handleError" @load="handleLoad"></web-view> <web-view v-if="withoutScene" :src="pageUrl" @message="getMessage" @error="handleError" @load="handleLoad"></web-view>
</div> </div>
</template> </template>
...@@ -41,7 +42,7 @@ export default { ...@@ -41,7 +42,7 @@ export default {
shareOrderSn: "", shareOrderSn: "",
shareTid: "", shareTid: "",
newWindowHref : '', newWindowHref : '',
withoutScene: true, withoutScene: false,
sharePageList: [ sharePageList: [
"goods/", "goods/",
"receivingGift", "receivingGift",
...@@ -92,6 +93,7 @@ export default { ...@@ -92,6 +93,7 @@ export default {
success: res => { success: res => {
this.code = res.code; this.code = res.code;
login.miniLogin({ code: this.code}).then(res1 => { login.miniLogin({ code: this.code}).then(res1 => {
this.withoutScene = true;
console.log(res1,555555) console.log(res1,555555)
if (res1.data.code == 200) { if (res1.data.code == 200) {
wx.setStorage({ wx.setStorage({
...@@ -148,10 +150,10 @@ export default { ...@@ -148,10 +150,10 @@ export default {
key: "sessionid", key: "sessionid",
data: params.sessionid data: params.sessionid
}); });
} else if (options.from && options.from == "livedToIndex") { } else if (options.from && (options.from == "home" || options.from == "livedToIndex")) {
//来自直播详情 //来自直播详情
this.page = decodeURIComponent(options.backpath); this.page = decodeURIComponent(options.backpath);
this.params += "&" + serialize(options.params); options.params && (this.params += "&" + serialize(options.params));
} else if (options.from && options.from == "livedBackShop") { } else if (options.from && options.from == "livedBackShop") {
//直播页back到商城 //直播页back到商城
this.page = decodeURIComponent(options.backpath); this.page = decodeURIComponent(options.backpath);
......
<!-- <!--
tabbar1 tabbar
--> -->
<template> <template>
<div> <div>
...@@ -8,25 +8,44 @@ ...@@ -8,25 +8,44 @@
</template> </template>
<script> <script>
import { getUrlofLink } from "../../utils/mayi.js";
export default { export default {
data() { data() {
return { return {
link: process.env.BASE_URL, link: process.env.BASE_URL,
page: "/", page: "/",
params: "?mixid=" + this.$store.state.mixid, params: "?mixid=" + this.$store.state.mixid,
index:1
}; };
}, },
computed: { computed: {
pageUrl() { pageUrl() {
return this.link+this.page+this.params; return this.link + this.page + this.params;
} },
}, },
onLoad(options) { onLoad(options) {
// tabbar 跳转 // tabbar 跳转
if (this.mpApp.globalData.tabBarPageLink) { if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = this.mpApp.globalData.tabBarPageLink; this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
this.mpApp.globalData.tabBarPageLink = "";
}
},
onShow(){
console.log('show')
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
this.mpApp.globalData.tabBarPageLink = ""; this.mpApp.globalData.tabBarPageLink = "";
} }
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
}, },
methods: { methods: {
handleError(data) { handleError(data) {
......
<!-- <!--
tabbar1 tabbar
--> -->
<template> <template>
<div> <div>
...@@ -8,26 +8,38 @@ ...@@ -8,26 +8,38 @@
</template> </template>
<script> <script>
import { getUrlofLink } from "../../utils/mayi.js";
export default { export default {
data() { data() {
return { return {
link: process.env.BASE_URL, link: process.env.BASE_URL,
page: "/", page: "/",
params: "?mixid=" + this.$store.state.mixid, params: "?mixid=" + this.$store.state.mixid,
index:2
}; };
}, },
computed: { computed: {
pageUrl() { pageUrl() {
return this.link+this.page+this.params; return this.link + this.page + this.params;
} },
}, },
onLoad(options) { onLoad(options) {
// tabbar 跳转 // tabbar 跳转
if (this.mpApp.globalData.tabBarPageLink) { if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = this.mpApp.globalData.tabBarPageLink; this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
this.mpApp.globalData.tabBarPageLink = ""; this.mpApp.globalData.tabBarPageLink = "";
} }
}, },
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
methods: { methods: {
handleError(data) { handleError(data) {
wx.showLoading({ wx.showLoading({
......
<!-- <!--
tabbar1 tabbar
--> -->
<template> <template>
<div> <div>
...@@ -8,26 +8,38 @@ ...@@ -8,26 +8,38 @@
</template> </template>
<script> <script>
import { getUrlofLink } from "../../utils/mayi.js";
export default { export default {
data() { data() {
return { return {
link: process.env.BASE_URL, link: process.env.BASE_URL,
page: "/", page: "/",
params: "?mixid=" + this.$store.state.mixid, params: "?mixid=" + this.$store.state.mixid,
index:3
}; };
}, },
computed: { computed: {
pageUrl() { pageUrl() {
return this.link+this.page+this.params; return this.link + this.page + this.params;
} },
}, },
onLoad(options) { onLoad(options) {
// tabbar 跳转 // tabbar 跳转
if (this.mpApp.globalData.tabBarPageLink) { if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = this.mpApp.globalData.tabBarPageLink; this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
this.mpApp.globalData.tabBarPageLink = ""; this.mpApp.globalData.tabBarPageLink = "";
} }
}, },
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
methods: { methods: {
handleError(data) { handleError(data) {
wx.showLoading({ wx.showLoading({
......
<!-- <!--
tabbar1 tabbar
--> -->
<template> <template>
<div> <div>
...@@ -8,26 +8,38 @@ ...@@ -8,26 +8,38 @@
</template> </template>
<script> <script>
import { getUrlofLink } from "../../utils/mayi.js";
export default { export default {
data() { data() {
return { return {
link: process.env.BASE_URL, link: process.env.BASE_URL,
page: "/", page: "/",
params: "?mixid=" + this.$store.state.mixid, params: "?mixid=" + this.$store.state.mixid,
index:4
}; };
}, },
computed: { computed: {
pageUrl() { pageUrl() {
return this.link+this.page+this.params; return this.link + this.page + this.params;
} },
}, },
onLoad(options) { onLoad(options) {
// tabbar 跳转 // tabbar 跳转
if (this.mpApp.globalData.tabBarPageLink) { if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = this.mpApp.globalData.tabBarPageLink; this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
);
this.mpApp.globalData.tabBarPageLink = ""; this.mpApp.globalData.tabBarPageLink = "";
} }
}, },
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
methods: { methods: {
handleError(data) { handleError(data) {
wx.showLoading({ wx.showLoading({
......
// 获取link 中页面地址(link兼容 有object或者string)
export function getUrlofLink(data) {
return data.link
}
// 全局跳转
export function $themeToLink(data) {
let app = getApp()
let footerVal = app.globalData.footerVal.componentData.list;
console.log('393939', footerVal)
let type = data.type;
if (type == undefined || type == 'undefined') {
if (data.length > 0) {
// this.$nuxt.$router.push(data);
}
return
}
// 底部导航跳转
let parseLink=getUrlofLink(data)
let isFooter = footerVal.findIndex(item => {
return item.link.link == parseLink
})
if (isFooter>-1) {
wx.switchTab({
url: parseLink=='/'?'/pages/home/main':`/pages/tabBar${isFooter}/main`,
})
return
}
// -----------------
if (type == 0) {//无链接
return
} else if (type == 1) {//h5页面
//兼容
if (data.link.substring(0, 1) == "/") {
// this.$nuxt.$router.push(data.link);
toPage(data.link)
} else {
if (data.link.startsWith('http') || data.link.startsWith('https')) {
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
wx.miniProgram.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
// } else {
// window.location = data.link
// }
} else {
window.location.href = data.link;
}
}
} else if (type == 1.1) {//小程序页面 可能增加登录态拦截
if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
wx.miniProgram.navigateTo({ url: data.link });
} else {
// Toast("暂不支持");
}
} else if (type == 1.2) { //第三方链接
if (data.link == 'outerChain:businessCenter') {
// 进入商家中心外链
let url = `${config.GUIDE_URL}/login?mixid=${this.$nuxt.$route.query.mixid}&back=${encodeURIComponent(window.location.href)}`;
window.location.href = url;
return
}
if (data.link.substring(0, 1) == "/") {
// this.$nuxt.$router.push(data.link);
toPage(data.link)
} else {
if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
$mp.miniProgram.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
} else {
window.location.href = data.link
}
}
} else if (type == 2) {//功能
let featureType = data.feature.type;
if (featureType == 'themeCouponClick' || featureType == 0) {//优惠券
this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
} else if (featureType == 1) {//分享
console.log('是分享了。。。。', cb);
// if (data.type == 2 && data.feature.type == 1) {
// //分享
// this.$nuxt.$SHARE({
// itemList: data.feature.value
// });
// }
} else if (featureType == "themeMemberCardClick" || featureType == 2) { //会员卡
// this.$themeMemberCardClick(data.feature.value);
}
} else if (type == 3) { //小程序跳转到小程序
// if (this.$store.state.miniProgram == 1 || this.$store.state.miniProgram == 2) {
// if (this.$store.getters['sceneModule/flushbonadingVisible']) {
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/toMini?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// return
// }
// $mp.miniProgram.navigateTo({
// url: `/pages/toMini/main?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
// })
// } else {
// Toast("暂不支持");
// }
} else {
//向后兼容
if (data.length > 0) {
this.$nuxt.$router.push(data.link);
}
}
}
function toPage(backPath, backParams) {
wx.navigateTo({
url: `../index/main?from=home&backpath=${backPath}&params=${encodeURIComponent(backParams)}`
});
}
// check url是否为底部栏配置项
\ No newline at end of file
export default {
}
const handler = {
get: function(obj, prop) {
console.log(obj,prop,'9999999999')
return prop in obj ? obj[prop] : 37;
}
};
const p = new Proxy({}, handler);
p.a = 1;
p.b = undefined;
console.log(p.a, p.b); // 1, undefined
console.log('c' in p, p.c); // false, 37
...@@ -31,5 +31,10 @@ Component({ ...@@ -31,5 +31,10 @@ Component({
console.log(val,'--------30') console.log(val,'--------30')
this.setData({ activeIndex:val.detail.current }); this.setData({ activeIndex:val.detail.current });
}, },
onClick(data){
let item=data.currentTarget.dataset.item;
console.log(data.currentTarget.dataset.item,'iiii')
app.$themeToLink(item.link)
}
} }
}); });
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<swiper class="swiper" indicator-dots="{{indicatorDots}}" <swiper class="swiper" indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="true" bindchange="bannerChange"> autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="true" bindchange="bannerChange">
<block wx:for="{{datas.componentData.imgList}}" wx:key="index"> <block wx:for="{{datas.componentData.imgList}}" wx:key="index">
<swiper-item> <swiper-item data-item="{{item}}" bindtap="onClick" >
<view class="swiper-item"> <view class="swiper-item">
<image src="{{item.imageUrl}}" style="width:100%;border-radius:{{datas.componentData.borderRadius*2}}rpx" mode="widthFix" class="bannerImgItem"></image> <image src="{{item.imageUrl}}" style="width:100%;border-radius:{{datas.componentData.borderRadius*2}}rpx" mode="widthFix" class="bannerImgItem"></image>
</view> </view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment