Commit 0849334c64e3f4941df9be92a11eb08f571096d6
1 parent
94a4ee91
宣化聚合支付
Showing
3 changed files
with
65 additions
and
10 deletions
src/utils/request.js
@@ -8,7 +8,7 @@ const service = axios.create({ | @@ -8,7 +8,7 @@ const service = axios.create({ | ||
8 | // http://pay.service.renniting.cn/ 赤峰 | 8 | // http://pay.service.renniting.cn/ 赤峰 |
9 | // http://pay.service.huangshiparking.com/ 黄石正式环境 | 9 | // http://pay.service.huangshiparking.com/ 黄石正式环境 |
10 | // http://39.98.54.240:8090/ 黄石测试环境 | 10 | // http://39.98.54.240:8090/ 黄石测试环境 |
11 | - baseURL: 'http://wxzhifu.natapp1.cc', // url = base url + request url | 11 | + baseURL: 'http://test.ccccitd.cc/pay', // url = base url + request url |
12 | // withCredentials: true, // send cookies when cross-domain requests | 12 | // withCredentials: true, // send cookies when cross-domain requests |
13 | timeout: 6000 // request timeout | 13 | timeout: 6000 // request timeout |
14 | }) | 14 | }) |
src/views/binding/binDing.vue
@@ -29,7 +29,7 @@ export default { | @@ -29,7 +29,7 @@ export default { | ||
29 | }, | 29 | }, |
30 | created() { | 30 | created() { |
31 | this.timeNum = this.timeText; | 31 | this.timeNum = this.timeText; |
32 | - this.webAppCode = this.getWxCode(); // 正式打开注释 | 32 | + // this.webAppCode = this.getWxCode(); // 正式打开注释 |
33 | }, | 33 | }, |
34 | methods: { | 34 | methods: { |
35 | getWxCode() { | 35 | getWxCode() { |
@@ -79,7 +79,9 @@ export default { | @@ -79,7 +79,9 @@ export default { | ||
79 | bindPhoneHandle() { | 79 | bindPhoneHandle() { |
80 | const reg = /^1[3-9]\d{9}$/; | 80 | const reg = /^1[3-9]\d{9}$/; |
81 | if (reg.test(this.phone)) { | 81 | if (reg.test(this.phone)) { |
82 | - this.getOpenIdByCode(); // 获取openid | 82 | + // this.getOpenIdByCode(); // 获取openid |
83 | + | ||
84 | + this.bindCustByOpenId(this.$route.query.openid) | ||
83 | 85 | ||
84 | } else { | 86 | } else { |
85 | this.$toast("请输入正确手机号"); | 87 | this.$toast("请输入正确手机号"); |
@@ -137,7 +139,10 @@ export default { | @@ -137,7 +139,10 @@ export default { | ||
137 | localStorage.setItem('userToken',response.data.token) | 139 | localStorage.setItem('userToken',response.data.token) |
138 | localStorage.setItem('userPhoneNum',response.data.phoneNum) | 140 | localStorage.setItem('userPhoneNum',response.data.phoneNum) |
139 | this.$router.push({ | 141 | this.$router.push({ |
140 | - name: "selfNav" | 142 | + name: "selfNav", |
143 | + query:{ | ||
144 | + openId:openId | ||
145 | + } | ||
141 | } | 146 | } |
142 | ); | 147 | ); |
143 | } | 148 | } |
src/views/mySelf/selfNav.vue
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | 38 | ||
39 | <script> | 39 | <script> |
40 | 40 | ||
41 | -import { getTokenByOpenId } from "@/api/getUserIfo"; | 41 | +import { getTokenByOpenId, getOpenIdByCode } from "@/api/getUserIfo"; |
42 | export default { | 42 | export default { |
43 | name: "selfNav", | 43 | name: "selfNav", |
44 | data() { | 44 | data() { |
@@ -63,7 +63,7 @@ export default { | @@ -63,7 +63,7 @@ export default { | ||
63 | }, | 63 | }, |
64 | 64 | ||
65 | created() { | 65 | created() { |
66 | - | 66 | + // this.phoneNum = localStorage.getItem('userPhoneNum') |
67 | }, | 67 | }, |
68 | mounted() { | 68 | mounted() { |
69 | // this.openId = this.$utils.openId; | 69 | // this.openId = this.$utils.openId; |
@@ -71,11 +71,58 @@ export default { | @@ -71,11 +71,58 @@ export default { | ||
71 | // this.getTokenAndphoneNum(); | 71 | // this.getTokenAndphoneNum(); |
72 | // } | 72 | // } |
73 | // console.log(this.openId); | 73 | // console.log(this.openId); |
74 | + // this.phoneNum = localStorage.getItem('userPhoneNum') | ||
75 | + | ||
76 | + | ||
77 | + if(this.$route.query.openId){ | ||
78 | + this.openId = this.$route.query.openId | ||
79 | + this.getTokenAndphoneNum(this.openId) | ||
80 | + }else{ | ||
81 | + this.webAppCode = this.getWxCode(); | ||
82 | + this.getOpenIdByCode() | ||
83 | + } | ||
74 | 84 | ||
75 | - this.phoneNum = this.$utils.userPhoneNum | ||
76 | console.log(this.$utils.userPhoneNum) | 85 | console.log(this.$utils.userPhoneNum) |
77 | }, | 86 | }, |
78 | methods: { | 87 | methods: { |
88 | + getWxCode() { | ||
89 | + var appID = this.$utils.myVxAppId; | ||
90 | + var code = this.getUrlParam("code"); | ||
91 | + var local = window.location.href; | ||
92 | + if (code == null || code === "") { | ||
93 | + window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect"; | ||
94 | + } else { | ||
95 | + return code; | ||
96 | + } | ||
97 | + }, | ||
98 | + getUrlParam(name) { // 获取url里面的参数 | ||
99 | + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | ||
100 | + var r = window.location.search.substr(1).match(reg) | ||
101 | + if (r != null) return unescape(r[2]) | ||
102 | + return null | ||
103 | + }, | ||
104 | + getOpenIdByCode() { // 获取openid | ||
105 | + | ||
106 | + // this.bindCustByOpenId() // 正式注释 | ||
107 | + | ||
108 | + | ||
109 | + | ||
110 | + // 正式打开注释 | ||
111 | + | ||
112 | + let jsondata = { | ||
113 | + appId: this.$utils.myVxAppId, | ||
114 | + code: this.webAppCode | ||
115 | + }; | ||
116 | + jsondata.sign = this.$utils.signObject(jsondata); | ||
117 | + console.log("停车记录传参 " + JSON.stringify(jsondata)); | ||
118 | + getOpenIdByCode(jsondata).then(response => { | ||
119 | + if(response.code=='0'){ | ||
120 | + let openId = response.data | ||
121 | + this.openId = openId | ||
122 | + this.getTokenAndphoneNum(openId) // 获取token和用户手机号 | ||
123 | + } | ||
124 | + }); | ||
125 | + }, | ||
79 | toNextPage(path) { | 126 | toNextPage(path) { |
80 | if (this.phoneNum) { | 127 | if (this.phoneNum) { |
81 | this.$router.push({ | 128 | this.$router.push({ |
@@ -92,13 +139,16 @@ export default { | @@ -92,13 +139,16 @@ export default { | ||
92 | }, | 139 | }, |
93 | toBindingPage() { | 140 | toBindingPage() { |
94 | this.$router.push({ | 141 | this.$router.push({ |
95 | - name: "binDing" | 142 | + name: "binDing", |
143 | + query:{ | ||
144 | + openid: this.openId | ||
145 | + } | ||
96 | } | 146 | } |
97 | ); | 147 | ); |
98 | }, | 148 | }, |
99 | - getTokenAndphoneNum() { | 149 | + getTokenAndphoneNum(openId) { |
100 | let jsondata = { | 150 | let jsondata = { |
101 | - openid: this.$utils.openId | 151 | + openid: openId |
102 | }; | 152 | }; |
103 | jsondata.sign = this.$utils.signObject(jsondata); | 153 | jsondata.sign = this.$utils.signObject(jsondata); |
104 | console.log("停车记录传参 " + JSON.stringify(jsondata)); | 154 | console.log("停车记录传参 " + JSON.stringify(jsondata)); |