Ming vor 4 Jahren
Ursprung
Commit
8320f0f94b
2 geänderte Dateien mit 66 neuen und 61 gelöschten Zeilen
  1. 6 6
      main.js
  2. 60 55
      util/api.js

+ 6 - 6
main.js

@@ -1,10 +1,10 @@
 import Vue from 'vue'
 import App from './App'
 
-import {
-	myRequest
-} from './util/api.js'
-Vue.prototype.$myRequest = myRequest
+import api from './util/api.js'
+Vue.prototype.$myRequest = api.myRequest;
+Vue.prototype.$BASE_URL = api.BASE_URL;
+Vue.prototype.$websiteUrl = api.websiteUrl
 
 // 引入colorui组件
 import cuCustom from 'colorui/components/cu-custom.vue'
@@ -15,8 +15,8 @@ import common from './common/common.js'
 Vue.prototype.$noMultipleClicks = common.noMultipleClicks; // (禁止重复点击)
 // Vue.prototype.$websiteUrl = common.websiteUrl;
 // Vue.prototype.$BASE_URL = common.BASE_URL;
-Vue.prototype.$websiteUrl =  'https://qhome.usky.cn';
-Vue.prototype.$BASE_URL = 'https://qhome.usky.cn/USKYZHAF/USKYZHAF.php/Home/';
+// Vue.prototype.$websiteUrl = 'https://qhome.usky.cn';
+// Vue.prototype.$BASE_URL = 'https://qhome.usky.cn/USKYZHAF/USKYZHAF.php/Home/';
 
 
 import JsonExcel from 'vue-json-excel'

+ 60 - 55
util/api.js

@@ -1,70 +1,75 @@
 // const BASE_URL = 'https://iot.usky.cn/USKYZHAF/USKYZHAF.php/Home/'
 const BASE_URL = 'https://qhome.usky.cn/USKYZHAF/USKYZHAF.php/Home/'
+const websiteUrl='https://qhome.usky.cn'
 
 // 同时发送异步代码的次数,防止一次点击中有多次请求,用于处理
 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) => {
-				if (res.data.flag == false) {
-					return uni.showToast({
-						title: res.data.msg?res.data.msg:"获取数据失败",
-						icon: "none"
-					})
-				}
-				resolve(res)
-			},
-			fail: (err) => {
-
-				uni.showModal({
-					showCancel: false,
-					content: '请求接口失败'
-				});
-				// uni.showToast({
-				// 	title: '请求接口失败',
-				// 	icon:"none"
-				// })
-				reject(err)
-
-			},
-			// 完成之后关闭加载效果
-			complete: () => {
-				if (showLoading) {
-					ajaxTimes--;
-					if (ajaxTimes === 0) {
-						//  关闭正在等待的图标
-						uni.hideLoading();
+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) => {
+					if (res.data.flag == false) {
+						return uni.showToast({
+							title: res.data.msg?res.data.msg:"获取数据失败",
+							icon: "none"
+						})
 					}
+					resolve(res)
+				},
+				fail: (err) => {
+	
+					uni.showModal({
+						showCancel: false,
+						content: '请求接口失败'
+					});
+					// uni.showToast({
+					// 	title: '请求接口失败',
+					// 	icon:"none"
+					// })
+					reject(err)
+	
+				},
+				// 完成之后关闭加载效果
+				complete: () => {
+					if (showLoading) {
+						ajaxTimes--;
+						if (ajaxTimes === 0) {
+							//  关闭正在等待的图标
+							uni.hideLoading();
+						}
+					}
+	
 				}
-
-			}
+			})
 		})
-	})
-
+	
+	
+	
 }
 
+
+
 export default {
-    BASE_URL
+    BASE_URL,myRequest,websiteUrl
 }