Authored by 陈峰

Merge branch 'feature/redenvelope' into 'master'

Feature/redenvelope



See merge request !8
{
"presets": ["es2015-rollup"],
"presets": [
[
"@babel/env",
{
"modules": false,
"targets": {}
}
]
],
"exclude": [
"node_modules/*"
]
}
\ No newline at end of file
... ...
registry=http://npm.yohops.com
package-lock=false
\ No newline at end of file
... ...
... ... @@ -10,6 +10,7 @@
### 2. 促销相关
1. 优惠券领取
2. YOHO币领取
3. 红包领取
### 3. 分享相关
1. 分享到微信好友
... ... @@ -62,7 +63,18 @@
</a>
```
6. 分享相关:
6. 红包领取:
<a> 标签加上`yoho-redenvelope`类名,并加上 `data-token` 属性,值为后台生成的 token。
示例:
```html
<a class="yoho-redenvelope" href="javascript:;" data-token="29-6ea9ab1baa0efb9e19094440c317e21b">
<h1>红包按钮</h1>
</a>
```
7. 分享相关:
如果需要定制分享参数时,通过<input type="hidden">方式自定义
示例:
... ... @@ -74,9 +86,9 @@
<input id="shareTitle" type="hidden" value="【YOHO!BUY有货】12月28日潮集会员日">
```
7. 个性化推荐:
8. 个性化推荐:
7.1. 定义商品模版
8.1. 定义商品模版
示例:
... ... @@ -106,7 +118,7 @@
</div>
```
7.2. 详细说明
8.2. 详细说明
以下属性class/id 需要固定不变,引入的 jssdk 会通过class名 来做动态替换
... ... @@ -123,7 +135,7 @@
.sale-price | 销售价格
.market-price | 市场价格
7.3. condition 说明
8.3. condition 说明
参数名称 | 说明 | 示范
------- | ---- | ----
... ...
import jssdk from './src/js/jssdk';
(function(factory) {
/* eslint-disable */
/* eslint-disable */
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
... ...
This diff could not be displayed because it is too large.
{
"name": "yoho-js-sdk",
"version": "1.3.7",
"version": "1.3.8",
"description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。",
"keywords": [
"YOHO!",
... ... @@ -8,7 +8,9 @@
],
"main": "index.js",
"scripts": {
"build": "rollup -c"
"build": "rollup -c --no-treeshake",
"dev": "rollup -c --watch --no-treeshake",
"fix": "eslint --fix src/**/*"
},
"repository": {
"type": "git",
... ... @@ -17,20 +19,22 @@
"author": "shenzm <zhimin.shen@yoho.cn>",
"licenses": "MIT",
"devDependencies": {
"babel-preset-es2015-rollup": "^3.0.0",
"cssnano": "^3.9.1",
"postcss-cssnext": "^2.9.0",
"postcss-nested": "^1.0.0",
"postcss-simple-vars": "^3.0.0",
"rollup": "^0.38.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^6.0.1",
"rollup-plugin-eslint": "^3.0.0",
"rollup-plugin-json": "^2.1.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-postcss": "^0.2.0",
"rollup-plugin-uglify": "^1.0.1",
"rollup-watch": "^2.5.0"
"@babel/core": "^7.1.0",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"cssnano": "^4.1.3",
"postcss-cssnext": "^3.1.0",
"postcss-nested": "^4.1.0",
"postcss-simple-vars": "^5.0.1",
"rollup": "^0.66.2",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.1.8",
"rollup-plugin-eslint": "^5.0.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-postcss": "^1.6.2",
"rollup-plugin-uglify": "^6.0.0",
"rollup-watch": "^4.3.1"
},
"dependencies": {
"jquery-lazyload": "^1.9.7",
... ...
// Rollup plugins
import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';
import {eslint} from 'rollup-plugin-eslint';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import {uglify} from 'rollup-plugin-uglify';
import json from 'rollup-plugin-json';
import postcss from 'rollup-plugin-postcss';
... ... @@ -15,13 +15,15 @@ import cssnano from 'cssnano';
const pkg = require('./package.json');
export default {
entry: 'index.js',
dest: `dist/js-sdk/${pkg.version}/jssdk.js`,
format: 'iife',
external: ['jquery'],
globals: {
jquery: 'jQuery'
input: 'index.js',
output: {
file: `dist/js-sdk/${pkg.version}/jssdk.js`,
format: 'iife',
globals: {
jquery: 'jQuery'
}
},
external: ['jquery'],
plugins: [
json({
include: 'node_modules/**',
... ... @@ -42,10 +44,12 @@ export default {
browser: true,
}),
commonjs(),
eslint(),
babel({
exclude: 'node_modules/**',
eslint({
exclude: [
'src/css/**'
]
}),
babel(),
uglify()
],
};
\ No newline at end of file
... ...
... ... @@ -116,7 +116,19 @@
<h1>ccc只能领取1次已领完 2cf7177163c833dff4b38fc8d2872f1ec6</h1>
</a>
<hr>
<a class="yoho-coin" href="javascript:;" data-token="2aa1d0c6e83f027327d8461063f4ac58a6">
<h1>测试 红包 </h1>
<a class="auth yoho-redenvelope" href="javascript:;" data-token="bf7867128e0bd248">
<h1>ccc已经结束 bf7867128e0bd248</h1>
</a>
<hr>
<a class="auth yoho-redenvelope" href="javascript:;" data-token="bf7867128e0bd248">
<h1>ccc还未开始 bf7867128e0bd248</h1>
</a>
<hr>
<hr>
<hr>
<a class="yoho-redenvelope" href="javascript:;" data-token="2aa1d0c6e83f027327d8461063f4ac58a6">
<img src="http://img02.yohoboys.com/staticimg/2016/04/22/14/02a8b1c09363f84c34aa56d11bb5cd7eb4.png">
</a>
<a class="anchor" href='http://union.yoho.cn/union/downapp.html'></a>
... ... @@ -184,6 +196,6 @@
</div>
</div>
<script src="//cdn.bootcss.com/jquery/1.8.3/jquery.min.js"></script>
<script src="../dist/js-sdk/1.0.0/jssdk.js"></script>
<script src="../dist/js-sdk/1.3.5/jssdk.js"></script>
</body>
</html>
... ...
... ... @@ -49,6 +49,7 @@ let _replaceData = function(el, cond, data, wh, fp) {
let brandDom = el.find('.product-brand');
if (brandDom) {
if (data.shop_id) {
// eslint-disable-next-line
brandDom.attr('href', `//m.yohobuy.com/product/index/brand?domain=${data.brand_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${data.shop_id},"shop_template_type":${data.shop_template_type || "1"},"is_red_shop":${data.is_red_shop || 1}}}`);
} else {
brandDom.attr('href', `//m.yohobuy.com/product/index/brand?domain=${data.brand_domain}&openby:yohobuy={"action":"go.brand","params":{"brand_id":${data.brand_id}}}`);
... ... @@ -103,7 +104,7 @@ let _getProductData = function(dataArr){
return _getProductData(dataArr);
}
return data;
}
};
let _jsonp = function(el, param, cond){
let cloneitem = el.attr('cloneitem');
... ... @@ -301,7 +302,7 @@ export default {
// });
// }, false);
_getProduct({
_getProduct({
uid: '',
udid: utils.queryString().udid || ''
});
... ...
... ... @@ -140,6 +140,49 @@ let _getCoupon = function(data){
});
};
let isSendRedEnevlope = false;
let _getRedEnevlope = function(data){
data.app = utils.queryString();
data.app.uid = data.app.uid || cookies.cookie('app_uid');
data.app.app_version = data.app.app_version || cookies.cookie('app_version');
data.app.client_type = data.app.client_type || cookies.cookie('app_client_type');
data.app.session_key = data.app.session_key || cookies.cookie('app_session_key');
if (isSendRedEnevlope) {
return;
}
isSendRedEnevlope = true;
jsonp({
url: '//m.yohobuy.com/activity/feature/redenvelope?callback=?',
timeout: 5000, // 5s
data: data
}).then(function(res) {
isSendRedEnevlope = false;
if (res.code === 200) {
utils.showTip({
title: '领取成功',
content: res.message,
close: true
});
} else if (res.message) {
utils.showTip({
title: '领取失败<br>请刷新重新领取',
content: res.message + '<br>如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
close: false
});
}
}, function(){
isSendRedEnevlope = false;
utils.showTip({
title: '领取失败<br>请刷新重新领取',
content: '如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
close: false
});
});
};
let _initCoin = function(uid){
if (uid) {
let cointoken = cookies.cookie('yoho-coin-token');
... ... @@ -218,9 +261,49 @@ let _initCoupon = function(uid) {
});
};
let _initRedEnvelope = function(uid) {
if (uid) {
let redevenlopetoken = cookies.cookie('yoho-redenvelope-token');
if (redevenlopetoken) {
_getRedEnevlope({
token: redevenlopetoken,
uid: uid
});
cookies.setCookie('yoho-redenvelope-token', '');
}
}
$('body').on('click', '.yoho-redenvelope', function() {
let token = $(this).data('token');
if (user.uid) {
_getRedEnevlope({
token: token,
uid: user.uid
});
} else {
cookies.setCookie('yoho-redenvelope-token', token);
if (window.__wxjs_environment === 'miniprogram' && typeof wx !== 'undefined' && wx.miniProgram) {
wx.miniProgram.navigateTo({
url: `../bindPhoneNumber/bindPhoneNumber?h5back=${location.href}`
});
return;
}
if ($('#intimacy-link').length <= 0) {
$('body').append('<a href=\'' + user.noLoginUrl() + '\' style="display:none;" id="intimacy-link"><span class="intimacy-link"></span></a>');
}
$('.intimacy-link').click();
return;
}
});
};
export default {
init(uid) {
_initCoin(uid); // 初始化有货币
_initCoupon(uid); // 初始化优惠券
_initRedEnvelope(uid); // 初始化红包
}
};
... ...