duanshenglang 3 weeks ago
parent
commit
2c4ab595ef
1 changed files with 102 additions and 70 deletions
  1. 102 70
      lottery/index.html

+ 102 - 70
lottery/index.html

@@ -14,9 +14,9 @@
 	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
 	<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
 	<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
-	<!-- <script>
+	<script>
 		var vConsole = new window.VConsole();
-	</script> -->
+	</script>
 </head>
 <style>
   body {
@@ -371,6 +371,13 @@
 		text-align: center;
     font-size: 18px;
 	}
+	.alert_dialog {
+		z-index: 999;
+		position: fixed;
+		top: 0;
+		left: 0;
+		width: 100%;
+	}
 </style>
 
 <body>
@@ -380,7 +387,9 @@
 			<img class="qrcode-img" :src="qrCodeData.qrCode" />
 			<div class="qrcode-msg">{{qrCodeData.msg}}</div>
 		</div>
-		<div v-if="h5Type == 19">
+		<el-alert v-if="showError" class="alert_dialog" :title="errorMsg" :closable="false" type="error" show-icon>
+		</el-alert>
+		<div v-if="h5Type == 19 && !qrCodeData.qrCode">
 			<div class="lotteryPage">
 				<div class="event_notice" @click="handleRule">
 					<span>活动须知</span>
@@ -410,7 +419,7 @@
 								<div class="prize_name">{{item.name}}</div>
 								<div class="prize_time">{{timeFormat(item.raffleTime)}}</div>
 							</div>
-							<el-button :disabled="item.status == -1 || item.status == 1" class="get_btn" onclick="handleOpenForm(item.id)">{{item.status == 1 ? '已领取' : (item.status == -1 ? '审核中' : '领取')}}</el-button>
+							<el-button :disabled="item.status == -1 || item.status == 1" class="get_btn" @click="handleOpenForm(item.id)">{{item.status == 1 ? '已领取' : (item.status == -1 ? '审核中' : '领取')}}</el-button>
 						</div>
 					</div>
 				</div>
@@ -494,7 +503,7 @@
 			<el-form :model="getInfoForm" class="prize_form"label-position="top">
 				<div v-if="preFormType">
 					<el-form-item label="手机号:">
-						<el-input type="number" v-model="getInfoForm.phone" autocomplete="off"
+						<el-input v-model="getInfoForm.phone" autocomplete="off"
 						maxlength="11"
 						oninput="value=value.replace(/[^\d]/g,'')" 
 						@blur="$event => {getInfoForm.phone = Number($event.target.value) || '';}"
@@ -594,6 +603,8 @@
 						intervalId: null,
 						showRuleDialog: false,
 						preFormType: null,
+						showError: false,
+						errorMsg: '',
           }
         },
         created() {
@@ -605,60 +616,7 @@
 					} else {
 						this.httpUrl = 'http://test.wefanbot.com:18993'
 					}
