Commit c47d445549522e49091d32971fe765fcf8ba6124

Authored by liuqimichale
1 parent 8676f3af

小票码 输入车牌页面 授权

src/components/plateNumber.vue
... ... @@ -294,8 +294,22 @@ export default {
294 294 }
295 295 },
296 296 mounted () {
  297 + var appID = this.$utils.myVxAppId;
  298 + var code = this.getUrlParam('code');
  299 + var local = window.location.href;
  300 + if (code == null || code === '') {
  301 + 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,0#wechat_redirect'
  302 + } else {
  303 + return code;
  304 + }
297 305 },
298 306 methods: {
  307 + getUrlParam(name) {
  308 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  309 + var r = window.location.search.substr(1).match(reg)
  310 + if (r != null) return unescape(r[2])
  311 + return null
  312 + },
299 313 chooseColor (index){ // 颜色选择
300 314 this.currentColor = index
301 315 switch (this.currentColor) {
... ...
src/router/index.js
... ... @@ -11,7 +11,7 @@ export default new Router({
11 11 {
12 12 path: '/',
13 13 redirect: {
14   - name: 'navigation'
  14 + name: 'plateNumber'
15 15 }
16 16 },
17 17 {
... ...