Commit e3739fa1 by zhangxw

修改

1 parent d3c20db2
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
"tabDate/pages/detail/detail", "tabDate/pages/detail/detail",
"tabMine/pages/index/index", "tabMine/pages/index/index",
"test/pages/test", "test/pages/test",
"pages/equityPage/equityPage" "pages/equityPage/equityPage",
"components/TabBar/TabBar",
"pages/equityPage/pages/index/index",
"pages/equityPage/pages/4sOverview/4sOcerview"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
......
// components/TabBar/TabBar.js
Component({
options: {
styleIsolation: 'shared'
},
/**
* 组件的属性列表
*/
properties: {
list: {
type: Array,
value: [],
observer(n) {
n && n.length && this.setData({
tabList: JSON.parse(JSON.stringify(n))
})
}
},
color: {
type: String,
observer(_color) {
this.setData({
_color
})
}
},
selectedColor: {
type: String,
observer(_selectedColor) {
this.setData({
_selectedColor
})
}
},
tabIndex: Number
},
/**
* 组件的初始数据
*/
data: {
tabList: []
},
/**
* 组件的方法列表
*/
methods: {
init() {
wx.$util.getViewInfo(
'#tab-bar',
res => {
const thisPage = wx.$router.getPageInstance()
thisPage.setData({
tabBarHeight: res.height
})
wx.setStorageSync('tabBarHeight', res.height)
},
this
)
wx.$eventbus.on('changeTabBar', res => {
let {
tabList
} = this.data, {
_color,
tabStyle,
changeKeyList
} = res
tabList.map((e,index) => {
changeKeyList.map((key) => {
e[key] = res[key][index]
})
})
this.setData({
_color,
tabStyle,
tabList
})
})
wx.$eventbus.on('restoreTabBar', _ => {
this.restoreTabBar()
})
},
restoreTabBar() {
const {
list,
color
} = this.data
this.setData({
tabList: JSON.parse(JSON.stringify(list)),
tabStyle: '',
_color: color
})
},
change(e) {
let {
index
} = e.currentTarget.dataset,
{tabIndex} = this.data
if(tabIndex == index) return
this.triggerEvent('change', index)
this.restoreTabBar()
}
},
lifetimes: {
attached() {
this.init()
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="tab-bar" id="tab-bar" style="{{tabStyle}}">
<block wx:for="{{tabList}}" wx:key="index">
<view class="item" style="color: {{tabIndex == index ? _selectedColor :_color}};" bindtap="change" data-index="{{index}}">
<view class="icon-box">
<block wx:if="{{tabIndex == index}}">
<image src="{{item.selectedIconPath}}" class="active-icon" />
</block>
<block wx:else>
<image src="{{item.iconPath}}" class="icon" />
</block>
</view>
{{item.name}}
</view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
/* components/TabBar/TabBar.wxss */
.tab-bar{
position: fixed;
left: 0;
background-color: #fff;
z-index: 99;
width: 100%;
height: 100rpx;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 24rpx;
animation: show-tab-bar .5s forwards;
border-top: 1rpx solid #F4F4F5;
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.tab-bar .item{
flex: 1;
flex-shrink: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: all .5s;
}
.tab-bar .item .icon-box{
width: 44rpx;
height: 44rpx;
margin-bottom: 8rpx;
}
.tab-bar .item .icon-box .active-icon{
animation: showicon .5s forwards;
}
@keyframes show-tab-bar {
0%{
bottom: -100%;
}
100%{
bottom: 0;
}
}
\ No newline at end of file \ No newline at end of file
// components/TabBar/TabBar.js // components/TabBar/TabBar.js
Component({ Component({
options: {
styleIsolation: 'shared'
},
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
list: { tabList: Array
type: Array,
value: [],
observer(n) {
n && n.length && this.setData({
tabList: JSON.parse(JSON.stringify(n))
})
}
},
color: {
type: String,
observer(_color) {
this.setData({
_color
})
}
},
selectedColor: {
type: String,
observer(_selectedColor) {
this.setData({
_selectedColor
})
}
},
tabIndex: Number
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
tabList: [] tabIndex: 0
},
lifetimes: {
ready() {
this.setTab()
}
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
init() {
wx.$util.getViewInfo(
'#tab-bar',
res => {
const thisPage = wx.$router.getPageInstance()
thisPage.setData({
tabBarHeight: res.height
})
wx.setStorageSync('tabBarHeight', res.height)
},
this
)
console.log(wx.$eventbus)
wx.$eventbus.on('changeTabBar', res => {
let {
tabList
} = this.data, {
_color,
tabStyle,
changeKeyList
} = res
tabList.map((e,index) => {
changeKeyList.map((key) => {
e[key] = res[key][index]
})
})
this.setData({
_color,
tabStyle,
tabList
})
})
wx.$eventbus.on('restoreTabBar', _ => {
this.restoreTabBar()
})
},
restoreTabBar() {
const {
list,
color
} = this.data
this.setData({
tabList: JSON.parse(JSON.stringify(list)),
tabStyle: '',
_color: color
})
},
change(e) { change(e) {
let { let {
index index
} = e.currentTarget.dataset, } = e.currentTarget.dataset
{tabIndex} = this.data this.setTab(index)
if(tabIndex == index) return },
this.triggerEvent('change', index) setTab(index = 0) {
this.restoreTabBar() let {
} tabIndex,
}, } = this.data
lifetimes: { wx.$util.getViewInfo(`#tab-${tabIndex}`, old => {
attached() { let oldLeft = old.left
this.init() let oldWidth = old.width
wx.$util.getViewInfo(`#tab-${index}`, res => {
let {
left,
width
} = res
if (tabIndex != index) {
let readyLeft = oldLeft > left ? left : oldLeft
let readyWidth = oldLeft > left ? oldLeft - left : left - oldLeft
this.setData({
activeStyle: `width:${readyWidth - oldWidth / 2 + width / 2}px;background-color:#3582EE;border-radius:3rpx;left:${readyLeft + oldWidth / 2}px;transition: all .1s;`
})
}
setTimeout(() => {
this.setData({
activeStyle: `width:${width}px;left:${left}px;background-color:#3582EE;`,
tabIndex: index
})
this.triggerEvent('click', index)
}, 100)
}, this)
}, this)
} }
} }
}) })
\ No newline at end of file \ No newline at end of file
<view class="tab-bar isFullSucreen" id="tab-bar" style="{{tabStyle}}"> <view class="tab" style="grid-template-columns: repeat({{tabList.length}}, 1fr)">
<block wx:for="{{tabList}}" wx:key="index"> <block wx:for="{{tabList}}" wx:key="index">
<view class="item" style="color: {{tabIndex == index ? _selectedColor :_color}};" bindtap="change" data-index="{{index}}"> <view class="tab-item" style="color:{{tabIndex==index?'#3582EE':''}};" bindtap="change" data-index="{{index}}">
<view class="icon-box"> <text class="tab-item-text" id="tab-{{index}}">{{item}}</text>
<block wx:if="{{tabIndex == index}}">
<image src="{{item.selectedIconPath}}" class="active-icon" />
</block>
<block wx:else>
<image src="{{item.iconPath}}" class="icon" />
</block>
</view>
{{item.name}}
</view> </view>
</block> </block>
<view class="active-doc" style="{{activeStyle}}"></view>
</view> </view>
\ No newline at end of file \ No newline at end of file
/* components/TabBar/TabBar.wxss */ /* components/TabBar/TabBar.wxss */
.tab-bar{ .tab {
position: fixed;
left: 0;
background-color: #fff; background-color: #fff;
z-index: 99; height: 104rpx;
width: 100%; box-sizing: border-box;
height: 100rpx; display: grid;
display: flex;
align-items: center; align-items: center;
justify-content: space-between; font-size: 28rpx;
font-size: 24rpx; color: #999999;
animation: show-tab-bar .5s forwards;
border-top: 1rpx solid #F4F4F5;
} }
.tab-bar .item{ .active-doc {
flex: 1; position: absolute;
flex-shrink: 0; bottom: 8rpx;
display: flex; height: 6rpx;
flex-direction: column; transition: all .25s;
align-items: center;
justify-content: center;
transition: all .5s;
}
.tab-bar .item .icon-box{
width: 44rpx;
height: 44rpx;
margin-bottom: 8rpx;
}
.tab-bar .item .icon-box .active-icon{
animation: showicon .5s forwards;
} }
.tab .tab-item {
@keyframes show-tab-bar { text-align: center;
0%{
bottom: -100%;
}
100%{
bottom: 0;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -171,10 +171,10 @@ Page({ ...@@ -171,10 +171,10 @@ Page({
wx.$SCENE = null wx.$SCENE = null
} else { } else {
// 判断开通的业务场景 // 判断开通的业务场景
if (data.isSuper) { if (!data.isSuper) {
wx.$router.reLaunch('pages.sceneIndex') wx.$router.reLaunch('pages.sceneIndex')
} else { } else {
wx.$router.go('tabIndex.index') wx.$router.reLaunch('tabIndex.index')
} }
} }
// app. // app.
......
...@@ -15,7 +15,8 @@ Page({ ...@@ -15,7 +15,8 @@ Page({
selectedIconPath: '/images/tab-equity-active.png', selectedIconPath: '/images/tab-equity-active.png',
}], }],
tabIndex: 0, tabIndex: 0,
pageShow: [true, false] pageShow: [true, false],
navBarHeight: 0
}, },
changeTabBar(e) { changeTabBar(e) {
...@@ -29,6 +30,7 @@ Page({ ...@@ -29,6 +30,7 @@ Page({
this.setData({ this.setData({
tabIndex tabIndex
}) })
console.log(pageShow[tabIndex])
if (!pageShow[tabIndex]) { if (!pageShow[tabIndex]) {
if (!loginData) this.onLoad() if (!loginData) this.onLoad()
else this.getComponentPage().onLoad && this.getComponentPage().onLoad(loginData, options) else this.getComponentPage().onLoad && this.getComponentPage().onLoad(loginData, options)
...@@ -39,6 +41,13 @@ Page({ ...@@ -39,6 +41,13 @@ Page({
this.onShow() this.onShow()
}, },
getComponentPage() {
const {
tabIndex
} = this.data
return this.selectComponent(`#page-${tabIndex}`)
},
changePicker(e) { changePicker(e) {
let { value } = e.detail let { value } = e.detail
let { merchantId } = this.data.merchantRange[value] let { merchantId } = this.data.merchantRange[value]
...@@ -66,6 +75,13 @@ Page({ ...@@ -66,6 +75,13 @@ Page({
back() { back() {
wx.$router.reLaunch('pages.sceneIndex') wx.$router.reLaunch('pages.sceneIndex')
}, },
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
......
{ {
"usingComponents": {}, "usingComponents": {
"tab-bar": "/components/CustomTabBar/CustomTabBar",
"page-quited": "./pages/index/index",
"page-equity": "./pages/4sOverview/4sOcerview"
},
"navigationStyle":"custom" "navigationStyle":"custom"
} }
\ No newline at end of file \ No newline at end of file
/* pages/equity/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/equity/index.wxml--> <!--pages/equity/index.wxml-->
<navigation-bar bindnavbarReady="navbarReady" showBack="{{true}}" bindback="back"> <navigation-bar bindnavbarReady="navbarReady" showBack="{{true}}" bindback="back">
<picker range="{{merchantRange}}" value="{{subIndex}}" range-key="merchantName" bindchange="changePicker" bindtap="tapPicker" bindcancel="tapPicker" disabled="{{merchantRange.length < 2}}"> <picker range="{{merchantRange}}" value="{{subIndex}}" range-key="merchantName" bindchange="changePicker" bindtap="tapPicker" bindcancel="tapPicker" disabled="{{merchantRange.length < 2}}">
<view class="navigation-title"> <view class="navigation-title">
<view class="navigation-title-text text-hide"> <view class="navigation-title-text text-hide">
{{merchantRange[subIndex].merchantName}} {{merchantRange[subIndex].merchantName}}
</view> </view>
<view class="arrow {{moveArrow?'move':''}}" wx:if="{{merchantRange.length > 1}}"> <view class="arrow {{moveArrow?'move':''}}" wx:if="{{merchantRange.length > 1}}">
<image src="/images/arrow-bottom.png" /> <image src="/images/arrow-bottom.png" />
</view> </view>
</view> </view>
</picker> </picker>
</navigation-bar> </navigation-bar>
<view class="page"> <view class="page" style="margin-top:{{navBarHeight}}px">
<page-quited id="page-0" class="{{pageShow[0] && tabIndex == 0?'show':'hide'}}"></page-quited> <block wx:if="{{navBarHeight > 0}}">
<page-equity id="page-1" class="{{pageShow[1] && tabIndex == 1?'show':'hide'}}"></page-equity> <page-quited id="page-0" class="{{pageShow[0] && tabIndex == 0?'show':'hide'}}"></page-quited>
<page-equity id="page-1" class="{{pageShow[1] && tabIndex == 1?'show':'hide'}}"></page-equity>
</block>
</view> </view>
<tab-bar list="{{tabBarList}}" color="#6C6C70" selectedColor="#3582EE" tabIndex="{{tabIndex}}" bindchange="changeTabBar"></tab-bar> <tab-bar list="{{tabBarList}}" color="#6C6C70" selectedColor="#3582EE" tabIndex="{{tabIndex}}" bindchange="changeTabBar"></tab-bar>
/* pages/equity/index.wxss */
.hide{
display: none;
}
.show{
display: block;
}
\ No newline at end of file \ No newline at end of file
// pages/equityPage/pages/4sOverview/4sOcerview.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/equityPage/pages/4sOverview/4sOcerview.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/equityPage/pages/4sOverview/4sOcerview.wxml-->
<text>pages/equityPage/pages/4sOverview/4sOcerview.wxml</text>
// pages/equityPage/pages/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/equityPage/pages/index/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/equityPage/pages/index/index.wxml-->
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
<view>pages/equityPage/pages/index/index.wxml</view>
// pages/sceneIndex/sceneIndex.js // pages/sceneIndex/sceneIndex.js
import api from '../../tabIndex/api'
Page({ Page({
/** /**
...@@ -11,25 +12,28 @@ Page({ ...@@ -11,25 +12,28 @@ Page({
sceneName: '1.0 精品升级', sceneName: '1.0 精品升级',
sceneDesc: '众筹活动', sceneDesc: '众筹活动',
sceneType: 1, sceneType: 1,
actived: true actived: false
}, { }, {
sceneIcon: '../../images/tab-grass.png', sceneIcon: '../../images/tab-grass.png',
sceneName: '2.0 车损升级', sceneName: '2.0 车损升级',
sceneDesc: '车损升级', sceneDesc: '车损升级',
scencType: 0, sceneType: 0,
actived: false actived: false
}] }]
}, },
// 选择场景 // 选择场景
selectScene(e) { selectScene(e) {
let {index} = e.target.dataset let {index} = e.currentTarget.dataset
let {sceneList} = this.data let {sceneList} = this.data
// wx.$router.reLaunch('pages.equityPage') if (index == 0) {
wx.$router.reLaunch('tabIndex.index') wx.$router.go('tabIndex.index')
} else {
wx.$router.go('pages.equityPage')
}
sceneList.map(i => i.actived = false) sceneList.map(i => i.actived = false)
console.log(sceneList[index])
sceneList[index].actived = true sceneList[index].actived = true
wx.$storage.set('sceneType', `${sceneList[index].sceneType}`)
this.setData({ this.setData({
sceneList sceneList
}) })
...@@ -42,10 +46,11 @@ Page({ ...@@ -42,10 +46,11 @@ Page({
this.setData({ this.setData({
timeState: wx.$util.getTimeState() timeState: wx.$util.getTimeState()
}) })
console.log(this.data.userInfo)
wx.hideHomeButton({ wx.hideHomeButton({
success: (res) => {}, success: (res) => {},
}) })
// 获取开通业务场景
api.waitinputorder().then(() => {})
}, },
/** /**
...@@ -59,7 +64,16 @@ Page({ ...@@ -59,7 +64,16 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
let selectSceneType = wx.$storage.get('sceneType') || null
let {sceneList} = this.data
selectSceneType && sceneList.map(i => {
i.actived = false
if (i.sceneType == selectSceneType) {
i.actived = true
}
return i
})
this.setData({sceneList})
}, },
/** /**
......
...@@ -17,19 +17,20 @@ ...@@ -17,19 +17,20 @@
</view> </view>
</view> </view>
<view class="scene-box"> <view class="scene-box">
<view class="scene-item {{item.actived ? 'active' : ''}}" wx:for="{{sceneList}}" wx:key="index" bindtap="selectScene" data-index="{{index}}"> <block wx:for="{{sceneList}}" wx:key="index">
<view class="left"> <view class="scene-item {{item.actived ? 'active' : ''}}" bindtap="selectScene" data-index="{{index}}">
<image class="scene-icon" src="{{item.sceneIcon}}"></image> <view class="left">
<view class="item-text"> <image class="scene-icon" src="{{item.sceneIcon}}"></image>
<view class="name">{{item.sceneName}}</view> <view class="item-text">
<view class="desc">{{item.sceneDesc}}</view> <view class="name">{{item.sceneName}}</view>
<view class="desc">{{item.sceneDesc}}</view>
</view>
</view>
<view class="right">
<image wx:if='{{!item.actived}}' src="../../images/arrow-right.png" />
<view class="selected-class" wx:else>当前场景</view>
</view> </view>
</view> </view>
<view class="right"> </block>
<image wx:if='{{!item.actived}}' src="../../images/arrow-right.png" />
<view class="selected-class" wx:else>当前场景</view>
</view>
</view>
</view> </view>
</view> </view>
...@@ -18,7 +18,7 @@ Page({ ...@@ -18,7 +18,7 @@ Page({
}) })
}, },
changeLoginType(e) { changeLoginType(e) {
let { type } = e.target.dataset let { type } = e.currentTarget.dataset
this.setData({ this.setData({
loginType: type loginType: type
}) })
......
...@@ -39,6 +39,7 @@ Page({ ...@@ -39,6 +39,7 @@ Page({
navbarReady(e) { navbarReady(e) {
// console.log(e) // console.log(e)
let navBarHeight = e.detail.height let navBarHeight = e.detail.height
console.log('123', navBarHeight)
this.setData({ this.setData({
navBarHeight navBarHeight
}) })
......
...@@ -17,7 +17,8 @@ export const STORAGE_OBJECTkEY = { ...@@ -17,7 +17,8 @@ export const STORAGE_OBJECTkEY = {
authphone: 'authphone', authphone: 'authphone',
disLikeRecordFlag: 'disLikeRecordFlag', disLikeRecordFlag: 'disLikeRecordFlag',
fileList: 'fileList', fileList: 'fileList',
posterId: 'posterId' posterId: 'posterId',
sceneType: 'sceneType'
} }
export const IMG_VERSION = () => { export const IMG_VERSION = () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!