-					if (this.h5Type == 19) {
-						if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
-							if (!this.getQueryParam('externalUserid')) {
-								this.gerQwAuth(this.bId);
-							} else {
-								if (this.getQueryParam('externalUserid') === 'unknown') {
-									this.gerQwCode(this.bId);
-								} else {
-									this.raffleInfo();
-									this.raffleRecord()
-									this.getCityLevel()
-									this.getAllCar()
-									this.getQyWxSign()
-								}
-							}
-						} else {
-							// 走授权操作
-							this.getAuth();
-						}
-					} else if (this.h5Type == 20) {
-						// 宝骏云海送祝福
-						var currentQueryParams = window.location.search;
-						window.location.replace('h5Type-20.html' + currentQueryParams)
-					} else if (this.h5Type == 21) {
-						// 活码
-						var currentQueryParams = window.location.search;
-						window.location.replace('live_code.html' + currentQueryParams)
-					} else if (this.h5Type == 22) {
-						// 红包兑换
-						var currentQueryParams = window.location.search;
-						window.location.replace('receiveMoney.html' + currentQueryParams)
-					} else if (this.h5Type == 23) {
-						// 会话列表
-						var currentQueryParams = window.location.search;
-						window.location.replace('sessionList.html' + currentQueryParams)
-					} else if (this.h5Type == 24) {
-						// 客户SOP提醒
-						var currentQueryParams = window.location.search;
-						window.location.replace('clientSopTip.html' + currentQueryParams)
-					} else if (this.h5Type == 25) {
-						// 客户SOP内容
-						var currentQueryParams = window.location.search;
-						window.location.replace('clientSop.html' + currentQueryParams)
-					} else if (this.h5Type == 26) {
-						// 群SOP提醒
-						var currentQueryParams = window.location.search;
-						window.location.replace('groupSopTip.html' + currentQueryParams)
-					} else if (this.h5Type == 27) {
-						// 群SOP内容
-						var currentQueryParams = window.location.search;
-						window.location.replace('groupSop.html' + currentQueryParams)
-					} else if (!this.h5Type) {
-						this.getAuth()
-					}
+					this.ifH5Type()
         },
         methods: {
 					// 公众号授权,获取code
@@ -666,28 +624,99 @@
 						// 获取url上的code
 						let code = this.getQueryParam('code')
 						if (code) {
-							fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
-              .then(res => {
+							// 判断业务id是否生产环境业务id
+							fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
+								.then(res => {
+									return res.json()
+								}).then(result => {
+									let { data, msg } = result
+									if (typeof data === 'boolean' && data) {
+										this.httpUrl = 'https://wlapi.wefanbot.com'
+									} else {
+										this.httpUrl = 'http://test.wefanbot.com:18993'
+									}
+									this.getInfoByh5Code(this.getQueryParam('code'))
+								})
+						} else {
+							let redirect_uri = window.location.href
+							// code 不存在,走微信网页授权逻辑 
+							let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
+							window.location.replace(url)							
+						}
+					},
+					getInfoByh5Code (code) {
+						fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
+							.then(res => {
 								return res.json()
-              }).then(result => {
+							}).then(result => {
 								let { data, code, msg } = result
 								if (code === 1) {
 									this.h5Type = data.h5Type
 									localStorage.setItem('openId', data.openId)
+									// this.gerQwAuth(this.bId);
+									this.ifH5Type();
+								}
+							})
+					},
+					ifH5Type () {
+						if (this.h5Type == 19) {
+							if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
+								if (!this.getQueryParam('externalUserid')) {
 									this.gerQwAuth(this.bId);
+								} else {
+									if (this.getQueryParam('externalUserid') === 'unknown') {
+										this.gerQwCode(this.bId);
+									} else {
+										this.raffleInfo();
+										this.raffleRecord()
+										this.getCityLevel()
+										this.getAllCar()
+										this.getQyWxSign()
+									}
 								}
-              })
-						} else {
-							let redirect_uri = window.location.href
-							// code 不存在,走微信网页授权逻辑 
-							let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
-							window.location.replace(url)
-						}
+							} else {
+								// 走授权操作
+								this.getAuth();
+							}
+						} else if (this.h5Type == 20) {
+							// 宝骏云海送祝福
+							var currentQueryParams = window.location.search;
+							window.location.replace('h5Type-20.html' + currentQueryParams)
+						} else if (this.h5Type == 21) {
+							// 活码
+							var currentQueryParams = window.location.search;
+							window.location.replace('live_code.html' + currentQueryParams)
+						} else if (this.h5Type == 22) {
+							// 红包兑换
+							var currentQueryParams = window.location.search;
+							window.location.replace('receiveMoney.html' + currentQueryParams)
+						} else if (this.h5Type == 23) {
+							// 会话列表
+							var currentQueryParams = window.location.search;
+							window.location.replace('sessionList.html' + currentQueryParams)
+						} else if (this.h5Type == 24) {
+							// 客户SOP提醒
+							var currentQueryParams = window.location.search;
+							window.location.replace('clientSopTip.html' + currentQueryParams)
+						} else if (this.h5Type == 25) {
+							// 客户SOP内容
+							var currentQueryParams = window.location.search;
+							window.location.replace('clientSop.html' + currentQueryParams)
+						} else if (this.h5Type == 26) {
+							// 群SOP提醒
+							var currentQueryParams = window.location.search;
+							window.location.replace('groupSopTip.html' + currentQueryParams)
+						} else if (this.h5Type == 27) {
+							// 群SOP内容
+							var currentQueryParams = window.location.search;
+							window.location.replace('groupSop.html' + currentQueryParams)
+						} else if (!this.h5Type) {
+							this.getAuth()
+						}	
 					},
 					// 企微授权
 					gerQwAuth (bId) {
 						let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
-
 						fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
               .then(res => {
 								return res.json()
@@ -783,6 +812,9 @@
 									if (data.preForm && !data.isSubmit) {
 										this.showTipDialog = true
 									}
+								} else {
+									this.showError = true
+									this.errorMsg = msg
 								}
               })
 					},