liujd 6 سال پیش
والد
کامیت
9cdbaacdae

+ 0 - 53
mobile-code/src/api/common/index.js

@@ -1,60 +1,7 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
-export const getCode = data => {
-	return https.post('/apihkds/api/misc/sms/send', data)
-}
-
-// 获取微信二维码
-export const getWxQrCode = data => {
-	return https.post('/apihkds/api/mini/getMiniRedirectQrcode', data)
-}
-
-// 小程序码获取地址
-export const getWxQrCodeQuery = data => {
-	return https.post('/apihkds/api/mini/getMiniQrcodeUrl', data)
-}
-
-export const wechatBack = data => {
-	return https.get('/apihkds/api/oauth/callback', data)
-}
-
-export const checkLogin = data => {
-	return https.post('/apihkds/api/user/checkLogin', data, {}, { hideError: true })
-}
-
-export const loginAll = data => {
-	return https.post('/apihkds/api/user/loginOrRegister', data)
-}
-
-export const getAccountList = data => {
-	return https.get('/apihkds/api/user/getAccountList', data)
-}
-
-// export const uploadPic = data => {
-// 	return https.post('/apihkds/api/uploads/image', data)
-// }
-
 export const uploadPic = data => {
 	return https.post('/admin/hkds/api/oa/upload_image', data)
 }
 
-export const getArea = data => {
-	return https.get('/apihkds/api/misc/getdata/region_new', data)
-}
-export const wechatJssdk = data => {
-	return https.post('/apihkds/api/wechat/jssdk', data)
-}
 export const getOptions = param => https.get('/apihkds/api/option/getOptions', param)
-
-// 行为轨迹埋点记录接口
-export const getbehavior = data => {
-	return https.post('/apihkds/api/hkds/stats/trace/add', data, {}, { hideError: true })
-}
-// 腾讯地图根据经纬度返回地址
-export const geocoder = data => {
-	return https.get('/apihkds/api/map/geocoder', data, {}, { hideError: true })
-}
-// 腾讯地图关键词搜索
-export const suggestion = data => {
-	return https.get('/apihkds/api/map/suggestion', data, {}, { hideError: true })
-}

+ 0 - 11
mobile-code/src/api/login/index.js

@@ -1,13 +1,2 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
-export const sendlogin = data => {
-	return https.post('/admin/hkds/api/oa/login', data)
-}
-
-export const logout = data => {
-	return https.post('/admin/hkds/api/oa/logout', data)
-}
-
-export const oauth = data => {
-	return https.post('/auth/prepare', data)
-}

+ 1 - 1
mobile-code/src/mixins/index.js

@@ -1,4 +1,4 @@
 export { default as list } from './list'
-export { default as allOptions } from './allOptions'
+// export { default as allOptions } from './allOptions'
 export { default as share } from './share'
 // export { default as area } from './area'

+ 13 - 1
mobile-code/src/pages/user/register.vue

@@ -33,7 +33,19 @@ export default {
 		tuiListCell
 	},
 	data() {
-		return {}
+		return {
+			aaa: {
+				cat_id: '',
+				limit: 5,
+				name: '',
+				order: 'newest',
+				owner_user_id: '7',
+				page: 1
+			}
+		}
+	},
+	onLoad(option) {
+		console.log(this.$util.parse(this.aaa))
 	},
 	methods: {}
 }

+ 0 - 76
mobile-code/src/plugins/luch-request_0.0.7/index.js

