From 0891b02adb0ae89391c6fff8f4e8937bdd750c16 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期五, 15 九月 2023 15:32:37 +0800
Subject: [PATCH] 修改前端页面
---
src/components/page/IndexTest.vue | 187 +++++++++++++++++++++++++++++++++++++---------
1 files changed, 148 insertions(+), 39 deletions(-)
diff --git a/src/components/page/IndexTest.vue b/src/components/page/IndexTest.vue
index 79b94c5..9102021 100644
--- a/src/components/page/IndexTest.vue
+++ b/src/components/page/IndexTest.vue
@@ -34,7 +34,7 @@
<!--<el-input v-model="statisticData.code" readonly></el-input>-->
</el-form-item>
<el-form-item class="weizhang-footer-box" style="display: flex;justify-content: center;margin-top: 4.498vh" label-width="0" v-show="showFlag">
- <el-button class="jiaofei-btn" type="primary" @click="getCode()" :loading="payFlag">鍘荤即璐�</el-button>
+ <el-button class="jiaofei-btn" type="primary" @click="pay()" :loading="payFlag">鍘荤即璐�</el-button>
</el-form-item>
</el-form>
<!-- <el-form label-width="100px" label-position="left">-->
@@ -55,12 +55,14 @@
</template>
<script>
- export default {
+import wx from 'weixin-js-sdk'
+export default {
name: 'dashboard',
data() {
return {
payFlag:false,
outParkId:"",
+ type:null,
statisticData:{
},
@@ -68,11 +70,35 @@
showFlag2:true,
status3:0,
carNo:"",
- code2:""
+ code2:"",
+ code:""
}
},
created(){
+ let ua = window.navigator.userAgent.toLowerCase();
+ //鍒ゆ柇鏄笉鏄井淇�
+ if (ua.match(/MicroMessenger/i) == "micromessenger") {
+ // 寰俊
+ this.type = 0
+ }
+ //鍒ゆ柇鏄笉鏄敮浠樺疂
+ if (ua.match(/AlipayClient/i) == "alipayclient") {
+ //鏀粯瀹�
+ this.type = 1
+ }
+ if(this.type == null){
+ this.$message.error("璇风敤寰俊鎴栨敮浠樺疂鎵弿浜岀淮鐮�")
+ return;
+ }
+
+
var url = window.location.href;
+ var count = url.split('?').length-1;
+ if(count >1){
+ this.code = this.getCodeFromUrl(url)
+ this.code2 = this.getCode2FromUrl(url)
+ window.location.href = "http://hesuancj.cn/#/indexTest?code="+this.code+"&state=STATE&code2="+this.code2
+ }
var cs = url.split('?')[1];
var cs_arr = cs.split('&');
var cs={};
@@ -80,20 +106,22 @@
cs[cs_arr[i].split('=')[0]] = cs_arr[i].split('=')[1]
}
//this.outParkId = cs.code;
- this.code2 = cs.code;
- this.$byutil.postData(this, this.$systemconfig.basePath + '/outPark/findByBarrierCode', {code:cs.code}, res => {
- this.statisticData = res.data;
- this.outParkId = this.statisticData.id;
- this.status3 = this.statisticData.status3;
- this.payFlag = false
- if(this.status3==1){
- this.$message({
- message: '鎮ㄦ湁杩濈珷鏈鐞嗭紝璇峰厛澶勭悊鎴栬仈绯诲仠杞﹀満绠$悊浜哄憳',
- type: 'error',
- duration:5000,
- });
- }
- })
+ this.code2 = cs.code2;
+ this.code = cs.code;
+ this.$byutil.postData(this, this.$systemconfig.basePath + '/ffzf/outpark/findByBarrierCode', {code2:cs.code2}, res => {
+ this.statisticData = res.data;
+ this.outParkId = this.statisticData.id;
+ this.status3 = this.statisticData.status3;
+ this.oldCarNo = this.statisticData.carNo;
+ this.payFlag = false
+ if(this.status3==1){
+ this.$message({
+ message: '鎮ㄦ湁杩濈珷鏈鐞嗭紝璇峰厛澶勭悊鎴栬仈绯诲仠杞﹀満绠$悊浜哄憳',
+ type: 'error',
+ duration:5000,
+ });
+ }
+ })
},
methods: {
pay(){
@@ -106,9 +134,9 @@
});
return;
}
- this.$byutil.postData(this, this.$systemconfig.basePath + '/ffzf/api/park', {id:this.outParkId}, res => {
+ this.$byutil.postData(this, this.$systemconfig.basePath + '/ffzf/api/parkXT', {id:this.outParkId}, res => {
if(res.code === 0){
- window.location.href = res.msg
+ this.getCode()
this.showFlag = false
}
})
@@ -141,31 +169,112 @@
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
},
+ /**
+ * 瑙f瀽寰俊redirect_uri鍦板潃涓殑code
+ */
+ getCodeFromUrl (cur_url) {
+ let index = cur_url.split('?')[1]
+ let paramStr =index.split('&')[0];
+ let code =paramStr.split('=')[1];
+ return code
+ },
+ /**
+ * 瑙f瀽寰俊redirect_uri鍦板潃涓殑code2
+ */
+ getCode2FromUrl (cur_url) {
+ let index = cur_url.split('?')[2]
+ let code2 =index.split('=')[1];
+ return code2
+ },
+
getCode(){
- var code = this.GetQueryString('code');
- var code2 = this.GetQueryString('code2');
- alert(code,'code=====')
- if(code==null||code==""){
- var url = encodeURIComponent("hesuancj.cn");
- window.location.href ="https://open.weixin.qq.com/connect/oauth2/authorize?" +
- "appid=wxcb0e4256748b327c&redirect_uri="+url+"&response_type=code" +
- // "&scope=snsapi_userinfo&state=STATE#wechat_redirect";
- "&scope=SCOPE&state=STATE#wechat_redirect";
- }else{
- $.ajax({
- type : "POST", //鎻愪氦鏂瑰紡
- url : this.$systemconfig.basePath + '/ffzf/test/getCode',//璺緞
- data : {
- "code" : code
- },
- success : function(result) {//杩斿洖鏁版嵁鏍规嵁缁撴灉杩涜鐩稿簲鐨勫鐞�
+ if(this.type == 0 ){
+ //寰俊锛岃幏鍙朿ode
+ if(this.code==null||this.code==""){
+ var url = encodeURIComponent("http://hesuancj.cn/#/indexTest?code2="+this.code2);
+ window.location.href ="https://open.weixin.qq.com/connect/oauth2/authorize?" +
+ "appid=wx46e756aed958f895&redirect_uri="+url+"&response_type=code" +
+ "&scope=snsapi_userinfo&state=STATE#wechat_redirect";
+ //"&scope=SCOPE&state=STATE#wechat_redirect";
+ }else{
+ this.$byutil.postData(this, this.$systemconfig.basePath + '/ffzf/api/getOpenId', {id:this.outParkId,code:this.code}, res => {
+ if(res.code === 0){
+ var param = res.data;
+ alert(param)
+ // 鐐瑰嚮鏀粯鏃跺�欒皟鐢�
+ if (typeof WeixinJSBridge === 'undefined') {
+ if (document.addEventListener) {
+ document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(param), false)
+ } else if (document.attachEvent) {
+ document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(param))
+ document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(param))
+ }
+ } else {
+ this.onBridgeReady(param)
+ }
+ this.showFlag = false
+ }else {
+ alert('寰俊鏀粯璋冭捣澶辫触锛�')
+ }
+ })
+ }
+ }else if(this.type == 1){
+ //鏀粯瀹濓紝涓嶈幏鍙朿ode
+ this.$byutil.postData(this, this.$systemconfig.basePath + '/ffzf/api/payByAli', {id:this.outParkId}, res => {
+ if(res.code != 0){
+ alert(res.data)
+ this.showFlag = false
+ }else {
+ this.$message({
+ message: '2绉掑悗鑷姩璺宠浆鍒版敮浠橀〉闈紝闃叉鍐呭缃戞暟鎹悓姝ュ欢杩燂紝璇风◢绛�',
+ type: 'success',
+ duration:2000,
+ });
+ setTimeout(function(){window.location.href = res.msg;},2000);
+ this.showFlag = false;
}
- });
- }
- }
+ })
+ }
+ },
+ onBridgeReady (params) {
+ const that = this
+ WeixinJSBridge.invoke(
+ 'getBrandWCPayRequest',
+ {
+ appId: params.appId, // 鍏紬鍙峰悕绉帮紝鐢卞晢鎴蜂紶鍏�
+ timeStamp: params.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴筹紝娉ㄦ剰寰俊jssdk涓殑鎵�鏈変娇鐢╰imestamp瀛楁鍧囦负灏忓啓銆備絾鏈�鏂扮増鐨勬敮浠樺悗鍙扮敓鎴愮鍚嶄娇鐢ㄧ殑timeStamp瀛楁鍚嶉渶澶у啓鍏朵腑鐨凷瀛楃
+ nonceStr: params.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣�
+ package: params.prepay_id, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_id鍙傛暟鍊硷紝鎻愪氦鏍煎紡濡傦細prepay_id=\*\*\*锛�
+ signType: params.signType, // 绛惧悕鏂瑰紡锛岄粯璁や负'SHA1'锛屼娇鐢ㄦ柊鐗堟敮浠橀渶浼犲叆'MD5'
+ paySign: params.paySign // 鏀粯绛惧悕
+ },
+ (res) => {
+ if (res.err_msg === 'get_brand_wcpay_request:ok') {
+ that.queryOrder() // 杩欓噷鏄煡璇㈣鍗曟槸鍚︽敮浠樺畬鎴愶紝鐒跺悗鎵ц鎴愬姛鍜屽け璐ョ殑涓氬姟閫昏緫
+ } else if (res.err_msg === 'get_brand_wcpay_request:fail') {
+ alert('鏀粯澶辫触锛�')
+ } else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
+ alert('鏀粯鍙栨秷锛�')
+ }
+ }
+ )
+ },
+ queryOrder() {
+ this.$byutil.postData(this, this.$systemconfig.basePath + '/ffzf/outpark/getById', {id: this.outParkId}, res => {
+ if (res.code == 0) {
+ let outpark = res.data
+ if(outPark.status == 1){
+ window.location.href = "http://hesuancj.cn/#/indexOk?code2="+this.code2
+ }else {
+ window.location.href = "http://hesuancj.cn/#/indexFail?code2="+this.code2
+ }
+ }
+ })
+ }
}
+
}
</script>
--
Gitblit v1.9.1