12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <script>
- export default {
- // 此处globalData为了演示其作用,不是uView框架的一部分
- globalData: {
- username: '白居易',
- appid: 'wxbf3a12d4b07dfcbf',
- uploadUrl: '',
- navHeight: 0,
- },
- onLaunch(options) {
- let that=this
- // console.log(that.globalData,'this.globalDatathis.globalData')
- let res = uni.getSystemInfoSync();
- let menu = wx.getMenuButtonBoundingClientRect();
- let statusBarHeight = menu.height;
- // this.statusBarHeight = (menu.top - res.statusBarHeight) * 2 + menu.height + res.statusBarHeight;
- if (res.model.indexOf('iPhone') > -1) {
- statusBarHeight += 4
- }
-
- that.globalData.navHeight = statusBarHeight + uni.getSystemInfoSync().statusBarHeight
- if (!this.vuex_token) {
- uni.reLaunch({
- url:'pages/login/login'
- })
- }
- else{
- uni.reLaunch({
- url:'pages/index/index'
- })
- }
- },
- methods: {
- async doLogin() {
- uni.login({
- provider: 'weixin',
- success: (res) => {
- console.log(res, 'ppp')
- console.log(this.$vm.$u, 'ppppp-----1212')
- if (res.code) {
- let data = {
- appid: 'wxbf3a12d4b07dfcbf',
- code: res.code
- }
- this.$vm.$u.post('/base/auth/weapp/login', data).then(res => {
- this.$vm.$u.vuex('vuex_token', res.data.token);
- this.$vm.$u.vuex('vuex_session_key', res.data.session_key);
- this.$vm.$u.vuex('vuex_is_auth', res.data.is_auth);
- this.$vm.$u.vuex('vuex_user', res.data.user);
- this.$vm.$u.vuex('vuex_exp', res.data.exp)
- })
- }
- }
- })
- },
- transformWeek(week) {
- switch (week) {
- case 0:
- return '一'
- case 1:
- return '二'
- case 2:
- return '三'
- case 3:
- return '四'
- case 4:
- return '五'
- case 5:
- return '六'
- case 6:
- return '日'
- }
- },
- },
- }
- </script>
- <style lang="scss">
- @import "uview-ui/index.scss";
- @import "common/demo.scss";
- u-loadmore{
- margin-top: 10px;
- }
- </style>
|