Authored by 李奇

webview逻辑修改

@@ -174,4 +174,7 @@ const api = { @@ -174,4 +174,7 @@ const api = {
174 } 174 }
175 }; 175 };
176 176
177 -export default api; 177 +module.exports = {
  178 + api,
  179 + verify
  180 +};
1 -import api from '../../common/api';  
2 import config from '../../config'; 1 import config from '../../config';
  2 +import { api } from '../../common/api';
3 3
4 export default { 4 export default {
5 /** 5 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../common/api'; 1 +import { api } from '../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
@@ -26,5 +26,19 @@ export default { @@ -26,5 +26,19 @@ export default {
26 method: 'app.shops.union' 26 method: 'app.shops.union'
27 }, params) 27 }, params)
28 }); 28 });
  29 + },
  30 +
  31 + /**
  32 + * 通过AppId查绑定店铺
  33 + * @param params
  34 + * @returns {*}
  35 + */
  36 + getMiniAppRealParam(code) {
  37 + return api.get({
  38 + url: '/wechat/miniapp/getMiniAppRealParam',
  39 + data: {
  40 + code
  41 + }
  42 + });
29 } 43 }
30 }; 44 };
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 /** 4 /**
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 shopList() { 4 shopList() {
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 getContent(content_code) { 4 getContent(content_code) {
1 -import api from '../../common/api'; 1 +import { api } from '../../common/api';
2 2
3 export default { 3 export default {
4 shopSort(params) { 4 shopSort(params) {
  1 +import config from '../../config';
  2 +import { verify } from '../../common/api';
  3 +import commonModel from '../../models/common';
  4 +
1 Page({ 5 Page({
2 data: { 6 data: {
3 url: '', 7 url: '',
@@ -5,8 +9,19 @@ Page({ @@ -5,8 +9,19 @@ Page({
5 }, 9 },
6 10
7 onLoad: function(options) { 11 onLoad: function(options) {
8 - this.loadElement(options); 12 + if (options && options.scene && options.scene.length > 0) {
  13 + let code = options.scene;
9 14
  15 + return commonModel.getMiniAppRealParam(code)
  16 + .then(json => {
  17 + if (json) {
  18 + this.load(json);
  19 + }
  20 + })
  21 + .catch(() => {});
  22 + }
  23 +
  24 + this.load(options);
10 }, 25 },
11 26
12 onShareAppMessage: function() { 27 onShareAppMessage: function() {
@@ -16,11 +31,28 @@ Page({ @@ -16,11 +31,28 @@ Page({
16 }; 31 };
17 }, 32 },
18 33
19 - loadElement: function(options) { 34 + load: function(options) {
  35 + let app = getApp();
  36 + let url = options.url;
  37 +
  38 + if (options && options.url) {
  39 + let params = {};
  40 + let sys = wx.getSystemInfoSync();
  41 +
  42 + params.uid = app.getUid();
  43 + params.udid = app._getSync('udid');
  44 + params.session_key = app._getSync('sessionKey');
  45 + params.app_version = config.apiParams.app_version;
  46 + params.client_type = config.apiParams.client_type;
  47 + params.screen_size = `${sys.windowWidth}x${sys.windowHeight}`;
  48 + params.os_version = sys.version;
  49 +
  50 + verify.sign(params);
  51 +
20 this.setData({ 52 this.setData({
21 - title: options.title,  
22 - url: decodeURIComponent(options.url) 53 + url: decodeURIComponent(`${url}`)
23 }); 54 });
  55 + }
24 }, 56 },
25 57
26 bindGetMsg: function(e) { 58 bindGetMsg: function(e) {
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 "list": [] 29 "list": []
30 }, 30 },
31 "miniprogram": { 31 "miniprogram": {
32 - "current": 1, 32 + "current": -1,
33 "list": [ 33 "list": [
34 { 34 {
35 "id": -1, 35 "id": -1,