zhengkaixin 4 gadi atpakaļ
vecāks
revīzija
53dc3c8032
9 mainītis faili ar 283 papildinājumiem un 11 dzēšanām
  1. 2 2
      .env.dev.js
  2. 3 2
      .env.prod.js
  3. 3 2
      .env.test.js
  4. 2 0
      README.md
  5. 48 0
      apis/common.js
  6. 2 1
      apis/weixin.js
  7. 2 1
      manifest.json
  8. 39 3
      pages/buytickets/index.js
  9. 182 0
      utils/wxJsApi.js

+ 2 - 2
.env.dev.js

@@ -1,10 +1,10 @@
 const UNI_APP = {  
 	
-    BASE_URL: 'https://qylhhapi.xiaoxinda.com/enterprise-server' ,
+    BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
 	NODE_ENV :"dev",
 	SIMPLE_RUN:true,//是否能 无视权限控制跳转页面
 	//企业联合会微信appid
-	VUE_APP_WXAPPID:"wx343bf93d2a3dc8af"
+	VUE_APP_WXAPPID:"wx7e70eb62a8459869"
 }  
 
 module.exports = UNI_APP;

+ 3 - 2
.env.prod.js

@@ -1,10 +1,11 @@
 const UNI_APP = {  
-	BASE_URL: 'https://qylhhapi.xiaoxinda.com/enterprise-server' ,
+	BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
+	
 	
 	NODE_ENV :"prod",
 	SIMPLE_RUN:false,
 	//企业联合会微信appid
-	VUE_APP_WXAPPID:"wx343bf93d2a3dc8af"
+	VUE_APP_WXAPPID:"wx7e70eb62a8459869"
 }  
 
 module.exports = UNI_APP;

+ 3 - 2
.env.test.js

@@ -1,10 +1,11 @@
 const UNI_APP = {  
-	BASE_URL: 'https://qylhhapi.xiaoxinda.com/enterprise-server' ,
+	BASE_URL: 'https://xpgjapi.xiaoxinda.com/' ,
+	
 	
 	NODE_ENV :"test",
 	SIMPLE_RUN:false,
 	//企业联合会微信appid
-	VUE_APP_WXAPPID:"wx343bf93d2a3dc8af"
+	VUE_APP_WXAPPID:"wx7e70eb62a8459869"
 }  
 
 module.exports = UNI_APP;

+ 2 - 0
README.md

