1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /** qhome.usky.cn测试域名 wx.ewoogi.com 正式域名 **/
- var BASE_URL = "";
- if (window.location.host.indexOf("localhost") == -1) {
- BASE_URL = "https://wx.ewoogi.com/USKYOF/USKYOF.php/Home/";
- } else {
- BASE_URL = "https://qhome.usky.cn/USKYOF/USKYOF.php/Home/";
- }
- const websiteUrl = "https://wx.ewoogi.com";
- // 同时发送异步代码的次数,防止一次点击中有多次请求,用于处理
- let ajaxTimes = 0;
- function myRequest(options) {
- let showLoading = options.showLoading || false;
- // 显示加载中 效果
- if (showLoading) {
- ajaxTimes++;
- uni.showLoading({
- title: "加载中",
- mask: true,
- });
- }
- return new Promise((resolve, reject) => {
- uni.request({
- url: BASE_URL + options.url,
- method: options.method || "POST",
- data: options.data || {},
- header: {
- "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
- },
- success: (res) => {
- let notShowToastUrl = ["Login/getLoginAuthorize"];
- if (!notShowToastUrl.includes(options.url)) {
- if (res.data.flag == false) {
- // 修复首页操作失败bug start
- let notIndexFail2 = ["Index/getDataStatistics"];
- let ua = navigator.userAgent.toLowerCase();
- if (notIndexFail2.includes(options.url) && ua.match(/MicroMessenger/i) == "micromessenger") {
- } else {
- return uni.showToast({
- title: res.data.msg ? res.data.msg : "获取数据失败",
- icon: "none",
- });
- }
- // end
- // return uni.showToast({
- // title: res.data.msg ? res.data.msg : "获取数据失败",
- // icon: "none"
- // })
- }
- resolve(res);
- }
- },
- fail: (err) => {
- // 修复首页请求接口失败bug start
- let notIndexFail = ["Index/getDataStatistics", "Com/getAuthorizationUrl"];
- if (notIndexFail.includes(options.url)) {
- window.location.href = "https://wx.ewoogi.com/wx/index.html#/pages/index/index";
- } else {
- uni.showModal({
- showCancel: false,
- content: "请求接口失败",
- });
- }
- // end
- reject(err);
- },
- // 完成之后关闭加载效果
- complete: () => {
- if (showLoading) {
- ajaxTimes--;
- if (ajaxTimes === 0) {
- // 关闭正在等待的图标
- uni.hideLoading();
- }
- }
- },
- });
- });
- }
- export default {
- BASE_URL,
- myRequest,
- websiteUrl,
- };
|