Authored by 王水玲

Merge branch 'master' into feature/activity-spike

... ... @@ -4,7 +4,7 @@
<p class="name">{{name}}</p>
</div>
{{#if roundInfo}}
<div class="swiper-container" data-loop="1" data-autoplay="2000">
<div class="swiper-container" data-loop="1" data-autoplay="3000">
<div class="swiper-wrapper">
{{#roundInfo}}
<div class="swiper-slide" style="{{styleFormat this percent=1}}">
... ...
... ... @@ -51,7 +51,7 @@ module.exports = {
appName: 'yohobuywap-node',
port: 6001,
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001/yohobuywap-node/',
assetUrl: '//m.yohobuy.com:5001/yohobuywap-node/',
testCode: 'yoho4946abcdef#$%&!@',
domains: domains,
... ...
{
"name": "yohobuywap-node",
"version": "6.8.54",
"version": "6.8.59",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
import 'scss/activity/yoluck/yoluck-detail.page.scss';
const cookie = require('yoho-cookie');
let Swiper = require('yoho-swiper');
const loading = require('js/plugin/loading');
let timeCountDownTpl = require('hbs/activity/yoluck/time-countdown.hbs');
let luckAlertTpl = require('hbs/activity/yoluck/luck-alert.hbs');
let formatCountDown = require('./yoluck/formatCountDown');
... ... @@ -12,6 +14,7 @@ let yoho = require('js/yoho-app');
let Clipboard = require('clipboard');
let makeShareData = require('./yoluck/share');
let versionCompare = require('./yoluck/version');
function reload() {
location = location; //eslint-disable-line
... ... @@ -21,7 +24,9 @@ require('js/plugin/modal.alert');
let store = {
running: false,
shareUid: window.queryString.shareUid || ''
shareUid: window.queryString.shareUid || '',
currentVersion: cookie.get('app_version'),
targetVersion: '6.8.3',
};
let $product = $('.product_name');
... ... @@ -32,6 +37,7 @@ let id = $product.data('id');
let user;
let shareData;
loading.init($(document.body), {timeout: 20000});
new Swiper('.swiper-container', {
direction: 'vertical',
lazyLoading: true,
... ... @@ -40,7 +46,6 @@ new Swiper('.swiper-container', {
autoplay: 4000
});
function fellow() {
$.yAlert({
content: `<div>公众号
... ... @@ -49,6 +54,10 @@ function fellow() {
});
}
function alertVersion() {
$.yAlert({content: '您的版本较低,请更新最新版本体验'});
}
function getUser() {
try {
if (user) {
... ... @@ -74,7 +83,25 @@ getUser();
function share() {
if (yoSdk.env === 'app') {
yoho.invokeMethod('go.showshareaction', shareData && shareData.app);
// 由于app版本兼容性问题
if (versionCompare(store.currentVersion, store.targetVersion) < 0) {
alertVersion();
return;
}
loading.showLoading();
if (store.running) {
return;
}
store.running = true;
getUser().then(() => {
yoho.invokeMethod('go.showshareaction', shareData && shareData.app);
loading.hideLoading();
store.running = false;
});
} else if (yoSdk.env === 'h5') {
$('.js-clipbroad').trigger('click');
}
... ...
import 'scss/activity/yoluck/yoluck-list.page.scss';
const cookie = require('yoho-cookie');
const loading = require('js/plugin/loading');
let $ = require('yoho-jquery');
let Api = require('./yoluck/api');
let productTpl = require('hbs/activity/yoluck/product-item.hbs');
... ... @@ -13,9 +15,11 @@ const makeShareData = require('./yoluck/share');
const DETAIL_URI = location.protocol + '//m.yohobuy.com/activity/yoluck';
let Clipboard = require('clipboard');
let versionCompare = require('./yoluck/version');
require('js/plugin/modal.alert');
loading.init($(document.body), {timeout: 20000});
let footerText = ['内容加载中...', '暂无更多内容'];
let store = {
... ... @@ -48,6 +52,9 @@ let tabpanelStore = {
footer: null
};
let currentVersion = cookie.get('app_version');
let targetVersion = '6.8.3';
function initStore() {
// 初始化为
let tabIndex = +$tabpanel.data('type');
... ... @@ -181,6 +188,10 @@ function fellow() {
});
}
function alertVersion() {
$.yAlert({content: '您的版本较低,请更新最新版本体验'});
}
function getUser() {
try {
if (store.user) {
... ... @@ -213,7 +224,24 @@ function share($el) {
});
if (yoSdk.env === 'app') {
yoho.invokeMethod('go.showshareaction', store.shareData && store.shareData.app);
// 由于app版本兼容性问题
if (versionCompare(currentVersion, targetVersion) < 0) {
alertVersion();
return;
}
loading.showLoading();
if (store.running) {
return;
}
store.running = true;
getUser().then(() => {
yoho.invokeMethod('go.showshareaction', store.shareData && store.shareData.app);
loading.hideLoading();
store.running = false;
});
} else if (yoSdk.env === 'h5') {
$('.js-clipbroad').trigger('click');
}
... ... @@ -281,9 +309,7 @@ $tabpanel
return false;
})
.on('click', '.js-share', function() {
getUser().then(() => {
share($(this));
});
share($(this));
return false;
})
.on('click', '.js-fellow', function() {
... ...
... ... @@ -16,23 +16,34 @@ function h5Name(name) {
return `【0元抽奖】${name}`;
}
function h5Desc(name) {
return `【限时抽奖】0元免费拿${name}`;
}
function shareData({name, imgUrl, price, shareUid, actPrizeId}) {
let urls = imgUrl.split('?');
let shareImg = urls[0] || imgUrl;
if (urls[0]) {
shareImg = `${shareImg}?imageView2/2/w/375/h/235/q/60`;
}
return {
app: {
shareType: 'yoluck',
title: name,
imgUrl: imgUrl,
imgUrl: shareImg,
market_price: price,
miniProgramUrl: miniPath(shareUid, actPrizeId),
miniProgramQCodeUrl: miniQrcode(shareUid, actPrizeId),
link: h5Path(shareUid, actPrizeId),
desc: '限时抽奖活动'
desc: h5Desc(name),
hideType: ['7', '8', '9']
},
h5: {
title: h5Name(name),
imgUrl: imgUrl,
link: h5Path(shareUid, actPrizeId),
desc: '限时抽奖活动'
desc: h5Desc(name)
}
};
}
... ...
function toVersion(str) {
const ver = str.split('.').map(i => Number(i));
if (!ver[0]) {
ver[0] = 0;
}
if (!ver[1]) {
ver[1] = 0;
}
if (!ver[2]) {
ver[2] = 0;
}
return ver;
}
function toNumber(ver) {
const major = ver[0] * 10000;
const minor = ver[1] * 100;
const patch = ver[2] * 1;
return major + minor + patch;
}
function compare(left, right) {
if (left > right) {
return 1;
} else if (left < right) {
return -1;
} else {
return 0;
}
}
module.exports = function(left, right) {
const leftVersion = toNumber(toVersion(left));
const rightVersion = toNumber(toVersion(right));
const result = compare(leftVersion, rightVersion);
return result;
};
... ...
... ... @@ -34,6 +34,8 @@ function init($container, options) {
$loading = $container.children('.loading-mask');
timeOut = options && options.timeout || timeOut;
// 产品优化loading时可以滑动
// $('body').on('touchstart touchmove touchend', '.loading-mask', function() {
// return false;
... ...
... ... @@ -9,6 +9,7 @@
@import "time-countdown";
@import "luck-alert";
@import "~scss/layout/modal";
@import "~scss/layout/loading";
.line {
height: 20px;
... ... @@ -36,14 +37,14 @@
position: fixed;
width: 100%;
top: 0;
z-index: 10;
z-index: 8;
}
.action-bar {
position: fixed;
width: 100%;
bottom: 0;
z-index: 10;
z-index: 8;
}
.foot {
... ...
... ... @@ -5,6 +5,7 @@
@import "tabs";
@import "time-countdown";
@import "~scss/layout/modal";
@import "~scss/layout/loading";
.product {
display: block;
... ...