维基小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 lines
1.9 KiB

<script>
import { mapState, mapMutations, mapActions } from 'vuex';
import { GET_USER_INFO, HEALTH_TYPE_STATUS } from 'api/api';
import { showLoading, hideLoading, showToast, showModal } from 'utils/ui';
import { formatQuery } from 'utils/util';
export default {
async onLaunch(options) {
console.log('options: ', options);
uni.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
uni.authorize({
scope: 'scope.userLocation',
success() {},
});
}
},
});
try {
if (options.query.scene) {
const query = formatQuery(decodeURIComponent(options.query.scene));
if (query && query.d) {
await this.getTokenByUserId({ params: { userId: query.d } });
this.initCommon();
} else {
await this.login();
this.initCommon();
return;
}
} else {
await this.login();
this.initCommon();
}
} catch (error) {
console.log('onLaunch error: ', error);
}
},
computed: mapState('user', ['token']),
methods: {
...mapActions('user', ['login', 'getUserInfo', 'getHealthTypeStatus', 'getTokenByUserId']),
async initCommon() {
const startTime = +this.$moment()
.startOf('year')
.format('x');
const endTime = +this.$moment()
.endOf('day')
.format('x');
const params = {
param: {
startTime,
endTime,
token: this.token,
},
};
await this.getUserInfo(params);
await this.getHealthTypeStatus();
},
},
};
</script>
<style lang="scss">
@import 'colorui/main.scss';
@import 'colorui/icon.scss';
@import 'colorui/animation.scss';
@import 'common/style/global';
@import 'common/style/iconfont';
</style>