204 lines
4.5 KiB
Plaintext
204 lines
4.5 KiB
Plaintext
<style lang="less">
|
|
|
|
.header {
|
|
width: 100%;
|
|
height: 536rpx;
|
|
z-index: -10;
|
|
}
|
|
|
|
.tab-bar-icon {
|
|
width: 30px;
|
|
height: 20px;
|
|
}
|
|
page {
|
|
background-color: #eeeeee;
|
|
}
|
|
|
|
</style>
|
|
<wxs module="m1" lang="babel">
|
|
const getTime = (time) => {
|
|
let date = getDate(time);
|
|
let hour = date.getHours();
|
|
let mins = date.getMinutes();
|
|
let sec = date.getSeconds();
|
|
let milli = date.getMilliseconds();
|
|
return `${hour}:${mins}:${sec}.${milli}`;
|
|
}
|
|
module.exports.getTime = getTime;
|
|
</wxs>
|
|
<template>
|
|
<van-tabbar active="{{ pageIndex }}" bind:change="onChange" fixed>
|
|
<van-tabbar-item info="3">
|
|
<image
|
|
slot="icon"
|
|
:src="imageDefine.TAP_BAR_ICON1_OFF"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
<image
|
|
slot="icon-active"
|
|
:src="imageDefine.TAP_BAR_ICON1_ON"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
自定义
|
|
</van-tabbar-item>
|
|
<van-tabbar-item info="3">
|
|
<image
|
|
slot="icon"
|
|
:src="imageDefine.TAP_BAR_ICON2_OFF"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
<image
|
|
slot="icon-active"
|
|
:src="imageDefine.TAP_BAR_ICON2_ON"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
自定义
|
|
</van-tabbar-item>
|
|
<van-tabbar-item info="3">
|
|
<image
|
|
slot="icon"
|
|
:src="imageDefine.TAP_BAR_ICON3_OFF"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
<image
|
|
slot="icon-active"
|
|
:src="imageDefine.TAP_BAR_ICON3_ON"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
自定义
|
|
</van-tabbar-item>
|
|
<van-tabbar-item info="3">
|
|
<image
|
|
slot="icon"
|
|
:src="imageDefine.TAP_BAR_ICON4_OFF"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
<image
|
|
slot="icon-active"
|
|
:src="imageDefine.TAP_BAR_ICON4_ON"
|
|
mode="aspectFit"
|
|
class="tab-bar-icon"
|
|
/>
|
|
自定义
|
|
</van-tabbar-item>
|
|
</van-tabbar>
|
|
<mall-home v-if="pageIndex === 0" />
|
|
<mall-shopping v-else-if="pageIndex === 1" />
|
|
<mall-bbs v-else-if="pageIndex === 2" />
|
|
<mall-my v-else-if="pageIndex === 3" />
|
|
<dialog-registration />
|
|
<van-button @tap="onTest">测试</van-button>
|
|
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import wepy from '@wepy/core'
|
|
import store from '@/store'
|
|
import { mapState, mapActions } from '@wepy/x'
|
|
import userApis from '../../apis/userApis'
|
|
import appManager from '../../appManager'
|
|
import eventHub from '../../common/eventHub'
|
|
import defaultMix from '../../mixins/defaultMix'
|
|
|
|
wepy.page({
|
|
store,
|
|
hooks: {},
|
|
|
|
mixins: [ defaultMix ],
|
|
data: {
|
|
pageIndex: 0
|
|
},
|
|
|
|
computed: {
|
|
...mapState({
|
|
'imageDefine': state => state.imageDefine,
|
|
'userInfo': state => state.user.userInfo
|
|
})
|
|
},
|
|
|
|
methods: {
|
|
...mapActions([
|
|
'setUserAction',
|
|
'setTokenAction',
|
|
'setOpenidAction'
|
|
]),
|
|
onTest() {
|
|
eventHub.$emit('onShowDialogUserInfo')
|
|
},
|
|
handleViewTap() {
|
|
console.log('handleVieTap clicked')
|
|
},
|
|
tap() {
|
|
|
|
},
|
|
onChange(event) {
|
|
this.pageIndex = event.$wx.detail
|
|
},
|
|
callAppLaunch() {
|
|
},
|
|
login() {
|
|
let self = this
|
|
wx.showLoading({ title: '正在连接...', mask: true })
|
|
wx.login({
|
|
success(res) {
|
|
let req = userApis.getSession(res.code)
|
|
|
|
req.then(rsp => {
|
|
if (rsp.data.openid) {
|
|
self.init(rsp.data.openid)
|
|
} else {
|
|
appManager.showToast('登录失败!' + res.errMsg)
|
|
wx.hideLoading()
|
|
}
|
|
}).catch(e => {
|
|
appManager.showToast('登录失败!' + res.errMsg)
|
|
})
|
|
// request.requestTaskMap.get(req.taskId).abort()
|
|
// console.log('中断请求,req:', req.taskId)
|
|
},
|
|
fail(res) {
|
|
appManager.showToast('登录失败,正在重试.')
|
|
wx.hideLoading()
|
|
self.login()
|
|
}
|
|
})
|
|
},
|
|
async init(openid) {
|
|
appManager.saveOpenid(openid)
|
|
|
|
let rsp = await userApis.loginByMini({ openid: openid })
|
|
if (rsp.token) {
|
|
this.setTokenAction(rsp.token)
|
|
}
|
|
wx.hideLoading()
|
|
}
|
|
},
|
|
|
|
ready() {
|
|
this.login()
|
|
},
|
|
onShow() {
|
|
}
|
|
})
|
|
</script>
|
|
<config>
|
|
{
|
|
navigationBarTitleText: '',
|
|
usingComponents: {
|
|
'mall-home': '../../components/mall/tab/mall-home',
|
|
'mall-shopping': '../../components/mall/tab/mall-shopping',
|
|
'mall-bbs': '../../components/mall/tab/mall-bbs',
|
|
'mall-my': '../../components/mall/tab/mall-my',
|
|
'dialog-registration': '../../components/user/dialog-registration'
|
|
}
|
|
}
|
|
</config>
|