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