提交 371d6c75 编写于 作者: 郭胜强

eslint fix

上级 a31633af
const TODOS = [ //不支持的 API 列表 const TODOS = [ // 不支持的 API 列表
'hideTabBar', 'hideTabBar',
'hideTabBarRedDot', 'hideTabBarRedDot',
'removeTabBarBadge', 'removeTabBarBadge',
'setTabBarBadge', 'setTabBarBadge',
'setTabBarItem', 'setTabBarItem',
'setTabBarStyle', 'setTabBarStyle',
'showTabBar', 'showTabBar',
'showTabBarRedDot' 'showTabBarRedDot'
] ]
const protocols = { //需要做转换的 API 列表 const protocols = { // 需要做转换的 API 列表
returnValue(methodName, res) { // 通用 returnValue 解析 returnValue (methodName, res) { // 通用 returnValue 解析
if (res.error || res.errorMessage) { if (res.error || res.errorMessage) {
res.errMsg = `${methodName}:fail ${res.errorMessage || res.error}` res.errMsg = `${methodName}:fail ${res.errorMessage || res.error}`
delete res.error delete res.error
delete res.errorMessage delete res.errorMessage
} }
return res return res
}, },
request: { request: {
name: 'httpRequest', name: 'httpRequest',
args(fromArgs) { args (fromArgs) {
if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type
fromArgs.header = {} fromArgs.header = {}
} }
return { return {
header(header = {}, toArgs) { header (header = {}, toArgs) {
const headers = { const headers = {
'content-type': 'application/json' 'content-type': 'application/json'
} }
Object.keys(header).forEach(key => { Object.keys(header).forEach(key => {
headers[key.toLocaleLowerCase()] = header[key] headers[key.toLocaleLowerCase()] = header[key]
}) })
return { return {
name: 'headers', name: 'headers',
value: headers value: headers
} }
}, },
method: 'method', // TODO 支付宝小程序仅支持 get,post method: 'method', // TODO 支付宝小程序仅支持 get,post
responseType: false responseType: false
} }
}, },
returnValue: { returnValue: {
status: 'statusCode', status: 'statusCode',
headers: 'header' headers: 'header'
} }
}, },
setNavigationBarColor: { setNavigationBarColor: {
name: 'setNavigationBar', name: 'setNavigationBar',
args: { args: {
frontColor: false, frontColor: false,
animation: false animation: false
} }
}, },
setNavigationBarTitle: { setNavigationBarTitle: {
name: 'setNavigationBar' name: 'setNavigationBar'
}, },
showModal({ showModal ({
showCancel = true showCancel = true
} = {}) { } = {}) {
if (showCancel) { if (showCancel) {
return { return {
name: 'confirm', name: 'confirm',
args: { args: {
cancelColor: false, cancelColor: false,
confirmColor: false, confirmColor: false,
cancelText: 'cancelButtonText', cancelText: 'cancelButtonText',
confirmText: 'confirmButtonText' confirmText: 'confirmButtonText'
}, },
returnValue(fromRes, toRes) { returnValue (fromRes, toRes) {
toRes.confirm = fromRes.confirm toRes.confirm = fromRes.confirm
toRes.cancel = !fromRes.confirm toRes.cancel = !fromRes.confirm
} }
} }
} }
return { return {
name: 'alert', name: 'alert',
args: { args: {
confirmColor: false, confirmColor: false,
confirmText: 'buttonText' confirmText: 'buttonText'
}, },
returnValue(fromRes, toRes) { returnValue (fromRes, toRes) {
toRes.confirm = true toRes.confirm = true
toRes.cancel = false toRes.cancel = false
} }
} }
}, },
showToast({ showToast ({
icon = 'success' icon = 'success'
} = {}) { } = {}) {
const args = { const args = {
title: 'content', title: 'content',
icon: 'type', icon: 'type',
duration: false, duration: false,
image: false, image: false,
mask: false mask: false
} }
if (icon === 'loading') { if (icon === 'loading') {
return { return {
name: 'showLoading', name: 'showLoading',
args args
} }
} }
return { return {
name: 'showToast', name: 'showToast',
args args
} }
}, },
showActionSheet: { showActionSheet: {
name: 'showActionSheet', name: 'showActionSheet',
args: { args: {
itemList: 'items', itemList: 'items',
itemColor: false itemColor: false
}, },
returnValue: { returnValue: {
index: 'tapIndex' index: 'tapIndex'
} }
} }
} }
TODOS.forEach(todoApi => { TODOS.forEach(todoApi => {
protocols[todoApi] = false protocols[todoApi] = false
}) })
export default protocols export default protocols
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册