-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
514 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//扩展方法函数配置 | ||
import ColorUISdk from '../mp-sdk/index' | ||
export const colorUISdk = new ColorUISdk({ | ||
//当前环境,produce,dev,host | ||
env: 'dev', | ||
//实际项目版本 | ||
version: '1.0.0', | ||
api: { | ||
//生产环境 | ||
produce: { | ||
url: '请求域名' | ||
}, | ||
//开发环境 | ||
dev: { | ||
url: '请求域名' | ||
}, | ||
//本地环境 | ||
host: { | ||
url: '请求域名' | ||
}, | ||
header: { | ||
"Content-Type": "application/json" | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import baseLib from './lib/index' | ||
import {request} from './lib/request' | ||
|
||
export default class ColorUISdk { | ||
constructor({env, version, api}) { | ||
//默认配置,防止没自定义配置时,出问题。 | ||
env = env||'dev' | ||
version = version||'1.0.0' | ||
if (!api.header) { | ||
api.header = {}; | ||
api.header['Content-Type'] = 'application/json'; | ||
} | ||
this.env = env; | ||
this.version = version; | ||
this.api = api; | ||
this.ColorUISdkInit(); | ||
} | ||
ColorUISdkInit() { | ||
Object.keys(baseLib).forEach(key => { | ||
if (typeof baseLib[key] === 'function') { | ||
this[key] = baseLib[key] | ||
} | ||
if (typeof baseLib[key] === 'object') { | ||
//二级方法函数 | ||
Object.keys(baseLib[key]).forEach(k => { | ||
if (typeof baseLib[key][k] === 'function' || typeof baseLib[key][k] === 'object') { | ||
this[k] = baseLib[key][k] | ||
} | ||
}) | ||
} | ||
}) | ||
//console.log(this) | ||
} | ||
//发起请求 | ||
request(data, loading = false) { | ||
return new Promise( (resolve, reject) => { | ||
request(data, loading, { | ||
env: this.env, | ||
api: this.api | ||
}).then(res=> { | ||
resolve(res); | ||
}).catch(err=> { | ||
reject(err) | ||
}); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.