Authored by TaoHuang

update app grass share picture

1 import {get, first} from 'lodash'; 1 import {get, first} from 'lodash';
  2 +const qs = require('yoho-qs');
  3 +const cookie = require('yoho-cookie');
  4 +
  5 +let app_version = cookie.get('app_version') || qs.app_version || '';
  6 +
  7 +function _version2num(version) {
  8 + if (!version) {
  9 + return 0;
  10 + }
  11 +
  12 + let [m, j, b] = version.split(',');
  13 +
  14 + return (+m) * 10000 + (+j) * 100 + (+b);
  15 +}
  16 +
  17 +function versionCompare(left, right) {
  18 + let leftNum = _version2num(left);
  19 + let rightNum = _version2num(right);
  20 +
  21 + if (leftNum === rightNum) {
  22 + return 0;
  23 + } else if (leftNum > rightNum) {
  24 + return 1;
  25 + } else {
  26 + return -1;
  27 + }
  28 +}
2 29
3 const DEFAULT_SHARE_IMAGE = 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png'; 30 const DEFAULT_SHARE_IMAGE = 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png';
4 31
@@ -35,12 +62,19 @@ const getDetailShareData = (article) => { @@ -35,12 +62,19 @@ const getDetailShareData = (article) => {
35 shareImage = `${window ? window.location.protocol : ''}//${shareImage.split('//')[1]}`; 62 shareImage = `${window ? window.location.protocol : ''}//${shareImage.split('//')[1]}`;
36 } 63 }
37 64
  65 + const requiredVersion = '6.9.11';
  66 + let hideType = ['7', '8', '9'];
  67 +
  68 + if (versionCompare(app_version, requiredVersion) >= 0) {
  69 + hideType = ['8', '9'];
  70 + }
  71 +
38 return { 72 return {
39 title: `@${article.authorName} 在有货社区上发了一篇内容,快点开看看!`, 73 title: `@${article.authorName} 在有货社区上发了一篇内容,快点开看看!`,
40 imgUrl: handleProtocol(get(shareImage.split('?'), '[0]') || DEFAULT_SHARE_IMAGE), 74 imgUrl: handleProtocol(get(shareImage.split('?'), '[0]') || DEFAULT_SHARE_IMAGE),
41 link: handleProtocol(`${window ? window.location.origin : ''}/grass/article/${article.articleId}?share=true`), 75 link: handleProtocol(`${window ? window.location.origin : ''}/grass/article/${article.articleId}?share=true`),
42 desc, 76 desc,
43 - hideType: ['8', '9'], 77 + hideType,
44 shareType: 'grassDetail', 78 shareType: 'grassDetail',
45 userName: article.authorName, 79 userName: article.authorName,
46 userIcon: article.authorHeadIco, 80 userIcon: article.authorHeadIco,
1 { 1 {
2 "name": "yoho-community-web", 2 "name": "yoho-community-web",
3 - "version": "6.9.11-beta2", 3 + "version": "6.9.11-beta3",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {