Authored by lzhy

Merge branch 'master' into feature/optimize20200528

* master:
  chore(*): npm version
  fix(电子刊): 电子刊资源解析
  fix(电子刊): 自定义购买数量bug修复
  fix(电子刊): 购买数量获取失败
  chore(*): npm verison
... ... @@ -24,6 +24,7 @@ const indexModel = require('../models/index');
const index = async function(req, res, next) {
let {e_id, token = ''} = req.query;
let isApp = req.yoho.isApp;
let userAgent = req.get('User-Agent');
let isYohobuy = /yohobuy/i.test(userAgent);
... ... @@ -76,7 +77,6 @@ const index = async function(req, res, next) {
let code = magazineInfo.data.code;
// 4000:获取成功 4001: 未购买该电子刊 4002:未获取到电子刊 4003:电子刊已删除
if (code === 4000) {
let url = magazineInfo.data.link;
... ... @@ -96,21 +96,35 @@ const index = async function(req, res, next) {
// HYPE生成的html有其固定格式的div id,此处获取的也是这个hype创建时的名称,此名称对应插入的js
if (idMatch && idMatch.length >= 2) {
let name = idMatch[1];
let id = `${name}_hype_container`;
let script = $(`#${id}`).html();
let head = $('head').html();
head = head.replace(/href="(.*)"/g, function(match, p1) {
if (p1.indexOf('//') > -1) {
return p1;
}
const src = p1.indexOf('.') > -1 ? p1.slice(2) : p1;
return 'href=' + resourceUrl + src;
});
$('head').html(head);
let htmlString = $.html();
let scriptSrc = script.match(/src="(.*)"/);
let hasHypeScript = /_hype_generated_script/.test(htmlString);
// 获取到对应div里面的script的src,并替换成带有域名的地址,可以让所有图片地址指向js对应的域名
if (scriptSrc && scriptSrc.length >= 2) {
let src = scriptSrc[1];
let newScript = '<script type="text/javascript" charset="utf-8" src="' +
resourceUrl + src + '">';
if (hasHypeScript) {
htmlString = htmlString.replace(/src="(.*)"/g, function(match, p1) {
if (p1.indexOf('//') > -1) {
return p1;
}
const src = p1.indexOf('.') > -1 ? p1.slice(2) : p1;
$(`#${id}`).html(newScript);
return 'src=' + resourceUrl + src;
});
return res.send($.html()); // 输出修改过的html
return res.send(htmlString); // 输出修改过的html
} else {
return renderErroPage({msg: NO_HYPE_SCRIPT});
}
... ...
... ... @@ -17,7 +17,7 @@
<p class="m-title">{{title}}</p>
<div class="magazine-info">
<div class="m-order to-download">如何订阅
<div class="m-order to-download">如何阅读
<i class="iconfont">&#xe614;</i>
</div>
{{#if subcribeCount }}
... ...
{
"name": "yohobuywap-node",
"version": "6.13.9",
"version": "6.13.12",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -24,7 +24,7 @@ $('.choose-list').on('click', '.choose-item', function(e) {
let data = $elm.data();
$totalPrice.text(data.price);
buyNumber = data.num;
buyNumber = data.number;
}
$activeItem.length && $activeItem.removeClass('active');
... ... @@ -41,6 +41,7 @@ $customNumInput.on('input', function() {
if (val !== handelVal) {
$(this).val(handelVal);
}
buyNumber = +handelVal;
}).on('change', function() {
let val = $(this).val();
... ...