Jelajahi Sumber

Merge branch 'dev2.0' of http://222.85.201.140:10002/xuyunhui/chain_jje_uniapp into dev2.0-huodong

# Conflicts:
#	common/js/env.js
zhanghui 1 tahun lalu
induk
melakukan
05f09e73be
2 mengubah file dengan 30 tambahan dan 14 penghapusan
  1. 27 13
      common/js/env.js
  2. 3 1
      common/js/request.js

+ 27 - 13
common/js/env.js

@@ -1,25 +1,39 @@
 "use strict";
 
-// let baseUrl = `https://jje.admin.xinyuekj.com.cn`
-// let baseUrl = `https://jje.xinyuekj.com.cn/prod-api`
+/** 正式环境 **/
+let releaseBaseUrl = `https://jje.xinyuekj.com.cn/prod-api`
+
 /** 测试环境 */
-// let baseUrl = `https://jje.admin.xinyuekj.com.cn/test-api`
+let trialBaseUrl = `https://jje.admin.xinyuekj.com.cn/test-api`
+
 /** 开发环境*/
-let baseUrl = `http://65i1sxopd9qp.ngrok.xiaomiqiu123.top`
-// let baseUrl = `http://u2mu3zixu5wm.ngrok.xiaomiqiu123.top`
-// let baseUrl = `http://47.108.114.127:10888`
+let developBaseUrl = `http://65i1sxopd9qp.ngrok.xiaomiqiu123.top`
+// let developBaseUrl = `http://u2mu3zixu5wm.ngrok.xiaomiqiu123.top`
+// let developBaseUrl = `http://47.108.114.127:10888`
+
 
+let baseUrl = ''
 
+function getBaseUrl(key) {
+	let accountInfo = uni.getAccountInfoSync()
+	let prefix = accountInfo.miniProgram.envVersion
 
-// let baseUrl = `http://127.0.0.1:9000`
-// let baseUrl = `http://192.168.1.7:8080`
-// let baseUrl = `http://192.168.1.2:8080`
+	if (prefix === 'release'){
+		 baseUrl = releaseBaseUrl
+	}
 
+	if (prefix === 'trial'){
+		 baseUrl = trialBaseUrl
+	}
+
+	if (prefix === 'develop'){
+		 baseUrl = developBaseUrl
+	}
+	return baseUrl;
+}
 
-// 变量可自行添加修改
-export default { //存放变量的容器
-	appid: '__UNI__1EEA945',
-	baseUrl,
+export default {
+	getBaseUrl,
 	uploadUrl: '/v1/file/put-file'
 
 }

+ 3 - 1
common/js/request.js

@@ -1,7 +1,9 @@
 import env from '../js/env.js';
 
 function service(options = {}) {
-	options.url = `${env.baseUrl}${options.url}`;
+	let baseUrl = env.getBaseUrl()
+	options.url = baseUrl + `${options.url}`;
+	// options.url = `${env.baseUrl}${options.url}`;
 	// 判断本地是否存在token,如果存在则带上请求头
 	let access_token = uni.getStorageSync('accessToken')
 	let refresh_token = uni.getStorageSync('refresh_token')