Authored by 黄敬囿

Merge branch 'UFO_1.0.0' of http://git.yoho.cn/mobile/yoho-miniapp-ufo into UFO_1.0.0

@@ -13,6 +13,7 @@ import collect from '../../static/images/collect.png'; @@ -13,6 +13,7 @@ import collect from '../../static/images/collect.png';
13 import collectOff from '../../static/images/collect-off.png'; 13 import collectOff from '../../static/images/collect-off.png';
14 import './index.scss'; 14 import './index.scss';
15 import event from '../../utils/event' 15 import event from '../../utils/event'
  16 +import { getQRCodeSource } from '../../libs/miniQRCodeRoute'
16 17
17 const SHARE_FRIENDS = 'user-share-friends'; 18 const SHARE_FRIENDS = 'user-share-friends';
18 const SHARE_MOMENTS = 'user-share-moments'; 19 const SHARE_MOMENTS = 'user-share-moments';
@@ -76,20 +77,52 @@ export default class ProductDetail extends Component { @@ -76,20 +77,52 @@ export default class ProductDetail extends Component {
76 } 77 }
77 } 78 }
78 componentDidMount() { 79 componentDidMount() {
79 - let id = this.$router.params.id; 80 + let options = this.$router.params;
80 81
81 - var scene = decodeURIComponent(this.$router.params.scene)  
82 console.log('===================================='); 82 console.log('====================================');
83 - console.log(this.$router.params); 83 + console.log(options);
  84 + console.log('====================================');
  85 +
  86 + if (options && options.scene && options.scene.length == 32) {
  87 + let code = options.scene;
  88 + getQRCodeSource(code).then(json => {
  89 + console.log('====================================');
  90 + console.log(json);
  91 + console.log('====================================');
  92 + if (json) {
  93 + this.loadElement(json);
  94 + }
  95 + })
  96 + .catch(error => {
  97 + });
  98 + } else {
  99 + this.loadElement(options);
  100 + }
  101 + }
  102 +
  103 + loadElement(options) {
  104 + let productId = options.id
  105 +
  106 + if (options && options.scene && options.scene.length > 0) {
  107 + var scene = decodeURIComponent(options.scene)
  108 + var arr = scene ? scene.split("&") : [];
  109 + console.log('====================================');
84 console.log(scene); 110 console.log(scene);
  111 + console.log(arr);
85 console.log('===================================='); 112 console.log('====================================');
  113 +
  114 + if (arr.length == 1) {
  115 + productId = scene;
  116 + }
  117 + }
  118 +
86 this.setState({ 119 this.setState({
87 - id: id 120 + id: productId
88 }); 121 });
89 122
90 - this.getProductData(id);  
91 - this.getRecommendGoods(id);  
92 - this.getFavoriteState(id); 123 + this.getProductData(productId);
  124 + this.getRecommendGoods(productId);
  125 + this.getFavoriteState(productId);
93 126
94 event.on(SHARE_CANCEL, () => { 127 event.on(SHARE_CANCEL, () => {
95 this.onCancelSharesheetCallback(); 128 this.onCancelSharesheetCallback();
@@ -2,6 +2,7 @@ import rules from './rules'; @@ -2,6 +2,7 @@ import rules from './rules';
2 import router from './router' 2 import router from './router'
3 const urlParse = require('url'); 3 const urlParse = require('url');
4 const queryString = require('querystring'); 4 const queryString = require('querystring');
  5 +import Taro from '@tarojs/taro'
5 6
6 const ACTION_TYPE = { 7 const ACTION_TYPE = {
7 h5: 'go.h5', 8 h5: 'go.h5',