import { basUrl } from './config' //request.js 此demo为简易封装,开发者可根据自己的业务场景进行修改 export const httpRequest = (url: string, method: any = 'GET', data: any = {}, header: any = {}) => { const uid = tt.getStorageSync('uid'); const platform = tt.getSystemInfoSync().platform; return new Promise((resolve, reject) => { let newUrl = ''; if (url.includes('https') || url.includes('http')) { newUrl = url; } else { newUrl = `${basUrl}${url}`; } tt.request({ url: newUrl, method: method, data: { uid: uid || '', platform: platform || '', ...data, }, header: header, success: (res: any) => { console.log(res,"pppppppp") if (res.data.status == 1) { resolve(res.data); } else { tt.showToast({ title: res.data.msg || '请求失败', icon: 'none' }); resolve(res.data); } }, fail: (err) => { reject(err) }, }); }) }