فهرست منبع

1. 合并分支h5

MONSTER-ygh 1 سال پیش
والد
کامیت
c0fbb4e3b4
14فایلهای تغییر یافته به همراه787 افزوده شده و 8 حذف شده
  1. 1 0
      App.vue
  2. 12 0
      common/apiurl.js
  3. 1 1
      common/config.js
  4. 5 1
      common/http.api.js
  5. 1 0
      js_sdk/jweixin-1.4.0.js
  6. 6 0
      main.js
  7. 6 2
      manifest.json
  8. 7 0
      pages.json
  9. 6 0
      pages/bookticket.vue
  10. 68 4
      pages/login/login.vue
  11. 332 0
      pages/login/loginh5.vue
  12. 40 0
      pay.js
  13. 118 0
      utils/axios.js
  14. 184 0
      wxapi.js

+ 1 - 0
App.vue

@@ -25,6 +25,7 @@
 			// #endif
 		 
 			// console.log('this.globalData==========',this.globalData)
+			this.$wxApi.config()
 		},
 		onShow: function() {
 			// console.log('App Show')

+ 12 - 0
common/apiurl.js

@@ -163,6 +163,18 @@ const apiurl = {
 		type: 'get'
 	},
 	
+	
+	/**
+	 * @author ygh
+	 * @date 2023-12-14
+	 * 公众号获取openid
+	 * 
+	 * */
+	wxinfoH5: {
+		url: '/member/wechat/h5/code/',
+		type: 'get',
+		addUrl: true
+	},
 }
 
 

+ 1 - 1
common/config.js

@@ -12,7 +12,7 @@
 // }
 
 //64
-let baseUrl='https://greatadmin.dev.gztjy.top/serviceapi';
+let baseUrl='https://greath5.dev.gztjy.top/serviceapi';
 let upFileUrl='http://fileupload.hw.hongweisoft.com/upload/single/minio';
 // let staticUrl='http://res.hw.hongweisoft.com/xushuo/';
 let staticUrl='https://miniores.hw.hongweisoft.com/greattransition/staticfile';

+ 5 - 1
common/http.api.js

@@ -13,7 +13,11 @@ const install = (Vue, vm) => {
 	// 循环请求路径对象生成对应的方式请求
 	Object.keys(apiurl).forEach((key) => {
 		if(apiurl[key]?.type=='get'){
-			httpMap[key] = (data = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url, {params:data}, config);
+			if(apiurl[key].addUrl){
+				httpMap[key] = (data = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url+data.code, {}, config);
+			}else {
+				httpMap[key] = (data = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url, {params:data}, config);
+			}
 		} else if (apiurl[key]?.type == 'delete') {
 			httpMap[key] = (data = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url + `${queryParams(data)}`, {}, config);
 		} else{

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 0
js_sdk/jweixin-1.4.0.js


+ 6 - 0
main.js

@@ -1,5 +1,11 @@
 import App from './App'
 
+import $wxApi from "./wxapi.js";
+Vue.prototype.$wxApi = $wxApi;
+//微信支付封装
+// import $pay from "./pay.js";
+// Vue.prototype.$pay = $pay
+
 // #ifndef VUE3
 import Vue from 'vue'
 Vue.config.productionTip = false

+ 6 - 2
manifest.json

@@ -84,6 +84,7 @@
         "devServer" : {
             "proxy" : {
                 "/api" : {
+                    "disableHostCheck" : true,
                     "target" : "https://xusfoodapi.hw.hongweisoft.com/appapi/app", //请求的目标域名
                     "changeOrigin" : true,
                     "secure" : false,
@@ -92,14 +93,17 @@
                         "^/api" : ""
                     }
                 }
-            }
+            },
+            "https" : false
         },
         "sdkConfigs" : {
             "maps" : {}
         },
+        "title" : "伟大转折",
         "router" : {
             "mode" : "history"
-        }
+        },
+        "template" : ""
     },
     "fallbackLocale" : "zh-Hans"
 }

+ 7 - 0
pages.json

@@ -14,6 +14,13 @@
 				"navigationStyle": "custom"
 			}
 		},
