140 lines
3.2 KiB
Plaintext
140 lines
3.2 KiB
Plaintext
![]() |
<style lang="less">
|
||
|
|
||
|
.header {
|
||
|
width: 100%;
|
||
|
height: 536rpx;
|
||
|
z-index: -10;
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
</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">
|
||
|
<van-tabbar-item icon="home-o">热点</van-tabbar-item>
|
||
|
<van-tabbar-item icon="shopping-cart-o">购物</van-tabbar-item>
|
||
|
<van-tabbar-item icon="comment-o">交流</van-tabbar-item>
|
||
|
<van-tabbar-item icon="shopping-cart-o">购物车</van-tabbar-item>
|
||
|
<van-tabbar-item icon="user-o">我的</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-car v-else-if="pageIndex === 3" />
|
||
|
<mall-my v-else-if="pageIndex === 4" />
|
||
|
<dialog-registration />
|
||
|
<van-button @tap="onTest" >测试</van-button>
|
||
|
|
||
|
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import wepy from '@wepy/core'
|
||
|
import store from '@/store'
|
||
|
import { mapActions } from '@wepy/x'
|
||
|
import userApis from '../../apis/userApis'
|
||
|
import xiao4rBase from '../../xiao4rBase'
|
||
|
import eventHub from '../../common/eventHub'
|
||
|
|
||
|
wepy.page({
|
||
|
store,
|
||
|
hooks: {
|
||
|
},
|
||
|
|
||
|
data: {
|
||
|
pageIndex: 0
|
||
|
},
|
||
|
|
||
|
computed: {
|
||
|
},
|
||
|
|
||
|
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 {
|
||
|
xiao4rBase.showToast('登录失败!' + res.errMsg)
|
||
|
wx.hideLoading()
|
||
|
}
|
||
|
}).catch(e => {
|
||
|
xiao4rBase.showToast('登录失败!' + res.errMsg)
|
||
|
})
|
||
|
// request.requestTaskMap.get(req.taskId).abort()
|
||
|
// console.log('中断请求,req:', req.taskId)
|
||
|
},
|
||
|
fail(res) {
|
||
|
xiao4rBase.showToast('登录失败,正在重试.')
|
||
|
wx.hideLoading()
|
||
|
self.login()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
async init(openid) {
|
||
|
xiao4rBase.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/mall-home',
|
||
|
'mall-shopping': '../../components/mall/mall-shopping',
|
||
|
'mall-bbs': '../../components/mall/mall-bbs',
|
||
|
'mall-car': '../../components/mall/mall-car',
|
||
|
'mall-my': '../../components/mall/mall-my',
|
||
|
'dialog-registration': '../../components/user/dialog-registration'
|
||
|
}
|
||
|
}
|
||
|
</config>
|