@@ -1,76 +0,0 @@
-import Request from './request'
-const test = new Request()
-test.setConfig((config) => { /* 设置全局配置 */
-    // config.baseUrl = 'http://www.aaa.cn';
-    // config.header = {
-    // 	a: 1,
-    // 	b: 2
-    // }
-    config = {
-        // #ifdef H5
-        baseUrl: '/api',   // 测试环境
-        // #endif
-        // #ifdef MP-WEIXIN
-        baseUrl: 'https://www.meijiabang.com',   // 测试环境
-        // #endif
-        // baseUrl: 'http://www.meijiabang.com',  // 正式环境
-        header: {
-            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
-        },
-        data: {},
-        method: 'GET',
-        dataType: 'json',  /* 如设为json,会对返回的数据做一次 JSON.parse */
-        responseType: 'text',
-        success() {},
-        fail() {},
-        complete() {}
-    }
-    return config
-})
-test.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
-    // config.header = {
-    // 	...config.header,
-    // 	a: 1
-    // }
-    /*
-	if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
-		cancel('token 不存在') // 接收一个参数,会传给catch((err) => {}) err.errMsg === 'token 不存在'
-	}
-	*/
-    return config
-})
-test.interceptor.response((response) => { /* 请求之后拦截器 */
-    console.log(response)
-    return response
-})
-
-const http = new Request()
-http.setConfig((config) => { /* 设置全局配置 */
-    config.baseUrl = 'http://www.bbb.cn' /* 根域名不同 */
-    config.header = {
-        a: 1,
-        b: 2
-    }
-    return config
-})
-http.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
-    config.header = {
-        ...config.header,
-        b: 1
-    }
-    /*
-	if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
-		cancel('token 不存在') // 接收一个参数,会传给catch((err) => {}) err.errMsg === 'token 不存在'
-	}
-	*/
-    return config
-})
-http.interceptor.response((response) => { /* 请求之后拦截器 */
-    console.log(response)
-    return response
-})
-export {
-    http,
-    test
-}
-

+ 4 - 2
mobile-code/src/plugins/luch-request_0.0.7/request.js

@@ -8,7 +8,8 @@
  * **/
 import qs from 'qs'
 import constant from '@/constant/index'
-import common from '@/utils/common'
+// import common from '@/utils/common'
+import { parse } from '@/utils/util'
 
 const Base64 = require('js-base64').Base64
 class Request {
@@ -187,7 +188,8 @@ class Request {
 	}
 
 	get(url, data, options = {}, config = {}) {
-		options.url = url + common.queryData(data, true)
+		// options.url = url + common.queryData(data, true)
+		options.url = url + parse(data, true)
 		options.data = {}
 		options.method = 'GET'
 		return this.request(options, config)

+ 43 - 41
mobile-code/src/utils/common.js

@@ -2,7 +2,7 @@ import store from '@/store'
 import { mobileReg } from './tools/validate'
 import { uploadPic } from '@/api/common'
 import CONSTANT from '@/constant/index'
-import util from '@/utils/util'
+import { parse } from '@/utils/util'
 
 // 判断是mobile 还是pc
 export function isMobile() {
@@ -63,7 +63,8 @@ export function getMiniAppUrl(data = {}, isPath = false) {
 	let getCurPagesObj = getCurPages[getCurPages.length - 1]
 	console.log(getCurPagesObj)
 	// let getRoute = getCurPagesObj.route + queryData(getCurPagesObj.options)
-	let getRoute = getCurPagesObj.route + queryData(data)
+	// let getRoute = getCurPagesObj.route + queryData(data)
+	let getRoute = getCurPagesObj.route + parse(data)
 	getRoute = isPath ? `${CONSTANT.formal}/#/${getRoute}` : getRoute
 
 	return getRoute
@@ -339,43 +340,44 @@ export function calcDistanceFn(lat1, lng1, lat2, lng2) {
 	return d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg))
 }
 
-export function queryData(data, getArr) {
-	let queryStr = ''
-	let num = 0
-	for (const i in data) {
-		if (!util.isEmpty(data[i])) {
-			if (num === 0) {
-				let arr = data[i]
-				if (getArr && Array.isArray(arr)) {
-					let str = ''
-					for (let j = 0; j < arr.length; j++) {
-						if (j == 0) {
-							str += `${i}[${j}]=${arr[j]}`
-						} else {
-							str += `&${i}[${j}]=${arr[j]}`
-						}
-					}
-					queryStr += `?${str}`
-				} else {
-					queryStr += `?${i}=${data[i]}`
-				}
-			} else {
-				let arr = data[i]
-				if (getArr && Array.isArray(arr)) {
-					let str = ''
-					for (let j = 0; j < arr.length; j++) {
-						str += `&${i}[${j}]=${arr[j]}`
-					}
-					queryStr += `${str}`
-				} else {
-					queryStr += `&${i}=${data[i]}`
-				}
-			}
-			num++
-		}
-	}
-	return queryStr
-}
+// 对象参数转为url参数
+// export function queryData(data, getArr) {
+// 	let queryStr = ''
+// 	let num = 0
+// 	for (const i in data) {
+// 		if (!util.isEmpty(data[i])) {
+// 			if (num === 0) {
+// 				let arr = data[i]
+// 				if (getArr && Array.isArray(arr)) {
+// 					let str = ''
+// 					for (let j = 0; j < arr.length; j++) {
+// 						if (j == 0) {
+// 							str += `${i}[${j}]=${arr[j]}`
+// 						} else {
+// 							str += `&${i}[${j}]=${arr[j]}`
+// 						}
+// 					}
+// 					queryStr += `?${str}`
+// 				} else {
+// 					queryStr += `?${i}=${data[i]}`
+// 				}
+// 			} else {
+// 				let arr = data[i]
+// 				if (getArr && Array.isArray(arr)) {
+// 					let str = ''
+// 					for (let j = 0; j < arr.length; j++) {
+// 						str += `&${i}[${j}]=${arr[j]}`
+// 					}
+// 					queryStr += `${str}`
+// 				} else {
+// 					queryStr += `&${i}=${data[i]}`
+// 				}
+// 			}
+// 			num++
+// 		}
+// 	}
+// 	return queryStr
+// }
 
 // 上传图片到服务器
 export function upLoadImg(arr) {
@@ -405,7 +407,7 @@ export function upLoadImg(arr) {
 		}
 	})
 }
