فهرست منبع

Merge branch 'zzx' into 2.0

wenjie 6 ماه پیش
والد
کامیت
e13c458389
3فایلهای تغییر یافته به همراه122 افزوده شده و 121 حذف شده
  1. 1 1
      my/vipActivation/index.vue
  2. 0 1
      pages/index/index.vue
  3. 121 119
      utils/request.js

+ 1 - 1
my/vipActivation/index.vue

@@ -137,7 +137,7 @@
 						});
 						this.vipQuery.activationCode = ''
 						this.get_activationList()
-					} else if(res.content=='该手机号已订购【惠生活优享会员】,请在会员到期后再使用激活码'){
+					} else{
 						this.$refs.uToast.show({
 							message:res.content
 						})

+ 0 - 1
pages/index/index.vue

@@ -672,7 +672,6 @@
 			   }
 		   });
 			console.log(444,query);
-			this.loading = true
 			const token = uni.getStorageSync('token')
 			console.log(!!token)
 			if(query.scene){

+ 121 - 119
utils/request.js

@@ -4,135 +4,137 @@
 // const BASE_URL = 'https://api.dev.zonelife.cn'
 import {
 	BASE_URL
-} from '@/utils/config.js'
-
+} from '@/utils/config.js';
 //封装请求方法
 export let request = (options) => {
 	return new Promise((resolve, reject) => {
-			//请求路径拼接,,其中options.url就是通过下面方法myRequest获取到接口部分的url
-			//method--请求方法,不是method的post就是get
-			//请求的参数,当没有参数的时候就是空对象
-			if(options.data){
-				options.data.platformType = 1
-			}
-			request.requestTask =uni.request({
-					url: options.url.indexOf('http')==-1?(BASE_URL + options.url):options.url,
-					method: options.method || 'GET',
-					data: options.data || {},
-					header: {
-						accessToken: uni.getStorageSync('token'),
-						code:'520100' //慧研学520100 中数5201000 贵大 p-0001
-					},
-					success: (res) => {
-						if (res.statusCode !== 200) {
-							return uni.showToast({
-								title: '获取失败',
-								icon: 'error',
-								duration: 5000
+		//请求路径拼接,,其中options.url就是通过下面方法myRequest获取到接口部分的url
+		//method--请求方法,不是method的post就是get
+		//请求的参数,当没有参数的时候就是空对象
+		request.requestTask = uni.request({
+			url: options.url.indexOf('http') == -1 ? (BASE_URL + options.url) : options.url,
+			method: options.method || 'GET',
+			data: options.data || {},
+			header: {
+				accessToken: uni.getStorageSync('token'),
+				code: '520100' //慧研学520100 中数5201000 贵大 p-0001
+			},
+			success: (res) => {
+				if (res.statusCode !== 200) {
+					return uni.showToast({
+						title: '获取失败',
+						icon: 'error',
+						duration: 5000
+					})
+					// uni.hideLoading()
+				} else if (res.data.msg != '成功') { //接口返回报错
+					let strUrl = '/vipserver/group/user/activation'
+					let isContained = options.url.indexOf(strUrl) !== -1;
+					if (!isContained) {
+						setTimeout(() => {
+							uni.showToast({
+								title: res.data.content || res.data.msg || (res.data.exception && res.data.exception.message) ||'请求失败',
+								icon: 'none',
+								duration: 3000
 							})
-							// uni.hideLoading()
-						} else if (res.data.msg != '成功'&&res.data.content!='该手机号已订购【惠生活优享会员】,请在会员到期后再使用激活码') { //接口返回报错
-							setTimeout(()=>{
-								uni.showToast({
-									title: res.data.content || res.data.msg ||(res.data.exception && res.data.exception.message) || '请求失败',
-									icon: 'none',
-									duration:3000
-								})
-							})
-							console.error('报错接口:',BASE_URL + options.url,'报错信息:', res.data);
+						})
+					}
+					console.error('报错接口:', BASE_URL + options.url, '报错信息:', res.data);
 
-							// token过期或出了问题
-							if (res.data.exception && res.data.exception.type ==
-								'AuthenticationCredentialsNotFoundException') {
-									uni.showToast({
-										title: '登录过期',
-										icon: 'error',
-										duration: 5000
-									})
-								if (uni.getStorageSync('refreshToken') && uni.getStorageSync('token') ) {
-									// 刷新token
-									uni.showLoading({
-										title: '刷新登录中',
-										duration: 5000
-									})
-									uni.request({
-											url: BASE_URL + '/zswl-cloud-bdb/user/refreshToken',
-											method: 'GET',
-											data: {
-												refreshToken: uni.getStorageSync('refreshToken')
-											},
-											success(r) {
-												uni.hideLoading()
-												if (r.data.content == '刷新令牌错误') {
-													setTimeout(()=>{
-														uni.showToast({
-															title: '登录失效',
-															icon: 'fail'
-														})
-													},0)
-													uni.clearStorageSync()
-													uni.reLaunch({
-														url: '/pages/index/index'
-													})
-												} else {
-													
-													uni.setStorageSync('token', r.data.content) //登录状态
-													// 刷新页面
-													var pages = getCurrentPages();
-													var url = '/' + pages[pages.length - 1].route
-													uni.reLaunch({
-														url
-													})
-													
-											}
-										}
-									})
-								}else{
+					// token过期或出了问题
+					if (res.data.exception && res.data.exception.type ==
+						'AuthenticationCredentialsNotFoundException') {
+						uni.showToast({
+							title: '登录过期',
+							icon: 'error',
+							duration: 5000
+						})
+						if (uni.getStorageSync('refreshToken') && uni.getStorageSync('token')) {
+							// 刷新token
+							uni.showLoading({
+								title: '刷新登录中',
+								duration: 5000
+							})
+							uni.request({
+								url: BASE_URL + '/zswl-cloud-bdb/user/refreshToken',
+								method: 'GET',
+								data: {
+									refreshToken: uni.getStorageSync('refreshToken')
+								},
+								success(r) {
 									uni.hideLoading()
-									console.log(111);
-									uni.showModal({
-										title:'请登录',
-										confirmText:'去登录',
-										success(res){
-											if(res.confirm){
-												var pages = getCurrentPages()
-												let parmas = pages[pages.length - 1].options
-												console.log(11111,parmas);
-												let str = ''
-												for (let key in parmas) {
-													str += `&${key}=${parmas[key]}`
-												}
-												console.log(2222222,str);
-												var url = '/' + pages[pages.length - 1].route
-												console.log(333333,url);
-												uni.reLaunch({
-													url:'/login/login/login?redirect='+url+str
-												})
-											}else if (res.cancel) {
-												console.log('拒绝登录,跳转首页');
-												uni.switchTab({
-													url:'/pages/index/index'
-												})
-											}
+									if (r.data.content == '刷新令牌错误') {
+										setTimeout(() => {
+											uni.showToast({
+												title: '登录失效',
+												icon: 'fail'
+											})
+										}, 0)
+										uni.clearStorageSync()
+										uni.reLaunch({
+											url: '/pages/index/index'
+										})
+									} else {
+
+										uni.setStorageSync('token', r.data
+											.content) //登录状态
+										// 刷新页面
+										var pages = getCurrentPages();
+										var url = '/' + pages[pages.length - 1].route
+										uni.reLaunch({
+											url
+										})
+
+									}
+								}
+							})
+						} else {
+							uni.hideLoading()
+							console.log(111);
+							uni.showModal({
+								title: '请登录',
+								confirmText: '去登录',
+								success(res) {
+									if (res.confirm) {
+										var pages = getCurrentPages()
+										let parmas = pages[pages.length - 1].options
+										console.log(11111, parmas);
+										let str = ''
+										for (let key in parmas) {
+											str += `&${key}=${parmas[key]}`
 										}
-									})
+										console.log(2222222, str);
+										var url = '/' + pages[pages.length - 1].route
+										console.log(333333, url);
+										uni.reLaunch({
+											url: '/login/login/login?redirect=' +
+												url + str
+										})
+									} else if (res.cancel) {
+										console.log('拒绝登录,跳转首页');
+										uni.switchTab({
+											url: '/pages/index/index'
+										})
+									}
 								}
+							})
 						}
-
 					}
-					resolve(res.data)
-				},
-				//请求失败
-				fail: (err) => {
-					setTimeout(()=>{
-						uni.showToast({
-							title: '请求接口失败',
-							icon:"none",
-							duration: 5000
-						})
-					},0)
-					reject(err)
+
 				}
-			})
+				resolve(res.data)
+			},
+			//请求失败
+			fail: (err) => {
+				setTimeout(() => {
+					uni.showToast({
+						title: '请求接口失败',
+						icon: "none",
+						duration: 5000
+					})
+				}, 0)
+				reject(err)
+			}
+		})
 	})
 }