123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- const ip = 'https://xdmly.qiyiiot.com/prod-api';
- const urls = {
- ip: ip,
- home: ip + '/api/index/home',
- feedback: ip + '/api/index/feedback',
- wxLogin: ip + '/api/login/wxLogin/',
- bindWxMobile: ip + '/api/index/bindWxMobile',
- getPageContent: ip + '/api/index/getPageContent',
- getContentInfo: ip + '/api/index/getContentInfo/',
- 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',
- roomList: ip + '/api/index/roomList',
- roomAdd: ip + '/api/index/roomAdd',
- hotelList: ip + '/api/index/hotelList',
- hotelDetail: ip + '/api/index/hotelDetail',
- shopManage: ip + '/api/index/shopManage',
- hotelBook: ip + '/api/index/hotelBook',
- hotelEnable: ip + '/api/index/hotelEnable',
- hotelDelete: ip + '/api/index/hotelDelete',
- order: ip + '/api/index/order',
- orderDeal: ip + '/api/index/orderDeal',
- orderDelete: ip + '/api/index/orderDelete',
- roomDel: ip + '/api/index/roomDel',
- uploadImg: ip + '/api/index/uploadImg',
- weather: 'https://www.tianqiapi.com/free/day?appid=46884165&appsecret=b7oFR7GK&unescape=1&city=谢通门&vue=1'
- }
- 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 === 500) {
- uni.showModal({
- content: res.data.msg,
- showCancel: false
- });
- return;
- }
- if (res.data.code === 401) {
- uni.removeStorageSync('user');
- uni.showModal({
- title: '提示',
- content: '您还未登陆,请先登陆!',
- success: res => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/user/login'
- })
- }
- }
- });
- return;
- }
- opt.success(res);
- },
- fail: e => {
- uni.hideLoading();
- uni.getNetworkType({
- success: res => {
- if (res.networkType == 'none') {
- uni.showModal({
- content: '当前网络不可用,请检查网络稍后重试',
- showCancel: false
- });
- } else {
- uni.showModal({
- content: '服务异常,请稍后重试',
- showCancel: false
- })
- }
- }
- });
- }
- })
- }
- const getParam = (url, parameter) => {
- let index = url.lastIndexOf(parameter);
- url = url.substring(index + 4, url.length);
- return url;
- }
- const getUser = () => {
- return uni.getStorageSync('user');
- }
- const call = (aboutUs) => {
-
- uni.authorize({
- scope: 'scope.userLocation',
- success: s => {
- uni.getLocation({
- type: 'wgs84',
- success: res => {
-
- request({
- method: 'POST',
- url: urls.pushHelp,
- data: {
- memberId: getUser().memberId,
- lat: res.latitude,
- lng: res.longitude,
- phone: aboutUs.helpPhone,
- memberPhone: getUser().mobile
- },
- success: r => {
- uni.makePhoneCall({
- phoneNumber: aboutUs
- .helpPhone
- });
- }
- });
- }
- });
- },
- fail(res) {
-
- console.log(JSON.stringify(res));
- }
- });
- }
- module.exports = {
- urls,
- request,
- getUser,
- call,
- getParam,
- };
|