Commit 7a847c25 by 李嘉林

Merge branch 'nativehome_tst' of http://code.mayi888.com/chengmo/mayi-mp-shop into nativehome_tst

parents 65b96a15 51970295
......@@ -2,6 +2,17 @@ const app = getApp()
console.log(app, 'apppppppppp')
Component({
pageLifetimes: {
show() {
console.log('哈哈哈哈')
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
this.getTabBar().setData({
selected: 1
})
}
}
},
data: {
selected: 0,
color: "#7A7E83",
......@@ -65,7 +76,9 @@ Component({
}
// ----------webview 变化
console.log('启动1111')
console.log('启动1111',this.getTabBar())
app.webviewCallBack = function (state,params) {
console.log('webview变化',state,params)
}
......@@ -75,27 +88,22 @@ Component({
},
switchTab(e) {
// mpApp.$themeToLink //
const {
index
} = e.currentTarget.dataset
console.log('755555555', this.data.list[index].link)
// if (index == this.data.selected) return
app.globalData.tabBarPageLink=this.data.list[index].link.link
app.$themeToLink(this.data.list[index]['link'],1)
console.log(app,'aaaa')
this.toPage(this.data.list[index].link,index)
// return
// app.$themeToLink(this.data.list[index].link)
// this.setData({
// selected: index
// })
// this.toPage(this.data.list[index].link,index)
// this.setData({
// selected: index
// })
},
toPage(data,index){
console.log('index98',index)
console.log('index98',index,this)
// index=index==0?index+1:index
// 跳转
if (data.link=='/') {
wx.switchTab({
......
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar">
<cover-view class="antt ant-daipinglun"></cover-view>
<cover-view class="iconfont icon-fenzhi">3</cover-view>
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.link}}" data-index="{{index}}"
bindtap="switchTab">
......
......@@ -53,6 +53,8 @@ export default {
let defaultComponentModel = res.data.data.shopThemeData;
this.mpApp.globalData.shopThemeData = res.data.data.shopThemeData;
this.mpApp.globalData.shopInfo=res.data.data;
// 获取底部栏数据
let val = JSON.parse(defaultComponentModel);
if (val && val.defaultComponentModel) {
......
<template>
<div class="domain">
<view class="ant-daipinglun">1</view>
<!-- <goods-list id="goodsList"></goods-list> -->
<scroll-view @scroll="scrolls" @scrolltolower="scrolltolower" style="height:100vh;" scroll-y="true">
<div v-for="(item,index) in pageData" :key="index">
......@@ -24,7 +25,7 @@
src="http://cdn.mayi888.com/public/jpg/33ff0efc-96b5-4044-a65a-07799dfe98e1.jpg?x-oss-process=image/resize,limit_1,w_750"
></image>
<van-button type="primary">按钮</van-button>
<view class="ant-bofang">1</view> -->
-->
<!-- ----瀑布流开始---- -->
<!-- <waterfall-flow id="waterfallFlow"></waterfall-flow> -->
<!-- ----瀑布流结束---- -->
......@@ -37,6 +38,8 @@
</template>
<script>
import { setTabBarActive, checkTabbarPage } from "../../utils/mayi.js";
export default {
data() {
return {
......@@ -54,11 +57,16 @@ export default {
};
}
},
onShow() {
setTabBarActive.bind(this)(checkTabbarPage('/'));
},
methods: {
init(pageList) {
setTabBarActive.bind(this)(checkTabbarPage('/'));
this.pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
this.pageData = JSON.parse(this.pageInfo.pageData);
console.log('36',this.pageData)
console.log("36", this.pageData);
},
scrolls(el){
console.log('scroll')
......@@ -73,7 +81,7 @@ export default {
<style>
.domain {
text-align: center;
/* text-align: center; */
/* padding-top: 50%; */
}
</style>
\ No newline at end of file
......@@ -79,15 +79,6 @@ export default {
this.options = options;
Object.assign(this.$data, this.$options.data());
console.log(
wx.getStorageSync("sessionid"),
options,
"index------",
this.shopId,
"-----",
wx.getStorageSync("openid"),
this.shopId
);
//获取openId
wx.login({
success: res => {
......@@ -109,21 +100,7 @@ export default {
//检测登录态
this.checkLogin();
console.log(this.params,6666666)
this.options = options;
console.log('-------1',options.scene)
console.log(this.options)
console.log('-------link',this.mpApp.globalData.tabBarPageLink)
// tabbar 跳转
// if (this.mpApp.globalData.tabBarPageLink) {
// this.page = this.mpApp.globalData.tabBarPageLink;
// this.mpApp.globalData.tabBarPageLink=''
// }
// if (options.from && options.from == "tabbar") {
// this.page = decodeURIComponent(options.backpath);
// }
// ---------
if (options.share) {
//来自分享
this.link = decodeURIComponent(options.share);
......@@ -330,6 +307,19 @@ export default {
}
this.init();
},
onShow(){
let ss=wx.getStorageSync("sessionid");
if (ss && !this.params.includes("sessionid")) {
this.params +=`&sessionid=${ss}`
}
console.log(this.getTabBar,'312')
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
this.getTabBar().setData({
selected: this.index
})
}
},
methods: {
init() {
// 获取小程序开启的订阅消息配置
......
......@@ -27,12 +27,14 @@
<script>
import { serialize } from "@/utils/index";
import { checkTabbarPage } from "@/utils/mayi";
import { wx_decode } from "@/utils/wxIndex.js";
import login from "@/api/login";
import shop from "@/api/shop";
import indexApi from "@/api/index.js";
var WXBizDataCrypt = require("@/utils/WXBizDataCrypt");
export default {
name:'login',
components: {
// card
},
......@@ -315,11 +317,24 @@ export default {
delta: 1
});
}else{
wx.reLaunch({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
let parseLink=decodeURIComponent(this.backPath);
let isTabbarIndex =checkTabbarPage(parseLink)
console.log('32111',isTabbarIndex,parseLink)
wx.navigateBack()
return
if(isTabbarIndex>-1){
wx.navigateBack()
// wx.switchTab({
// url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
// })
}else{
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
}
}
},
getPhoneNumber(e) {
......
......@@ -3,28 +3,39 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:1
index: 1,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
......@@ -32,20 +43,13 @@ export default {
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 = "";
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
......
......@@ -3,28 +3,39 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:2
index: 2,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
......@@ -32,14 +43,14 @@ export default {
this.mpApp.globalData.tabBarPageLink = "";
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
wx.showLoading({
......
......@@ -3,28 +3,39 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:3
index: 3,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
......@@ -32,14 +43,14 @@ export default {
this.mpApp.globalData.tabBarPageLink = "";
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
wx.showLoading({
......
......@@ -3,28 +3,39 @@
-->
<template>
<div>
{{ pageUrl }}
<web-view :src="pageUrl" @error="handleError"></web-view>
</div>
</template>
<script>
import { getUrlofLink } from "../../utils/mayi.js";
import {
getUrlofLink,
setTabBarActive,
checkTabbarPage,
} from "../../utils/mayi.js";
export default {
data() {
return {
link: process.env.BASE_URL,
page: "/",
params: "?mixid=" + this.$store.state.mixid,
index:4
index: 4,
ss: "",
};
},
computed: {
pageUrl() {
return this.link + this.page + this.params;
return this.link + this.page + this.params + this.ss;
},
},
onLoad(options) {
let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : "";
// tabbar 跳转
let homeIndex = checkTabbarPage("/");
homeIndex != 0 && homeIndex==this.index && (this.index = 0);
if (this.mpApp.globalData.footerVal.componentData.list[this.index].link) {
this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link
......@@ -32,14 +43,14 @@ export default {
this.mpApp.globalData.tabBarPageLink = "";
}
},
// onShow(){
// if (typeof this.getTabBar === 'function' &&
// this.getTabBar()) {
// this.getTabBar().setData({
// selected: 0
// })
// }
// },
onShow() {
let ss = wx.getStorageSync("sessionid");
if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`;
}
setTabBarActive.bind(this)(this.index);
},
methods: {
handleError(data) {
wx.showLoading({
......
......@@ -3,13 +3,24 @@ 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)
// 全局跳转 data:link数据 option:是否为底部栏触发
export function $themeToLink(data, option) {
let type = data.type;
// 点击底部栏
if (option) {
let parseLink = getUrlofLink(data);
let isTabbarIndex = checkTabbarPage(parseLink);
// 替换首页位置
isTabbarIndex = isTabbarIndex == 0 ? checkTabbarPage('/') : isTabbarIndex
wx.switchTab({
url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
})
console.log(option, data)
return
}
// 历史数据
if (type == undefined || type == 'undefined') {
if (data.length > 0) {
......@@ -17,17 +28,16 @@ export function $themeToLink(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
}
// let parseLink=getUrlofLink(data)
// let isTabbarIndex =checkTabbarPage(parseLink )
// if (isTabbarIndex>-1) {
// wx.switchTab({
// url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
// })
// return
// }
// -----------------
......@@ -83,4 +93,26 @@ function toPage(backPath, backParams = "") {
});
}
// check url是否为底部栏配置项
\ No newline at end of file
// check 链接是否为底部导航栏页面 返回索引
export function checkTabbarPage(link) {
let app = getApp()
if (!app.globalData.footerVal) return -1
let footerVal = app.globalData.footerVal.componentData.list;
let isFooter = footerVal.findIndex(item => {
return item.link.link == link
})
return isFooter
}
// 当前底部栏选中项
export function setTabBarActive(data) {
console.log(this, 'this', data)
if (data < 0 || !this.$mp.page) return
if (typeof this.$mp.page.getTabBar === 'function' &&
this.$mp.page.getTabBar()) {
this.$mp.page.getTabBar().setData({
selected: data
})
}
}
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