|
|
@ -2,9 +2,11 @@ |
|
|
|
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() { |
|
|
|
async onLaunch(options) { |
|
|
|
console.log('options: ', options); |
|
|
|
uni.getSetting({ |
|
|
|
success(res) { |
|
|
|
if (!res.authSetting['scope.userLocation']) { |
|
|
@ -17,8 +19,30 @@ export default { |
|
|
|
}); |
|
|
|
|
|
|
|
try { |
|
|
|
await this.login(); |
|
|
|
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'); |
|
|
@ -34,15 +58,7 @@ export default { |
|
|
|
}; |
|
|
|
await this.getUserInfo(params); |
|
|
|
await this.getHealthTypeStatus(); |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
computed: mapState('user', ['token']), |
|
|
|
|
|
|
|
methods: { |
|
|
|
...mapActions('user', ['login', 'getUserInfo', 'getHealthTypeStatus']), |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
</script> |
|
|
|