123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //const ip = 'http://127.0.0.1:8080';
- //const ip = 'http://192.168.2.102:8080';
- const ip = 'https://xtmly.zhongchuang-tech.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/', //根据景区id获取标记物
- 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&cityid=101140214'
- }
- /**
- * 封装的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 === 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) {
- //1.2 拒绝授权
- console.log(JSON.stringify(res));
- }
- });
- }
- module.exports = {
- urls,
- request,
- getUser,
- call,
- getParam,
- };
|