123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <script>
- export default {
- onLaunch: function() {
- console.log('App Launch')
- uni.hideTabBar()
- // this.getuser()
- if (uni.getStorageSync("token")) {
- this.$u.post('/User/getDetail').then(res => {
- if (res.code == 0) {
- this.$Socket.connectSocket()
- } else {
- uni.removeStorageSync("token")
- }
- })
- }
- this.$u.post('/Version/initialization').then(res => {
- if (res.response.is_open_bottom_business == 1) {
- uni.$tabbar = [{
- "iconPath": "/static/images/index1.png",
- "selectedIconPath": "/static/images/index.png",
- "pagePath": "/pages/index/home",
- "text": "主页"
- },
- {
- "iconPath": "/static/images/order1.png",
- "selectedIconPath": "/static/images/order.png",
- "pagePath": "/pages/order/order",
- "text": "订单",
- "count": 0
- },
- {
- "iconPath": "/static/images/shop1.png",
- "selectedIconPath": "/static/images/shop.png",
- "pagePath": "/pages/shop/shop",
- "text": "商城"
- },
- {
- "iconPath": "/static/images/mine1.png",
- "selectedIconPath": "/static/images/mine.png",
- "pagePath": "/pages/mine/mine",
- "text": "我的"
- }
- ]
- } else {
- uni.$tabbar = [{
- "iconPath": "/static/images/index1.png",
- "selectedIconPath": "/static/images/index.png",
- "pagePath": "/pages/index/home",
- "text": "主页"
- },
- {
- "iconPath": "/static/images/order1.png",
- "selectedIconPath": "/static/images/order.png",
- "pagePath": "/pages/order/order",
- "text": "订单",
- "count": 0
- },
- // {
- // "iconPath": "/static/images/shop1.png",
- // "selectedIconPath": "/static/images/shop.png",
- // "pagePath": "/pages/shop/shop",
- // "text": "商城"
- // },
- {
- "iconPath": "/static/images/mine1.png",
- "selectedIconPath": "/static/images/mine.png",
- "pagePath": "/pages/mine/mine",
- "text": "我的"
- }
- ]
- }
- console.log(uni.$tabbar);
- })
- uni.login({
- provider: "weixin",
- success: (code) => {
- this.$u.post('/Auth/getWechatMiniOpenid', {
- content: {
- code: code.code
- }
- }).then(res => {
- uni.setStorageSync("openid", res.response.openid)
- })
- }
- })
- },
- onShow: function() {
- console.log('App Show')
- },
- onHide: function() {
- console.log('App Hide')
- },
- methods: {
- getuser() {
- if (getCurrentPages()[0] && getCurrentPages()[0].route != 'pages/index/index') {
- // console.log(getCurrentPages()[0].route);
- if (uni.getStorageSync("token")) {
- this.$u.post('/User/getDetail').then(res => {
- if (res.code == 0) {
- setTimeout(() => {
- this.getuser()
- }, 1500)
- } else {
- uni.removeStorageSync("token")
- setTimeout(() => {
- this.getuser()
- }, 2000)
- if (res.msg == '请登录。' || res.msg == '账号在其他地方登录,请重新登录。') {
- this.$u.toast(res.msg)
- console.log(getCurrentPages()[0].route);
- if (getCurrentPages()[0] && getCurrentPages()[0].route != 'pages/index/index') {
- setTimeout(() => {
- uni.navigateTo({
- url: "/pages/mine/login-wx"
- })
- }, 800)
- }
- // console.log(getCurrentPages()[0].route);
- }
- }
- })
- } else {
- setTimeout(() => {
- this.getuser()
- }, 2000)
- }
- } else {
- setTimeout(() => {
- this.getuser()
- }, 2000)
- }
- }
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import "uview-ui/index.scss";
- page {
- background-color: #E3F7F0;
- }
- </style>
|