| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <script>
- import ProductInfo from '@/components/ProductInfo';
- export default {
- onLaunch(options) {
- wx.login({
- success: res => {
- console.log(res);
- this.$http
- .post('/auth/maLogin', { code: res.code })
- .then(res => {
- this.$http.setToken(res.token);
- this.$store.commit('setSessionKey', res.sessionKey);
- this.$store
- .dispatch('getUserInfo')
- .then(() => {
- this.globalData.initialize = true;
- console.log(this.globalData);
- if (this.globalData.initializeCallback) {
- this.globalData.initializeCallback();
- }
- })
- .catch(() => {
- this.globalData.initialize = true;
- });
- })
- .catch(e => {
- console.log(e);
- });
- }
- });
- wx.getSystemInfo({
- success: res => {
- console.log(res);
- this.$store.commit('setSystemInfo', res);
- }
- });
- // Do something initial when launch.
- },
- onShow(options) {
- // Do something when show.
- console.log('App onShow');
- },
- onHide() {
- // Do something when hide.
- console.log('App onHide');
- },
- onError(msg) {
- console.log('App onError');
- console.log(msg);
- },
- globalData() {
- return {
- a: 'I am global data'
- };
- }
- };
- </script>
- <style lang="less" scoped>
- /deep/.van-image {
- display: block;
- }
- </style>
|