function requestP(options = {}) {
    let {
        url,
        data,
        header,
        method,
        dataType,
        responseType,
        success,
        fail,
        complete
    } = options;
    uni.showLoading({title:"加载中",mask:true,})
    const host = "https://car.zgwl66.com/index.php/Api/"
    if (method == "post" || method == "POST") {
        if (header == undefined) {
            header = {}
        }
        header['content-type'] = 'application/x-www-form-urlencoded'
    }
    if(data == undefined){
        data = {}
    }
    data.openid = uni.getStorageSync("openid")
    return new Promise((res, rej) => {
        console.log(host + url)
        uni.request({
            url: host + url,
            data,
            header,
            method,
            dataType,
            responseType,
            success(r) {
                uni.hideLoading()
                if(r.data.code == 0){
                    uni.showToast({
                        title:r.data.msg,
                        icon:"none"
                    })
                    rej({msg:"验证失败"})
                }else{
                    res(r);
                }
            },
            fail(err) {
                wx.hideLoading()
                rej(err);
            },
            complete
        });
    });
}
module.exports = {
    requestP: requestP
  }