+		// {
+		// 	"path": "pages/login/loginh5",
+		// 	"style": {
+		// 		"navigationBarTitleText": "登录",
+		// 		"navigationStyle": "custom"
+		// 	}
+		// },
 		{
 			"path": "pages/login/regulation",
 			"style": {

+ 6 - 0
pages/bookticket.vue

@@ -313,6 +313,12 @@
 					},
 					viewerList:this.visitors
 				}
+				// #ifdef MP
+				params['source'] = 1
+				// #endif 
+				// #ifdef H5
+				params['source'] = 4
+				// #endif
 				this.cansubmit = false;
 				// console.log('pageData',this.pageData);
 				// console.log('visitors',this.visitors);

+ 68 - 4
pages/login/login.vue

@@ -14,6 +14,7 @@
 			<!-- <u-button v-if="loginBtn" text="手机号快捷登录" type="success" :hairline="false" throttleTime="2000" shape="circle" 
 				@click="openAuth"></u-button> -->
 			<view class="btn-wrap" style="margin:94rpx">
+				<!-- #ifdef MP -->
 				<u-button
 					v-if="loginBtn&&checked.length>0" 
 					:hair-line='false' 
@@ -32,6 +33,16 @@
 					@click="disabledClick"
 					shape="circle">登录
 				</u-button>
+				<!-- #endif -->
+				<!-- #ifdef H5 -->
+				<u-button
+					:hair-line='false' 
+					type="error" 
+					color="#ED0000"
+					@click="disabledClick"
+					shape="circle">登录
+				</u-button>
+				<!-- #endif -->
 			</view>
 			<view class="rule-wrap u-flex u-flex-wrap u-row-center">
 				<u-checkbox-group v-model="checked" @change="checkboxChange" placement="row">
@@ -125,7 +136,14 @@
 				scene:'',
 			};
 		},
