123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- // 弹窗
- function alertError(title) {
- document.addEventListener('plusready', function() {
- console.log('......')
- })
- try {
- plus.nativeUI.toast(title, {
- icon: '/static/common/toast-error.png',
- style: 'inline',
- verticalAlign: 'top'
- });
- } catch (e) {
- //TODO handle the exception
- }
- }
- //获取get传值的方法
- function getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return decodeURI(r[2]);
- return null;
- }
- let baseUrl = 'https://aws.okx.com';
- // post请求封装
- function axiosPost(url, data) {
- return new Promise((resolve, reject) => {
- axios({
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- },
- method: 'post',
- url: baseUrl + url,
- data: data || {}
- })
- .then(res => {
- if (res.data.code == 0) {
- resolve(res.data)
- } else {
- reject()
- alertError('请求超时')
- }
- })
- .catch(err => {
- alertError('请求超时')
- })
- })
- }
- // get请求封装
- function axiosGet(url, data) {
- return new Promise((resolve, reject) => {
- axios({
- method: 'get',
- url: baseUrl + url,
- params: data || {}
- })
- .then(res => {
- // console.log("res: " + JSON.stringify(res.data.data));
- if (res.data.code == 0) {
- resolve(res.data.data)
- } else {
- reject()
- alertError('请求超时')
- }
- })
- .catch(err => {
- alertError('请求超时')
- })
- })
- }
|