123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- const ip = 'https://xdmly.qiyiiot.com/prod-api';
- const urls = {
- ip: ip,
- home: ip + '/app/home/index',
- wxLogin: ip + '/api/login/wxLogin/',
- bindWxMobile: ip + '/api/index/bindWxMobile',
- 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',
- getMarkerList: ip + '/api/index/getMarkerList/',
- pushHelp: ip + '/api/index/pushHelp',
- uploadImg: ip + '/api/index/uploadImg',
- }
- 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
- };
|