#
zhou zhou
4 天以前 205b92161eaeb386e0765280d01b621627ba02ed
#
1个文件已添加
41 ■■■■■ 已修改文件
common/request2.js 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/request2.js
New file
@@ -0,0 +1,41 @@
/**
 * @param {string} url url地址
 * @param {any} postData 参数
 * @param {string} method 请求方式
 * @param {boolean} hideLoading 是否load
 * @description: 格式化时间
 */
export function request(url, postData, method = 'POST', hideLoading = 'false') {
    if (!hideLoading) {
        uni.showLoading({
            title: '请稍候...',
            mask: true
        })
    }
    return new Promise((resolve, reject) => {
        const token = uni.getStorageSync('token');
        // const URL = 'http://47.76.147.249:8080/rsf-server/pda' + url;
        // const URL = 'http://test.zoneyung.net:8080/rsf-server/pda' + url;
        const URL = 'http://127.0.0.1:8085/rsf-server' + url;
        uni.request({
            url: URL,
            data: postData,
            header: {
                'content-type': 'application/json',
                'authorization': token
            },
            method: method, //'GET','POST'
            dataType: 'json',
            success: (res) => {
                !hideLoading && uni.hideLoading()
                resolve(res.data)
            },
            fail: (res) => {
                // !hideLoading && toast("网络不给力,请稍后再试~")
                //wx.hideLoading()
                reject(res)
            }
        })
    })
}