Authored by yyq

Merge remote-tracking branch 'origin/master' into feature/yoluckShare

... ... @@ -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');
... ... @@ -13,6 +15,7 @@ let yoho = require('js/yoho-app');
let Clipboard = require('clipboard');
let makeShareData = require('./yoluck/share');
let Lottery = require('./yoluck/lottery');
let versionCompare = require('./yoluck/version');
function reload() {
location = location; //eslint-disable-line
... ... @@ -23,7 +26,9 @@ require('js/common');
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');
... ... @@ -37,6 +42,7 @@ let shareData;
let lottery = new Lottery('#lottery-list');
let sharePlugin = require('js/common/share');
loading.init($(document.body), {timeout: 20000});
new Swiper('.swiper-container', {
direction: 'vertical',
lazyLoading: true,
... ... @@ -45,7 +51,6 @@ new Swiper('.swiper-container', {
autoplay: 4000
});
function fellow() {
$.yAlert({
content: `<div>公众号
... ... @@ -54,6 +59,10 @@ function fellow() {
});
}
function alertVersion() {
$.yAlert({content: '您的版本较低,请更新最新版本体验'});
}
function getUser() {
try {
if (user) {
... ... @@ -91,7 +100,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 (/QQ/i.test(navigator.userAgent) ||
/MicroMessenger/i.test(navigator.userAgent)) {
yoSdk.tip({tipClassName: 'yoluck-guide-mask'});
... ...
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 = {
... ... @@ -66,6 +70,8 @@ let prizeListStore = {
return this.list[id];
}
};
let currentVersion = cookie.get('app_version');
let targetVersion = '6.8.3';
function initStore() {
// 初始化为
... ... @@ -223,6 +229,10 @@ function fellow(id) {
});
}
function alertVersion() {
$.yAlert({content: '您的版本较低,请更新最新版本体验'});
}
function getUser() {
try {
if (store.user) {
... ... @@ -255,7 +265,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') {
if (/QQ/i.test(navigator.userAgent) ||
/MicroMessenger/i.test(navigator.userAgent)) {
... ... @@ -331,9 +358,7 @@ $tabpanel
return false;
})
.on('click', '.js-share', function() {
getUser().then(() => {
share($(this));
});
share($(this));
return false;
})
.on('click', '.js-fellow', function() {
... ...
... ... @@ -16,25 +16,36 @@ function h5Name(name) {
return `【0元抽奖】${name}`;
}
function h5Desc() {
return '【限时抽奖】0元免费拿';
}
function shareData({name, imgUrl, price, shareUid, actPrizeId}) {
let link = h5Path(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: link,
desc: '限时抽奖活动'
desc: h5Desc(name),
hideType: ['7', '8', '9']
},
h5: {
title: h5Name(name),
imgUrl: imgUrl,
link: link,
desc: '【限时抽奖】0元免费拿',
desc: h5Desc(name),
copyDeac: `【0元抽奖】点一下免费拿走${name} ${link} (分享自@Yoho!Buy有货APP)`
}
};
... ...
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;
... ...
... ... @@ -10,6 +10,7 @@
@import "time-countdown";
@import "luck-alert";
@import "~scss/layout/modal";
@import "~scss/layout/loading";
.line {
height: 20px;
... ... @@ -37,14 +38,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;
... ...