UNPKG

minix-template

Version:

minix template

286 lines (284 loc) 6.19 kB
/* * @Description: * @Autor: tangsj * @Date: 2022-04-28 11:09:14 * @LastEditTime: 2022-05-23 15:39:39 */ import router from '@system.router' import prompt from '@system.prompt' export default { data: { baseList:[ { name:'getLoginInfo', // url:'pages/base/canlUse/index', describe:'获取身份信息、token等' }, { name:'getUserInfo', // url:'pages/base/log/index', describe:'获取登录态信息' }, { name:'logout', // url:"pages/base/getSystemInfo/index", describe:'退出登录' }, { name:'getUnionId', describe:'用户标识unionid主要用于微信、QQ用户系统打通' }, { name:'getAuthToken', // url:"pages/base/fireGlobalEvent/index", describe:'获取授权token,24小时有效' }, { name:'getAuthorizeUserControl', // url:'pages/base/getPluginInfo/index', describe:'用户授权控制的接口' }, { name:'checkAuthorize', describe:'查询是否授权的接口' }, { name:'deleteAuthorizeUser', describe:'取消授权的接口' }, { name:'bindThirdParty', describe:'绑定第三方账号' }, ] }, goRouter(url){ router.push({ uri: url, }) }, /** * @description: 获取登录态信息 * @param {*} * @return {*} */ getLoginInfo(){ this.$app.$def.bridge.getLoginInfo() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 身份信息、token等 * @param {*} * @return {*} */ getUserInfo(){ this.$app.$def.bridge.getUserInfo() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 退出 * @param {*} * @return {*} */ logout(){ this.$app.$def.bridge.logout() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 用户标识unionid主要用于微信、QQ用户系统打通 * @param {*} * @return {*} */ getUnionId(){ const params = { "type": "wx|qq" } this.$app.$def.bridge.getUnionId(params) .then((res)=>{ prompt.showToast({ message: '接口调用成功', duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 获取授权token,24小时有效 * @param {*} * @return {*} */ getAuthToken (){ this.$app.$def.bridge.getAuthToken() .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 用户授权控制的接口 * @param {*} * @return {*} */ getAuthorizeUserControl(){ const params = { "thirtyCode": "(第三方的code,中台分配的)或者(thirtyCode优先)", "deviceId": " (设备ID)", "iotAppId": "(中台分配的appId)", "userOption": "" } this.$app.$def.bridge.getAuthorizeUserControl(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: err, duration: 200, }) }) }, /** * @description: 查询是否授权的接口 * @param {*} * @return {*} */ checkAuthorize(){ const params = { "thirtyCode": "(第三方的code,中台分配的)或者(thirtyCode优先)", "deviceId": "xxx(设备ID)" } this.$app.$def.bridge.checkAuthorize(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: err, duration: 200, }) }) }, /** * @description: 查询是否授权的接口 * @param {*} * @return {*} */ deleteAuthorizeUser(){ const params = { "thirtyCode": "(第三方的code,中台分配的)或者(thirtyCode优先)", "deviceId": "xxx(设备ID)" } this.$app.$def.bridge.deleteAuthorizeUser(params) .then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: err, duration: 200, }) }) }, /** * @description: 绑定第三方账号 * @param {*} * @return {*} */ bindThirdParty(){ const params = { "type": "wx" } this.$app.$def.bridge.bindThirdParty(params) .then((res)=>{ prompt.showToast({ message: '接口调用成功', duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, testBridge(name){ switch(name){ case 'getLoginInfo': this.getLoginInfo() break; case 'getUserInfo': this.getUserInfo() break; case 'logout': this.logout() break; case 'getUnionId': this.getUnionId() break; case 'getAuthToken': this.getAuthToken() break; case 'getAuthorizeUserControl': this.getAuthorizeUserControl() break; case 'checkAuthorize': this.checkAuthorize() break; case 'deleteAuthorizeUser': this.deleteAuthorizeUser() break; case 'bindThirdParty': this.bindThirdParty() break; default: break; } } }