@@ -51,3 +51,5 @@ npm install uni-simple-router uni-read-pages(取消使用, 存在h5 刷新白
 
 [vue-router-uni ](https://ext.dcloud.net.cn/plugin?id=605)
 [mac80端口问题无法使用](https://blog.csdn.net/weixin_41047933/article/details/97765502)
+sudo pfctl -ef /etc/pf-tomcat.conf
+

+ 48 - 0
apis/common.js

@@ -0,0 +1,48 @@
+import request from '@/utils/request'
+import Qs from 'qs';
+
+//上传图片
+export function uploadBase64(formData) {
+	return request({
+		url: '/mobile/personInfoApi/uploadBase64',
+		data: formData,
+		method: 'post',
+		timeout: 60000,
+	})
+}
+export function getSchoolServeList(params) {
+	return request({
+		url: '/mobile/companyInfoApi/schoolServeList',
+		data: Qs.stringify(params),
+		method: 'post',
+	})
+}
+
+//获取banner图片
+export function getBannerInfo(type) {
+	return request({
+		url: '/mobile/bannerInfo/getBannerInfo',
+		data: Qs.stringify({
+			type: type
+		}),
+		method: 'post',
+	})
+}
+
+//发送短信
+export function sendMsg(params) {
+	return request({
+		url: '/mobile/personInfoApi/getVerifyCode',
+		data: Qs.stringify(params),
+		method: 'post',
+	})
+}
+
+//验证验证码并登录
+export function validateCode(params) {
+	return request({
+		url: '/mobile/personInfoApi/validateCode',
+		data: Qs.stringify(params),
+		method: 'post',
+	})
+}

+ 2 - 1
apis/weixin.js

@@ -23,9 +23,10 @@ export function getDataByOpenId(openId) {
 
 //获得配置
 export function getConfig() {
+	
 	return request({
 		url: '/wechat/getConfig',
-		params: {
+		data: {
 			url: window.location.href.split('#')[0]
 		},
 		method: 'get',

+ 2 - 1
manifest.json

@@ -71,7 +71,8 @@
     "h5" : {
         "devServer" : {
             "port" : 8080,
-            "https" : true
+            "https" : false,
+			 "disableHostCheck": true
         },
         "optimization" : {
             "treeShaking" : {

+ 39 - 3
pages/buytickets/index.js

@@ -1,9 +1,14 @@
+import * as WxJsApi from '@/utils/wxJsApi.js'
 export default {
     data() {
         return {
-      id:0, // 使用 marker点击事件 需要填写id
+			id:0, // 使用 marker点击事件 需要填写id
             title: 'map',
-  
+			info:{
+				init:false,
+				longitude: '',
+				latitude: '',
+			},
 			longitude: 112.276527,
 			latitude: 30.306427,
             covers: [{
@@ -17,7 +22,33 @@ export default {
             }]
         }
     },
+	
     methods: {
+		getPoint(){
+		  
+		    //this.isLoading = true;
+		    WxJsApi.getLocation().then((res) => {
+		        this.isLoading = false;
+				this.info.init=true
+				
+		        var latitude = parseFloat(res.latitude);
+		        var longitude = parseFloat(res.longitude);
+				this.latitude=latitude;
+				this.longitude=longitude;
+		       // mui.toast("经纬度已经获取,正在转换地址...");
+				this.covers=[{
+				   longitude: longitude,
+				   latitude: latitude,
+				   iconPath: '/static/img/map_2.png'
+				}]
+		     
+		    }).catch(error => {
+		
+		        this.isLoading = false;
+		        console.log(error)
+		       // WxJsApi.addSysLog(error)
+		    })
+		}, 
 		update(){
 			this.covers=[{
                longitude: 112.276527,
@@ -29,5 +60,10 @@ export default {
                iconPath: '/static/img/map_1.png'
             }]
 		}
-    }
+    },onReady(){
+		WxJsApi.getWxConfig(['chooseImage', 'getLocalImgData', 'getLocation']);
+		
+		   this.getPoint();
+		   
+	}
 }

+ 182 - 0
utils/wxJsApi.js

@@ -0,0 +1,182 @@
+import wx from 'weixin-js-sdk'
+import * as API_WeiXin from '@/apis/weixin.js'
+import * as API_Common from '@/apis/common.js'
+
+import Qs from 'qs';
+import request from './request.js'
+export function addSysLog(message) {
+
+	return request({
+		url: '/mobile/sysLogApi/submit',
+		data: Qs.stringify({
+			message: JSON.stringify(message)
+		}),
+		method: 'post',
+	})
+}
+//获取微信配置
+export function getWxConfig(jsApiList) {
+	var jsApiList = jsApiList || ['chooseImage', 'getLocalImgData', 'scanQRCode'];
+	let promise = (jsApiList => {
+		return new Promise((resolve, reject) => {
+			console.log(jsApiList);
+			API_WeiXin.getConfig().then(response => {
+				var wxconfig = response.wxConfig;
+				console.log(wxconfig.nonceStr)
+				wx.config({
+					debug: false, // 开启调试模式,
+					appId: wxconfig.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
+					timestamp: wxconfig.timestamp, // 必填,生成签名的时间戳
+					nonceStr: wxconfig.nonceStr, // 必填,生成签名的随机串
+					signature: wxconfig.signature, // 必填,签名,见附录1
+					jsApiList: jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+				});
+				wx.ready(function() {
+					resolve(response);
+				})
+				wx.error(function(res) {
+					reject('微信api配置出错');
+				});
+			}).catch(error => {
+				mui.toast(error);
+				reject(error);
+			})
+		})
+	})(jsApiList)
+
+	return promise;
+}
+
+//选择图片,多图上传和单图上传的回调处理不一样
+export function chooseImage(count) {
+	var count = count || 1;
+	let promise = new Promise((resolve, reject) => {
+		wx.chooseImage({
+			count: count,
+			sizeType: ['compressed'],
+			sourceType: ['album', 'camera'],
+			success: function(res) {
+				var localIds = res.localIds;
+				console.log(localIds);
+				if (count == 1) {
+					wx.getLocalImgData({
+						localId: localIds[0],
+						success: function(res) {
+							resolve(res);
+						}
+					});
+				} else {
+					resolve(localIds);
+				}
+			}
+		});
+	});
+	return promise;
+}
+
+//获取图片,用于多图上传时的递归处理
+export function getLocalImgData(localId, fun) {
+	wx.getLocalImgData({
+		localId: localId,
+		success: function(res) {
+			fun(res);
+		}
+	});
+}
+
+//上传图片
+export function uploadPic(imgBase64) {
+	let promise = new Promise((resolve, reject) => {
+		var formData = new FormData();
+		formData.append('photoName', '1.jpg');
+		formData.append('photoBase64Data', imgBase64);
+
+		console.log(formData);
+		console.log(typeof formData);
+
+		API_Common.uploadBase64(formData).then(response => {
+			resolve(response);
+		}).catch(error => {
+			mui.toast(error);
+			reject(error);
+		})
+	});
+	return promise;
+}
+
+//获取坐标
+export function getLocation() {
+	let promise = new Promise((resolve, reject) => {
+		wx.ready(function() {
+			wx.getLocation({
+				type: 'gcj02', // 默认为wgs84的gps坐标,可传入'gcj02'
+				success: function(res) {
+					resolve(res);
+				},
+				faile: function(res) {
+					reject(res);
+				},
+				fail: function(res) {
+					if (res.errMsg == 'getLocation:timeout') {
+						mui.alert("定位超时,请检查是否开启'定位'");
+					} else if (res.errMsg == 'getLocation:ERROR_NETWORK') {
+						mui.alert("网络异常");
+					} else if (res.errMsg == 'getLocation:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF') {
+						mui.alert("没开启系统定位");
+					} else if (res.errMsg == 'getLocation:system permission denied') {
+						mui.alert("未给微信位置授权");
+					} else if (res.errMsg == 'getLocation:location permission') {
+						mui.alert("未给微信位置授权");
+					} else if (res.errMsg == 'getLocation:auth denied') {
+						mui.alert("用户在小程序中未授权");
+					} else if (res.errMsg == 'getLocation:fail authorize no response') {
+						mui.alert("用户在小程序中未授权");
+					}
+					reject(res);
+				},
+				complete() {}
+			})
+		})
+	})
+	return promise;
+}
+
+//扫描二维码
+export function scanQRCode(needResult) {
+	var needResult = needResult || 1;
+	let promise = new Promise((resolve, reject) => {
+		wx.scanQRCode({
+			needResult: needResult,
+			scanType: ["qrCode"],
+			success: function(res) {
+				var url = res.resultStr;
+				resolve(url);
+			},
+			faile: function(res) {
+				reject(res);
+			},
+			fail: function(res) {
+
+
+				if (res.errMsg == 'getLocation:timeout') {
+					mui.alert("定位超时,请检查是否开启'定位'");
+				} else if (res.errMsg == 'getLocation:ERROR_NETWORK') {
+					mui.alert("网络异常");
+				} else if (res.errMsg == 'getLocation:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF') {
+					mui.alert("没开启系统定位");
+				} else if (res.errMsg == 'getLocation:system permission denied') {
+					mui.alert("未给微信位置授权");
+				} else if (res.errMsg == 'getLocation:location permission') {
+					mui.alert("未给微信位置授权");
+				} else if (res.errMsg == 'getLocation:auth denied') {
+					mui.alert("用户在小程序中未授权");
+				} else if (res.errMsg == 'getLocation:fail authorize no response') {
+					mui.alert("用户在小程序中未授权");
+				}
+				reject(res);
+			},
+			complete() {}
+		})
+	});
+	return promise;
+}