
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@byhealth/points
Advanced tools
防伪积分: 公共模块防伪积分,在多个项目中应用,因此抽出来避免重复工作。
文件大小69kb
tips:
1、涉及微信环境,jssdk授权config时需要授权扫码( jsApiList:['scanQRCode'] );
2、通过方式引入js时将在window对象中全局 ___Points___ 构造方法,使用构造方法时务必在资源文件引入之后使用,如有命名上的冲突请自行处理
3、模块css部分由js动态插入用页面,命名使用到hash,但也不排除有冲突和被复写的可能性
npm i
运行开发环境
npm run dev
打包Uat环境
npm run build:uat
打包发布Uat环境
./deploy.sh
打包生产环境
npm run build
将master分支下dist目录内文件发布至cdn 路径下
1、npm或yarn安装
npm install @byhealth/points
yarn add @byhealth/points
2、通过script引用。
测试环境path如下:
http://wx-test1.by-health.com/web/trialcontroller/points.js
生产环境path如下:
http://cdn-yyj.4000916916.com/yyj/2018/points/points.js
js时将在window对象中全局 ___Points___ 构造方法,使用构造方法时务必在资源文件引入之后使用,如有命名上的冲突请自行处理 var points = new ___Points___(Options)
基本用法:
import points from '@byhealth/points';
const Point = new points({
uatApiBase: 'http://wx-test.by-health.com'
});
const {
showSecuritycode
} = Point;
const options = {
memberMobileNo: '13888888888'
};
const callback = () => {
console.log('do something!!!');
}
// 显示防伪积分登录框
showSecuritycode(options, callback)
自定义入口UI用法
import points from '@byhealth/points';
const customPoint = new points({
async: false,
securitycodeDom:'securitycodeDom',
phoneDom:'phoneDom',
QrDom:'QrDom',
submitDom:'submitDom',
uatApiBase: 'http://wx-test.by-health.com'
});
const {
customSecuritycode,
} = customPoint;
const options = {
memberMobileNo: '13888888888'
};
const callback = () => {
console.log('do something!!!');
}
customSecuritycode(options, callback)
默认ui直接显示防伪积分弹窗
showSecuritycode(options, callback)
自定义入口ui时调用下面方法初始化积分入口
customSecuritycode(options, callback)
参数:options = {...}
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
memberMobileNo | 是 | string | 会员手机号 |
storeNo | 是 | string | 门店编号(网站门店:WB00001 微信门店:WX00002) |
clerkMobileNo | 否 | string | 店员手机号 |
source | 否 | string | 来源 |
sceneCode | 否 | string | 场景码 |
sceneSubcode | 否 | string | 场景子码 |
comments | 否 | string | 备注 |
openId | 否 | string | 微信openId |
回调:callback: (data: any) => void
注意:回调返回结果即为积分接口返回结果,为了保留积分模块的灵活性这里的回调不只是积分成功才发生,失败情况也会调用回调,请在使用时根据业务需要来进行处理
data值是积分接口返回,示例如下(参数说明见附表1)
{
"state": "100",
"msg": "您所查询的是汤臣倍健正品,并已积分成功",
"securityCode": "0145750020940500",
"serialNumber": "JF161210WX000020032",
"qualifyingPointsBalance": "187824",
"fwFirstQueryTime": "2016/6/21 20:25:33",
"transactionId": "1-AZLZKV",
"accruedPointsTotal": "9800",
"memberNumber": "1-255809163",
"memberPhone": "13702637637",
"memberId": "1-48AVM3",
"memberName": "feng",
"memTotalPoints": "232015",
"giftPointsBalance": "0",
"productName": "汤臣倍健维生素A维生素D软胶囊(儿童型)",
"salePointsBalance": "0",
"productPointsBalance": "221316",
"barCode": "",
"createTime": "2016-12-10T15:21:05.641+08:00",
"regionId": null,
"regionName": null,
"mregionName": null,
"clerkMobileNo": "",
"storeNo": "WX00002",
"storeId": null,
"storeName": null,
"comments": "",
"sceneCode": ""
}
暴露部分私有方法,方便小型项目使用
**1. initData: () => void 初始化防伪码和条形码数据 **
Points.initData()
2. showLoading: () => void 显示loading
Points.showLoading()
3. hideLoading: () => void 隐藏loading
Points.hideLoading()
4. showMsg: (msg: string, title: string) => any 显示弹窗
@param msg
— 弹窗内容,可以使用HTMLdom
@param title
— 弹窗标题
Points.showMsg('<div>这是弹窗文字</div>', '这是弹窗标题')
5. hideMsg: ƒ () 隐藏弹窗
points.hideMsg()
6. validate
引用包validate-by-health,查询api文档请访问:https://github.com/by-healthFED/validate
7. wechat
引用包share-wechat,查询api文档请访问:https://github.com/by-healthFED/share-wechat
8. nativeApp
引用包@byhealth/native-app-jssdk,查询api文档请访问:https://github.com/by-healthFED/native-app-jssdk
附表一:返回参数说明
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
status | 是 | String | 返回状态见下面积分状态表 |
errorMsg | 是 | String | 返回描述 |
securityCode | 是 | String | 产品防伪码 |
qualifyingPointsBalance | 是 | int | 会员定级积分 |
fWFirstQueryTime | 是 | String | 防伪码首次查询时间 |
transactionId | 是 | String | 本次积分交易ID |
accruedPointsTotal | 是 | String | 本次累计积分 |
memberNumber | 是 | String | 会员编号,目前存在重复情况,不建议当键值使用 |
memberId | 是 | String | 会员ID,键值,全局唯一 |
memberName | 是 | String | 会员名称 |
memTotalPoints | 是 | String | 会员历史累计积分总计 |
giftPointsBalance | 是 | String | 会员可用礼品积分余额 |
productName | 是 | String | 产品名称 |
salePointsBalance | 是 | String | 会员销售积分 |
productPointsBalance | 是 | String | 会员可用产品积分余额 |
附表二:积分状态表
status(=String) | 说明 | 备注 |
---|---|---|
100 或 0 | 积分成功 | |
136 | 补充条形码 | Points.showBarcode() 模块自动调用 |
110 | 返回接口异常错误,如:系统异常,本次未能成功积分,敬请稍后再试/查询防伪异常,请稍后再试 | |
120 | 渠道类型不能为空且仅支持1(IVR)、2(短信)、3(网络)、4(WAP) | |
123 | 防伪码不能为空 | |
124 | 流水号不能为空 | |
125 | 来源系统不能为空 | |
126 | 用户类型不能为空且仅支持1(消费者)、2(客服) | |
127 | 必填字段为空或不正确 | |
130 | 消费者会员自动注册时出错:-- 促销员会员自动注册时出错:-- | |
131 | 会员信息已被冻结,不能进行积分操作 | |
132 | 健力多品牌不能积分,请到其他渠道积分 | |
133 | 防伪码非汤臣倍健的产品,不能进行积分 | |
134 | 防伪码不存在,不能积分,请核对后再输入 | |
135 | 您所查询的防伪码有误,请重新输入16位防伪码 | |
136 | 此防伪码信息不完整,请扫描或输入产品瓶身条形码 | |
137 | 您所查询的是汤臣倍健正品,请放心使用,本品暂不积分 | |
138 | 本品暂不积分,如有疑问请致电4000-916-916 | |
139 | 您所查询的是汤臣倍健赠品,不单独销售,暂不积分 | |
140 | 您所查询的是礼盒正品,请放心使用,本品暂不积分 | |
141 | 您所查询的是礼盒正品,请放心使用,礼盒已查询并积分/此防伪码已查询并积分 | |
142 | 此防伪码已在" YYYY-MM-DD ... "查询并积分 | |
143 | 您今天的产品累计成功积分已经达到单日积分限额,请明天再积分,如有疑问,请致电4000-916-916 | |
144 | 您今天的产品累计成功积分已经达到单日积分瓶数限额,请明天再积分,如有疑问,请致电4000-916-916 | |
161 | 不满足任何积分规则 | |
162 | 积分池剩余积分不足 | |
163 | 抛积分引擎异常错误信息 |
FAQs
查看文档 [document](http://wx-test.by-health.com/web/points2020/#/)
We found that @byhealth/points demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.