代码拉取完成,页面将自动刷新
<script>
import Vue from 'vue';
import {
mapMutations,
mapActions,
mapState
} from 'vuex';
import Wechat from './common/wechat/wechat';
import store from '@/common/store';
import i18n from './lang/index.js'
export default {
methods: {
//应用初始化,获取模板,获取页面路由,获取用户信息,保存用户Token并返回初始进入页面
...mapActions(['getMallSet', 'getRoutes', 'getUserInfo', 'setTokenAndBack', 'cartNum']),
// 获取系统栏高度
async setAppInfo() {
let that = this;
let platform = '';
return new Promise((resolve, reject) => {
uni.getSystemInfo({
success: function(e) {
Vue.prototype.StatusBar = e.statusBarHeight;
// #ifdef H5
Vue.prototype.CustomBar = e.statusBarHeight + 45;
if (that.$wxsdk.isWechat()) {
platform = 'wxOfficialAccount';
} else {
platform = 'H5';
}
// #endif
// #ifdef APP-PLUS
platform = 'App';
if (e.platform == 'android') {
uni.setStorageSync('isAndroid', true);
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
uni.setStorageSync('isAndroid', false);
}
// #endif
// #ifdef MP-WEIXIN
// platform = 'wxMiniProgram';
// new Wechat().getWxMiniProgramSessionKey();
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e
.statusBarHeight;
// #endif
uni.setStorageSync('platform', platform);
resolve(platform);
}
});
});
},
// 自动登录
async autoLogin(data) {
let initData = data;
var wechat = new Wechat();
if (initData.wechat.autologin && !uni.getStorageSync('token')) {
// #ifdef H5
uni.setStorageSync('appid', initData.wechat.appid);
let token = await wechat.login();
this.setTokenAndBack(token);
// #endif
// #ifdef MP-WEIXIN
wechat.login();
// #endif
}
},
changeTabBar() {
const langType = uni.getStorageSync('CURRENT_LANG')
let tabBarText = {}
if (langType === 'zh-CN') {
tabBarText = {
home: '主頁',
category: '所有產品',
cart: '購物車',
user: '賬戶'
}
return tabBarText
} else {
tabBarText = {
home: 'Home',
category: 'List',
cart: 'Cart',
user: 'My'
}
return tabBarText
}
}
},
onLaunch: async function(options) {
let that = this;
if (!uni.getStorageSync('launchFlag')) {
uni.reLaunch({
url: '/pages/index/guide'
})
}
uni.$emit('setTabBarItem')
if (options.query.mode === 'save') {
//截图模式
uni.setStorageSync('screenShot', true);
uni.setStorageSync('shop_id', options.query.shop_id);
}
await this.setAppInfo();
try {
await this.getMallSet(options);
} catch (e) {
console.log(e);
}
},
onShow: function() {
this.$store.commit('CART_NUM');
},
onHide: function() {},
created: function() {
uni.$on('setTabBarItem', res => {
const i18n = this.changeTabBar()
uni.setTabBarItem({
index: 0,
text: i18n.home,
})
uni.setTabBarItem({
index: 1,
text: i18n.category,
})
uni.setTabBarItem({
index: 2,
text: i18n.cart,
})
uni.setTabBarItem({
index: 3,
text: i18n.user,
})
})
},
};
</script>
<style lang="scss">
@import 'static/colorui/main.css';
@import 'static/colorui/icon.css';
@import 'static/font/shopro-icon.css';
@import 'uview-ui/index.scss';
// 其他scss集成在uni.scss,(变量,class,minix)
uni-radio:not([disabled]) .uni-radio-input:hover,
uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
border-color: #ccc !important;
}
page {
-webkit-overflow-scrolling: touch; //ios滑动不流畅
height: 100%;
background: #f6f6f6;
width: 100%;
font-size: 30upx;
font-family: 'Arial' !important;
word-break: keep-all; //英文文本不换行
color: #333;
}
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。