|
|
|
@ -8,6 +8,15 @@ export default { |
|
|
|
async onLaunch(options) { |
|
|
|
// TODO: this 先判断是不是通过扫二维码进来的 |
|
|
|
console.log('options: ', options); |
|
|
|
if (options.scene === 1047) { |
|
|
|
// 扫描小程序码 |
|
|
|
if (options.query && options.query.scene) { |
|
|
|
const scene = options.query.scene; |
|
|
|
const toolCode = scene.substring(scene.length - 10); |
|
|
|
this.setEnterByCode(true); |
|
|
|
this.setToolCode(toolCode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.getSystemInfo(); // 获取系统设备信息 |
|
|
|
|
|
|
|
@ -35,13 +44,16 @@ export default { |
|
|
|
computed: { |
|
|
|
...mapGetters(['useStorage']), |
|
|
|
...mapState('user', ['token']), |
|
|
|
...mapState('yanyuan', ['enterByCode', 'toolCode']), |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
...mapActions('user', ['getToken']), |
|
|
|
...mapActions('socket', ['initSocket']), |
|
|
|
...mapActions('yanyuan', ['getBindTool']), |
|
|
|
...mapMutations(['setSystemInfo']), |
|
|
|
...mapMutations('user', ['setToken', 'setUser']), |
|
|
|
...mapMutations('yanyuan', ['setIdentityInfo', 'setToolCode', 'setEnterByCode']), |
|
|
|
|
|
|
|
// 登录 |
|
|
|
async signin() { |
|
|
|
@ -51,6 +63,11 @@ export default { |
|
|
|
this.setUser(data); |
|
|
|
this.setToken(data.token); |
|
|
|
this.noPhone(data); |
|
|
|
// 首页用户身份判断 |
|
|
|
await this.homeIdentity(); |
|
|
|
if (this.enterByCode && this.toolCode) { |
|
|
|
await this.bindTool(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.$t.ui.showToast('返回数据异常'); |
|
|
|
} |
|
|
|
@ -81,6 +98,32 @@ export default { |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 首页用户身份判断 |
|
|
|
*/ |
|
|
|
async homeIdentity() { |
|
|
|
try { |
|
|
|
const data = await this.$u.api.homeIdentity(); |
|
|
|
this.setIdentityInfo(data); |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 绑定工具箱 |
|
|
|
*/ |
|
|
|
async bindTool() { |
|
|
|
console.log('绑定工具箱'); |
|
|
|
try { |
|
|
|
const params = { toolCode: this.toolCode }; |
|
|
|
await this.getBindTool(params); |
|
|
|
this.initTool(); |
|
|
|
} catch (error) { |
|
|
|
console.error('error: ', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|