-// weixin 64转图片
+// weixin base64转图片
 export function weixinBase64src(base64data) {
 	return new Promise((resolve, reject) => {
 		const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || []
@@ -429,6 +431,7 @@ export function weixinBase64src(base64data) {
 	})
 }
 
+// 深拷贝
 export function deepCopy(obj) {
 	if (typeof obj !== 'object') { return }
 	var str = JSON.stringify(obj)
@@ -489,6 +492,5 @@ export default {
 	getRoleTypeId,
 	verifiPhone,
 	calcDistance,
-	queryData,
 	upLoadImg
 }

+ 13 - 5
mobile-code/src/utils/util.js

@@ -42,9 +42,13 @@ const isFunction = (obj) => {
 	return (typeof obj == 'object') && obj.constructor == Function
 }
 
-// 对象参数转为url参数
-const parse = (query) => {
-	return Object.keys(query)
+/** *
+ * 对象参数转为url参数
+ * @parmas query 拼接得参数对象
+ * @parmas isFrist 为true时开头为&
+ */
+export const parse = (query, isFrist = false) => {
+	let str = Object.keys(query)
 		.filter(key => !isEmpty(query[key]))
 		.reduce((result, key) => {
 			const value = query[key]
@@ -61,7 +65,7 @@ const parse = (query) => {
 
 			return `${result}&${key}=${value}`
 		}, '')
-		.replace(/^&/, '?')
+	return isFrist ? str : str.replace(/^&/, '?')
 }
 
 const $checkMobile = (num) => {
@@ -112,7 +116,7 @@ export const $formatDate = (num, fmt = 'YYYY-MM-DD HH:mm:ss') => {
  * @parmas item.funtion 为可执行函数
  * @parmas item.url 为跳转的路径
  * @parmas item.query 为跳转携带的参数
- * @parmas item.type 为跳转调用的函数 1为navigateTo, 2为redirectTo, 3为reLaunch
+ * @parmas item.type 为跳转调用的函数 1为navigateTo, 2为redirectTo, 3为reLaunch, 4为switchTab
  */
 export const pageTo = (item) => {
 	if (isString(item)) {
@@ -135,6 +139,10 @@ export const pageTo = (item) => {
 			uni.reLaunch({
 				url: allUrl
 			})
+		} else if (item.type == 4) {
+			uni.switchTab({
+				url: allUrl
+			})
 		} else {
 			uni.navigateTo({
 				url: allUrl