-		onLoad() {
+		onLoad(e) {
+			// #ifdef H5
+			console.log("回调参数=======",e)
+			if(e&&e.code) { // 微信第三方登录成功
+				this.code = e.code
+				this.login(e)
+			}
+			// #endif
 			let that = this;
 			//获取屏幕高度,我的项目再store里已经取到了
 			uni.getSystemInfo({
@@ -141,6 +159,11 @@
 			});
 		},
 		onShow() {
+			// #ifdef H5
+			let pages = getCurrentPages(); //当前页面栈
+			console.log("pages=====",pages)
+			// #endif
+			// #ifdef MP
 			// uni.showLoading({
 			// 	mask:true
 			// });
@@ -149,6 +172,7 @@
 			// 	this.openAuth();
 			// 	// this.showAuthorizeUser = true //弹出头像用户名
 			// }, 100);
+			// #endif
 			let userInfo = uni.getStorageSync('userInfo');
 			this.user.name = userInfo.name;
 		},
@@ -249,13 +273,17 @@
 			async login(e){
 				// console.log('e',e);
 				let _this = this;
-				let wxinfo = await this.$u.api.wxinfo({code:this.code});
+				let wxinfo = null
+				let data = {}
+				// #ifdef MP
+				wxinfo = await this.$u.api.wxinfo({code:this.code});
 				let {openid,sessionKey,unionid} = wxinfo.data;
 				
 				_this.$u.vuex('vuex_wechatOpenid', openid);
 				const { errMsg, iv, encryptedData } = e.detail;
 				if (errMsg !== 'getPhoneNumber:ok') return;
-				let data = {
+				
+				data = {
 					code: this.code,
 					encryptedData: encryptedData,
 					ivStr: iv,
@@ -264,6 +292,7 @@
 					sourceType:1,
 					mobile:this.mobile
 				}
+				
 				if(this.scene&&this.scene!='undefined'){
 					await this.$u.api.uncompress({scene:this.scene}).then(res=>{
 						data.agentId = res.data.agentId;
@@ -274,6 +303,17 @@
 						console.log('uncompress',err);
 					})
 				}
+				// #endif
+				
+				// #ifdef H5
+				wxinfo = await this.$u.api.wxinfoH5({code:this.code});
+				let { openid } = wxinfo.data;
+				data = {
+					"openId": "",
+					"h5OpenId": openid,
+					"mobile": ""
+				}
+				// #endif
 				// console.log('----------登陆中',data)
 				this.$u.api.login(data).then(res=>{
 					// console.log('微信登录返回结果========',res.data)
@@ -388,6 +428,7 @@
 			disabledClick(){
 				// console.log('checked',this.checked?.length);
 				// console.log('loginBtn',this.loginBtn);
+				// #ifdef MP
 				if(!this.checked||this.checked?.length<=0){
 					uni.showToast({
 						title:'请先同意使用条款!',
@@ -399,8 +440,31 @@
 						icon:'none'
 					})
 				}
+				// #endif
 				
-			}
+				// #ifdef H5 
+				if(!this.checked||this.checked?.length<=0){
+					uni.showToast({
+						title:'请先同意使用条款!',
+						icon:'none'
+					})
+				}else{
+					uni.showToast({
+						title:'登录中!',
+						icon:'none'
+					})
+					this.redirectToAuth()
+				}
+				// #endif
+			},
+			/**  公众号 微信授权登录  */
+			redirectToAuth() {
+			    const appid = 'wx6490eaa0d20d2be2';
+			    const redirectUri = encodeURIComponent('https://greath5.dev.gztjy.top/pages/login/login');
+			    const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
+			 
+			    window.location.href = authUrl;
+			},
 		}
 	}
 </script>

+ 332 - 0
pages/login/loginh5.vue

@@ -0,0 +1,332 @@
+<template>
+	<view class="body" :style="{height:screenHeight}">
+		<image class="login-bg" :src="staticUrl+'/img/login-bg.png'" mode="widthFix"></image>
+		<u-toast ref="uToast"></u-toast>
+		<view style="height: 40%;position: relative;z-index: 10;">
+			<view class="logo-wrap">
+				<img :src="logoSrc" class="logo" alt="">
+			</view>
+			<view class="btn-wrap" style="margin:94rpx">
+				<u-button
+					:hair-line='false' 
+					type="error" 
+					color="#ED0000"
+					@click="disabledClick"
+					shape="circle">登录
+				</u-button>
+			</view>
+			<view class="rule-wrap u-flex u-flex-wrap u-row-center">
+				<u-checkbox-group v-model="checked" @change="checkboxChange" placement="row">
+					<u-checkbox activeColor="#1677FF" name="同意" labelSize="24rpx" shape="circle" label="我已阅读并同意"></u-checkbox>
+				</u-checkbox-group>
+				<text class="link" @click="$u.route('/pages/login/regulation',{regulationName:'用户服务协议',type:1})">《用户服务协议》</text>
+				和<text class="link" @click="$u.route('/pages/login/regulation',{regulationName:'用户隐私政策',type:2})">《用户隐私政策》</text>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				staticUrl:this.$commonConfig.staticUrl,
+				checked:false,
+				checkboxVal:null,
+				loginBtn:true,
+				bname:'旭烁集团',
+				//屏幕高度
+				screenHeight: "",
+				logoSrc: "/static/logo.png",
+				// sitename:"/static/sitename.png",
+				miniappLoginInfo:null,
+				hasUserInfo:false,
+				userInfo: null,
+				user:{   
+					avatar:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
+					name:'',
+					mobile:'',
+				},
+				code: '',
+				showAuthorizeUser: false,
+				showAuthorizePhone: false,
+				customStyleUnOk:{},
+				customStyleOk:{'margin-left': '30px',color:'#00A447'},
+				backUrl:null,
+				scene:'',
+			};
+		},
+		onLoad(e) {
+			console.log("回调参数=======",e)
+			if(e&&e.code) { // 微信第三方登录成功
+				this.code = e.code
+				this.login(e)
+			}
+			let that = this;
+			//获取屏幕高度,我的项目再store里已经取到了
+			uni.getSystemInfo({
+				success: (res) => {
+					this.screenHeight = res.windowHeight + "px"
+				}
+			});
+			uni.getStorage({
+				key: 'backUrl',
+				success: function (res) {
+					that.backUrl = '/'+res.data;
+				}
+			});
+		},
+		onShow() {
+			let pages = getCurrentPages(); //当前页面栈
+			console.log("pages=====",pages)
+			let userInfo = uni.getStorageSync('userInfo');
+			this.user.name = userInfo.name;
+		},
+		methods: {
+			openAuth(){
+				this.showAuthorizePhone = true;
+			},
+			//获取昵称输入内容
+			// userNameInput(e){
+			//     this.user.nickName = e.detail.value
+			// },
+			onChooseAvatar(e) {
+				console.log('头像信息》')
+				console.log(e)
+				this.user.avatar = e.detail.avatarUrl;
+			},
+			async login(e){
+				// console.log('e',e);
+				let _this = this;
+				let wxinfo = await this.$u.api.wxinfoH5({code:this.code});
+				let {openid,nickname} = wxinfo.data;
+
+				// console.log('----------登陆中',data)
+				this.$u.api.login({
+					"openId": "",
+					"h5OpenId":"openid",
+					"mobile": ""
+				}).then(res=>{
+					// console.log('微信登录返回结果========',res.data)
+					_this.$u.vuex('vuex_user_info', res.data);
+					// _this.$u.vuex('vuex_member_info',res.data);
+					// uni.setStorageSync('userInfo', res.data)
+					this.showAuthorizePhone = false;
+					uni.removeStorage({
+						key:'scene'
+					});
+					// console.log('res.data.userid',res.data.userid);
+					this.getMemberInfo(res.data.userId);
+					
+				}).catch(err=>{
+					console.log('err',err);
+					this.showAuthorizePhone = false
+				})
+			},
+			/**
+			 * @author ygh
+			 * @date 2023-12-14
+			 * @param {Object} userid
+			 * 根据userId 获取用户信息
+			 */
+			getMemberInfo(userid){
+				// console.log('userid',userid);
+				let _this = this;
+				this.$u.api.memberInfo({id:userid}).then(res=> {
+					if(res.code ===200) {
+						_this.userInfo = res.data;
+						this.$u.vuex('vuex_member_info', res.data);
+						// this.$u.vuex('vuex_member_info.avatar', 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0');
+						if(!res.data.name){
+							this.$u.vuex('vuex_member_info.name', '微信用户');
+							this.updateMemberInfo();
+						}else{
+							this.goBack();
+						}
+					}
+				})
+			},
+			/**
+			 * @author ygh 
+			 * @date 2023-12-14
+			 * 更新用户信息
+			 */
+			updateMemberInfo(){
+				let params ={
+					id:this.userInfo.id,
+					// avatar:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
+					name:'微信用户'
+				};
+				this.$u.api.updateMemberInfo(params).then(res=>{
+					this.goBack();
+				}).catch(err=>{
+					console.log('err',err);
+				})
+			},
+			goBack(){
+				let url = this.backUrl&&this.backUrl.length>0?this.backUrl:'/pages/index/index';
+				// console.log('url',url);
+				uni.removeStorage({
+					key: 'backUrl',
+					success: function (res) {
+						// console.log('success');
+						uni.reLaunch({url: decodeURIComponent(url)});
+					}
+				});
+			},
+			checkboxChange(e){
+				this.checkboxVal = e[0];
+			},
+			disabledClick(){
+				console.log("this.checked====",this.checked)
+				// console.log('checked',this.checked?.length);
+				// console.log('loginBtn',this.loginBtn);
+				if(!this.checked||this.checked?.length<=0){
+					uni.showToast({
+						title:'请先同意使用条款!',
+						icon:'none'
+					})
+				}else{
+					uni.showToast({
+						title:'登录中!',
+						icon:'none'
+					})
+					this.redirectToAuth()
+				}
+			},
+			/**  微信授权登录  */
+			redirectToAuth() {
+			    const appid = 'wx6490eaa0d20d2be2';
+			    const redirectUri = encodeURIComponent('https://greath5.dev.gztjy.top/pages/login/loginh5');
+			    const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
+			 
+			    window.location.href = authUrl;
+			},
+			
+			getAccessToken() {
+				const code = (new URLSearchParams(window.location.search)).get('code');
+				if (code) {
+				    const appid = 'wx6490eaa0d20d2be2';
+				    const requestUrl = `https://api.weixin.qq.com/sns/oauth2/access_token?appid=${appid}&secret=YOUR_APP_SECRET&code=${code}&grant_type=authorization_code`;
+				    fetch(requestUrl)
+				    .then(response => response.json())
+				    .then(data => {
+				        if (data && data.openid) {
+				            const openid = data.openid;
+				            // 在这里可以存储或使用用户的openid
+				            // ...
+				        }
+				    })
+				    .catch(error => {
+				        console.error(error);
+				    });
+				}
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+.login-bg{
+	position: fixed;
+	left: 0;
+	right: 0;
+	bottom: 0;
+	width: 100%;
+}
+.body {
+	background-color: #fff;
+	box-sizing: border-box;
+	text-align: center;
+	.logo-wrap {
+		padding-top: 248rpx;
+		img{
+			display: block;
+			margin: 0 auto;
+		}
+		.logo{
+			width: 306rpx;
+			height: 258rpx;
+		}
+		.sitename{
+			width: 460rpx;
+			height: 142rpx;
+		}
+	}
+}
+
+// 
+
+.auth-btncard{
+	margin-top: 20px;
+    .btn-unok{
+        width: 45%;
+        float: left;
+    }
+    .btn-ok{
+        width: 45%;
+        float: left;
+        margin: 0;
+        padding: 0;
+        border: 0px solid transparent;  //自定义边框
+        outline: none;    //消除默认点击蓝色边框效果
+        u-button{
+			font-size: 16px;
+            margin: 0;
+            padding: 0;
+            // border: 0px solid transparent;  //自定义边框
+            outline: none;    //消除默认点击蓝色边框效果
+        }
+    }
+}
+.auth-card{
+    text-align: center;
+    .avatar-img{
+        width: 150rpx;
+        height: 150rpx;
+        overflow: hidden;
+        border-radius: 100%;
+        margin-top: 30rpx;
+    }
+    .title{
+        font-size: 30rpx;
+    }
+    .content{
+        margin-top: 10rpx;
+		margin-bottom: 20rpx;
+    }
+}
+.avatar-wrapper{
+	width: 150rpx;
+	height: 100rpx;
+	color: #333 !important;
+	text-align: center !important;
+	border: none !important;
+	border-radius:0 !important;
+	background-color:transparent !important;
+}
+.avatar-wrapper::after {
+	border: none !important;
+}
+.avatar{
+	width: 100rpx;
+	height: 100rpx;
+	overflow: hidden;
+	border-radius: 100%;
+}
+
+.rule-wrap{
+	position: fixed;
+	left: 0;
+	right: 0;
+	bottom: 20px;
+	margin: 40rpx auto;
+	font-size: 24rpx;
+	line-height: 1.5;
+	.link{
+		white-space: nowrap;
+		color: #1677FF;
+	}
+}
+</style>
+

+ 40 - 0
pay.js

@@ -0,0 +1,40 @@
+/**
+ * 订单支付
+ */
+import Vue from "vue";
+//#ifdef H5
+import $wxApi from "./wxapi.js";
+//#endif
+import $http from "./utils/axios.js"
+
+export default {
+	//微信支付
+	wxPay(obj = {}) {
+		uni.showLoading({
+			title: '支付中'
+		});
+		return new Promise(r => {
+			$http.post("/wechat/h5/pay",obj)
+				.then(res=>{
+					//#ifdef H5
+					$wxApi.JSAPI(res.retBody).then(r);
+					//#endif
+					this.payError(res);
+				})
+		});
+	},
+	//支付错误处理
+	payError(res){
+		uni.hideLoading();
+		if(res.code == 623){
+			setTimeout(i=>{
+				new Vue().$api.goto("/pages/userCenter/myOrder/myOrder");
+			},2000);
+			uni.showToast({
+				title:res.msg + "    即将跳转到订单页",
+				icon:"none",
+				duration:2000
+			});
+		}
+	}
+}

+ 118 - 0
utils/axios.js

@@ -0,0 +1,118 @@
+import { commonConfig } from '../common/config'
+
+export default { 
+	async post(url, param,yanci=true) {
+		// if(yanci){ 
+		// 	uni.showLoading({
+		// 		title:'加载中'
+		// 	})
+		// 	setTimeout(()=>{
+		// 		uni.hideLoading()
+		// 	},3000)			
+		// }
+		const res = await this.uni_request(url,param,'post')  
+		// if(yanci){
+		// 	setTimeout(()=>{
+		// 		uni.hideLoading()
+		// 	},200)	
+		// }
+		return res;
+	},
+	async get(url, param,yanci=true) {
+		// if(yanci){ 
+		// 	uni.showLoading({
+		// 		title:'加载中'
+		// 	})
+		// 	setTimeout(()=>{
+		// 		uni.hideLoading()
+		// 	},3000)			
+		// }
+		const res = await this.uni_request(url,param,'get') 
+		// if(yanci){
+		// 	setTimeout(()=>{
+		// 		uni.hideLoading()
+		// 	},200)
+		// }
+		return res;
+	}, 
+	async put(url, param) {
+		const res = await this.uni_request(url,param,'put') 
+		return res;
+	}, 
+	async delete(url, param) {
+		const res = await this.uni_request(url,param,'delete') 
+		return res;
+	}, 
+	uni_request(url,param,method,again_quest=true) {
+		const that = this
+	    return new Promise((cback, reject) => {
+	    	uni.request({
+	    		url: commonConfig.baseUrl + url,
+	    		data: param,
+	    		method:method,
+	    		header: {
+					accessToken:uni.getStorageSync("token")  	    		 	    			
+	    		},
+	    	}).then(data => { //data为一个数组,数组第一项为错误信息,第二项为返回数据				
+				var [error, res] = data;
+				cback(res.data); 
+	    		var res_code = res.statusCode.toString(); 
+				let errCode = res.data?.retHead?.errCode;
+	    		if (res_code.charAt(0) == 2) {
+	    			if(res_code==200){
+	    				// console.log('200',url)
+	    				cback(res.data); 
+					}else{
+						console.log('201',url)
+						uni.showToast({
+							title:res.data.retHead.errMsg,
+							icon:'none'
+						})
+					}
+				};
+				if(errCode==401||errCode==405){
+					uni.showToast({
+						title:res.data.retHead.errMsg,
+						icon:'none',
+						duration: 12000,
+						complete:function(){
+							window.location.replace(config.loginUrl)
+						}
+					})
+					
+				};
+				// else{
+				// 	if(res_code==401){
+				// 		//登录失效
+				// 		console.log('401',url) 
+				// 		if(again_quest){
+				// 			// token.getTokenFromServer(()=>{
+				// 			// 	const again_res=that.uni_request(url,param,method,false)	
+				// 			// 	//注意这里需要cback,因为是上一个promis的cback
+				// 			// 	cback(again_res); 
+				// 			// });				
+				// 		}else{
+				// 			console.log('再次登陆仍然失败',url)
+				// 		} 
+				// 	}else{
+				// 		console.log('400/500',url,error,res)
+				// 		uni.showToast({
+				// 			title:res.data.msg?res.data.msg:'请求异常',
+				// 			icon:'none'
+				// 		})
+				// 	}
+				// };
+				// console.log('uni_requestdata',data[1].data.retHead);
+				if(data[1].data.retHead.errCode&&data[1].data.retHead.errCode!='0'&&data[1].data.retHead.errMsg){
+					uni.showToast({
+						title:data[1].data.retHead.errMsg,
+						icon:'none'
+					});
+				};
+			}).catch(err => { 
+				console.log('catch:',err);					 
+			})
+		})	
+	}, 
+
+}

+ 184 - 0
wxapi.js

@@ -0,0 +1,184 @@
+//引入微信jssdk
+const wx = require('@/js_sdk/jweixin-1.4.0.js')
+
+//配置注册url
+const url = '/wechat/h5/getJsapiTicket';
+
+//http方法
+import $http from './utils/axios.js'
+
+//系统域名url
+const href = location.href.split('#')[0];
+// const href = location.href.split("?")[0]
+
+import { commonConfig } from './common/config'
+
+//系统域名url
+export default {
+	...wx,
+	isOk: false,
+	async config() {
+		wx.config({
+			debug: false,
+			jsApiList: [
+				"updateAppMessageShareData",
+				"updateTimelineShareData",
+				"onMenuShareTimeline",
+				"onMenuShareAppMessage",
+				"onMenuShareQQ",
+				"onMenuShareWeibo",
+				"onMenuShareQZone",
+				"startRecord",
+				"stopRecord",
+				"onVoiceRecordEnd",
+				"playVoice",
+				"pauseVoice",
+				"stopVoice",
+				"onVoicePlayEnd",
+				"uploadVoice",
+				"downloadVoice",
+				"chooseImage",
+				"previewImage",
+				"uploadImage",
+				"downloadImage",
+				"translateVoice",
+				"getNetworkType",
+				"openLocation",
+				"getLocation",
+				"hideOptionMenu",
+				"showOptionMenu",
+				"hideMenuItems",
+				"showMenuItems",
+				"hideAllNonBaseMenuItem",
+				"showAllNonBaseMenuItem",
+				"closeWindow",
+				"scanQRCode",
+				"chooseWXPay",
+				"openProductSpecificView",
+				"addCard",
+				"chooseCard",
+				"openCard"
+			],
+			// ...(await $http.get(url,{url:href})).retBody,
+		});
+		wx.ready(e => {
+			/**
+			 * 默认分享内容
+			 */
+			let shareParams = {
+				nickname:null,
+				desc:null,
+				togetherId:null,
+				routeUrl:null
+			}
+			this.share(shareParams)
+			
+			this.isOk = true;
+			// this.hideMenu();
+		});
+		wx.error(e => {
+			console.log("失败")
+			this.isOk = false;
+		});
+	},
+	hideMenu() {
+		wx.hideAllNonBaseMenuItem();
+		wx.hideMenuItems({		
+		    menuList: [
+				"menuItem:share:appMessage",
+				"menuItem:profile",
+				"menuItem:addContact",
+				"menuItem:dayMode",
+				"menuItem:nightMode",
+				"menuItem:share:timeline",
+				"menuItem:favorite"				
+			] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3		
+		});
+	},
+	showMenu() {
+		wx.showMenuItems({
+			menuList: [
+				"menuItem:share:appMessage",
+				"menuItem:profile",
+				"menuItem:addContact",
+				"menuItem:dayMode",
+				"menuItem:nightMode",
+				"menuItem:share:timeline",
+				"menuItem:favorite"
+			] // 要显示的菜单项,所有menu项见附录3
+		});
+	},
+	/**
+	 * 分享配置
+	 * @param {Object} info
+	 */
+	share(data = {}, info = {}) {
+		//添加链接时间戳
+		// data.v = new Date().getTime();
+		// console.log("shareData",data)
+		// let search = [];
+		// for (const [key, value] of Object.entries(data)) {
+		// 	// search.push(`${key}=${encodeURIComponent(value)}`);
+		// 	search.push(`${key}=${value}`);
+		// }
+		// search = "?" + search.join("&");
+		
+		let afterEndUrl = commonConfig.afterEndUrl;
+		// let afterEndUrl = 'http://tanhui.hongweisoft.com/api/wechat/h5/authorize?returnUrl='
+		// let afterEndUrl = 'http://gzhjt.gzsdzth.com/api/wechat/h5/authorize?returnUrl='
+		
+		let fullUrl= '';
+		if(data.togetherId&&data.routeUrl){
+			fullUrl = afterEndUrl + location.href.split('?')[0] + '?togetherId=' + data.togetherId + '/#/' + data.routeUrl
+		}else{
+			fullUrl = afterEndUrl + location.href.split('?')[0]
+		};
+		let shareInfo = {
+			title: data.nickname?data.nickname + '邀请你参与贵州省单株碳汇平台':'贵州省单株碳汇平台',
+			link: fullUrl,
+			desc: data.desc||"购买碳汇,你我同行",
+			imgUrl: href + "/static/logo.png",
+			trigger(res) {},
+			success(res) {},
+			cancel(res) {},
+			fail(res) {},
+			...info
+		};
+		console.log('shareInfo',shareInfo,'fullUrl',fullUrl)
+		//自定义“分享给朋友”及“分享到QQ”按钮的分享内容(1.4.0)
+		wx.updateAppMessageShareData(shareInfo);
+		//自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容(1.4.0)
+		wx.updateTimelineShareData(shareInfo);
+	},
+	//拉起微信浏览器端支付
+	JSAPI(res) {
+		return new Promise(r => {
+			wx.chooseWXPay({
+				"timestamp": res.timeStamp, //时间戳,自1970年以来的秒数     
+				"nonceStr": res.nonceStr, //随机串     
+				"package": res.packageValue,
+				"signType": res.signType, //微信签名方式:     
+				"paySign": res.paySign, //微信签名 
+				success() {
+					r({
+						code: 0,
+						msg: "成功"
+					});
+				},
+				cancel() {
+					r({
+						code: 1,
+						msg: "取消"
+					});
+				},
+				fail(err) {
+					console.log('支付失败',err.errMsg.split(':')[1]);
+					r({
+						code: 2,
+						msg: err.errMsg.split(':')[1]
+					});
+				}
+			});
+		});
+	},
+}