12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- const BASE_URL = 'https://iot.usky.cn/USKYOF/USKYOF.php/Home/'
- let ajaxTimes = 0;
- export const 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) {
-
- 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"
- })
- }
-
-
-
-
-
- }
- resolve(res)
- }
- },
- fail: (err) => {
-
- 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: '请求接口失败'
- });
- }
-
- reject(err)
- },
-
- complete: () => {
- if (showLoading) {
- ajaxTimes--;
- if (ajaxTimes === 0) {
-
- uni.hideLoading();
- }
- }
- }
- })
- })
- }
- export default {
-
- }
|