UNPKG

minix-template

Version:

minix template

205 lines (203 loc) 4.96 kB
/* * @Description: * @Autor: tangsj * @Date: 2022-05-12 19:08:11 * @LastEditTime: 2022-05-23 16:36:38 */ import router from '@system.router' import prompt from '@system.prompt' export default { data: { networkList:[ { name:'requestDataTransmit', // url:'pages/base/canlUse/index', describe:'服务透传接口,提供给插件发送请求至事业部的品类服务器' }, { name:'resetCookie', // url:'pages/base/log/index', describe:'删除所有的cookie' }, { name:'sendCentralCloudRequest', // url:'pages/base/canlUse/index', describe:'发送给中台的通用网络请求接口' }, { name:'sendElectronicRequest', // url:'pages/base/log/index', describe:'发送商城请求' }, { name:'sendMCloudRequest', // url:'pages/base/log/index', describe:'发送智慧云网络请求:此接口固定Post到智慧云https地址及端口' } ] }, goRouter(url){ router.push({ uri: url, }) }, /** * @description: 服务透传接口 * @param {*} * @return {*} */ requestDataTransmit(){ const params = { ype: '0xDB', //插件调用可以不传,因为容器中会再获取一次,接口测试必须传type queryStrings: { applianceId: '3298544979980', expendType: '3', handleType: 'GetWasherCost', resultType: '1', time: '20210621', type: '0xDB', }, transmitData: { data: 'handleType=GetWasherCost&applianceId=3298544979980&resultType=1&expendType=3&time=20210621', }, } this.$app.$def.bridge.requestDataTransmit(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 删除所有的cookie * @param {*} * @return {*} */ resetCookie(){ const params = { urls: ['http://baidu.com'] } this.$app.$def.bridge.resetCookie(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 发送给中台的通用网络请求接口 * @param {*} * @return {*} */ sendCentralCloudRequest(){ const params = { data: { reqId: '52fdde5b-2e6c-40b1-aa70-ea576502eefc', stamp: '20210430164113', isNeedClientData: 1, activityId: 'HD20210115ZNGC', }, method: 'POST', headers: {}, url: '/v1/activity/plant/energy/exchange/detail/get' } this.$app.$def.bridge.sendCentralCloudRequest(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 发送商城请求 * @param {*} * @return {*} */ sendElectronicRequest(){ const params = { data: { nonceid: '1624261250', appId: 'test_assets', source: 'APP', version: '7.7.0.1_2021061017', bizargs: { pageno: '1', pagesize: '20', state: 4 }, }, method: 'GET', headers: { 'Content-Type': 'application/json;charset=utf-8', }, url: '/next/outer_assets/getoutcouponlist', hostUrl: 'http://sitm.midea.cn', } this.$app.$def.bridge.sendElectronicRequest(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description:发送智慧云网络请求:此接口固定Post到智慧云https地址及端口 * @param {*} * @return {*} */ sendMCloudRequest(){ const params = { version: 'xxx', url: 'xxx', params:{} } this.$app.$def.bridge.sendMCloudRequest(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, testBridge(name){ switch(name){ case 'requestDataTransmit': this.requestDataTransmit() break; case 'resetCookie': this.resetCookie() break; case 'sendCentralCloudRequest': this.sendCentralCloudRequest() break; case 'sendElectronicRequest': this.sendElectronicRequest() break; case 'sendMCloudRequest': this.sendMCloudRequest() break; default: break; } } }