//const ip = 'http://192.168.0.101:8080'; //const ip = 'https://qfnj.gaswkj.com/prod-api'; //const ip = 'http://192.168.2.102:8080'; const ip = 'http://139.159.189.40/prod-api'; /** * 全部接口(集中管理) */ const urls = { ip: ip, home: ip + '/app/home/index', //首页数据 wxLogin: ip + '/api/login/wxLogin/', //游客微信小程序登录 getPageContent: ip + '/api/index/getPageContent', //分页获取主要内容信息 getContentInfo: ip + '/api/index/getContentInfo/', //获取主要内容详细信息 getAboutUs: ip + '/api/index/getAboutUs/', //获取关于我们的信息 pushRecord: ip + '/api/index/pushRecord', //门店数据上报 shopApply: ip + '/api/index/shopApply', //商铺开通申请 getShopList: ip + '/api/index/getShopList', //获取商铺列表 updateShop: ip + '/api/index/updateShop', //更新门店信息 getPageMarker: ip + '/api/index/getPageMarker', //根据标记物类型分页获取标记物信息 pushHelp: ip + '/api/index/pushHelp', //上传会员拨打记录 } /** * 封装的http请求 */ const request = (opt) => { opt = opt || {}; opt.url = opt.url || ''; opt.data = opt.data || null; opt.method = opt.method || 'GET'; opt.header = opt.header || { "Content-Type": "application/json;charset=UTF-8", "apiToken": getUser().apiToken || '' }; opt.loading = opt.loading || 'true'; opt.success = opt.success || function() {}; console.log("**************************************参数调式***************************************************"); console.log("请求地址:" + opt.url + " 请求参数:" + JSON.stringify(opt.data)); console.log("************************************************************************************************"); if (opt.loading == 'true') { uni.showLoading({ title: '正在加载', mask: true }); } uni.request({ url: opt.url, data: opt.data, method: opt.method, header: opt.header, dataType: 'json', success: res => { setTimeout(() => { uni.hideLoading(); }, 500) if (res.data.code == 200) { opt.success(res); } else { uni.showModal({ content: res.data.msg, showCancel: false }); return; } }, fail: e => { uni.hideLoading(); uni.getNetworkType({ success: res => { if (res.networkType == 'none') { uni.showModal({ content: '当前网络不可用,请检查网络稍后重试', showCancel: false }); } else { uni.showModal({ content: '服务异常,请稍后重试', showCancel: false }) } } }); } }) } const getUser = () => { return uni.getStorageSync('user'); } module.exports = { urls, request, getUser };