From 8771da2ccf6f7c3fd2a8c89a1a0e230c6386db7f Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期一, 17 十一月 2025 15:40:48 +0800
Subject: [PATCH] feat(api): 新增多个API接口并优化配置
---
common/http.interceptor.js | 130
common/math.js | 24
pages/pay/discountpay.vue | 616 +++
static/imgs/store-logo.png | 0
static/cart/icon_addLight.png | 0
common/api/index.js | 137
pages/pay/scanRes.vue | 116
pages/pay/addCardCode.vue | 141
static/coupon-bg2.png | 0
index.html | 43
static/imgs/pay-union.png | 0
static/shuaka/pay-by-card-bg-top.png | 0
static/shuaka/pay-by-card-modal-bg.png | 0
main.js | 5
common/jweixin-1.6.0.js | 1
pages/pay/wxpay.vue | 292 +
static/imgs/pay-jyk.png | 0
pages/pay/addCardFirst.vue | 113
static/shuaka/notice-check.png | 0
pages/pay/scanpay.vue | 876 ++++
pages.json | 127
static/check-type.png | 0
components/card-agreement/card-agreement.vue | 106
static/pay-btn.png | 0
static/shuaka/pay-by-card-dto-ttitle-bg.png | 0
common/jsencrypt.js | 5371 ++++++++++++++++++++++++++
pages/pay/register.vue | 218 +
uni_modules/uview-ui/components/u-input/u-input.vue | 4
pages/pay/paySuccess.vue | 95
components/user-agreement/user-agreement.vue | 261 +
static/bind-card-modal.png | 0
static/cart/icon_lessLight.png | 0
static/register-btn.png | 0
pages/pay/bindCard/bindCard.vue | 392 +
components/key-bord/key-bord.vue | 254
static/cart/icon_less.png | 0
static/shuaka/title-icon1.png | 0
components/input-number/input-number.vue | 171
static/pay-btn.jpeg | 0
static/imgs/pay-wx.png | 0
static/paySuccess.png | 0
static/shuaka/title-icon2.png | 0
common/util.js | 1008 ++++
uni_modules/uview-ui/components/u-textarea/u-textarea.vue | 2
static/cart/icon_add.png | 0
static/shuaka/pay-by-card-bg.png | 0
static/shuaka/popup-close.png | 0
static/shuaka/title-bg.png | 0
common/config.js | 64
App.vue | 14
static/shuaka/pay-by-card-coupon.png | 0
static/bind-card-title.png | 0
static/coupon-icon.png | 0
common/api/shuaka.js | 18
static/shuaka/pay-by-card-coupon-get.png | 0
static/shuaka/coupon-title-right.png | 0
pages/pay/shuaKa/shuaKa.vue | 673 +++
static/imgs/pay-zfb.png | 0
common/bankName.js | 209 +
uni_modules/uview-ui/components/u-parse/u-parse.vue | 4
static/act-bg.png | 0
static/bangka.png | 0
pages/pay/login.vue | 42
static/shuaka/pay-by-card-step.png | 0
static/bank-card-ad2.png | 0
static/shuaka/pay-by-card-step-act.png | 0
static/integral.png | 0
static/shuaka/pay-by-card-btn.png | 0
components/bind-card-activity/bind-card-activity.vue | 161
/dev/null | 0
static/bank-card-ad1.png | 0
static/shuaka/pay-by-card-lock.png | 0
static/shuaka/shuaka.png | 0
manifest.json | 28
static/title-right.png | 0
package.json | 1
static/shuaka/coupon-title-left.png | 0
static/shuaka/pay-by-card-coupon-lock.png | 0
pages/pay/shuaKa/introduce.vue | 92
static/imgs/del-icon.png | 0
static/title-left.png | 0
pages/pay/addCardSecond.vue | 151
static/close-icon.png | 0
83 files changed, 11,473 insertions(+), 487 deletions(-)
diff --git a/App.vue b/App.vue
index d313404..6d4c20d 100644
--- a/App.vue
+++ b/App.vue
@@ -1,13 +1,7 @@
<script>
-import Vconsole from 'vconsole';
export default {
- onLaunch: function(opt) {
- if(opt.query?.debug){
- uni.setStorageSync('DEBUG', opt.query?.debug == 'true');
- }
- if (uni.getStorageSync('DEBUG')) {
- new Vconsole();
- }
+ onLaunch: function() {
+ console.log('App Launch')
},
onShow: function() {
console.log('App Show')
@@ -51,10 +45,6 @@
.color-red {
color: #DE2D35;
- }
-
- .color-green {
- color: #3fde2d;
}
.font-bold {
diff --git a/common/api/index.js b/common/api/index.js
index 7b61c6e..f2f48b0 100644
--- a/common/api/index.js
+++ b/common/api/index.js
@@ -1,60 +1,123 @@
import {
- config
+ config
} from '@/common/config.js';
-
const http = uni.$u.http;
const URL = config.baseURL;
-/* 鏍规嵁cid鑾峰彇鍟嗛摵淇℃伅 */
-export const queryShopByCid = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/queryShopById', params, config)
+/* 鑾峰彇鍟嗛摵淇℃伅 */
+export const queryShop = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/queryShopById', params, config)
-/* 鏍规嵁鍔ㄦ�佺爜id鑾峰彇鍟嗛摵淇℃伅 */
-export const queryShopByActQrId = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/getPayInfo', params, config)
+/* 鑾峰彇鎴愬姛椤甸潰閰嶇疆 */
+export const getPayCompleteUrl = (params, config = {}) => http.get(URL +
+ '/service-base/v1/base/pc/global/config/getPayCompleteUrl', params, config)
-/* 鏍规嵁璁㈠崟id鑾峰彇鍟嗛摵淇℃伅 */
-export const queryShopByOnlineId = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/getOnlineId', params, config)
+/* 鑾峰彇绉垎浠峰�� */
+export const getScoreWorth = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/getScoreWorth', params, config)
-/* 鏍规嵁shopId鑾峰彇鍟嗛摵淇℃伅 */
-export const queryShopByShopId = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/queryShopByShopId', params, config)
+/* 鑾峰彇鐢ㄦ埛閾惰鍗� */
+export const myBankCard = (params, config = {}) => http.get(URL +
+ '/service-shop/v1/shop/wechat/h5/bankCard/myBankCard', params, config)
-/*缁熶竴鎺堟潈*/
+/* 鑾峰彇鍟嗛摵寰俊閰嶇疆 */
+export const getWechatInfo = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/getWechatInfo', params, config = {});
+/* 闈欓粯鎺堟潈鐧诲綍 */
+export const getOpenIdBase = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/getOpenIdBase', params, config = {});
+
+/* 寰俊鏅�氭巿鏉冪櫥褰� */
+export const getOpenId = (params, config = {}) => http.get(URL + '/service-merchant/v1/web/aggregatePayAllin/getOpenId',
+ params, config = {});
+/* 鏀粯瀹濇櫘閫氭巿鏉冪櫥褰� */
+export const getUserId = (params, config = {}) => http.get(URL + '/service-merchant/v1/web/h5PayAli/getUserIdByCode',
+ params, config = {});
+
export const userLogin = (params, config = {}) => {
- let path = '/payfour-merchant/v1/web/aggregatePayAllin/getOpenId' //寰俊鎺堟潈
- if (params.platform == 5) { //鏀粯瀹濇巿鏉�
- path = '/payfour-merchant/v1/web/h5PayAli/getUserIdByCode'
- }
- if (params.platform == 15) { //浜戦棯浠樻巿鏉�
- path = '/payfour-merchant/v1/web/h5PayUnionPay/getUserIdByCode'
- }
- return http.get(URL + path,
- params, config = {})
+ let path = '/service-merchant/v1/web/aggregatePayAllin/getOpenId'
+ if (params.platform == 5) {
+ path = '/service-merchant/v1/web/h5PayAli/getUserIdByCode'
+ }
+ if (params.platform == 15) {
+ path = '/service-merchant/v1/web/h5PayUnionPay/getUserIdByCode'
+ }
+ return http.get(URL + path,
+ params, config = {})
};
-
+/* 鑾峰彇鐢ㄦ埛绉垎 */
+export const queryScore = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/queryScore', params, config = {});
/* 鑾峰彇鐢ㄦ埛鍙敤浼樻儬鍒� 闈㈠�兼渶澶х殑*/
export const queryMyUseSweepPayMaxCoupon = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/queryMyUseSweepPayMaxCoupon', params, config = {});
-
+ '/service-merchant/v1/web/aggregatePayAllin/queryMyUseSweepPayMaxCoupon', params, config = {});
/* 鑾峰彇鐢ㄦ埛鍙敤浼樻儬鍒� */
export const queryUseSweepPayCoupon = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/queryUseSweepPayCoupon', params, config = {});
+ '/service-merchant/v1/web/aggregatePayAllin/queryUseSweepPayCoupon', params, config = {});
/* 鑾峰彇寰俊js sdk閰嶇疆 */
export const getWechatConfigInfo = (params, config = {}) => http.post(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/getWechatConfigInfo', params, config = {});
+ '/service-merchant/v1/web/aggregatePayAllin/getWechatConfigInfo', params, config = {});
-/*缁熶竴鏀粯*/
-export const saveOrder = (params, config = {}) => http.post(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/saveOrder', params, config = {});
+/* 寰俊鏀粯 */
+export const saveWxOrder = (params, config = {}) => http.post(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/saveWxOrder', params, config = {});
-/*鍙栨秷璁㈠崟*/
-export const closeOrder = (params, config = {}) => http.get(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/scanPayOrderClose', params, config = {});
+/* 鍥惧舰楠岃瘉鍚� */
+export const getVerify = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/getVerify', params, config = {});
+
+/* 鐭俊楠岃瘉鐮� */
+export const getH5PayCheckVerifyCode = (params, config = {}) => http.post(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/getH5PayCheckVerifyCode', params, config = {});
+
+/* 寰俊鏀粯 */
+export const h5PayLogin = (params, config = {}) => http.post(URL + '/service-shop/v1/shop/web/wechat/h5PayLogin',
+ params, config = {});
+
+/* 閫氳仈蹇嵎鏀粯 */
+export const tlPay = (params, config = {}) => http.post(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/payagreeconfirm',
+ params, config = {});
/* 寰俊鏀粯缁撴灉 */
export const getWxOrderInfo = (params, config = {}) => http.post(URL +
- '/payfour-merchant/v1/web/aggregatePayAllin/getWxOrderInfo',
- params, config = {});
+ '/service-merchant/v1/web/aggregatePayAllin/getWxOrderInfo',
+ params, config = {});
+
+/* 鍒ゆ柇鏄惁鍦ㄥ崱娈靛唴 */
+export const isContain = (params, config = {}) => http.get(URL +
+ '/service-base/v1/base/pc/bankCardPeriod/isContain',
+ params, config = {});
+
+/* 鑾峰彇閾惰鍗¢厤缃� */
+export const bankCardStyle = (params, config = {}) => http.get(URL +
+ '/service-base/v1/base/pc/global/config/bankCardStyle',
+ params, config = {});
+
+/* 鑾峰彇鐢ㄦ埛淇℃伅 */
+export const getUserInfo = (params, config = {}) => http.post(URL +
+ '/service-shop/v1/shop/wechat/h5/bankCard/noEnc',
+ params, config = {});
+/* 鑾峰彇搴楅摵浼樻儬淇℃伅 */
+export const queryMyDiscount = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/queryMyDiscount',
+ params, config = {});
+/* 绛剧害鐢宠缁戝崱 */
+export const signUpToApply = (params, config = {}) => http.post(URL +
+ '/service-shop/v1/shop/wechat/h5/bankCard/signUpToApply',
+ params, config = {});
+
+/* 绛剧害鐢宠纭 */
+export const bindCard = (params, config = {}) => http.post(URL +
+ '/service-shop/v1/shop/wechat/h5/bankCard/bindCard',
+ params, config = {});
+
+/* 鑾峰彇缁戝崱娲诲姩璧犻�佺殑浼樻儬鍒� */
+export const getMyCoupUseDetail = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/aggregatePayAllin/headBand/getMyCoupUseDetail',
+ params, config = {});
+/* 鑾峰彇棣栫粦鏈夌ぜ */
+export const headBand = (params, config = {}) => http.get(URL +
+ '/service-shop/v1/shop/wechat/activity/headBand/detail',
+ params, config = {});
\ No newline at end of file
diff --git a/common/api/shuaka.js b/common/api/shuaka.js
new file mode 100644
index 0000000..426f956
--- /dev/null
+++ b/common/api/shuaka.js
@@ -0,0 +1,18 @@
+import {
+ config
+} from '@/common/config.js';
+const http = uni.$u.http;
+const URL = config.baseURL;
+
+/* 鑾峰彇鍒峰崱娲诲姩淇℃伅 */
+export const activityInfo = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/monthBrush/info', params, config)
+/* 鍙備笌娲诲姩 */
+export const signActivity = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/monthBrush/sign', params, config)
+/* 鑾峰彇鐢ㄦ埛鍙備笌淇℃伅 */
+export const myBrushDetail = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/monthBrush/myBrushDetail', params, config)
+/* 鏌ヨ浼樻儬鍒� */
+export const orderRefBrushNode = (params, config = {}) => http.get(URL +
+ '/service-merchant/v1/web/monthBrush/orderRefBrushNode', params, config)
\ No newline at end of file
diff --git a/common/bankName.js b/common/bankName.js
new file mode 100644
index 0000000..1ba40fa
--- /dev/null
+++ b/common/bankName.js
@@ -0,0 +1,209 @@
+const list = {
+
+ "CDB": "鍥藉寮�鍙戦摱琛�",
+ "ICBC": "涓浗宸ュ晢閾惰",
+ "ABC": "涓浗鍐滀笟閾惰",
+ "BOC": "涓浗閾惰",
+
+ "CCB": "涓浗寤鸿閾惰",
+ "PSBC": "涓浗閭斂鍌ㄨ搫閾惰",
+ "COMM": "浜ら�氶摱琛�",
+ "CMB": "鎷涘晢閾惰",
+
+ "SPDB": "涓婃捣娴︿笢鍙戝睍閾惰",
+ "CIB": "鍏翠笟閾惰",
+ "HXBANK": "鍗庡閾惰",
+ "GDB": "骞夸笢鍙戝睍閾惰",
+
+ "CMBC": "涓浗姘戠敓閾惰",
+ "CITIC": "涓俊閾惰",
+ "CEB": "涓浗鍏夊ぇ閾惰",
+ "EGBANK": "鎭掍赴閾惰",
+
+ "CZBANK": "娴欏晢閾惰",
+ "BOHAIB": "娓ゆ捣閾惰",
+ "SPABANK": "骞冲畨閾惰",
+ "SHRCB": "涓婃捣鍐滄潙鍟嗕笟閾惰",
+
+ "YXCCB": "鐜夋邯甯傚晢涓氶摱琛�",
+ "YDRCB": "灏ч兘鍐滃晢琛�",
+ "BJBANK": "鍖椾含閾惰",
+ "SHBANK": "涓婃捣閾惰",
+
+ "JSBANK": "姹熻嫃閾惰",
+ "HZCB": "鏉窞閾惰",
+ "NJCB": "鍗椾含閾惰",
+ "NBBANK": "瀹佹尝閾惰",
+ "HSBANK": "寰藉晢閾惰",
+
+ "CSCB": "闀挎矙閾惰",
+ "CDCB": "鎴愰兘閾惰",
+ "CQBANK": "閲嶅簡閾惰",
+ "DLB": "澶ц繛閾惰",
+ "NCB": "鍗楁槍閾惰",
+
+ "FJHXBC": "绂忓缓娴峰场閾惰",
+ "HKB": "姹夊彛閾惰",
+ "WZCB": "娓╁窞閾惰",
+ "QDCCB": "闈掑矝閾惰",
+ "TZCB": "鍙板窞閾惰",
+
+ "JXBANK": "鍢夊叴閾惰",
+ "CSRCB": "甯哥啛鍐滄潙鍟嗕笟閾惰",
+ "NHB": "鍗楁捣鍐滄潙淇$敤鑱旂ぞ",
+ "CZRCB": "甯稿窞鍐滄潙淇$敤鑱旂ぞ",
+
+ "H3CB": "鍐呰挋鍙ら摱琛�",
+ "SXCB": "缁嶅叴閾惰",
+ "SDEB": "椤哄痉鍐滃晢閾惰",
+ "WJRCB": "鍚存睙鍐滃晢閾惰",
+ "ZBCB": "榻愬晢閾惰",
+
+ "GYCB": "璐甸槼甯傚晢涓氶摱琛�",
+ "ZYCBANK": "閬典箟甯傚晢涓氶摱琛�",
+ "HZCCB": "婀栧窞甯傚晢涓氶摱琛�",
+ "DAQINGB": "榫欐睙閾惰",
+
+ "JINCHB": "鏅嬪煄閾惰JCBANK",
+ "ZJTLCB": "娴欐睙娉伴殕鍟嗕笟閾惰",
+ "GDRCC": "骞夸笢鐪佸啘鏉戜俊鐢ㄧぞ鑱斿悎绀�",
+
+ "DRCBCL": "涓滆帪鍐滄潙鍟嗕笟閾惰",
+ "MTBANK": "娴欐睙姘戞嘲鍟嗕笟閾惰",
+ "GCB": "骞垮窞閾惰",
+ "LYCB": "杈介槼甯傚晢涓氶摱琛�",
+
+ "JSRCU": "姹熻嫃鐪佸啘鏉戜俊鐢ㄨ仈鍚堢ぞ",
+ "LANGFB": "寤婂潑閾惰",
+ "CZCB": "娴欐睙绋犲窞鍟嗕笟閾惰",
+ "DYCB": "寰烽槼鍟嗕笟閾惰",
+
+ "JZBANK": "鏅嬩腑甯傚晢涓氶摱琛�",
+ "BOSZ": "鑻忓窞閾惰",
+ "GLBANK": "妗傛灄閾惰",
+ "URMQCCB": "涔岄瞾鏈ㄩ綈甯傚晢涓氶摱琛�",
+
+ "CDRCB": "鎴愰兘鍐滃晢閾惰",
+ "ZRCBANK": "寮犲娓啘鏉戝晢涓氶摱琛�",
+ "BOD": "涓滆帪閾惰",
+ "LSBANK": "鑾卞晢閾惰",
+
+ "BJRCB": "鍖椾含鍐滄潙鍟嗕笟閾惰",
+ "TRCB": "澶╂触鍐滃晢閾惰",
+ "SRBANK": "涓婇ザ閾惰",
+ "FDB": "瀵屾粐閾惰",
+
+ "CRCBANK": "閲嶅簡鍐滄潙鍟嗕笟閾惰",
+ "ASCB": "闉嶅北閾惰",
+ "NXBANK": "瀹佸閾惰",
+ "BHB": "娌冲寳閾惰",
+
+ "HRXJB": "鍗庤瀺婀樻睙閾惰",
+ "ZGCCB": "鑷础甯傚晢涓氶摱琛�",
+ "YNRCC": "浜戝崡鐪佸啘鏉戜俊鐢ㄧぞ",
+ "JLBANK": "鍚夋灄閾惰",
+
+ "DYCCB": "涓滆惀甯傚晢涓氶摱琛�",
+ "KLB": "鏄嗕粦閾惰",
+ "ORBANK": "閯傚皵澶氭柉閾惰",
+ "XTB": "閭㈠彴閾惰",
+ "JSB": "鏅嬪晢閾惰",
+
+ "TCCB": "澶╂触閾惰",
+ "BOYK": "钀ュ彛閾惰",
+ "JLRCU": "鍚夋灄鍐滀俊",
+ "SDRCU": "灞变笢鍐滀俊",
+ "XABANK": "瑗垮畨閾惰",
+
+ "HBRCU": "娌冲寳鐪佸啘鏉戜俊鐢ㄧぞ",
+ "NXRCU": "瀹佸榛勬渤鍐滄潙鍟嗕笟閾惰",
+ "GZRCU": "璐靛窞鐪佸啘鏉戜俊鐢ㄧぞ",
+
+ "FXCB": "闃滄柊閾惰",
+ "HBHSBANK": "婀栧寳閾惰榛勭煶鍒嗚",
+ "ZJNX": "娴欐睙鐪佸啘鏉戜俊鐢ㄧぞ鑱斿悎绀�",
+ "XXBANK": "鏂颁埂閾惰",
+
+ "HBYCBANK": "婀栧寳閾惰瀹滄槍鍒嗚",
+ "LSCCB": "涔愬北甯傚晢涓氶摱琛�",
+ "TCRCB": "姹熻嫃澶粨鍐滄潙鍟嗕笟閾惰",
+
+ "BZMD": "椹婚┈搴楅摱琛�",
+ "GZB": "璧e窞閾惰",
+ "WRCB": "鏃犻敗鍐滄潙鍟嗕笟閾惰",
+ "BGB": "骞胯タ鍖楅儴婀鹃摱琛�",
+
+ "GRCB": "骞垮窞鍐滃晢閾惰",
+ "JRCB": "姹熻嫃姹熼槾鍐滄潙鍟嗕笟閾惰",
+ "BOP": "骞抽《灞遍摱琛�",
+ "TACCB": "娉板畨甯傚晢涓氶摱琛�",
+
+ "CGNB": "鍗楀厖甯傚晢涓氶摱琛�",
+ "CCQTGB": "閲嶅簡涓夊场閾惰",
+ "XLBANK": "涓北灏忔鏉戦晣閾惰",
+ "HDBANK": "閭兏閾惰",
+
+ "KORLABANK": "搴撳皵鍕掑競鍟嗕笟閾惰",
+ "BOJZ": "閿﹀窞閾惰",
+ "QLBANK": "榻愰瞾閾惰",
+ "BOQH": "闈掓捣閾惰",
+
+ "YQCCB": "闃虫硥閾惰",
+ "SJBANK": "鐩涗含閾惰",
+ "FSCB": "鎶氶『閾惰",
+ "ZZBANK": "閮戝窞閾惰",
+ "SRCB": "娣卞湷鍐滄潙鍟嗕笟閾惰",
+
+ "BANKWF": "娼嶅潑閾惰",
+ "JJBANK": "涔濇睙閾惰",
+ "JXRCU": "姹熻タ鐪佸啘鏉戜俊鐢�",
+ "HNRCU": "娌冲崡鐪佸啘鏉戜俊鐢�",
+
+ "GSRCU": "鐢樿們鐪佸啘鏉戜俊鐢�",
+ "SCRCU": "鍥涘窛鐪佸啘鏉戜俊鐢�",
+ "GXRCU": "骞胯タ鐪佸啘鏉戜俊鐢�",
+ "SXRCCU": "闄曡タ淇″悎",
+
+ "WHRCB": "姝︽眽鍐滄潙鍟嗕笟閾惰",
+ "YBCCB": "瀹滃甯傚晢涓氶摱琛�",
+ "KSRB": "鏄嗗北鍐滄潙鍟嗕笟閾惰",
+ "SZSBK": "鐭冲槾灞遍摱琛�",
+
+ "HSBK": "琛℃按閾惰",
+ "XYBANK": "淇¢槼閾惰",
+ "NBYZ": "閯炲窞閾惰",
+ "ZJKCCB": "寮犲鍙e競鍟嗕笟閾惰",
+ "XCYH": "璁告槍閾惰",
+
+ "JNBANK": "娴庡畞閾惰",
+ "CBKF": "寮�灏佸競鍟嗕笟閾惰",
+ "WHCCB": "濞佹捣甯傚晢涓氶摱琛�",
+ "HBC": "婀栧寳閾惰",
+
+ "BOCD": "鎵垮痉閾惰",
+ "BODD": "涓逛笢閾惰",
+ "JHBANK": "閲戝崕閾惰",
+ "BOCY": "鏈濋槼閾惰",
+ "LSBC": "涓村晢閾惰",
+
+ "BSB": "鍖呭晢閾惰",
+ "LZYH": "鍏板窞閾惰",
+ "BOZK": "鍛ㄥ彛閾惰",
+ "DZBANK": "寰峰窞閾惰",
+ "SCCB": "涓夐棬宄¢摱琛�",
+
+ "AYCB": "瀹夐槼閾惰",
+ "ARCU": "瀹夊窘鐪佸啘鏉戜俊鐢ㄧぞ",
+ "HURCB": "婀栧寳鐪佸啘鏉戜俊鐢ㄧぞ",
+ "HNRCC": "婀栧崡鐪佸啘鏉戜俊鐢ㄧぞ",
+
+ "NYNB": "骞夸笢鍗楃菠閾惰",
+ "LYBANK": "娲涢槼閾惰",
+ "NHQS": "鍐滀俊閾舵竻绠椾腑蹇�",
+ "CBBQS": "鍩庡競鍟嗕笟閾惰璧勯噾娓呯畻涓績"
+
+}
+
+module.exports = {
+ bankName: list,
+};
\ No newline at end of file
diff --git a/common/config.js b/common/config.js
index 4097f19..f222f9f 100644
--- a/common/config.js
+++ b/common/config.js
@@ -2,32 +2,50 @@
// 寮�鍙�
const dev = {
- webURL: 'https://sfzf.cpbtsoft.cn',
- baseURL: 'https://sfzf.cpbtsoft.cn/dev-api',
- // baseURL: 'http://172.16.2.117:8080',
- wx_appid: 'wx4c146dba764dcb05',
- ali_appid: '2021004193639959'
+ webURL: 'https://zhxx.jinmingyuan.com/pay',
+ baseURL: 'http://1.14.252.104:7101',
+ sftpURL: 'https://zhkj.jinmingyuan.com:8443/sftp',
+ imgUrl: 'https://zhkj.jinmingyuan.com:8443/sftp/platform/app/',
+ wx_appid: 'wxad8cc511da676bd4',
+ ali_appid: '2021003199690698'
}
-// 娴嬭瘯
-const test = {
- webURL: 'https://sfzf.cpbtsoft.cn',
- baseURL: 'https://sfzf.cpbtsoft.cn/prod-api',
- wx_appid: 'wx4c146dba764dcb05',
- ali_appid: '2021004193639959'
+// 缈兼敮浠樻祴璇�
+const yPayTest = {
+ webURL: 'https://zhxx.jinmingyuan.com/yPayTest',
+ baseURL: 'http://1.14.252.104:7101',
+ sftpURL: 'https://zhkj.jinmingyuan.com:8443/sftp',
+ imgUrl: 'https://zhkj.jinmingyuan.com:8443/sftp/platform/app/',
+ wx_appid: 'wxd163440fc91fd9af',
+ ali_appid: '2021003199690698'
}
-// 姝e紡
-const prod = {
- webURL: 'https://uif.hepost.com',
- baseURL: 'https://uif.hepost.com/prod-api',
- wx_appid: 'wx4c146dba764dcb05',
- ali_appid: '2021004149689887'
+// 鐢熸�佸湀
+const stq = {
+ webURL: 'https://zhxx.jinmingyuan.com/pay',
+ baseURL: 'https://zhxx.jinmingyuan.com',
+ sftpURL: 'https://zhkj.jinmingyuan.com:8443/sftp',
+ imgUrl: 'https://zhkj.jinmingyuan.com:8443/sftp/platform/app/',
+ wx_appid: 'wxad8cc511da676bd4',
+ ali_appid: '2021003199690698'
}
+// 浜烘墠鐮�
+const rcm = {
+ webURL: 'https://zhxx.jinmingyuan.com/rcmpay',
+ baseURL: 'https://zhxx.jinmingyuan.com/rcmapi',
+ sftpURL: 'https://zhkj.jinmingyuan.com:8443/sftp',
+ imgUrl: 'https://zhkj.jinmingyuan.com:8443/sftp/platform/app/',
+ wx_appid: 'wxad8cc511da676bd4',
+ ali_appid: '2021003199690698'
+}
+
+const cardType = {
+ '00': '鍌ㄨ搫鍗�',
+ '02': '淇$敤鍗�'
+}
module.exports = {
- config: process.env.NODE_ENV === 'development' ? dev : prod,
- ACCESSTOKEN: "Authorization",
- /* 鏄惁鎵撳嵃璇锋眰鏃ュ織 */
- DEBUG: false,
- /* 鏄惁鏍¢獙浣嶇疆缁忕含搴� */
- CHECK_LOCATION: true
+ config: stq,
+ ACCESSTOKEN: "SCAN-WECHAT-TOKEN-HEADER",
+ /* 鏄惁鎵撳嵃璇锋眰鏃ュ織 */
+ DEBUG: false,
+ cardType: cardType
}
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 364454d..5371580 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -1,77 +1,61 @@
import {
- ACCESSTOKEN,
- config,
- DEBUG
+ ACCESSTOKEN,
+ config,
+ DEBUG
} from '@/common/config.js';
-import {
- getPlat
-} from 'common/util.js';
-
module.exports = (vm) => {
- uni.$u.http.setConfig((x) => {
- return x = {
- // baseURL: config.baseURL,
- dataType: 'json',
- timeout: 60000,
- showLoading: false, //鏄惁鏄剧ず鍏ㄥ眬loading
- timer: null,
- loadingTime: 800, //澶氬皯绉掓棤杩斿洖鍐嶆樉绀簂oading
- header: {
- 'Clientid': '944c6aade52ebbffc015478e6ce51b5a',
- 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
- 'Access-Control-Allow-Origin': '*'
- }
- }
- })
- // 璇锋眰鎷︽埅
- uni.$u.http.interceptors.request.use((x) => {
- DEBUG && console.log('璇锋眰鍙傛暟', x);
- // 寮曠敤token
- const TOKEN = uni.getStorageSync(ACCESSTOKEN);
- if (TOKEN) {
- x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN;
- }
- const plat = getPlat()
- if (plat == 2) { //寰俊
- const OPENID = uni.getStorageSync('OPENID') || null
- const UNIONID = uni.getStorageSync('UNIONID') || null
- if (OPENID) {
- x.header['Openid'] = OPENID;
- }
- if (UNIONID) {
- x.header['Unionid'] = UNIONID;
- }
- }
- if (plat == 5) { //鏀粯瀹�
- const ALIUSERID = uni.getStorageSync('ALIUSERID') || null
- if (ALIUSERID) {
- x.header['Aliuserid'] = ALIUSERID;
- }
- }
- if (plat == 15) { //浜戦棯浠�
- const UNIONPAYID = uni.getStorageSync('UNIONPAYID') || null
- if (UNIONPAYID) {
- x.header['Unionpayid '] = UNIONPAYID;
- }
- }
- return x;
- }, x => {
- return Promise.reject(x)
- })
- // 鍝嶅簲鎷︽埅
- uni.$u.http.interceptors.response.use((x) => {
- DEBUG && console.log('杩斿洖缁撴灉', x);
- let res = x.data
- if (res.code == 10000) {
- return res.data;
- } else if (res.code == 10002) {
- return Promise.reject(res)
- } else {
- vm.$u.toast(res.description || res.msg || res.info || "璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
- return Promise.reject(res)
- }
- }, (response) => {
- vm.$u.toast("璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
- return Promise.reject(response)
- })
+ uni.$u.http.setConfig((x) => {
+ return x = {
+ // baseURL: config.baseURL,
+ dataType: 'json',
+ timeout: 60000,
+ showLoading: false, //鏄惁鏄剧ず鍏ㄥ眬loading
+ timer: null,
+ loadingTime: 800, //澶氬皯绉掓棤杩斿洖鍐嶆樉绀簂oading
+ header: {
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
+ 'Access-Control-Allow-Origin': '*'
+ }
+ }
+ })
+ // 璇锋眰鎷︽埅
+ uni.$u.http.interceptors.request.use((x) => {
+ DEBUG && console.log('璇锋眰鍙傛暟', x);
+ // 寮曠敤token
+ const TOKEN = uni.getStorageSync(ACCESSTOKEN);
+ if (TOKEN) {
+ x.header[ACCESSTOKEN] = TOKEN;
+ } else {
+ delete x.header[ACCESSTOKEN]
+ }
+ return x;
+ }, x => {
+ return Promise.reject(x)
+ })
+ // 鍝嶅簲鎷︽埅
+ uni.$u.http.interceptors.response.use((x) => {
+ DEBUG && console.log('杩斿洖缁撴灉', x);
+ let res = x.data
+ if (res.code == 10000) {
+ return res.data;
+ } else if (res.code == 20002) {
+ const cid = uni.getStorageSync('CID')
+ uni.removeStorageSync(ACCESSTOKEN)
+ vm.$u.toast("鎺堟潈杩囨湡,璇烽噸鏂扮櫥褰�");
+ setTimeout(() => {
+ uni.reLaunch({
+ url: "/pages/pay/scanpay?cid=" + cid
+ })
+ }, 800);
+ return Promise.reject(res)
+ } else if (res.code == 10002) {
+ return Promise.reject(res)
+ } else {
+ vm.$u.toast(res.description || "璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
+ return Promise.reject(res)
+ }
+ }, (response) => {
+ vm.$u.toast("璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
+ return Promise.reject(response)
+ })
}
diff --git a/common/jsencrypt.js b/common/jsencrypt.js
new file mode 100644
index 0000000..e2dada5
--- /dev/null
+++ b/common/jsencrypt.js
@@ -0,0 +1,5371 @@
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.JSEncrypt = {})));
+}(this, (function (exports) { 'use strict';
+
+var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
+function int2char(n) {
+ return BI_RM.charAt(n);
+}
+//#region BIT_OPERATIONS
+// (public) this & a
+function op_and(x, y) {
+ return x & y;
+}
+// (public) this | a
+function op_or(x, y) {
+ return x | y;
+}
+// (public) this ^ a
+function op_xor(x, y) {
+ return x ^ y;
+}
+// (public) this & ~a
+function op_andnot(x, y) {
+ return x & ~y;
+}
+// return index of lowest 1-bit in x, x < 2^31
+function lbit(x) {
+ if (x == 0) {
+ return -1;
+ }
+ var r = 0;
+ if ((x & 0xffff) == 0) {
+ x >>= 16;
+ r += 16;
+ }
+ if ((x & 0xff) == 0) {
+ x >>= 8;
+ r += 8;
+ }
+ if ((x & 0xf) == 0) {
+ x >>= 4;
+ r += 4;
+ }
+ if ((x & 3) == 0) {
+ x >>= 2;
+ r += 2;
+ }
+ if ((x & 1) == 0) {
+ ++r;
+ }
+ return r;
+}
+// return number of 1 bits in x
+function cbit(x) {
+ var r = 0;
+ while (x != 0) {
+ x &= x - 1;
+ ++r;
+ }
+ return r;
+}
+//#endregion BIT_OPERATIONS
+
+var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+var b64pad = "=";
+function hex2b64(h) {
+ var i;
+ var c;
+ var ret = "";
+ for (i = 0; i + 3 <= h.length; i += 3) {
+ c = parseInt(h.substring(i, i + 3), 16);
+ ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
+ }
+ if (i + 1 == h.length) {
+ c = parseInt(h.substring(i, i + 1), 16);
+ ret += b64map.charAt(c << 2);
+ }
+ else if (i + 2 == h.length) {
+ c = parseInt(h.substring(i, i + 2), 16);
+ ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
+ }
+ while ((ret.length & 3) > 0) {
+ ret += b64pad;
+ }
+ return ret;
+}
+// convert a base64 string to hex
+function b64tohex(s) {
+ var ret = "";
+ var i;
+ var k = 0; // b64 state, 0-3
+ var slop = 0;
+ for (i = 0; i < s.length; ++i) {
+ if (s.charAt(i) == b64pad) {
+ break;
+ }
+ var v = b64map.indexOf(s.charAt(i));
+ if (v < 0) {
+ continue;
+ }
+ if (k == 0) {
+ ret += int2char(v >> 2);
+ slop = v & 3;
+ k = 1;
+ }
+ else if (k == 1) {
+ ret += int2char((slop << 2) | (v >> 4));
+ slop = v & 0xf;
+ k = 2;
+ }
+ else if (k == 2) {
+ ret += int2char(slop);
+ ret += int2char(v >> 2);
+ slop = v & 3;
+ k = 3;
+ }
+ else {
+ ret += int2char((slop << 2) | (v >> 4));
+ ret += int2char(v & 0xf);
+ k = 0;
+ }
+ }
+ if (k == 1) {
+ ret += int2char(slop << 2);
+ }
+ return ret;
+}
+
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+/* global Reflect, Promise */
+
+var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+};
+
+function __extends(d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+}
+
+// Hex JavaScript decoder
+// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
+var decoder;
+var Hex = {
+ decode: function (a) {
+ var i;
+ if (decoder === undefined) {
+ var hex = "0123456789ABCDEF";
+ var ignore = " \f\n\r\t\u00A0\u2028\u2029";
+ decoder = {};
+ for (i = 0; i < 16; ++i) {
+ decoder[hex.charAt(i)] = i;
+ }
+ hex = hex.toLowerCase();
+ for (i = 10; i < 16; ++i) {
+ decoder[hex.charAt(i)] = i;
+ }
+ for (i = 0; i < ignore.length; ++i) {
+ decoder[ignore.charAt(i)] = -1;
+ }
+ }
+ var out = [];
+ var bits = 0;
+ var char_count = 0;
+ for (i = 0; i < a.length; ++i) {
+ var c = a.charAt(i);
+ if (c == "=") {
+ break;
+ }
+ c = decoder[c];
+ if (c == -1) {
+ continue;
+ }
+ if (c === undefined) {
+ throw new Error("Illegal character at offset " + i);
+ }
+ bits |= c;
+ if (++char_count >= 2) {
+ out[out.length] = bits;
+ bits = 0;
+ char_count = 0;
+ }
+ else {
+ bits <<= 4;
+ }
+ }
+ if (char_count) {
+ throw new Error("Hex encoding incomplete: 4 bits missing");
+ }
+ return out;
+ }
+};
+
+// Base64 JavaScript decoder
+// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
+var decoder$1;
+var Base64 = {
+ decode: function (a) {
+ var i;
+ if (decoder$1 === undefined) {
+ var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ var ignore = "= \f\n\r\t\u00A0\u2028\u2029";
+ decoder$1 = Object.create(null);
+ for (i = 0; i < 64; ++i) {
+ decoder$1[b64.charAt(i)] = i;
+ }
+ for (i = 0; i < ignore.length; ++i) {
+ decoder$1[ignore.charAt(i)] = -1;
+ }
+ }
+ var out = [];
+ var bits = 0;
+ var char_count = 0;
+ for (i = 0; i < a.length; ++i) {
+ var c = a.charAt(i);
+ if (c == "=") {
+ break;
+ }
+ c = decoder$1[c];
+ if (c == -1) {
+ continue;
+ }
+ if (c === undefined) {
+ throw new Error("Illegal character at offset " + i);
+ }
+ bits |= c;
+ if (++char_count >= 4) {
+ out[out.length] = (bits >> 16);
+ out[out.length] = (bits >> 8) & 0xFF;
+ out[out.length] = bits & 0xFF;
+ bits = 0;
+ char_count = 0;
+ }
+ else {
+ bits <<= 6;
+ }
+ }
+ switch (char_count) {
+ case 1:
+ throw new Error("Base64 encoding incomplete: at least 2 bits missing");
+ case 2:
+ out[out.length] = (bits >> 10);
+ break;
+ case 3:
+ out[out.length] = (bits >> 16);
+ out[out.length] = (bits >> 8) & 0xFF;
+ break;
+ }
+ return out;
+ },
+ re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
+ unarmor: function (a) {
+ var m = Base64.re.exec(a);
+ if (m) {
+ if (m[1]) {
+ a = m[1];
+ }
+ else if (m[2]) {
+ a = m[2];
+ }
+ else {
+ throw new Error("RegExp out of sync");
+ }
+ }
+ return Base64.decode(a);
+ }
+};
+
+// Big integer base-10 printing library
+// Copyright (c) 2014 Lapo Luchini <lapo@lapo.it>
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
+var max = 10000000000000; // biggest integer that can still fit 2^53 when multiplied by 256
+var Int10 = /** @class */ (function () {
+ function Int10(value) {
+ this.buf = [+value || 0];
+ }
+ Int10.prototype.mulAdd = function (m, c) {
+ // assert(m <= 256)
+ var b = this.buf;
+ var l = b.length;
+ var i;
+ var t;
+ for (i = 0; i < l; ++i) {
+ t = b[i] * m + c;
+ if (t < max) {
+ c = 0;
+ }
+ else {
+ c = 0 | (t / max);
+ t -= c * max;
+ }
+ b[i] = t;
+ }
+ if (c > 0) {
+ b[i] = c;
+ }
+ };
+ Int10.prototype.sub = function (c) {
+ // assert(m <= 256)
+ var b = this.buf;
+ var l = b.length;
+ var i;
+ var t;
+ for (i = 0; i < l; ++i) {
+ t = b[i] - c;
+ if (t < 0) {
+ t += max;
+ c = 1;
+ }
+ else {
+ c = 0;
+ }
+ b[i] = t;
+ }
+ while (b[b.length - 1] === 0) {
+ b.pop();
+ }
+ };
+ Int10.prototype.toString = function (base) {
+ if ((base || 10) != 10) {
+ throw new Error("only base 10 is supported");
+ }
+ var b = this.buf;
+ var s = b[b.length - 1].toString();
+ for (var i = b.length - 2; i >= 0; --i) {
+ s += (max + b[i]).toString().substring(1);
+ }
+ return s;
+ };
+ Int10.prototype.valueOf = function () {
+ var b = this.buf;
+ var v = 0;
+ for (var i = b.length - 1; i >= 0; --i) {
+ v = v * max + b[i];
+ }
+ return v;
+ };
+ Int10.prototype.simplify = function () {
+ var b = this.buf;
+ return (b.length == 1) ? b[0] : this;
+ };
+ return Int10;
+}());
+
+// ASN.1 JavaScript decoder
+var ellipsis = "\u2026";
+var reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
+var reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
+function stringCut(str, len) {
+ if (str.length > len) {
+ str = str.substring(0, len) + ellipsis;
+ }
+ return str;
+}
+var Stream = /** @class */ (function () {
+ function Stream(enc, pos) {
+ this.hexDigits = "0123456789ABCDEF";
+ if (enc instanceof Stream) {
+ this.enc = enc.enc;
+ this.pos = enc.pos;
+ }
+ else {
+ // enc should be an array or a binary string
+ this.enc = enc;
+ this.pos = pos;
+ }
+ }
+ Stream.prototype.get = function (pos) {
+ if (pos === undefined) {
+ pos = this.pos++;
+ }
+ if (pos >= this.enc.length) {
+ throw new Error("Requesting byte offset " + pos + " on a stream of length " + this.enc.length);
+ }
+ return ("string" === typeof this.enc) ? this.enc.charCodeAt(pos) : this.enc[pos];
+ };
+ Stream.prototype.hexByte = function (b) {
+ return this.hexDigits.charAt((b >> 4) & 0xF) + this.hexDigits.charAt(b & 0xF);
+ };
+ Stream.prototype.hexDump = function (start, end, raw) {
+ var s = "";
+ for (var i = start; i < end; ++i) {
+ s += this.hexByte(this.get(i));
+ if (raw !== true) {
+ switch (i & 0xF) {
+ case 0x7:
+ s += " ";
+ break;
+ case 0xF:
+ s += "\n";
+ break;
+ default:
+ s += " ";
+ }
+ }
+ }
+ return s;
+ };
+ Stream.prototype.isASCII = function (start, end) {
+ for (var i = start; i < end; ++i) {
+ var c = this.get(i);
+ if (c < 32 || c > 176) {
+ return false;
+ }
+ }
+ return true;
+ };
+ Stream.prototype.parseStringISO = function (start, end) {
+ var s = "";
+ for (var i = start; i < end; ++i) {
+ s += String.fromCharCode(this.get(i));
+ }
+ return s;
+ };
+ Stream.prototype.parseStringUTF = function (start, end) {
+ var s = "";
+ for (var i = start; i < end;) {
+ var c = this.get(i++);
+ if (c < 128) {
+ s += String.fromCharCode(c);
+ }
+ else if ((c > 191) && (c < 224)) {
+ s += String.fromCharCode(((c & 0x1F) << 6) | (this.get(i++) & 0x3F));
+ }
+ else {
+ s += String.fromCharCode(((c & 0x0F) << 12) | ((this.get(i++) & 0x3F) << 6) | (this.get(i++) & 0x3F));
+ }
+ }
+ return s;
+ };
+ Stream.prototype.parseStringBMP = function (start, end) {
+ var str = "";
+ var hi;
+ var lo;
+ for (var i = start; i < end;) {
+ hi = this.get(i++);
+ lo = this.get(i++);
+ str += String.fromCharCode((hi << 8) | lo);
+ }
+ return str;
+ };
+ Stream.prototype.parseTime = function (start, end, shortYear) {
+ var s = this.parseStringISO(start, end);
+ var m = (shortYear ? reTimeS : reTimeL).exec(s);
+ if (!m) {
+ return "Unrecognized time: " + s;
+ }
+ if (shortYear) {
+ // to avoid querying the timer, use the fixed range [1970, 2069]
+ // it will conform with ITU X.400 [-10, +40] sliding window until 2030
+ m[1] = +m[1];
+ m[1] += (+m[1] < 70) ? 2000 : 1900;
+ }
+ s = m[1] + "-" + m[2] + "-" + m[3] + " " + m[4];
+ if (m[5]) {
+ s += ":" + m[5];
+ if (m[6]) {
+ s += ":" + m[6];
+ if (m[7]) {
+ s += "." + m[7];
+ }
+ }
+ }
+ if (m[8]) {
+ s += " UTC";
+ if (m[8] != "Z") {
+ s += m[8];
+ if (m[9]) {
+ s += ":" + m[9];
+ }
+ }
+ }
+ return s;
+ };
+ Stream.prototype.parseInteger = function (start, end) {
+ var v = this.get(start);
+ var neg = (v > 127);
+ var pad = neg ? 255 : 0;
+ var len;
+ var s = "";
+ // skip unuseful bits (not allowed in DER)
+ while (v == pad && ++start < end) {
+ v = this.get(start);
+ }
+ len = end - start;
+ if (len === 0) {
+ return neg ? -1 : 0;
+ }
+ // show bit length of huge integers
+ if (len > 4) {
+ s = v;
+ len <<= 3;
+ while (((+s ^ pad) & 0x80) == 0) {
+ s = +s << 1;
+ --len;
+ }
+ s = "(" + len + " bit)\n";
+ }
+ // decode the integer
+ if (neg) {
+ v = v - 256;
+ }
+ var n = new Int10(v);
+ for (var i = start + 1; i < end; ++i) {
+ n.mulAdd(256, this.get(i));
+ }
+ return s + n.toString();
+ };
+ Stream.prototype.parseBitString = function (start, end, maxLength) {
+ var unusedBit = this.get(start);
+ var lenBit = ((end - start - 1) << 3) - unusedBit;
+ var intro = "(" + lenBit + " bit)\n";
+ var s = "";
+ for (var i = start + 1; i < end; ++i) {
+ var b = this.get(i);
+ var skip = (i == end - 1) ? unusedBit : 0;
+ for (var j = 7; j >= skip; --j) {
+ s += (b >> j) & 1 ? "1" : "0";
+ }
+ if (s.length > maxLength) {
+ return intro + stringCut(s, maxLength);
+ }
+ }
+ return intro + s;
+ };
+ Stream.prototype.parseOctetString = function (start, end, maxLength) {
+ if (this.isASCII(start, end)) {
+ return stringCut(this.parseStringISO(start, end), maxLength);
+ }
+ var len = end - start;
+ var s = "(" + len + " byte)\n";
+ maxLength /= 2; // we work in bytes
+ if (len > maxLength) {
+ end = start + maxLength;
+ }
+ for (var i = start; i < end; ++i) {
+ s += this.hexByte(this.get(i));
+ }
+ if (len > maxLength) {
+ s += ellipsis;
+ }
+ return s;
+ };
+ Stream.prototype.parseOID = function (start, end, maxLength) {
+ var s = "";
+ var n = new Int10();
+ var bits = 0;
+ for (var i = start; i < end; ++i) {
+ var v = this.get(i);
+ n.mulAdd(128, v & 0x7F);
+ bits += 7;
+ if (!(v & 0x80)) { // finished
+ if (s === "") {
+ n = n.simplify();
+ if (n instanceof Int10) {
+ n.sub(80);
+ s = "2." + n.toString();
+ }
+ else {
+ var m = n < 80 ? n < 40 ? 0 : 1 : 2;
+ s = m + "." + (n - m * 40);
+ }
+ }
+ else {
+ s += "." + n.toString();
+ }
+ if (s.length > maxLength) {
+ return stringCut(s, maxLength);
+ }
+ n = new Int10();
+ bits = 0;
+ }
+ }
+ if (bits > 0) {
+ s += ".incomplete";
+ }
+ return s;
+ };
+ return Stream;
+}());
+var ASN1 = /** @class */ (function () {
+ function ASN1(stream, header, length, tag, sub) {
+ if (!(tag instanceof ASN1Tag)) {
+ throw new Error("Invalid tag value.");
+ }
+ this.stream = stream;
+ this.header = header;
+ this.length = length;
+ this.tag = tag;
+ this.sub = sub;
+ }
+ ASN1.prototype.typeName = function () {
+ switch (this.tag.tagClass) {
+ case 0: // universal
+ switch (this.tag.tagNumber) {
+ case 0x00:
+ return "EOC";
+ case 0x01:
+ return "BOOLEAN";
+ case 0x02:
+ return "INTEGER";
+ case 0x03:
+ return "BIT_STRING";
+ case 0x04:
+ return "OCTET_STRING";
+ case 0x05:
+ return "NULL";
+ case 0x06:
+ return "OBJECT_IDENTIFIER";
+ case 0x07:
+ return "ObjectDescriptor";
+ case 0x08:
+ return "EXTERNAL";
+ case 0x09:
+ return "REAL";
+ case 0x0A:
+ return "ENUMERATED";
+ case 0x0B:
+ return "EMBEDDED_PDV";
+ case 0x0C:
+ return "UTF8String";
+ case 0x10:
+ return "SEQUENCE";
+ case 0x11:
+ return "SET";
+ case 0x12:
+ return "NumericString";
+ case 0x13:
+ return "PrintableString"; // ASCII subset
+ case 0x14:
+ return "TeletexString"; // aka T61String
+ case 0x15:
+ return "VideotexString";
+ case 0x16:
+ return "IA5String"; // ASCII
+ case 0x17:
+ return "UTCTime";
+ case 0x18:
+ return "GeneralizedTime";
+ case 0x19:
+ return "GraphicString";
+ case 0x1A:
+ return "VisibleString"; // ASCII subset
+ case 0x1B:
+ return "GeneralString";
+ case 0x1C:
+ return "UniversalString";
+ case 0x1E:
+ return "BMPString";
+ }
+ return "Universal_" + this.tag.tagNumber.toString();
+ case 1:
+ return "Application_" + this.tag.tagNumber.toString();
+ case 2:
+ return "[" + this.tag.tagNumber.toString() + "]"; // Context
+ case 3:
+ return "Private_" + this.tag.tagNumber.toString();
+ }
+ };
+ ASN1.prototype.content = function (maxLength) {
+ if (this.tag === undefined) {
+ return null;
+ }
+ if (maxLength === undefined) {
+ maxLength = Infinity;
+ }
+ var content = this.posContent();
+ var len = Math.abs(this.length);
+ if (!this.tag.isUniversal()) {
+ if (this.sub !== null) {
+ return "(" + this.sub.length + " elem)";
+ }
+ return this.stream.parseOctetString(content, content + len, maxLength);
+ }
+ switch (this.tag.tagNumber) {
+ case 0x01: // BOOLEAN
+ return (this.stream.get(content) === 0) ? "false" : "true";
+ case 0x02: // INTEGER
+ return this.stream.parseInteger(content, content + len);
+ case 0x03: // BIT_STRING
+ return this.sub ? "(" + this.sub.length + " elem)" :
+ this.stream.parseBitString(content, content + len, maxLength);
+ case 0x04: // OCTET_STRING
+ return this.sub ? "(" + this.sub.length + " elem)" :
+ this.stream.parseOctetString(content, content + len, maxLength);
+ // case 0x05: // NULL
+ case 0x06: // OBJECT_IDENTIFIER
+ return this.stream.parseOID(content, content + len, maxLength);
+ // case 0x07: // ObjectDescriptor
+ // case 0x08: // EXTERNAL
+ // case 0x09: // REAL
+ // case 0x0A: // ENUMERATED
+ // case 0x0B: // EMBEDDED_PDV
+ case 0x10: // SEQUENCE
+ case 0x11: // SET
+ if (this.sub !== null) {
+ return "(" + this.sub.length + " elem)";
+ }
+ else {
+ return "(no elem)";
+ }
+ case 0x0C: // UTF8String
+ return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
+ case 0x12: // NumericString
+ case 0x13: // PrintableString
+ case 0x14: // TeletexString
+ case 0x15: // VideotexString
+ case 0x16: // IA5String
+ // case 0x19: // GraphicString
+ case 0x1A: // VisibleString
+ // case 0x1B: // GeneralString
+ // case 0x1C: // UniversalString
+ return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
+ case 0x1E: // BMPString
+ return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
+ case 0x17: // UTCTime
+ case 0x18: // GeneralizedTime
+ return this.stream.parseTime(content, content + len, (this.tag.tagNumber == 0x17));
+ }
+ return null;
+ };
+ ASN1.prototype.toString = function () {
+ return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + ((this.sub === null) ? "null" : this.sub.length) + "]";
+ };
+ ASN1.prototype.toPrettyString = function (indent) {
+ if (indent === undefined) {
+ indent = "";
+ }
+ var s = indent + this.typeName() + " @" + this.stream.pos;
+ if (this.length >= 0) {
+ s += "+";
+ }
+ s += this.length;
+ if (this.tag.tagConstructed) {
+ s += " (constructed)";
+ }
+ else if ((this.tag.isUniversal() && ((this.tag.tagNumber == 0x03) || (this.tag.tagNumber == 0x04))) && (this.sub !== null)) {
+ s += " (encapsulates)";
+ }
+ s += "\n";
+ if (this.sub !== null) {
+ indent += " ";
+ for (var i = 0, max = this.sub.length; i < max; ++i) {
+ s += this.sub[i].toPrettyString(indent);
+ }
+ }
+ return s;
+ };
+ ASN1.prototype.posStart = function () {
+ return this.stream.pos;
+ };
+ ASN1.prototype.posContent = function () {
+ return this.stream.pos + this.header;
+ };
+ ASN1.prototype.posEnd = function () {
+ return this.stream.pos + this.header + Math.abs(this.length);
+ };
+ ASN1.prototype.toHexString = function () {
+ return this.stream.hexDump(this.posStart(), this.posEnd(), true);
+ };
+ ASN1.decodeLength = function (stream) {
+ var buf = stream.get();
+ var len = buf & 0x7F;
+ if (len == buf) {
+ return len;
+ }
+ // no reason to use Int10, as it would be a huge buffer anyways
+ if (len > 6) {
+ throw new Error("Length over 48 bits not supported at position " + (stream.pos - 1));
+ }
+ if (len === 0) {
+ return null;
+ } // undefined
+ buf = 0;
+ for (var i = 0; i < len; ++i) {
+ buf = (buf * 256) + stream.get();
+ }
+ return buf;
+ };
+ /**
+ * Retrieve the hexadecimal value (as a string) of the current ASN.1 element
+ * @returns {string}
+ * @public
+ */
+ ASN1.prototype.getHexStringValue = function () {
+ var hexString = this.toHexString();
+ var offset = this.header * 2;
+ var length = this.length * 2;
+ return hexString.substr(offset, length);
+ };
+ ASN1.decode = function (str) {
+ var stream;
+ if (!(str instanceof Stream)) {
+ stream = new Stream(str, 0);
+ }
+ else {
+ stream = str;
+ }
+ var streamStart = new Stream(stream);
+ var tag = new ASN1Tag(stream);
+ var len = ASN1.decodeLength(stream);
+ var start = stream.pos;
+ var header = start - streamStart.pos;
+ var sub = null;
+ var getSub = function () {
+ var ret = [];
+ if (len !== null) {
+ // definite length
+ var end = start + len;
+ while (stream.pos < end) {
+ ret[ret.length] = ASN1.decode(stream);
+ }
+ if (stream.pos != end) {
+ throw new Error("Content size is not correct for container starting at offset " + start);
+ }
+ }
+ else {
+ // undefined length
+ try {
+ for (;;) {
+ var s = ASN1.decode(stream);
+ if (s.tag.isEOC()) {
+ break;
+ }
+ ret[ret.length] = s;
+ }
+ len = start - stream.pos; // undefined lengths are represented as negative values
+ }
+ catch (e) {
+ throw new Error("Exception while decoding undefined length content: " + e);
+ }
+ }
+ return ret;
+ };
+ if (tag.tagConstructed) {
+ // must have valid content
+ sub = getSub();
+ }
+ else if (tag.isUniversal() && ((tag.tagNumber == 0x03) || (tag.tagNumber == 0x04))) {
+ // sometimes BitString and OctetString are used to encapsulate ASN.1
+ try {
+ if (tag.tagNumber == 0x03) {
+ if (stream.get() != 0) {
+ throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
+ }
+ }
+ sub = getSub();
+ for (var i = 0; i < sub.length; ++i) {
+ if (sub[i].tag.isEOC()) {
+ throw new Error("EOC is not supposed to be actual content.");
+ }
+ }
+ }
+ catch (e) {
+ // but silently ignore when they don't
+ sub = null;
+ }
+ }
+ if (sub === null) {
+ if (len === null) {
+ throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
+ }
+ stream.pos = start + Math.abs(len);
+ }
+ return new ASN1(streamStart, header, len, tag, sub);
+ };
+ return ASN1;
+}());
+var ASN1Tag = /** @class */ (function () {
+ function ASN1Tag(stream) {
+ var buf = stream.get();
+ this.tagClass = buf >> 6;
+ this.tagConstructed = ((buf & 0x20) !== 0);
+ this.tagNumber = buf & 0x1F;
+ if (this.tagNumber == 0x1F) { // long tag
+ var n = new Int10();
+ do {
+ buf = stream.get();
+ n.mulAdd(128, buf & 0x7F);
+ } while (buf & 0x80);
+ this.tagNumber = n.simplify();
+ }
+ }
+ ASN1Tag.prototype.isUniversal = function () {
+ return this.tagClass === 0x00;
+ };
+ ASN1Tag.prototype.isEOC = function () {
+ return this.tagClass === 0x00 && this.tagNumber === 0x00;
+ };
+ return ASN1Tag;
+}());
+
+// Copyright (c) 2005 Tom Wu
+// Bits per digit
+var dbits;
+// JavaScript engine analysis
+var canary = 0xdeadbeefcafe;
+var j_lm = ((canary & 0xffffff) == 0xefcafe);
+//#region
+var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
+var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
+//#endregion
+// (public) Constructor
+var BigInteger = /** @class */ (function () {
+ function BigInteger(a, b, c) {
+ if (a != null) {
+ if ("number" == typeof a) {
+ this.fromNumber(a, b, c);
+ }
+ else if (b == null && "string" != typeof a) {
+ this.fromString(a, 256);
+ }
+ else {
+ this.fromString(a, b);
+ }
+ }
+ }
+ //#region PUBLIC
+ // BigInteger.prototype.toString = bnToString;
+ // (public) return string representation in given radix
+ BigInteger.prototype.toString = function (b) {
+ if (this.s < 0) {
+ return "-" + this.negate().toString(b);
+ }
+ var k;
+ if (b == 16) {
+ k = 4;
+ }
+ else if (b == 8) {
+ k = 3;
+ }
+ else if (b == 2) {
+ k = 1;
+ }
+ else if (b == 32) {
+ k = 5;
+ }
+ else if (b == 4) {
+ k = 2;
+ }
+ else {
+ return this.toRadix(b);
+ }
+ var km = (1 << k) - 1;
+ var d;
+ var m = false;
+ var r = "";
+ var i = this.t;
+ var p = this.DB - (i * this.DB) % k;
+ if (i-- > 0) {
+ if (p < this.DB && (d = this[i] >> p) > 0) {
+ m = true;
+ r = int2char(d);
+ }
+ while (i >= 0) {
+ if (p < k) {
+ d = (this[i] & ((1 << p) - 1)) << (k - p);
+ d |= this[--i] >> (p += this.DB - k);
+ }
+ else {
+ d = (this[i] >> (p -= k)) & km;
+ if (p <= 0) {
+ p += this.DB;
+ --i;
+ }
+ }
+ if (d > 0) {
+ m = true;
+ }
+ if (m) {
+ r += int2char(d);
+ }
+ }
+ }
+ return m ? r : "0";
+ };
+ // BigInteger.prototype.negate = bnNegate;
+ // (public) -this
+ BigInteger.prototype.negate = function () {
+ var r = nbi();
+ BigInteger.ZERO.subTo(this, r);
+ return r;
+ };
+ // BigInteger.prototype.abs = bnAbs;
+ // (public) |this|
+ BigInteger.prototype.abs = function () {
+ return (this.s < 0) ? this.negate() : this;
+ };
+ // BigInteger.prototype.compareTo = bnCompareTo;
+ // (public) return + if this > a, - if this < a, 0 if equal
+ BigInteger.prototype.compareTo = function (a) {
+ var r = this.s - a.s;
+ if (r != 0) {
+ return r;
+ }
+ var i = this.t;
+ r = i - a.t;
+ if (r != 0) {
+ return (this.s < 0) ? -r : r;
+ }
+ while (--i >= 0) {
+ if ((r = this[i] - a[i]) != 0) {
+ return r;
+ }
+ }
+ return 0;
+ };
+ // BigInteger.prototype.bitLength = bnBitLength;
+ // (public) return the number of bits in "this"
+ BigInteger.prototype.bitLength = function () {
+ if (this.t <= 0) {
+ return 0;
+ }
+ return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
+ };
+ // BigInteger.prototype.mod = bnMod;
+ // (public) this mod a
+ BigInteger.prototype.mod = function (a) {
+ var r = nbi();
+ this.abs().divRemTo(a, null, r);
+ if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) {
+ a.subTo(r, r);
+ }
+ return r;
+ };
+ // BigInteger.prototype.modPowInt = bnModPowInt;
+ // (public) this^e % m, 0 <= e < 2^32
+ BigInteger.prototype.modPowInt = function (e, m) {
+ var z;
+ if (e < 256 || m.isEven()) {
+ z = new Classic(m);
+ }
+ else {
+ z = new Montgomery(m);
+ }
+ return this.exp(e, z);
+ };
+ // BigInteger.prototype.clone = bnClone;
+ // (public)
+ BigInteger.prototype.clone = function () {
+ var r = nbi();
+ this.copyTo(r);
+ return r;
+ };
+ // BigInteger.prototype.intValue = bnIntValue;
+ // (public) return value as integer
+ BigInteger.prototype.intValue = function () {
+ if (this.s < 0) {
+ if (this.t == 1) {
+ return this[0] - this.DV;
+ }
+ else if (this.t == 0) {
+ return -1;
+ }
+ }
+ else if (this.t == 1) {
+ return this[0];
+ }
+ else if (this.t == 0) {
+ return 0;
+ }
+ // assumes 16 < DB < 32
+ return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
+ };
+ // BigInteger.prototype.byteValue = bnByteValue;
+ // (public) return value as byte
+ BigInteger.prototype.byteValue = function () {
+ return (this.t == 0) ? this.s : (this[0] << 24) >> 24;
+ };
+ // BigInteger.prototype.shortValue = bnShortValue;
+ // (public) return value as short (assumes DB>=16)
+ BigInteger.prototype.shortValue = function () {
+ return (this.t == 0) ? this.s : (this[0] << 16) >> 16;
+ };
+ // BigInteger.prototype.signum = bnSigNum;
+ // (public) 0 if this == 0, 1 if this > 0
+ BigInteger.prototype.signum = function () {
+ if (this.s < 0) {
+ return -1;
+ }
+ else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+ };
+ // BigInteger.prototype.toByteArray = bnToByteArray;
+ // (public) convert to bigendian byte array
+ BigInteger.prototype.toByteArray = function () {
+ var i = this.t;
+ var r = [];
+ r[0] = this.s;
+ var p = this.DB - (i * this.DB) % 8;
+ var d;
+ var k = 0;
+ if (i-- > 0) {
+ if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) {
+ r[k++] = d | (this.s << (this.DB - p));
+ }
+ while (i >= 0) {
+ if (p < 8) {
+ d = (this[i] & ((1 << p) - 1)) << (8 - p);
+ d |= this[--i] >> (p += this.DB - 8);
+ }
+ else {
+ d = (this[i] >> (p -= 8)) & 0xff;
+ if (p <= 0) {
+ p += this.DB;
+ --i;
+ }
+ }
+ if ((d & 0x80) != 0) {
+ d |= -256;
+ }
+ if (k == 0 && (this.s & 0x80) != (d & 0x80)) {
+ ++k;
+ }
+ if (k > 0 || d != this.s) {
+ r[k++] = d;
+ }
+ }
+ }
+ return r;
+ };
+ // BigInteger.prototype.equals = bnEquals;
+ BigInteger.prototype.equals = function (a) {
+ return (this.compareTo(a) == 0);
+ };
+ // BigInteger.prototype.min = bnMin;
+ BigInteger.prototype.min = function (a) {
+ return (this.compareTo(a) < 0) ? this : a;
+ };
+ // BigInteger.prototype.max = bnMax;
+ BigInteger.prototype.max = function (a) {
+ return (this.compareTo(a) > 0) ? this : a;
+ };
+ // BigInteger.prototype.and = bnAnd;
+ BigInteger.prototype.and = function (a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_and, r);
+ return r;
+ };
+ // BigInteger.prototype.or = bnOr;
+ BigInteger.prototype.or = function (a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_or, r);
+ return r;
+ };
+ // BigInteger.prototype.xor = bnXor;
+ BigInteger.prototype.xor = function (a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_xor, r);
+ return r;
+ };
+ // BigInteger.prototype.andNot = bnAndNot;
+ BigInteger.prototype.andNot = function (a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_andnot, r);
+ return r;
+ };
+ // BigInteger.prototype.not = bnNot;
+ // (public) ~this
+ BigInteger.prototype.not = function () {
+ var r = nbi();
+ for (var i = 0; i < this.t; ++i) {
+ r[i] = this.DM & ~this[i];
+ }
+ r.t = this.t;
+ r.s = ~this.s;
+ return r;
+ };
+ // BigInteger.prototype.shiftLeft = bnShiftLeft;
+ // (public) this << n
+ BigInteger.prototype.shiftLeft = function (n) {
+ var r = nbi();
+ if (n < 0) {
+ this.rShiftTo(-n, r);
+ }
+ else {
+ this.lShiftTo(n, r);
+ }
+ return r;
+ };
+ // BigInteger.prototype.shiftRight = bnShiftRight;
+ // (public) this >> n
+ BigInteger.prototype.shiftRight = function (n) {
+ var r = nbi();
+ if (n < 0) {
+ this.lShiftTo(-n, r);
+ }
+ else {
+ this.rShiftTo(n, r);
+ }
+ return r;
+ };
+ // BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
+ // (public) returns index of lowest 1-bit (or -1 if none)
+ BigInteger.prototype.getLowestSetBit = function () {
+ for (var i = 0; i < this.t; ++i) {
+ if (this[i] != 0) {
+ return i * this.DB + lbit(this[i]);
+ }
+ }
+ if (this.s < 0) {
+ return this.t * this.DB;
+ }
+ return -1;
+ };
+ // BigInteger.prototype.bitCount = bnBitCount;
+ // (public) return number of set bits
+ BigInteger.prototype.bitCount = function () {
+ var r = 0;
+ var x = this.s & this.DM;
+ for (var i = 0; i < this.t; ++i) {
+ r += cbit(this[i] ^ x);
+ }
+ return r;
+ };
+ // BigInteger.prototype.testBit = bnTestBit;
+ // (public) true iff nth bit is set
+ BigInteger.prototype.testBit = function (n) {
+ var j = Math.floor(n / this.DB);
+ if (j >= this.t) {
+ return (this.s != 0);
+ }
+ return ((this[j] & (1 << (n % this.DB))) != 0);
+ };
+ // BigInteger.prototype.setBit = bnSetBit;
+ // (public) this | (1<<n)
+ BigInteger.prototype.setBit = function (n) {
+ return this.changeBit(n, op_or);
+ };
+ // BigInteger.prototype.clearBit = bnClearBit;
+ // (public) this & ~(1<<n)
+ BigInteger.prototype.clearBit = function (n) {
+ return this.changeBit(n, op_andnot);
+ };
+ // BigInteger.prototype.flipBit = bnFlipBit;
+ // (public) this ^ (1<<n)
+ BigInteger.prototype.flipBit = function (n) {
+ return this.changeBit(n, op_xor);
+ };
+ // BigInteger.prototype.add = bnAdd;
+ // (public) this + a
+ BigInteger.prototype.add = function (a) {
+ var r = nbi();
+ this.addTo(a, r);
+ return r;
+ };
+ // BigInteger.prototype.subtract = bnSubtract;
+ // (public) this - a
+ BigInteger.prototype.subtract = function (a) {
+ var r = nbi();
+ this.subTo(a, r);
+ return r;
+ };
+ // BigInteger.prototype.multiply = bnMultiply;
+ // (public) this * a
+ BigInteger.prototype.multiply = function (a) {
+ var r = nbi();
+ this.multiplyTo(a, r);
+ return r;
+ };
+ // BigInteger.prototype.divide = bnDivide;
+ // (public) this / a
+ BigInteger.prototype.divide = function (a) {
+ var r = nbi();
+ this.divRemTo(a, r, null);
+ return r;
+ };
+ // BigInteger.prototype.remainder = bnRemainder;
+ // (public) this % a
+ BigInteger.prototype.remainder = function (a) {
+ var r = nbi();
+ this.divRemTo(a, null, r);
+ return r;
+ };
+ // BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
+ // (public) [this/a,this%a]
+ BigInteger.prototype.divideAndRemainder = function (a) {
+ var q = nbi();
+ var r = nbi();
+ this.divRemTo(a, q, r);
+ return [q, r];
+ };
+ // BigInteger.prototype.modPow = bnModPow;
+ // (public) this^e % m (HAC 14.85)
+ BigInteger.prototype.modPow = function (e, m) {
+ var i = e.bitLength();
+ var k;
+ var r = nbv(1);
+ var z;
+ if (i <= 0) {
+ return r;
+ }
+ else if (i < 18) {
+ k = 1;
+ }
+ else if (i < 48) {
+ k = 3;
+ }
+ else if (i < 144) {
+ k = 4;
+ }
+ else if (i < 768) {
+ k = 5;
+ }
+ else {
+ k = 6;
+ }
+ if (i < 8) {
+ z = new Classic(m);
+ }
+ else if (m.isEven()) {
+ z = new Barrett(m);
+ }
+ else {
+ z = new Montgomery(m);
+ }
+ // precomputation
+ var g = [];
+ var n = 3;
+ var k1 = k - 1;
+ var km = (1 << k) - 1;
+ g[1] = z.convert(this);
+ if (k > 1) {
+ var g2 = nbi();
+ z.sqrTo(g[1], g2);
+ while (n <= km) {
+ g[n] = nbi();
+ z.mulTo(g2, g[n - 2], g[n]);
+ n += 2;
+ }
+ }
+ var j = e.t - 1;
+ var w;
+ var is1 = true;
+ var r2 = nbi();
+ var t;
+ i = nbits(e[j]) - 1;
+ while (j >= 0) {
+ if (i >= k1) {
+ w = (e[j] >> (i - k1)) & km;
+ }
+ else {
+ w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
+ if (j > 0) {
+ w |= e[j - 1] >> (this.DB + i - k1);
+ }
+ }
+ n = k;
+ while ((w & 1) == 0) {
+ w >>= 1;
+ --n;
+ }
+ if ((i -= n) < 0) {
+ i += this.DB;
+ --j;
+ }
+ if (is1) { // ret == 1, don't bother squaring or multiplying it
+ g[w].copyTo(r);
+ is1 = false;
+ }
+ else {
+ while (n > 1) {
+ z.sqrTo(r, r2);
+ z.sqrTo(r2, r);
+ n -= 2;
+ }
+ if (n > 0) {
+ z.sqrTo(r, r2);
+ }
+ else {
+ t = r;
+ r = r2;
+ r2 = t;
+ }
+ z.mulTo(r2, g[w], r);
+ }
+ while (j >= 0 && (e[j] & (1 << i)) == 0) {
+ z.sqrTo(r, r2);
+ t = r;
+ r = r2;
+ r2 = t;
+ if (--i < 0) {
+ i = this.DB - 1;
+ --j;
+ }
+ }
+ }
+ return z.revert(r);
+ };
+ // BigInteger.prototype.modInverse = bnModInverse;
+ // (public) 1/this % m (HAC 14.61)
+ BigInteger.prototype.modInverse = function (m) {
+ var ac = m.isEven();
+ if ((this.isEven() && ac) || m.signum() == 0) {
+ return BigInteger.ZERO;
+ }
+ var u = m.clone();
+ var v = this.clone();
+ var a = nbv(1);
+ var b = nbv(0);
+ var c = nbv(0);
+ var d = nbv(1);
+ while (u.signum() != 0) {
+ while (u.isEven()) {
+ u.rShiftTo(1, u);
+ if (ac) {
+ if (!a.isEven() || !b.isEven()) {
+ a.addTo(this, a);
+ b.subTo(m, b);
+ }
+ a.rShiftTo(1, a);
+ }
+ else if (!b.isEven()) {
+ b.subTo(m, b);
+ }
+ b.rShiftTo(1, b);
+ }
+ while (v.isEven()) {
+ v.rShiftTo(1, v);
+ if (ac) {
+ if (!c.isEven() || !d.isEven()) {
+ c.addTo(this, c);
+ d.subTo(m, d);
+ }
+ c.rShiftTo(1, c);
+ }
+ else if (!d.isEven()) {
+ d.subTo(m, d);
+ }
+ d.rShiftTo(1, d);
+ }
+ if (u.compareTo(v) >= 0) {
+ u.subTo(v, u);
+ if (ac) {
+ a.subTo(c, a);
+ }
+ b.subTo(d, b);
+ }
+ else {
+ v.subTo(u, v);
+ if (ac) {
+ c.subTo(a, c);
+ }
+ d.subTo(b, d);
+ }
+ }
+ if (v.compareTo(BigInteger.ONE) != 0) {
+ return BigInteger.ZERO;
+ }
+ if (d.compareTo(m) >= 0) {
+ return d.subtract(m);
+ }
+ if (d.signum() < 0) {
+ d.addTo(m, d);
+ }
+ else {
+ return d;
+ }
+ if (d.signum() < 0) {
+ return d.add(m);
+ }
+ else {
+ return d;
+ }
+ };
+ // BigInteger.prototype.pow = bnPow;
+ // (public) this^e
+ BigInteger.prototype.pow = function (e) {
+ return this.exp(e, new NullExp());
+ };
+ // BigInteger.prototype.gcd = bnGCD;
+ // (public) gcd(this,a) (HAC 14.54)
+ BigInteger.prototype.gcd = function (a) {
+ var x = (this.s < 0) ? this.negate() : this.clone();
+ var y = (a.s < 0) ? a.negate() : a.clone();
+ if (x.compareTo(y) < 0) {
+ var t = x;
+ x = y;
+ y = t;
+ }
+ var i = x.getLowestSetBit();
+ var g = y.getLowestSetBit();
+ if (g < 0) {
+ return x;
+ }
+ if (i < g) {
+ g = i;
+ }
+ if (g > 0) {
+ x.rShiftTo(g, x);
+ y.rShiftTo(g, y);
+ }
+ while (x.signum() > 0) {
+ if ((i = x.getLowestSetBit()) > 0) {
+ x.rShiftTo(i, x);
+ }
+ if ((i = y.getLowestSetBit()) > 0) {
+ y.rShiftTo(i, y);
+ }
+ if (x.compareTo(y) >= 0) {
+ x.subTo(y, x);
+ x.rShiftTo(1, x);
+ }
+ else {
+ y.subTo(x, y);
+ y.rShiftTo(1, y);
+ }
+ }
+ if (g > 0) {
+ y.lShiftTo(g, y);
+ }
+ return y;
+ };
+ // BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
+ // (public) test primality with certainty >= 1-.5^t
+ BigInteger.prototype.isProbablePrime = function (t) {
+ var i;
+ var x = this.abs();
+ if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
+ for (i = 0; i < lowprimes.length; ++i) {
+ if (x[0] == lowprimes[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (x.isEven()) {
+ return false;
+ }
+ i = 1;
+ while (i < lowprimes.length) {
+ var m = lowprimes[i];
+ var j = i + 1;
+ while (j < lowprimes.length && m < lplim) {
+ m *= lowprimes[j++];
+ }
+ m = x.modInt(m);
+ while (i < j) {
+ if (m % lowprimes[i++] == 0) {
+ return false;
+ }
+ }
+ }
+ return x.millerRabin(t);
+ };
+ //#endregion PUBLIC
+ //#region PROTECTED
+ // BigInteger.prototype.copyTo = bnpCopyTo;
+ // (protected) copy this to r
+ BigInteger.prototype.copyTo = function (r) {
+ for (var i = this.t - 1; i >= 0; --i) {
+ r[i] = this[i];
+ }
+ r.t = this.t;
+ r.s = this.s;
+ };
+ // BigInteger.prototype.fromInt = bnpFromInt;
+ // (protected) set from integer value x, -DV <= x < DV
+ BigInteger.prototype.fromInt = function (x) {
+ this.t = 1;
+ this.s = (x < 0) ? -1 : 0;
+ if (x > 0) {
+ this[0] = x;
+ }
+ else if (x < -1) {
+ this[0] = x + this.DV;
+ }
+ else {
+ this.t = 0;
+ }
+ };
+ // BigInteger.prototype.fromString = bnpFromString;
+ // (protected) set from string and radix
+ BigInteger.prototype.fromString = function (s, b) {
+ var k;
+ if (b == 16) {
+ k = 4;
+ }
+ else if (b == 8) {
+ k = 3;
+ }
+ else if (b == 256) {
+ k = 8;
+ /* byte array */
+ }
+ else if (b == 2) {
+ k = 1;
+ }
+ else if (b == 32) {
+ k = 5;
+ }
+ else if (b == 4) {
+ k = 2;
+ }
+ else {
+ this.fromRadix(s, b);
+ return;
+ }
+ this.t = 0;
+ this.s = 0;
+ var i = s.length;
+ var mi = false;
+ var sh = 0;
+ while (--i >= 0) {
+ var x = (k == 8) ? (+s[i]) & 0xff : intAt(s, i);
+ if (x < 0) {
+ if (s.charAt(i) == "-") {
+ mi = true;
+ }
+ continue;
+ }
+ mi = false;
+ if (sh == 0) {
+ this[this.t++] = x;
+ }
+ else if (sh + k > this.DB) {
+ this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
+ this[this.t++] = (x >> (this.DB - sh));
+ }
+ else {
+ this[this.t - 1] |= x << sh;
+ }
+ sh += k;
+ if (sh >= this.DB) {
+ sh -= this.DB;
+ }
+ }
+ if (k == 8 && ((+s[0]) & 0x80) != 0) {
+ this.s = -1;
+ if (sh > 0) {
+ this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
+ }
+ }
+ this.clamp();
+ if (mi) {
+ BigInteger.ZERO.subTo(this, this);
+ }
+ };
+ // BigInteger.prototype.clamp = bnpClamp;
+ // (protected) clamp off excess high words
+ BigInteger.prototype.clamp = function () {
+ var c = this.s & this.DM;
+ while (this.t > 0 && this[this.t - 1] == c) {
+ --this.t;
+ }
+ };
+ // BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
+ // (protected) r = this << n*DB
+ BigInteger.prototype.dlShiftTo = function (n, r) {
+ var i;
+ for (i = this.t - 1; i >= 0; --i) {
+ r[i + n] = this[i];
+ }
+ for (i = n - 1; i >= 0; --i) {
+ r[i] = 0;
+ }
+ r.t = this.t + n;
+ r.s = this.s;
+ };
+ // BigInteger.prototype.drShiftTo = bnpDRShiftTo;
+ // (protected) r = this >> n*DB
+ BigInteger.prototype.drShiftTo = function (n, r) {
+ for (var i = n; i < this.t; ++i) {
+ r[i - n] = this[i];
+ }
+ r.t = Math.max(this.t - n, 0);
+ r.s = this.s;
+ };
+ // BigInteger.prototype.lShiftTo = bnpLShiftTo;
+ // (protected) r = this << n
+ BigInteger.prototype.lShiftTo = function (n, r) {
+ var bs = n % this.DB;
+ var cbs = this.DB - bs;
+ var bm = (1 << cbs) - 1;
+ var ds = Math.floor(n / this.DB);
+ var c = (this.s << bs) & this.DM;
+ for (var i = this.t - 1; i >= 0; --i) {
+ r[i + ds + 1] = (this[i] >> cbs) | c;
+ c = (this[i] & bm) << bs;
+ }
+ for (var i = ds - 1; i >= 0; --i) {
+ r[i] = 0;
+ }
+ r[ds] = c;
+ r.t = this.t + ds + 1;
+ r.s = this.s;
+ r.clamp();
+ };
+ // BigInteger.prototype.rShiftTo = bnpRShiftTo;
+ // (protected) r = this >> n
+ BigInteger.prototype.rShiftTo = function (n, r) {
+ r.s = this.s;
+ var ds = Math.floor(n / this.DB);
+ if (ds >= this.t) {
+ r.t = 0;
+ return;
+ }
+ var bs = n % this.DB;
+ var cbs = this.DB - bs;
+ var bm = (1 << bs) - 1;
+ r[0] = this[ds] >> bs;
+ for (var i = ds + 1; i < this.t; ++i) {
+ r[i - ds - 1] |= (this[i] & bm) << cbs;
+ r[i - ds] = this[i] >> bs;
+ }
+ if (bs > 0) {
+ r[this.t - ds - 1] |= (this.s & bm) << cbs;
+ }
+ r.t = this.t - ds;
+ r.clamp();
+ };
+ // BigInteger.prototype.subTo = bnpSubTo;
+ // (protected) r = this - a
+ BigInteger.prototype.subTo = function (a, r) {
+ var i = 0;
+ var c = 0;
+ var m = Math.min(a.t, this.t);
+ while (i < m) {
+ c += this[i] - a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ if (a.t < this.t) {
+ c -= a.s;
+ while (i < this.t) {
+ c += this[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ }
+ else {
+ c += this.s;
+ while (i < a.t) {
+ c -= a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c -= a.s;
+ }
+ r.s = (c < 0) ? -1 : 0;
+ if (c < -1) {
+ r[i++] = this.DV + c;
+ }
+ else if (c > 0) {
+ r[i++] = c;
+ }
+ r.t = i;
+ r.clamp();
+ };
+ // BigInteger.prototype.multiplyTo = bnpMultiplyTo;
+ // (protected) r = this * a, r != this,a (HAC 14.12)
+ // "this" should be the larger one if appropriate.
+ BigInteger.prototype.multiplyTo = function (a, r) {
+ var x = this.abs();
+ var y = a.abs();
+ var i = x.t;
+ r.t = i + y.t;
+ while (--i >= 0) {
+ r[i] = 0;
+ }
+ for (i = 0; i < y.t; ++i) {
+ r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
+ }
+ r.s = 0;
+ r.clamp();
+ if (this.s != a.s) {
+ BigInteger.ZERO.subTo(r, r);
+ }
+ };
+ // BigInteger.prototype.squareTo = bnpSquareTo;
+ // (protected) r = this^2, r != this (HAC 14.16)
+ BigInteger.prototype.squareTo = function (r) {
+ var x = this.abs();
+ var i = r.t = 2 * x.t;
+ while (--i >= 0) {
+ r[i] = 0;
+ }
+ for (i = 0; i < x.t - 1; ++i) {
+ var c = x.am(i, x[i], r, 2 * i, 0, 1);
+ if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
+ r[i + x.t] -= x.DV;
+ r[i + x.t + 1] = 1;
+ }
+ }
+ if (r.t > 0) {
+ r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
+ }
+ r.s = 0;
+ r.clamp();
+ };
+ // BigInteger.prototype.divRemTo = bnpDivRemTo;
+ // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
+ // r != q, this != m. q or r may be null.
+ BigInteger.prototype.divRemTo = function (m, q, r) {
+ var pm = m.abs();
+ if (pm.t <= 0) {
+ return;
+ }
+ var pt = this.abs();
+ if (pt.t < pm.t) {
+ if (q != null) {
+ q.fromInt(0);
+ }
+ if (r != null) {
+ this.copyTo(r);
+ }
+ return;
+ }
+ if (r == null) {
+ r = nbi();
+ }
+ var y = nbi();
+ var ts = this.s;
+ var ms = m.s;
+ var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
+ if (nsh > 0) {
+ pm.lShiftTo(nsh, y);
+ pt.lShiftTo(nsh, r);
+ }
+ else {
+ pm.copyTo(y);
+ pt.copyTo(r);
+ }
+ var ys = y.t;
+ var y0 = y[ys - 1];
+ if (y0 == 0) {
+ return;
+ }
+ var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
+ var d1 = this.FV / yt;
+ var d2 = (1 << this.F1) / yt;
+ var e = 1 << this.F2;
+ var i = r.t;
+ var j = i - ys;
+ var t = (q == null) ? nbi() : q;
+ y.dlShiftTo(j, t);
+ if (r.compareTo(t) >= 0) {
+ r[r.t++] = 1;
+ r.subTo(t, r);
+ }
+ BigInteger.ONE.dlShiftTo(ys, t);
+ t.subTo(y, y); // "negative" y so we can replace sub with am later
+ while (y.t < ys) {
+ y[y.t++] = 0;
+ }
+ while (--j >= 0) {
+ // Estimate quotient digit
+ var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
+ if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
+ y.dlShiftTo(j, t);
+ r.subTo(t, r);
+ while (r[i] < --qd) {
+ r.subTo(t, r);
+ }
+ }
+ }
+ if (q != null) {
+ r.drShiftTo(ys, q);
+ if (ts != ms) {
+ BigInteger.ZERO.subTo(q, q);
+ }
+ }
+ r.t = ys;
+ r.clamp();
+ if (nsh > 0) {
+ r.rShiftTo(nsh, r);
+ } // Denormalize remainder
+ if (ts < 0) {
+ BigInteger.ZERO.subTo(r, r);
+ }
+ };
+ // BigInteger.prototype.invDigit = bnpInvDigit;
+ // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
+ // justification:
+ // xy == 1 (mod m)
+ // xy = 1+km
+ // xy(2-xy) = (1+km)(1-km)
+ // x[y(2-xy)] = 1-k^2m^2
+ // x[y(2-xy)] == 1 (mod m^2)
+ // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
+ // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
+ // JS multiply "overflows" differently from C/C++, so care is needed here.
+ BigInteger.prototype.invDigit = function () {
+ if (this.t < 1) {
+ return 0;
+ }
+ var x = this[0];
+ if ((x & 1) == 0) {
+ return 0;
+ }
+ var y = x & 3; // y == 1/x mod 2^2
+ y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
+ y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
+ y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
+ // last step - calculate inverse mod DV directly;
+ // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
+ y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
+ // we really want the negative inverse, and -DV < y < DV
+ return (y > 0) ? this.DV - y : -y;
+ };
+ // BigInteger.prototype.isEven = bnpIsEven;
+ // (protected) true iff this is even
+ BigInteger.prototype.isEven = function () {
+ return ((this.t > 0) ? (this[0] & 1) : this.s) == 0;
+ };
+ // BigInteger.prototype.exp = bnpExp;
+ // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
+ BigInteger.prototype.exp = function (e, z) {
+ if (e > 0xffffffff || e < 1) {
+ return BigInteger.ONE;
+ }
+ var r = nbi();
+ var r2 = nbi();
+ var g = z.convert(this);
+ var i = nbits(e) - 1;
+ g.copyTo(r);
+ while (--i >= 0) {
+ z.sqrTo(r, r2);
+ if ((e & (1 << i)) > 0) {
+ z.mulTo(r2, g, r);
+ }
+ else {
+ var t = r;
+ r = r2;
+ r2 = t;
+ }
+ }
+ return z.revert(r);
+ };
+ // BigInteger.prototype.chunkSize = bnpChunkSize;
+ // (protected) return x s.t. r^x < DV
+ BigInteger.prototype.chunkSize = function (r) {
+ return Math.floor(Math.LN2 * this.DB / Math.log(r));
+ };
+ // BigInteger.prototype.toRadix = bnpToRadix;
+ // (protected) convert to radix string
+ BigInteger.prototype.toRadix = function (b) {
+ if (b == null) {
+ b = 10;
+ }
+ if (this.signum() == 0 || b < 2 || b > 36) {
+ return "0";
+ }
+ var cs = this.chunkSize(b);
+ var a = Math.pow(b, cs);
+ var d = nbv(a);
+ var y = nbi();
+ var z = nbi();
+ var r = "";
+ this.divRemTo(d, y, z);
+ while (y.signum() > 0) {
+ r = (a + z.intValue()).toString(b).substr(1) + r;
+ y.divRemTo(d, y, z);
+ }
+ return z.intValue().toString(b) + r;
+ };
+ // BigInteger.prototype.fromRadix = bnpFromRadix;
+ // (protected) convert from radix string
+ BigInteger.prototype.fromRadix = function (s, b) {
+ this.fromInt(0);
+ if (b == null) {
+ b = 10;
+ }
+ var cs = this.chunkSize(b);
+ var d = Math.pow(b, cs);
+ var mi = false;
+ var j = 0;
+ var w = 0;
+ for (var i = 0; i < s.length; ++i) {
+ var x = intAt(s, i);
+ if (x < 0) {
+ if (s.charAt(i) == "-" && this.signum() == 0) {
+ mi = true;
+ }
+ continue;
+ }
+ w = b * w + x;
+ if (++j >= cs) {
+ this.dMultiply(d);
+ this.dAddOffset(w, 0);
+ j = 0;
+ w = 0;
+ }
+ }
+ if (j > 0) {
+ this.dMultiply(Math.pow(b, j));
+ this.dAddOffset(w, 0);
+ }
+ if (mi) {
+ BigInteger.ZERO.subTo(this, this);
+ }
+ };
+ // BigInteger.prototype.fromNumber = bnpFromNumber;
+ // (protected) alternate constructor
+ BigInteger.prototype.fromNumber = function (a, b, c) {
+ if ("number" == typeof b) {
+ // new BigInteger(int,int,RNG)
+ if (a < 2) {
+ this.fromInt(1);
+ }
+ else {
+ this.fromNumber(a, c);
+ if (!this.testBit(a - 1)) {
+ // force MSB set
+ this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
+ }
+ if (this.isEven()) {
+ this.dAddOffset(1, 0);
+ } // force odd
+ while (!this.isProbablePrime(b)) {
+ this.dAddOffset(2, 0);
+ if (this.bitLength() > a) {
+ this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
+ }
+ }
+ }
+ }
+ else {
+ // new BigInteger(int,RNG)
+ var x = [];
+ var t = a & 7;
+ x.length = (a >> 3) + 1;
+ b.nextBytes(x);
+ if (t > 0) {
+ x[0] &= ((1 << t) - 1);
+ }
+ else {
+ x[0] = 0;
+ }
+ this.fromString(x, 256);
+ }
+ };
+ // BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
+ // (protected) r = this op a (bitwise)
+ BigInteger.prototype.bitwiseTo = function (a, op, r) {
+ var i;
+ var f;
+ var m = Math.min(a.t, this.t);
+ for (i = 0; i < m; ++i) {
+ r[i] = op(this[i], a[i]);
+ }
+ if (a.t < this.t) {
+ f = a.s & this.DM;
+ for (i = m; i < this.t; ++i) {
+ r[i] = op(this[i], f);
+ }
+ r.t = this.t;
+ }
+ else {
+ f = this.s & this.DM;
+ for (i = m; i < a.t; ++i) {
+ r[i] = op(f, a[i]);
+ }
+ r.t = a.t;
+ }
+ r.s = op(this.s, a.s);
+ r.clamp();
+ };
+ // BigInteger.prototype.changeBit = bnpChangeBit;
+ // (protected) this op (1<<n)
+ BigInteger.prototype.changeBit = function (n, op) {
+ var r = BigInteger.ONE.shiftLeft(n);
+ this.bitwiseTo(r, op, r);
+ return r;
+ };
+ // BigInteger.prototype.addTo = bnpAddTo;
+ // (protected) r = this + a
+ BigInteger.prototype.addTo = function (a, r) {
+ var i = 0;
+ var c = 0;
+ var m = Math.min(a.t, this.t);
+ while (i < m) {
+ c += this[i] + a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ if (a.t < this.t) {
+ c += a.s;
+ while (i < this.t) {
+ c += this[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ }
+ else {
+ c += this.s;
+ while (i < a.t) {
+ c += a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c += a.s;
+ }
+ r.s = (c < 0) ? -1 : 0;
+ if (c > 0) {
+ r[i++] = c;
+ }
+ else if (c < -1) {
+ r[i++] = this.DV + c;
+ }
+ r.t = i;
+ r.clamp();
+ };
+ // BigInteger.prototype.dMultiply = bnpDMultiply;
+ // (protected) this *= n, this >= 0, 1 < n < DV
+ BigInteger.prototype.dMultiply = function (n) {
+ this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
+ ++this.t;
+ this.clamp();
+ };
+ // BigInteger.prototype.dAddOffset = bnpDAddOffset;
+ // (protected) this += n << w words, this >= 0
+ BigInteger.prototype.dAddOffset = function (n, w) {
+ if (n == 0) {
+ return;
+ }
+ while (this.t <= w) {
+ this[this.t++] = 0;
+ }
+ this[w] += n;
+ while (this[w] >= this.DV) {
+ this[w] -= this.DV;
+ if (++w >= this.t) {
+ this[this.t++] = 0;
+ }
+ ++this[w];
+ }
+ };
+ // BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
+ // (protected) r = lower n words of "this * a", a.t <= n
+ // "this" should be the larger one if appropriate.
+ BigInteger.prototype.multiplyLowerTo = function (a, n, r) {
+ var i = Math.min(this.t + a.t, n);
+ r.s = 0; // assumes a,this >= 0
+ r.t = i;
+ while (i > 0) {
+ r[--i] = 0;
+ }
+ for (var j = r.t - this.t; i < j; ++i) {
+ r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
+ }
+ for (var j = Math.min(a.t, n); i < j; ++i) {
+ this.am(0, a[i], r, i, 0, n - i);
+ }
+ r.clamp();
+ };
+ // BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
+ // (protected) r = "this * a" without lower n words, n > 0
+ // "this" should be the larger one if appropriate.
+ BigInteger.prototype.multiplyUpperTo = function (a, n, r) {
+ --n;
+ var i = r.t = this.t + a.t - n;
+ r.s = 0; // assumes a,this >= 0
+ while (--i >= 0) {
+ r[i] = 0;
+ }
+ for (i = Math.max(n - this.t, 0); i < a.t; ++i) {
+ r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
+ }
+ r.clamp();
+ r.drShiftTo(1, r);
+ };
+ // BigInteger.prototype.modInt = bnpModInt;
+ // (protected) this % n, n < 2^26
+ BigInteger.prototype.modInt = function (n) {
+ if (n <= 0) {
+ return 0;
+ }
+ var d = this.DV % n;
+ var r = (this.s < 0) ? n - 1 : 0;
+ if (this.t > 0) {
+ if (d == 0) {
+ r = this[0] % n;
+ }
+ else {
+ for (var i = this.t - 1; i >= 0; --i) {
+ r = (d * r + this[i]) % n;
+ }
+ }
+ }
+ return r;
+ };
+ // BigInteger.prototype.millerRabin = bnpMillerRabin;
+ // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
+ BigInteger.prototype.millerRabin = function (t) {
+ var n1 = this.subtract(BigInteger.ONE);
+ var k = n1.getLowestSetBit();
+ if (k <= 0) {
+ return false;
+ }
+ var r = n1.shiftRight(k);
+ t = (t + 1) >> 1;
+ if (t > lowprimes.length) {
+ t = lowprimes.length;
+ }
+ var a = nbi();
+ for (var i = 0; i < t; ++i) {
+ // Pick bases at random, instead of starting at 2
+ a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
+ var y = a.modPow(r, this);
+ if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
+ var j = 1;
+ while (j++ < k && y.compareTo(n1) != 0) {
+ y = y.modPowInt(2, this);
+ if (y.compareTo(BigInteger.ONE) == 0) {
+ return false;
+ }
+ }
+ if (y.compareTo(n1) != 0) {
+ return false;
+ }
+ }
+ }
+ return true;
+ };
+ // BigInteger.prototype.square = bnSquare;
+ // (public) this^2
+ BigInteger.prototype.square = function () {
+ var r = nbi();
+ this.squareTo(r);
+ return r;
+ };
+ //#region ASYNC
+ // Public API method
+ BigInteger.prototype.gcda = function (a, callback) {
+ var x = (this.s < 0) ? this.negate() : this.clone();
+ var y = (a.s < 0) ? a.negate() : a.clone();
+ if (x.compareTo(y) < 0) {
+ var t = x;
+ x = y;
+ y = t;
+ }
+ var i = x.getLowestSetBit();
+ var g = y.getLowestSetBit();
+ if (g < 0) {
+ callback(x);
+ return;
+ }
+ if (i < g) {
+ g = i;
+ }
+ if (g > 0) {
+ x.rShiftTo(g, x);
+ y.rShiftTo(g, y);
+ }
+ // Workhorse of the algorithm, gets called 200 - 800 times per 512 bit keygen.
+ var gcda1 = function () {
+ if ((i = x.getLowestSetBit()) > 0) {
+ x.rShiftTo(i, x);
+ }
+ if ((i = y.getLowestSetBit()) > 0) {
+ y.rShiftTo(i, y);
+ }
+ if (x.compareTo(y) >= 0) {
+ x.subTo(y, x);
+ x.rShiftTo(1, x);
+ }
+ else {
+ y.subTo(x, y);
+ y.rShiftTo(1, y);
+ }
+ if (!(x.signum() > 0)) {
+ if (g > 0) {
+ y.lShiftTo(g, y);
+ }
+ setTimeout(function () { callback(y); }, 0); // escape
+ }
+ else {
+ setTimeout(gcda1, 0);
+ }
+ };
+ setTimeout(gcda1, 10);
+ };
+ // (protected) alternate constructor
+ BigInteger.prototype.fromNumberAsync = function (a, b, c, callback) {
+ if ("number" == typeof b) {
+ if (a < 2) {
+ this.fromInt(1);
+ }
+ else {
+ this.fromNumber(a, c);
+ if (!this.testBit(a - 1)) {
+ this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
+ }
+ if (this.isEven()) {
+ this.dAddOffset(1, 0);
+ }
+ var bnp_1 = this;
+ var bnpfn1_1 = function () {
+ bnp_1.dAddOffset(2, 0);
+ if (bnp_1.bitLength() > a) {
+ bnp_1.subTo(BigInteger.ONE.shiftLeft(a - 1), bnp_1);
+ }
+ if (bnp_1.isProbablePrime(b)) {
+ setTimeout(function () { callback(); }, 0); // escape
+ }
+ else {
+ setTimeout(bnpfn1_1, 0);
+ }
+ };
+ setTimeout(bnpfn1_1, 0);
+ }
+ }
+ else {
+ var x = [];
+ var t = a & 7;
+ x.length = (a >> 3) + 1;
+ b.nextBytes(x);
+ if (t > 0) {
+ x[0] &= ((1 << t) - 1);
+ }
+ else {
+ x[0] = 0;
+ }
+ this.fromString(x, 256);
+ }
+ };
+ return BigInteger;
+}());
+//#region REDUCERS
+//#region NullExp
+var NullExp = /** @class */ (function () {
+ function NullExp() {
+ }
+ // NullExp.prototype.convert = nNop;
+ NullExp.prototype.convert = function (x) {
+ return x;
+ };
+ // NullExp.prototype.revert = nNop;
+ NullExp.prototype.revert = function (x) {
+ return x;
+ };
+ // NullExp.prototype.mulTo = nMulTo;
+ NullExp.prototype.mulTo = function (x, y, r) {
+ x.multiplyTo(y, r);
+ };
+ // NullExp.prototype.sqrTo = nSqrTo;
+ NullExp.prototype.sqrTo = function (x, r) {
+ x.squareTo(r);
+ };
+ return NullExp;
+}());
+// Modular reduction using "classic" algorithm
+var Classic = /** @class */ (function () {
+ function Classic(m) {
+ this.m = m;
+ }
+ // Classic.prototype.convert = cConvert;
+ Classic.prototype.convert = function (x) {
+ if (x.s < 0 || x.compareTo(this.m) >= 0) {
+ return x.mod(this.m);
+ }
+ else {
+ return x;
+ }
+ };
+ // Classic.prototype.revert = cRevert;
+ Classic.prototype.revert = function (x) {
+ return x;
+ };
+ // Classic.prototype.reduce = cReduce;
+ Classic.prototype.reduce = function (x) {
+ x.divRemTo(this.m, null, x);
+ };
+ // Classic.prototype.mulTo = cMulTo;
+ Classic.prototype.mulTo = function (x, y, r) {
+ x.multiplyTo(y, r);
+ this.reduce(r);
+ };
+ // Classic.prototype.sqrTo = cSqrTo;
+ Classic.prototype.sqrTo = function (x, r) {
+ x.squareTo(r);
+ this.reduce(r);
+ };
+ return Classic;
+}());
+//#endregion
+//#region Montgomery
+// Montgomery reduction
+var Montgomery = /** @class */ (function () {
+ function Montgomery(m) {
+ this.m = m;
+ this.mp = m.invDigit();
+ this.mpl = this.mp & 0x7fff;
+ this.mph = this.mp >> 15;
+ this.um = (1 << (m.DB - 15)) - 1;
+ this.mt2 = 2 * m.t;
+ }
+ // Montgomery.prototype.convert = montConvert;
+ // xR mod m
+ Montgomery.prototype.convert = function (x) {
+ var r = nbi();
+ x.abs().dlShiftTo(this.m.t, r);
+ r.divRemTo(this.m, null, r);
+ if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) {
+ this.m.subTo(r, r);
+ }
+ return r;
+ };
+ // Montgomery.prototype.revert = montRevert;
+ // x/R mod m
+ Montgomery.prototype.revert = function (x) {
+ var r = nbi();
+ x.copyTo(r);
+ this.reduce(r);
+ return r;
+ };
+ // Montgomery.prototype.reduce = montReduce;
+ // x = x/R mod m (HAC 14.32)
+ Montgomery.prototype.reduce = function (x) {
+ while (x.t <= this.mt2) {
+ // pad x so am has enough room later
+ x[x.t++] = 0;
+ }
+ for (var i = 0; i < this.m.t; ++i) {
+ // faster way of calculating u0 = x[i]*mp mod DV
+ var j = x[i] & 0x7fff;
+ var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
+ // use am to combine the multiply-shift-add into one call
+ j = i + this.m.t;
+ x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
+ // propagate carry
+ while (x[j] >= x.DV) {
+ x[j] -= x.DV;
+ x[++j]++;
+ }
+ }
+ x.clamp();
+ x.drShiftTo(this.m.t, x);
+ if (x.compareTo(this.m) >= 0) {
+ x.subTo(this.m, x);
+ }
+ };
+ // Montgomery.prototype.mulTo = montMulTo;
+ // r = "xy/R mod m"; x,y != r
+ Montgomery.prototype.mulTo = function (x, y, r) {
+ x.multiplyTo(y, r);
+ this.reduce(r);
+ };
+ // Montgomery.prototype.sqrTo = montSqrTo;
+ // r = "x^2/R mod m"; x != r
+ Montgomery.prototype.sqrTo = function (x, r) {
+ x.squareTo(r);
+ this.reduce(r);
+ };
+ return Montgomery;
+}());
+//#endregion Montgomery
+//#region Barrett
+// Barrett modular reduction
+var Barrett = /** @class */ (function () {
+ function Barrett(m) {
+ this.m = m;
+ // setup Barrett
+ this.r2 = nbi();
+ this.q3 = nbi();
+ BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
+ this.mu = this.r2.divide(m);
+ }
+ // Barrett.prototype.convert = barrettConvert;
+ Barrett.prototype.convert = function (x) {
+ if (x.s < 0 || x.t > 2 * this.m.t) {
+ return x.mod(this.m);
+ }
+ else if (x.compareTo(this.m) < 0) {
+ return x;
+ }
+ else {
+ var r = nbi();
+ x.copyTo(r);
+ this.reduce(r);
+ return r;
+ }
+ };
+ // Barrett.prototype.revert = barrettRevert;
+ Barrett.prototype.revert = function (x) {
+ return x;
+ };
+ // Barrett.prototype.reduce = barrettReduce;
+ // x = x mod m (HAC 14.42)
+ Barrett.prototype.reduce = function (x) {
+ x.drShiftTo(this.m.t - 1, this.r2);
+ if (x.t > this.m.t + 1) {
+ x.t = this.m.t + 1;
+ x.clamp();
+ }
+ this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
+ this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
+ while (x.compareTo(this.r2) < 0) {
+ x.dAddOffset(1, this.m.t + 1);
+ }
+ x.subTo(this.r2, x);
+ while (x.compareTo(this.m) >= 0) {
+ x.subTo(this.m, x);
+ }
+ };
+ // Barrett.prototype.mulTo = barrettMulTo;
+ // r = x*y mod m; x,y != r
+ Barrett.prototype.mulTo = function (x, y, r) {
+ x.multiplyTo(y, r);
+ this.reduce(r);
+ };
+ // Barrett.prototype.sqrTo = barrettSqrTo;
+ // r = x^2 mod m; x != r
+ Barrett.prototype.sqrTo = function (x, r) {
+ x.squareTo(r);
+ this.reduce(r);
+ };
+ return Barrett;
+}());
+//#endregion
+//#endregion REDUCERS
+// return new, unset BigInteger
+function nbi() { return new BigInteger(null); }
+function parseBigInt(str, r) {
+ return new BigInteger(str, r);
+}
+// am: Compute w_j += (x*this_i), propagate carries,
+// c is initial carry, returns final carry.
+// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
+// We need to select the fastest one that works in this environment.
+// am1: use a single mult and divide to get the high bits,
+// max digit bits should be 26 because
+// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
+function am1(i, x, w, j, c, n) {
+ while (--n >= 0) {
+ var v = x * this[i++] + w[j] + c;
+ c = Math.floor(v / 0x4000000);
+ w[j++] = v & 0x3ffffff;
+ }
+ return c;
+}
+// am2 avoids a big mult-and-extract completely.
+// Max digit bits should be <= 30 because we do bitwise ops
+// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
+function am2(i, x, w, j, c, n) {
+ var xl = x & 0x7fff;
+ var xh = x >> 15;
+ while (--n >= 0) {
+ var l = this[i] & 0x7fff;
+ var h = this[i++] >> 15;
+ var m = xh * l + h * xl;
+ l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
+ c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
+ w[j++] = l & 0x3fffffff;
+ }
+ return c;
+}
+// Alternately, set max digit bits to 28 since some
+// browsers slow down when dealing with 32-bit numbers.
+function am3(i, x, w, j, c, n) {
+ var xl = x & 0x3fff;
+ var xh = x >> 14;
+ while (--n >= 0) {
+ var l = this[i] & 0x3fff;
+ var h = this[i++] >> 14;
+ var m = xh * l + h * xl;
+ l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
+ c = (l >> 28) + (m >> 14) + xh * h;
+ w[j++] = l & 0xfffffff;
+ }
+ return c;
+}
+if (j_lm && (navigator && navigator.appName == "Microsoft Internet Explorer")) {
+ BigInteger.prototype.am = am2;
+ dbits = 30;
+}
+else if (j_lm && (navigator && navigator.appName != "Netscape")) {
+ BigInteger.prototype.am = am1;
+ dbits = 26;
+}
+else { // Mozilla/Netscape seems to prefer am3
+ BigInteger.prototype.am = am3;
+ dbits = 28;
+}
+BigInteger.prototype.DB = dbits;
+BigInteger.prototype.DM = ((1 << dbits) - 1);
+BigInteger.prototype.DV = (1 << dbits);
+var BI_FP = 52;
+BigInteger.prototype.FV = Math.pow(2, BI_FP);
+BigInteger.prototype.F1 = BI_FP - dbits;
+BigInteger.prototype.F2 = 2 * dbits - BI_FP;
+// Digit conversions
+var BI_RC = [];
+var rr;
+var vv;
+rr = "0".charCodeAt(0);
+for (vv = 0; vv <= 9; ++vv) {
+ BI_RC[rr++] = vv;
+}
+rr = "a".charCodeAt(0);
+for (vv = 10; vv < 36; ++vv) {
+ BI_RC[rr++] = vv;
+}
+rr = "A".charCodeAt(0);
+for (vv = 10; vv < 36; ++vv) {
+ BI_RC[rr++] = vv;
+}
+function intAt(s, i) {
+ var c = BI_RC[s.charCodeAt(i)];
+ return (c == null) ? -1 : c;
+}
+// return bigint initialized to value
+function nbv(i) {
+ var r = nbi();
+ r.fromInt(i);
+ return r;
+}
+// returns bit length of the integer x
+function nbits(x) {
+ var r = 1;
+ var t;
+ if ((t = x >>> 16) != 0) {
+ x = t;
+ r += 16;
+ }
+ if ((t = x >> 8) != 0) {
+ x = t;
+ r += 8;
+ }
+ if ((t = x >> 4) != 0) {
+ x = t;
+ r += 4;
+ }
+ if ((t = x >> 2) != 0) {
+ x = t;
+ r += 2;
+ }
+ if ((t = x >> 1) != 0) {
+ x = t;
+ r += 1;
+ }
+ return r;
+}
+// "constants"
+BigInteger.ZERO = nbv(0);
+BigInteger.ONE = nbv(1);
+
+// prng4.js - uses Arcfour as a PRNG
+var Arcfour = /** @class */ (function () {
+ function Arcfour() {
+ this.i = 0;
+ this.j = 0;
+ this.S = [];
+ }
+ // Arcfour.prototype.init = ARC4init;
+ // Initialize arcfour context from key, an array of ints, each from [0..255]
+ Arcfour.prototype.init = function (key) {
+ var i;
+ var j;
+ var t;
+ for (i = 0; i < 256; ++i) {
+ this.S[i] = i;
+ }
+ j = 0;
+ for (i = 0; i < 256; ++i) {
+ j = (j + this.S[i] + key[i % key.length]) & 255;
+ t = this.S[i];
+ this.S[i] = this.S[j];
+ this.S[j] = t;
+ }
+ this.i = 0;
+ this.j = 0;
+ };
+ // Arcfour.prototype.next = ARC4next;
+ Arcfour.prototype.next = function () {
+ var t;
+ this.i = (this.i + 1) & 255;
+ this.j = (this.j + this.S[this.i]) & 255;
+ t = this.S[this.i];
+ this.S[this.i] = this.S[this.j];
+ this.S[this.j] = t;
+ return this.S[(t + this.S[this.i]) & 255];
+ };
+ return Arcfour;
+}());
+// Plug in your RNG constructor here
+function prng_newstate() {
+ return new Arcfour();
+}
+// Pool size must be a multiple of 4 and greater than 32.
+// An array of bytes the size of the pool will be passed to init()
+var rng_psize = 256;
+
+// Random number generator - requires a PRNG backend, e.g. prng4.js
+var rng_state;
+var rng_pool = null;
+var rng_pptr;
+// Initialize the pool with junk if needed.
+if (rng_pool == null) {
+ rng_pool = [];
+ rng_pptr = 0;
+ var t = void 0;
+ if (window && window.crypto && window.crypto.getRandomValues) {
+ // Extract entropy (2048 bits) from RNG if available
+ var z = new Uint32Array(256);
+ window.crypto.getRandomValues(z);
+ for (t = 0; t < z.length; ++t) {
+ rng_pool[rng_pptr++] = z[t] & 255;
+ }
+ }
+ // Use mouse events for entropy, if we do not have enough entropy by the time
+ // we need it, entropy will be generated by Math.random.
+ var onMouseMoveListener_1 = function (ev) {
+ this.count = this.count || 0;
+ if (this.count >= 256 || rng_pptr >= rng_psize) {
+ if (window.removeEventListener) {
+ window.removeEventListener("mousemove", onMouseMoveListener_1, false);
+ }
+ else if (window.detachEvent) {
+ window.detachEvent("onmousemove", onMouseMoveListener_1);
+ }
+ return;
+ }
+ try {
+ var mouseCoordinates = ev.x + ev.y;
+ rng_pool[rng_pptr++] = mouseCoordinates & 255;
+ this.count += 1;
+ }
+ catch (e) {
+ // Sometimes Firefox will deny permission to access event properties for some reason. Ignore.
+ }
+ };
+ if (window && window.addEventListener) {
+ window.addEventListener("mousemove", onMouseMoveListener_1, false);
+ }
+ else if (window && window.attachEvent) {
+ window.attachEvent("onmousemove", onMouseMoveListener_1);
+ }
+}
+function rng_get_byte() {
+ if (rng_state == null) {
+ rng_state = prng_newstate();
+ // At this point, we may not have collected enough entropy. If not, fall back to Math.random
+ while (rng_pptr < rng_psize) {
+ var random = Math.floor(65536 * Math.random());
+ rng_pool[rng_pptr++] = random & 255;
+ }
+ rng_state.init(rng_pool);
+ for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) {
+ rng_pool[rng_pptr] = 0;
+ }
+ rng_pptr = 0;
+ }
+ // TODO: allow reseeding after first request
+ return rng_state.next();
+}
+var SecureRandom = /** @class */ (function () {
+ function SecureRandom() {
+ }
+ SecureRandom.prototype.nextBytes = function (ba) {
+ for (var i = 0; i < ba.length; ++i) {
+ ba[i] = rng_get_byte();
+ }
+ };
+ return SecureRandom;
+}());
+
+// Depends on jsbn.js and rng.js
+// function linebrk(s,n) {
+// var ret = "";
+// var i = 0;
+// while(i + n < s.length) {
+// ret += s.substring(i,i+n) + "\n";
+// i += n;
+// }
+// return ret + s.substring(i,s.length);
+// }
+// function byte2Hex(b) {
+// if(b < 0x10)
+// return "0" + b.toString(16);
+// else
+// return b.toString(16);
+// }
+function pkcs1pad1(s, n) {
+ if (n < s.length + 22) {
+ console.error("Message too long for RSA");
+ return null;
+ }
+ var len = n - s.length - 6;
+ var filler = "";
+ for (var f = 0; f < len; f += 2) {
+ filler += "ff";
+ }
+ var m = "0001" + filler + "00" + s;
+ return parseBigInt(m, 16);
+}
+// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
+function pkcs1pad2(s, n) {
+ if (n < s.length + 11) { // TODO: fix for utf-8
+ console.error("Message too long for RSA");
+ return null;
+ }
+ var ba = [];
+ var i = s.length - 1;
+ while (i >= 0 && n > 0) {
+ var c = s.charCodeAt(i--);
+ if (c < 128) { // encode using utf-8
+ ba[--n] = c;
+ }
+ else if ((c > 127) && (c < 2048)) {
+ ba[--n] = (c & 63) | 128;
+ ba[--n] = (c >> 6) | 192;
+ }
+ else {
+ ba[--n] = (c & 63) | 128;
+ ba[--n] = ((c >> 6) & 63) | 128;
+ ba[--n] = (c >> 12) | 224;
+ }
+ }
+ ba[--n] = 0;
+ var rng = new SecureRandom();
+ var x = [];
+ while (n > 2) { // random non-zero pad
+ x[0] = 0;
+ while (x[0] == 0) {
+ rng.nextBytes(x);
+ }
+ ba[--n] = x[0];
+ }
+ ba[--n] = 2;
+ ba[--n] = 0;
+ return new BigInteger(ba);
+}
+// "empty" RSA key constructor
+var RSAKey = /** @class */ (function () {
+ function RSAKey() {
+ this.n = null;
+ this.e = 0;
+ this.d = null;
+ this.p = null;
+ this.q = null;
+ this.dmp1 = null;
+ this.dmq1 = null;
+ this.coeff = null;
+ }
+ //#region PROTECTED
+ // protected
+ // RSAKey.prototype.doPublic = RSADoPublic;
+ // Perform raw public operation on "x": return x^e (mod n)
+ RSAKey.prototype.doPublic = function (x) {
+ return x.modPowInt(this.e, this.n);
+ };
+ // RSAKey.prototype.doPrivate = RSADoPrivate;
+ // Perform raw private operation on "x": return x^d (mod n)
+ RSAKey.prototype.doPrivate = function (x) {
+ if (this.p == null || this.q == null) {
+ return x.modPow(this.d, this.n);
+ }
+ // TODO: re-calculate any missing CRT params
+ var xp = x.mod(this.p).modPow(this.dmp1, this.p);
+ var xq = x.mod(this.q).modPow(this.dmq1, this.q);
+ while (xp.compareTo(xq) < 0) {
+ xp = xp.add(this.p);
+ }
+ return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq);
+ };
+ //#endregion PROTECTED
+ //#region PUBLIC
+ // RSAKey.prototype.setPublic = RSASetPublic;
+ // Set the public key fields N and e from hex strings
+ RSAKey.prototype.setPublic = function (N, E) {
+ if (N != null && E != null && N.length > 0 && E.length > 0) {
+ this.n = parseBigInt(N, 16);
+ this.e = parseInt(E, 16);
+ }
+ else {
+ console.error("Invalid RSA public key");
+ }
+ };
+ // RSAKey.prototype.encrypt = RSAEncrypt;
+ // Return the PKCS#1 RSA encryption of "text" as an even-length hex string
+ RSAKey.prototype.encrypt = function (text) {
+ var m = pkcs1pad2(text, (this.n.bitLength() + 7) >> 3);
+ if (m == null) {
+ return null;
+ }
+ var c = this.doPublic(m);
+ if (c == null) {
+ return null;
+ }
+ var h = c.toString(16);
+ if ((h.length & 1) == 0) {
+ return h;
+ }
+ else {
+ return "0" + h;
+ }
+ };
+ // RSAKey.prototype.setPrivate = RSASetPrivate;
+ // Set the private key fields N, e, and d from hex strings
+ RSAKey.prototype.setPrivate = function (N, E, D) {
+ if (N != null && E != null && N.length > 0 && E.length > 0) {
+ this.n = parseBigInt(N, 16);
+ this.e = parseInt(E, 16);
+ this.d = parseBigInt(D, 16);
+ }
+ else {
+ console.error("Invalid RSA private key");
+ }
+ };
+ // RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
+ // Set the private key fields N, e, d and CRT params from hex strings
+ RSAKey.prototype.setPrivateEx = function (N, E, D, P, Q, DP, DQ, C) {
+ if (N != null && E != null && N.length > 0 && E.length > 0) {
+ this.n = parseBigInt(N, 16);
+ this.e = parseInt(E, 16);
+ this.d = parseBigInt(D, 16);
+ this.p = parseBigInt(P, 16);
+ this.q = parseBigInt(Q, 16);
+ this.dmp1 = parseBigInt(DP, 16);
+ this.dmq1 = parseBigInt(DQ, 16);
+ this.coeff = parseBigInt(C, 16);
+ }
+ else {
+ console.error("Invalid RSA private key");
+ }
+ };
+ // RSAKey.prototype.generate = RSAGenerate;
+ // Generate a new random private key B bits long, using public expt E
+ RSAKey.prototype.generate = function (B, E) {
+ var rng = new SecureRandom();
+ var qs = B >> 1;
+ this.e = parseInt(E, 16);
+ var ee = new BigInteger(E, 16);
+ for (;;) {
+ for (;;) {
+ this.p = new BigInteger(B - qs, 1, rng);
+ if (this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) {
+ break;
+ }
+ }
+ for (;;) {
+ this.q = new BigInteger(qs, 1, rng);
+ if (this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) {
+ break;
+ }
+ }
+ if (this.p.compareTo(this.q) <= 0) {
+ var t = this.p;
+ this.p = this.q;
+ this.q = t;
+ }
+ var p1 = this.p.subtract(BigInteger.ONE);
+ var q1 = this.q.subtract(BigInteger.ONE);
+ var phi = p1.multiply(q1);
+ if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
+ this.n = this.p.multiply(this.q);
+ this.d = ee.modInverse(phi);
+ this.dmp1 = this.d.mod(p1);
+ this.dmq1 = this.d.mod(q1);
+ this.coeff = this.q.modInverse(this.p);
+ break;
+ }
+ }
+ };
+ // RSAKey.prototype.decrypt = RSADecrypt;
+ // Return the PKCS#1 RSA decryption of "ctext".
+ // "ctext" is an even-length hex string and the output is a plain string.
+ RSAKey.prototype.decrypt = function (ctext) {
+ var c = parseBigInt(ctext, 16);
+ var m = this.doPrivate(c);
+ if (m == null) {
+ return null;
+ }
+ return pkcs1unpad2(m, (this.n.bitLength() + 7) >> 3);
+ };
+ // Generate a new random private key B bits long, using public expt E
+ RSAKey.prototype.generateAsync = function (B, E, callback) {
+ var rng = new SecureRandom();
+ var qs = B >> 1;
+ this.e = parseInt(E, 16);
+ var ee = new BigInteger(E, 16);
+ var rsa = this;
+ // These functions have non-descript names because they were originally for(;;) loops.
+ // I don't know about cryptography to give them better names than loop1-4.
+ var loop1 = function () {
+ var loop4 = function () {
+ if (rsa.p.compareTo(rsa.q) <= 0) {
+ var t = rsa.p;
+ rsa.p = rsa.q;
+ rsa.q = t;
+ }
+ var p1 = rsa.p.subtract(BigInteger.ONE);
+ var q1 = rsa.q.subtract(BigInteger.ONE);
+ var phi = p1.multiply(q1);
+ if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
+ rsa.n = rsa.p.multiply(rsa.q);
+ rsa.d = ee.modInverse(phi);
+ rsa.dmp1 = rsa.d.mod(p1);
+ rsa.dmq1 = rsa.d.mod(q1);
+ rsa.coeff = rsa.q.modInverse(rsa.p);
+ setTimeout(function () { callback(); }, 0); // escape
+ }
+ else {
+ setTimeout(loop1, 0);
+ }
+ };
+ var loop3 = function () {
+ rsa.q = nbi();
+ rsa.q.fromNumberAsync(qs, 1, rng, function () {
+ rsa.q.subtract(BigInteger.ONE).gcda(ee, function (r) {
+ if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
+ setTimeout(loop4, 0);
+ }
+ else {
+ setTimeout(loop3, 0);
+ }
+ });
+ });
+ };
+ var loop2 = function () {
+ rsa.p = nbi();
+ rsa.p.fromNumberAsync(B - qs, 1, rng, function () {
+ rsa.p.subtract(BigInteger.ONE).gcda(ee, function (r) {
+ if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
+ setTimeout(loop3, 0);
+ }
+ else {
+ setTimeout(loop2, 0);
+ }
+ });
+ });
+ };
+ setTimeout(loop2, 0);
+ };
+ setTimeout(loop1, 0);
+ };
+ RSAKey.prototype.sign = function (text, digestMethod, digestName) {
+ var header = getDigestHeader(digestName);
+ var digest = header + digestMethod(text).toString();
+ var m = pkcs1pad1(digest, this.n.bitLength() / 4);
+ if (m == null) {
+ return null;
+ }
+ var c = this.doPrivate(m);
+ if (c == null) {
+ return null;
+ }
+ var h = c.toString(16);
+ if ((h.length & 1) == 0) {
+ return h;
+ }
+ else {
+ return "0" + h;
+ }
+ };
+ RSAKey.prototype.verify = function (text, signature, digestMethod) {
+ var c = parseBigInt(signature, 16);
+ var m = this.doPublic(c);
+ if (m == null) {
+ return null;
+ }
+ var unpadded = m.toString(16).replace(/^1f+00/, "");
+ var digest = removeDigestHeader(unpadded);
+ return digest == digestMethod(text).toString();
+ };
+ return RSAKey;
+}());
+// Undo PKCS#1 (type 2, random) padding and, if valid, return the plaintext
+function pkcs1unpad2(d, n) {
+ var b = d.toByteArray();
+ var i = 0;
+ while (i < b.length && b[i] == 0) {
+ ++i;
+ }
+ if (b.length - i != n - 1 || b[i] != 2) {
+ return null;
+ }
+ ++i;
+ while (b[i] != 0) {
+ if (++i >= b.length) {
+ return null;
+ }
+ }
+ var ret = "";
+ while (++i < b.length) {
+ var c = b[i] & 255;
+ if (c < 128) { // utf-8 decode
+ ret += String.fromCharCode(c);
+ }
+ else if ((c > 191) && (c < 224)) {
+ ret += String.fromCharCode(((c & 31) << 6) | (b[i + 1] & 63));
+ ++i;
+ }
+ else {
+ ret += String.fromCharCode(((c & 15) << 12) | ((b[i + 1] & 63) << 6) | (b[i + 2] & 63));
+ i += 2;
+ }
+ }
+ return ret;
+}
+// https://tools.ietf.org/html/rfc3447#page-43
+var DIGEST_HEADERS = {
+ md2: "3020300c06082a864886f70d020205000410",
+ md5: "3020300c06082a864886f70d020505000410",
+ sha1: "3021300906052b0e03021a05000414",
+ sha224: "302d300d06096086480165030402040500041c",
+ sha256: "3031300d060960864801650304020105000420",
+ sha384: "3041300d060960864801650304020205000430",
+ sha512: "3051300d060960864801650304020305000440",
+ ripemd160: "3021300906052b2403020105000414",
+};
+function getDigestHeader(name) {
+ return DIGEST_HEADERS[name] || "";
+}
+function removeDigestHeader(str) {
+ for (var name_1 in DIGEST_HEADERS) {
+ if (DIGEST_HEADERS.hasOwnProperty(name_1)) {
+ var header = DIGEST_HEADERS[name_1];
+ var len = header.length;
+ if (str.substr(0, len) == header) {
+ return str.substr(len);
+ }
+ }
+ }
+ return str;
+}
+// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
+// function RSAEncryptB64(text) {
+// var h = this.encrypt(text);
+// if(h) return hex2b64(h); else return null;
+// }
+// public
+// RSAKey.prototype.encrypt_b64 = RSAEncryptB64;
+
+/*!
+Copyright (c) 2011, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.com/yui/license.html
+version: 2.9.0
+*/
+var YAHOO = {};
+YAHOO.lang = {
+ /**
+ * Utility to set up the prototype, constructor and superclass properties to
+ * support an inheritance strategy that can chain constructors and methods.
+ * Static members will not be inherited.
+ *
+ * @method extend
+ * @static
+ * @param {Function} subc the object to modify
+ * @param {Function} superc the object to inherit
+ * @param {Object} overrides additional properties/methods to add to the
+ * subclass prototype. These will override the
+ * matching items obtained from the superclass
+ * if present.
+ */
+ extend: function(subc, superc, overrides) {
+ if (! superc || ! subc) {
+ throw new Error("YAHOO.lang.extend failed, please check that " +
+ "all dependencies are included.");
+ }
+
+ var F = function() {};
+ F.prototype = superc.prototype;
+ subc.prototype = new F();
+ subc.prototype.constructor = subc;
+ subc.superclass = superc.prototype;
+
+ if (superc.prototype.constructor == Object.prototype.constructor) {
+ superc.prototype.constructor = superc;
+ }
+
+ if (overrides) {
+ var i;
+ for (i in overrides) {
+ subc.prototype[i] = overrides[i];
+ }
+
+ /*
+ * IE will not enumerate native functions in a derived object even if the
+ * function was overridden. This is a workaround for specific functions
+ * we care about on the Object prototype.
+ * @property _IEEnumFix
+ * @param {Function} r the object to receive the augmentation
+ * @param {Function} s the object that supplies the properties to augment
+ * @static
+ * @private
+ */
+ var _IEEnumFix = function() {},
+ ADD = ["toString", "valueOf"];
+ try {
+ if (/MSIE/.test(navigator.userAgent)) {
+ _IEEnumFix = function(r, s) {
+ for (i = 0; i < ADD.length; i = i + 1) {
+ var fname = ADD[i], f = s[fname];
+ if (typeof f === 'function' && f != Object.prototype[fname]) {
+ r[fname] = f;
+ }
+ }
+ };
+ }
+ } catch (ex) {} _IEEnumFix(subc.prototype, overrides);
+ }
+ }
+};
+
+/* asn1-1.0.13.js (c) 2013-2017 Kenji Urushima | kjur.github.com/jsrsasign/license
+ */
+
+/**
+ * @fileOverview
+ * @name asn1-1.0.js
+ * @author Kenji Urushima kenji.urushima@gmail.com
+ * @version asn1 1.0.13 (2017-Jun-02)
+ * @since jsrsasign 2.1
+ * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
+ */
+
+/**
+ * kjur's class library name space
+ * <p>
+ * This name space provides following name spaces:
+ * <ul>
+ * <li>{@link KJUR.asn1} - ASN.1 primitive hexadecimal encoder</li>
+ * <li>{@link KJUR.asn1.x509} - ASN.1 structure for X.509 certificate and CRL</li>
+ * <li>{@link KJUR.crypto} - Java Cryptographic Extension(JCE) style MessageDigest/Signature
+ * class and utilities</li>
+ * </ul>
+ * </p>
+ * NOTE: Please ignore method summary and document of this namespace. This caused by a bug of jsdoc2.
+ * @name KJUR
+ * @namespace kjur's class library name space
+ */
+var KJUR = {};
+
+/**
+ * kjur's ASN.1 class library name space
+ * <p>
+ * This is ITU-T X.690 ASN.1 DER encoder class library and
+ * class structure and methods is very similar to
+ * org.bouncycastle.asn1 package of
+ * well known BouncyCaslte Cryptography Library.
+ * <h4>PROVIDING ASN.1 PRIMITIVES</h4>
+ * Here are ASN.1 DER primitive classes.
+ * <ul>
+ * <li>0x01 {@link KJUR.asn1.DERBoolean}</li>
+ * <li>0x02 {@link KJUR.asn1.DERInteger}</li>
+ * <li>0x03 {@link KJUR.asn1.DERBitString}</li>
+ * <li>0x04 {@link KJUR.asn1.DEROctetString}</li>
+ * <li>0x05 {@link KJUR.asn1.DERNull}</li>
+ * <li>0x06 {@link KJUR.asn1.DERObjectIdentifier}</li>
+ * <li>0x0a {@link KJUR.asn1.DEREnumerated}</li>
+ * <li>0x0c {@link KJUR.asn1.DERUTF8String}</li>
+ * <li>0x12 {@link KJUR.asn1.DERNumericString}</li>
+ * <li>0x13 {@link KJUR.asn1.DERPrintableString}</li>
+ * <li>0x14 {@link KJUR.asn1.DERTeletexString}</li>
+ * <li>0x16 {@link KJUR.asn1.DERIA5String}</li>
+ * <li>0x17 {@link KJUR.asn1.DERUTCTime}</li>
+ * <li>0x18 {@link KJUR.asn1.DERGeneralizedTime}</li>
+ * <li>0x30 {@link KJUR.asn1.DERSequence}</li>
+ * <li>0x31 {@link KJUR.asn1.DERSet}</li>
+ * </ul>
+ * <h4>OTHER ASN.1 CLASSES</h4>
+ * <ul>
+ * <li>{@link KJUR.asn1.ASN1Object}</li>
+ * <li>{@link KJUR.asn1.DERAbstractString}</li>
+ * <li>{@link KJUR.asn1.DERAbstractTime}</li>
+ * <li>{@link KJUR.asn1.DERAbstractStructured}</li>
+ * <li>{@link KJUR.asn1.DERTaggedObject}</li>
+ * </ul>
+ * <h4>SUB NAME SPACES</h4>
+ * <ul>
+ * <li>{@link KJUR.asn1.cades} - CAdES long term signature format</li>
+ * <li>{@link KJUR.asn1.cms} - Cryptographic Message Syntax</li>
+ * <li>{@link KJUR.asn1.csr} - Certificate Signing Request (CSR/PKCS#10)</li>
+ * <li>{@link KJUR.asn1.tsp} - RFC 3161 Timestamping Protocol Format</li>
+ * <li>{@link KJUR.asn1.x509} - RFC 5280 X.509 certificate and CRL</li>
+ * </ul>
+ * </p>
+ * NOTE: Please ignore method summary and document of this namespace.
+ * This caused by a bug of jsdoc2.
+ * @name KJUR.asn1
+ * @namespace
+ */
+if (typeof KJUR.asn1 == "undefined" || !KJUR.asn1) KJUR.asn1 = {};
+
+/**
+ * ASN1 utilities class
+ * @name KJUR.asn1.ASN1Util
+ * @class ASN1 utilities class
+ * @since asn1 1.0.2
+ */
+KJUR.asn1.ASN1Util = new function() {
+ this.integerToByteHex = function(i) {
+ var h = i.toString(16);
+ if ((h.length % 2) == 1) h = '0' + h;
+ return h;
+ };
+ this.bigIntToMinTwosComplementsHex = function(bigIntegerValue) {
+ var h = bigIntegerValue.toString(16);
+ if (h.substr(0, 1) != '-') {
+ if (h.length % 2 == 1) {
+ h = '0' + h;
+ } else {
+ if (! h.match(/^[0-7]/)) {
+ h = '00' + h;
+ }
+ }
+ } else {
+ var hPos = h.substr(1);
+ var xorLen = hPos.length;
+ if (xorLen % 2 == 1) {
+ xorLen += 1;
+ } else {
+ if (! h.match(/^[0-7]/)) {
+ xorLen += 2;
+ }
+ }
+ var hMask = '';
+ for (var i = 0; i < xorLen; i++) {
+ hMask += 'f';
+ }
+ var biMask = new BigInteger(hMask, 16);
+ var biNeg = biMask.xor(bigIntegerValue).add(BigInteger.ONE);
+ h = biNeg.toString(16).replace(/^-/, '');
+ }
+ return h;
+ };
+ /**
+ * get PEM string from hexadecimal data and header string
+ * @name getPEMStringFromHex
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {String} dataHex hexadecimal string of PEM body
+ * @param {String} pemHeader PEM header string (ex. 'RSA PRIVATE KEY')
+ * @return {String} PEM formatted string of input data
+ * @description
+ * This method converts a hexadecimal string to a PEM string with
+ * a specified header. Its line break will be CRLF("\r\n").
+ * @example
+ * var pem = KJUR.asn1.ASN1Util.getPEMStringFromHex('616161', 'RSA PRIVATE KEY');
+ * // value of pem will be:
+ * -----BEGIN PRIVATE KEY-----
+ * YWFh
+ * -----END PRIVATE KEY-----
+ */
+ this.getPEMStringFromHex = function(dataHex, pemHeader) {
+ return hextopem(dataHex, pemHeader);
+ };
+
+ /**
+ * generate ASN1Object specifed by JSON parameters
+ * @name newObject
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {Array} param JSON parameter to generate ASN1Object
+ * @return {KJUR.asn1.ASN1Object} generated object
+ * @since asn1 1.0.3
+ * @description
+ * generate any ASN1Object specified by JSON param
+ * including ASN.1 primitive or structured.
+ * Generally 'param' can be described as follows:
+ * <blockquote>
+ * {TYPE-OF-ASNOBJ: ASN1OBJ-PARAMETER}
+ * </blockquote>
+ * 'TYPE-OF-ASN1OBJ' can be one of following symbols:
+ * <ul>
+ * <li>'bool' - DERBoolean</li>
+ * <li>'int' - DERInteger</li>
+ * <li>'bitstr' - DERBitString</li>
+ * <li>'octstr' - DEROctetString</li>
+ * <li>'null' - DERNull</li>
+ * <li>'oid' - DERObjectIdentifier</li>
+ * <li>'enum' - DEREnumerated</li>
+ * <li>'utf8str' - DERUTF8String</li>
+ * <li>'numstr' - DERNumericString</li>
+ * <li>'prnstr' - DERPrintableString</li>
+ * <li>'telstr' - DERTeletexString</li>
+ * <li>'ia5str' - DERIA5String</li>
+ * <li>'utctime' - DERUTCTime</li>
+ * <li>'gentime' - DERGeneralizedTime</li>
+ * <li>'seq' - DERSequence</li>
+ * <li>'set' - DERSet</li>
+ * <li>'tag' - DERTaggedObject</li>
+ * </ul>
+ * @example
+ * newObject({'prnstr': 'aaa'});
+ * newObject({'seq': [{'int': 3}, {'prnstr': 'aaa'}]})
+ * // ASN.1 Tagged Object
+ * newObject({'tag': {'tag': 'a1',
+ * 'explicit': true,
+ * 'obj': {'seq': [{'int': 3}, {'prnstr': 'aaa'}]}}});
+ * // more simple representation of ASN.1 Tagged Object
+ * newObject({'tag': ['a1',
+ * true,
+ * {'seq': [
+ * {'int': 3},
+ * {'prnstr': 'aaa'}]}
+ * ]});
+ */
+ this.newObject = function(param) {
+ var _KJUR = KJUR,
+ _KJUR_asn1 = _KJUR.asn1,
+ _DERBoolean = _KJUR_asn1.DERBoolean,
+ _DERInteger = _KJUR_asn1.DERInteger,
+ _DERBitString = _KJUR_asn1.DERBitString,
+ _DEROctetString = _KJUR_asn1.DEROctetString,
+ _DERNull = _KJUR_asn1.DERNull,
+ _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+ _DEREnumerated = _KJUR_asn1.DEREnumerated,
+ _DERUTF8String = _KJUR_asn1.DERUTF8String,
+ _DERNumericString = _KJUR_asn1.DERNumericString,
+ _DERPrintableString = _KJUR_asn1.DERPrintableString,
+ _DERTeletexString = _KJUR_asn1.DERTeletexString,
+ _DERIA5String = _KJUR_asn1.DERIA5String,
+ _DERUTCTime = _KJUR_asn1.DERUTCTime,
+ _DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime,
+ _DERSequence = _KJUR_asn1.DERSequence,
+ _DERSet = _KJUR_asn1.DERSet,
+ _DERTaggedObject = _KJUR_asn1.DERTaggedObject,
+ _newObject = _KJUR_asn1.ASN1Util.newObject;
+
+ var keys = Object.keys(param);
+ if (keys.length != 1)
+ throw "key of param shall be only one.";
+ var key = keys[0];
+
+ if (":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":" + key + ":") == -1)
+ throw "undefined key: " + key;
+
+ if (key == "bool") return new _DERBoolean(param[key]);
+ if (key == "int") return new _DERInteger(param[key]);
+ if (key == "bitstr") return new _DERBitString(param[key]);
+ if (key == "octstr") return new _DEROctetString(param[key]);
+ if (key == "null") return new _DERNull(param[key]);
+ if (key == "oid") return new _DERObjectIdentifier(param[key]);
+ if (key == "enum") return new _DEREnumerated(param[key]);
+ if (key == "utf8str") return new _DERUTF8String(param[key]);
+ if (key == "numstr") return new _DERNumericString(param[key]);
+ if (key == "prnstr") return new _DERPrintableString(param[key]);
+ if (key == "telstr") return new _DERTeletexString(param[key]);
+ if (key == "ia5str") return new _DERIA5String(param[key]);
+ if (key == "utctime") return new _DERUTCTime(param[key]);
+ if (key == "gentime") return new _DERGeneralizedTime(param[key]);
+
+ if (key == "seq") {
+ var paramList = param[key];
+ var a = [];
+ for (var i = 0; i < paramList.length; i++) {
+ var asn1Obj = _newObject(paramList[i]);
+ a.push(asn1Obj);
+ }
+ return new _DERSequence({'array': a});
+ }
+
+ if (key == "set") {
+ var paramList = param[key];
+ var a = [];
+ for (var i = 0; i < paramList.length; i++) {
+ var asn1Obj = _newObject(paramList[i]);
+ a.push(asn1Obj);
+ }
+ return new _DERSet({'array': a});
+ }
+
+ if (key == "tag") {
+ var tagParam = param[key];
+ if (Object.prototype.toString.call(tagParam) === '[object Array]' &&
+ tagParam.length == 3) {
+ var obj = _newObject(tagParam[2]);
+ return new _DERTaggedObject({tag: tagParam[0],
+ explicit: tagParam[1],
+ obj: obj});
+ } else {
+ var newParam = {};
+ if (tagParam.explicit !== undefined)
+ newParam.explicit = tagParam.explicit;
+ if (tagParam.tag !== undefined)
+ newParam.tag = tagParam.tag;
+ if (tagParam.obj === undefined)
+ throw "obj shall be specified for 'tag'.";
+ newParam.obj = _newObject(tagParam.obj);
+ return new _DERTaggedObject(newParam);
+ }
+ }
+ };
+
+ /**
+ * get encoded hexadecimal string of ASN1Object specifed by JSON parameters
+ * @name jsonToASN1HEX
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {Array} param JSON parameter to generate ASN1Object
+ * @return hexadecimal string of ASN1Object
+ * @since asn1 1.0.4
+ * @description
+ * As for ASN.1 object representation of JSON object,
+ * please see {@link newObject}.
+ * @example
+ * jsonToASN1HEX({'prnstr': 'aaa'});
+ */
+ this.jsonToASN1HEX = function(param) {
+ var asn1Obj = this.newObject(param);
+ return asn1Obj.getEncodedHex();
+ };
+};
+
+/**
+ * get dot noted oid number string from hexadecimal value of OID
+ * @name oidHexToInt
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {String} hex hexadecimal value of object identifier
+ * @return {String} dot noted string of object identifier
+ * @since jsrsasign 4.8.3 asn1 1.0.7
+ * @description
+ * This static method converts from hexadecimal string representation of
+ * ASN.1 value of object identifier to oid number string.
+ * @example
+ * KJUR.asn1.ASN1Util.oidHexToInt('550406') → "2.5.4.6"
+ */
+KJUR.asn1.ASN1Util.oidHexToInt = function(hex) {
+ var s = "";
+ var i01 = parseInt(hex.substr(0, 2), 16);
+ var i0 = Math.floor(i01 / 40);
+ var i1 = i01 % 40;
+ var s = i0 + "." + i1;
+
+ var binbuf = "";
+ for (var i = 2; i < hex.length; i += 2) {
+ var value = parseInt(hex.substr(i, 2), 16);
+ var bin = ("00000000" + value.toString(2)).slice(- 8);
+ binbuf = binbuf + bin.substr(1, 7);
+ if (bin.substr(0, 1) == "0") {
+ var bi = new BigInteger(binbuf, 2);
+ s = s + "." + bi.toString(10);
+ binbuf = "";
+ }
+ }
+ return s;
+};
+
+/**
+ * get hexadecimal value of object identifier from dot noted oid value
+ * @name oidIntToHex
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {String} oidString dot noted string of object identifier
+ * @return {String} hexadecimal value of object identifier
+ * @since jsrsasign 4.8.3 asn1 1.0.7
+ * @description
+ * This static method converts from object identifier value string.
+ * to hexadecimal string representation of it.
+ * @example
+ * KJUR.asn1.ASN1Util.oidIntToHex("2.5.4.6") → "550406"
+ */
+KJUR.asn1.ASN1Util.oidIntToHex = function(oidString) {
+ var itox = function(i) {
+ var h = i.toString(16);
+ if (h.length == 1) h = '0' + h;
+ return h;
+ };
+
+ var roidtox = function(roid) {
+ var h = '';
+ var bi = new BigInteger(roid, 10);
+ var b = bi.toString(2);
+ var padLen = 7 - b.length % 7;
+ if (padLen == 7) padLen = 0;
+ var bPad = '';
+ for (var i = 0; i < padLen; i++) bPad += '0';
+ b = bPad + b;
+ for (var i = 0; i < b.length - 1; i += 7) {
+ var b8 = b.substr(i, 7);
+ if (i != b.length - 7) b8 = '1' + b8;
+ h += itox(parseInt(b8, 2));
+ }
+ return h;
+ };
+
+ if (! oidString.match(/^[0-9.]+$/)) {
+ throw "malformed oid string: " + oidString;
+ }
+ var h = '';
+ var a = oidString.split('.');
+ var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
+ h += itox(i0);
+ a.splice(0, 2);
+ for (var i = 0; i < a.length; i++) {
+ h += roidtox(a[i]);
+ }
+ return h;
+};
+
+
+// ********************************************************************
+// Abstract ASN.1 Classes
+// ********************************************************************
+
+// ********************************************************************
+
+/**
+ * base class for ASN.1 DER encoder object
+ * @name KJUR.asn1.ASN1Object
+ * @class base class for ASN.1 DER encoder object
+ * @property {Boolean} isModified flag whether internal data was changed
+ * @property {String} hTLV hexadecimal string of ASN.1 TLV
+ * @property {String} hT hexadecimal string of ASN.1 TLV tag(T)
+ * @property {String} hL hexadecimal string of ASN.1 TLV length(L)
+ * @property {String} hV hexadecimal string of ASN.1 TLV value(V)
+ * @description
+ */
+KJUR.asn1.ASN1Object = function() {
+ var hV = '';
+
+ /**
+ * get hexadecimal ASN.1 TLV length(L) bytes from TLV value(V)
+ * @name getLengthHexFromValue
+ * @memberOf KJUR.asn1.ASN1Object#
+ * @function
+ * @return {String} hexadecimal string of ASN.1 TLV length(L)
+ */
+ this.getLengthHexFromValue = function() {
+ if (typeof this.hV == "undefined" || this.hV == null) {
+ throw "this.hV is null or undefined.";
+ }
+ if (this.hV.length % 2 == 1) {
+ throw "value hex must be even length: n=" + hV.length + ",v=" + this.hV;
+ }
+ var n = this.hV.length / 2;
+ var hN = n.toString(16);
+ if (hN.length % 2 == 1) {
+ hN = "0" + hN;
+ }
+ if (n < 128) {
+ return hN;
+ } else {
+ var hNlen = hN.length / 2;
+ if (hNlen > 15) {
+ throw "ASN.1 length too long to represent by 8x: n = " + n.toString(16);
+ }
+ var head = 128 + hNlen;
+ return head.toString(16) + hN;
+ }
+ };
+
+ /**
+ * get hexadecimal string of ASN.1 TLV bytes
+ * @name getEncodedHex
+ * @memberOf KJUR.asn1.ASN1Object#
+ * @function
+ * @return {String} hexadecimal string of ASN.1 TLV
+ */
+ this.getEncodedHex = function() {
+ if (this.hTLV == null || this.isModified) {
+ this.hV = this.getFreshValueHex();
+ this.hL = this.getLengthHexFromValue();
+ this.hTLV = this.hT + this.hL + this.hV;
+ this.isModified = false;
+ //alert("first time: " + this.hTLV);
+ }
+ return this.hTLV;
+ };
+
+ /**
+ * get hexadecimal string of ASN.1 TLV value(V) bytes
+ * @name getValueHex
+ * @memberOf KJUR.asn1.ASN1Object#
+ * @function
+ * @return {String} hexadecimal string of ASN.1 TLV value(V) bytes
+ */
+ this.getValueHex = function() {
+ this.getEncodedHex();
+ return this.hV;
+ };
+
+ this.getFreshValueHex = function() {
+ return '';
+ };
+};
+
+// == BEGIN DERAbstractString ================================================
+/**
+ * base class for ASN.1 DER string classes
+ * @name KJUR.asn1.DERAbstractString
+ * @class base class for ASN.1 DER string classes
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @property {String} s internal string of value
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>str - specify initial ASN.1 value(V) by a string</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERAbstractString = function(params) {
+ KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
+
+ /**
+ * get string value of this string object
+ * @name getString
+ * @memberOf KJUR.asn1.DERAbstractString#
+ * @function
+ * @return {String} string value of this string object
+ */
+ this.getString = function() {
+ return this.s;
+ };
+
+ /**
+ * set value by a string
+ * @name setString
+ * @memberOf KJUR.asn1.DERAbstractString#
+ * @function
+ * @param {String} newS value by a string to set
+ */
+ this.setString = function(newS) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.s = newS;
+ this.hV = stohex(this.s);
+ };
+
+ /**
+ * set value by a hexadecimal string
+ * @name setStringHex
+ * @memberOf KJUR.asn1.DERAbstractString#
+ * @function
+ * @param {String} newHexString value by a hexadecimal string to set
+ */
+ this.setStringHex = function(newHexString) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.s = null;
+ this.hV = newHexString;
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+
+ if (typeof params != "undefined") {
+ if (typeof params == "string") {
+ this.setString(params);
+ } else if (typeof params['str'] != "undefined") {
+ this.setString(params['str']);
+ } else if (typeof params['hex'] != "undefined") {
+ this.setStringHex(params['hex']);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
+// == END DERAbstractString ================================================
+
+// == BEGIN DERAbstractTime ==================================================
+/**
+ * base class for ASN.1 DER Generalized/UTCTime class
+ * @name KJUR.asn1.DERAbstractTime
+ * @class base class for ASN.1 DER Generalized/UTCTime class
+ * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERAbstractTime = function(params) {
+ KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
+
+ // --- PRIVATE METHODS --------------------
+ this.localDateToUTC = function(d) {
+ utc = d.getTime() + (d.getTimezoneOffset() * 60000);
+ var utcDate = new Date(utc);
+ return utcDate;
+ };
+
+ /*
+ * format date string by Data object
+ * @name formatDate
+ * @memberOf KJUR.asn1.AbstractTime;
+ * @param {Date} dateObject
+ * @param {string} type 'utc' or 'gen'
+ * @param {boolean} withMillis flag for with millisections or not
+ * @description
+ * 'withMillis' flag is supported from asn1 1.0.6.
+ */
+ this.formatDate = function(dateObject, type, withMillis) {
+ var pad = this.zeroPadding;
+ var d = this.localDateToUTC(dateObject);
+ var year = String(d.getFullYear());
+ if (type == 'utc') year = year.substr(2, 2);
+ var month = pad(String(d.getMonth() + 1), 2);
+ var day = pad(String(d.getDate()), 2);
+ var hour = pad(String(d.getHours()), 2);
+ var min = pad(String(d.getMinutes()), 2);
+ var sec = pad(String(d.getSeconds()), 2);
+ var s = year + month + day + hour + min + sec;
+ if (withMillis === true) {
+ var millis = d.getMilliseconds();
+ if (millis != 0) {
+ var sMillis = pad(String(millis), 3);
+ sMillis = sMillis.replace(/[0]+$/, "");
+ s = s + "." + sMillis;
+ }
+ }
+ return s + "Z";
+ };
+
+ this.zeroPadding = function(s, len) {
+ if (s.length >= len) return s;
+ return new Array(len - s.length + 1).join('0') + s;
+ };
+
+ // --- PUBLIC METHODS --------------------
+ /**
+ * get string value of this string object
+ * @name getString
+ * @memberOf KJUR.asn1.DERAbstractTime#
+ * @function
+ * @return {String} string value of this time object
+ */
+ this.getString = function() {
+ return this.s;
+ };
+
+ /**
+ * set value by a string
+ * @name setString
+ * @memberOf KJUR.asn1.DERAbstractTime#
+ * @function
+ * @param {String} newS value by a string to set such like "130430235959Z"
+ */
+ this.setString = function(newS) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.s = newS;
+ this.hV = stohex(newS);
+ };
+
+ /**
+ * set value by a Date object
+ * @name setByDateValue
+ * @memberOf KJUR.asn1.DERAbstractTime#
+ * @function
+ * @param {Integer} year year of date (ex. 2013)
+ * @param {Integer} month month of date between 1 and 12 (ex. 12)
+ * @param {Integer} day day of month
+ * @param {Integer} hour hours of date
+ * @param {Integer} min minutes of date
+ * @param {Integer} sec seconds of date
+ */
+ this.setByDateValue = function(year, month, day, hour, min, sec) {
+ var dateObject = new Date(Date.UTC(year, month - 1, day, hour, min, sec, 0));
+ this.setByDate(dateObject);
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+};
+YAHOO.lang.extend(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
+// == END DERAbstractTime ==================================================
+
+// == BEGIN DERAbstractStructured ============================================
+/**
+ * base class for ASN.1 DER structured class
+ * @name KJUR.asn1.DERAbstractStructured
+ * @class base class for ASN.1 DER structured class
+ * @property {Array} asn1Array internal array of ASN1Object
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERAbstractStructured = function(params) {
+ KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
+
+ /**
+ * set value by array of ASN1Object
+ * @name setByASN1ObjectArray
+ * @memberOf KJUR.asn1.DERAbstractStructured#
+ * @function
+ * @param {array} asn1ObjectArray array of ASN1Object to set
+ */
+ this.setByASN1ObjectArray = function(asn1ObjectArray) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.asn1Array = asn1ObjectArray;
+ };
+
+ /**
+ * append an ASN1Object to internal array
+ * @name appendASN1Object
+ * @memberOf KJUR.asn1.DERAbstractStructured#
+ * @function
+ * @param {ASN1Object} asn1Object to add
+ */
+ this.appendASN1Object = function(asn1Object) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.asn1Array.push(asn1Object);
+ };
+
+ this.asn1Array = new Array();
+ if (typeof params != "undefined") {
+ if (typeof params['array'] != "undefined") {
+ this.asn1Array = params['array'];
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
+
+
+// ********************************************************************
+// ASN.1 Object Classes
+// ********************************************************************
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Boolean
+ * @name KJUR.asn1.DERBoolean
+ * @class class for ASN.1 DER Boolean
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERBoolean = function() {
+ KJUR.asn1.DERBoolean.superclass.constructor.call(this);
+ this.hT = "01";
+ this.hTLV = "0101ff";
+};
+YAHOO.lang.extend(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Integer
+ * @name KJUR.asn1.DERInteger
+ * @class class for ASN.1 DER Integer
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>int - specify initial ASN.1 value(V) by integer value</li>
+ * <li>bigint - specify initial ASN.1 value(V) by BigInteger object</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERInteger = function(params) {
+ KJUR.asn1.DERInteger.superclass.constructor.call(this);
+ this.hT = "02";
+
+ /**
+ * set value by Tom Wu's BigInteger object
+ * @name setByBigInteger
+ * @memberOf KJUR.asn1.DERInteger#
+ * @function
+ * @param {BigInteger} bigIntegerValue to set
+ */
+ this.setByBigInteger = function(bigIntegerValue) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
+ };
+
+ /**
+ * set value by integer value
+ * @name setByInteger
+ * @memberOf KJUR.asn1.DERInteger
+ * @function
+ * @param {Integer} integer value to set
+ */
+ this.setByInteger = function(intValue) {
+ var bi = new BigInteger(String(intValue), 10);
+ this.setByBigInteger(bi);
+ };
+
+ /**
+ * set value by integer value
+ * @name setValueHex
+ * @memberOf KJUR.asn1.DERInteger#
+ * @function
+ * @param {String} hexadecimal string of integer value
+ * @description
+ * <br/>
+ * NOTE: Value shall be represented by minimum octet length of
+ * two's complement representation.
+ * @example
+ * new KJUR.asn1.DERInteger(123);
+ * new KJUR.asn1.DERInteger({'int': 123});
+ * new KJUR.asn1.DERInteger({'hex': '1fad'});
+ */
+ this.setValueHex = function(newHexString) {
+ this.hV = newHexString;
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+
+ if (typeof params != "undefined") {
+ if (typeof params['bigint'] != "undefined") {
+ this.setByBigInteger(params['bigint']);
+ } else if (typeof params['int'] != "undefined") {
+ this.setByInteger(params['int']);
+ } else if (typeof params == "number") {
+ this.setByInteger(params);
+ } else if (typeof params['hex'] != "undefined") {
+ this.setValueHex(params['hex']);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER encoded BitString primitive
+ * @name KJUR.asn1.DERBitString
+ * @class class for ASN.1 DER encoded BitString primitive
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>bin - specify binary string (ex. '10111')</li>
+ * <li>array - specify array of boolean (ex. [true,false,true,true])</li>
+ * <li>hex - specify hexadecimal string of ASN.1 value(V) including unused bits</li>
+ * <li>obj - specify {@link KJUR.asn1.ASN1Util.newObject}
+ * argument for "BitString encapsulates" structure.</li>
+ * </ul>
+ * NOTE1: 'params' can be omitted.<br/>
+ * NOTE2: 'obj' parameter have been supported since
+ * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).<br/>
+ * @example
+ * // default constructor
+ * o = new KJUR.asn1.DERBitString();
+ * // initialize with binary string
+ * o = new KJUR.asn1.DERBitString({bin: "1011"});
+ * // initialize with boolean array
+ * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]});
+ * // initialize with hexadecimal string (04 is unused bits)
+ * o = new KJUR.asn1.DEROctetString({hex: "04bac0"});
+ * // initialize with ASN1Util.newObject argument for encapsulated
+ * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
+ * // above generates a ASN.1 data like this:
+ * // BIT STRING, encapsulates {
+ * // SEQUENCE {
+ * // INTEGER 3
+ * // PrintableString 'aaa'
+ * // }
+ * // }
+ */
+KJUR.asn1.DERBitString = function(params) {
+ if (params !== undefined && typeof params.obj !== "undefined") {
+ var o = KJUR.asn1.ASN1Util.newObject(params.obj);
+ params.hex = "00" + o.getEncodedHex();
+ }
+ KJUR.asn1.DERBitString.superclass.constructor.call(this);
+ this.hT = "03";
+
+ /**
+ * set ASN.1 value(V) by a hexadecimal string including unused bits
+ * @name setHexValueIncludingUnusedBits
+ * @memberOf KJUR.asn1.DERBitString#
+ * @function
+ * @param {String} newHexStringIncludingUnusedBits
+ */
+ this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.hV = newHexStringIncludingUnusedBits;
+ };
+
+ /**
+ * set ASN.1 value(V) by unused bit and hexadecimal string of value
+ * @name setUnusedBitsAndHexValue
+ * @memberOf KJUR.asn1.DERBitString#
+ * @function
+ * @param {Integer} unusedBits
+ * @param {String} hValue
+ */
+ this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
+ if (unusedBits < 0 || 7 < unusedBits) {
+ throw "unused bits shall be from 0 to 7: u = " + unusedBits;
+ }
+ var hUnusedBits = "0" + unusedBits;
+ this.hTLV = null;
+ this.isModified = true;
+ this.hV = hUnusedBits + hValue;
+ };
+
+ /**
+ * set ASN.1 DER BitString by binary string<br/>
+ * @name setByBinaryString
+ * @memberOf KJUR.asn1.DERBitString#
+ * @function
+ * @param {String} binaryString binary value string (i.e. '10111')
+ * @description
+ * Its unused bits will be calculated automatically by length of
+ * 'binaryValue'. <br/>
+ * NOTE: Trailing zeros '0' will be ignored.
+ * @example
+ * o = new KJUR.asn1.DERBitString();
+ * o.setByBooleanArray("01011");
+ */
+ this.setByBinaryString = function(binaryString) {
+ binaryString = binaryString.replace(/0+$/, '');
+ var unusedBits = 8 - binaryString.length % 8;
+ if (unusedBits == 8) unusedBits = 0;
+ for (var i = 0; i <= unusedBits; i++) {
+ binaryString += '0';
+ }
+ var h = '';
+ for (var i = 0; i < binaryString.length - 1; i += 8) {
+ var b = binaryString.substr(i, 8);
+ var x = parseInt(b, 2).toString(16);
+ if (x.length == 1) x = '0' + x;
+ h += x;
+ }
+ this.hTLV = null;
+ this.isModified = true;
+ this.hV = '0' + unusedBits + h;
+ };
+
+ /**
+ * set ASN.1 TLV value(V) by an array of boolean<br/>
+ * @name setByBooleanArray
+ * @memberOf KJUR.asn1.DERBitString#
+ * @function
+ * @param {array} booleanArray array of boolean (ex. [true, false, true])
+ * @description
+ * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
+ * @example
+ * o = new KJUR.asn1.DERBitString();
+ * o.setByBooleanArray([false, true, false, true, true]);
+ */
+ this.setByBooleanArray = function(booleanArray) {
+ var s = '';
+ for (var i = 0; i < booleanArray.length; i++) {
+ if (booleanArray[i] == true) {
+ s += '1';
+ } else {
+ s += '0';
+ }
+ }
+ this.setByBinaryString(s);
+ };
+
+ /**
+ * generate an array of falses with specified length<br/>
+ * @name newFalseArray
+ * @memberOf KJUR.asn1.DERBitString
+ * @function
+ * @param {Integer} nLength length of array to generate
+ * @return {array} array of boolean falses
+ * @description
+ * This static method may be useful to initialize boolean array.
+ * @example
+ * o = new KJUR.asn1.DERBitString();
+ * o.newFalseArray(3) → [false, false, false]
+ */
+ this.newFalseArray = function(nLength) {
+ var a = new Array(nLength);
+ for (var i = 0; i < nLength; i++) {
+ a[i] = false;
+ }
+ return a;
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+
+ if (typeof params != "undefined") {
+ if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
+ this.setHexValueIncludingUnusedBits(params);
+ } else if (typeof params['hex'] != "undefined") {
+ this.setHexValueIncludingUnusedBits(params['hex']);
+ } else if (typeof params['bin'] != "undefined") {
+ this.setByBinaryString(params['bin']);
+ } else if (typeof params['array'] != "undefined") {
+ this.setByBooleanArray(params['array']);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER OctetString<br/>
+ * @name KJUR.asn1.DEROctetString
+ * @class class for ASN.1 DER OctetString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * This class provides ASN.1 OctetString simple type.<br/>
+ * Supported "params" attributes are:
+ * <ul>
+ * <li>str - to set a string as a value</li>
+ * <li>hex - to set a hexadecimal string as a value</li>
+ * <li>obj - to set a encapsulated ASN.1 value by JSON object
+ * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li>
+ * </ul>
+ * NOTE: A parameter 'obj' have been supported
+ * for "OCTET STRING, encapsulates" structure.
+ * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
+ * @see KJUR.asn1.DERAbstractString - superclass
+ * @example
+ * // default constructor
+ * o = new KJUR.asn1.DEROctetString();
+ * // initialize with string
+ * o = new KJUR.asn1.DEROctetString({str: "aaa"});
+ * // initialize with hexadecimal string
+ * o = new KJUR.asn1.DEROctetString({hex: "616161"});
+ * // initialize with ASN1Util.newObject argument
+ * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
+ * // above generates a ASN.1 data like this:
+ * // OCTET STRING, encapsulates {
+ * // SEQUENCE {
+ * // INTEGER 3
+ * // PrintableString 'aaa'
+ * // }
+ * // }
+ */
+KJUR.asn1.DEROctetString = function(params) {
+ if (params !== undefined && typeof params.obj !== "undefined") {
+ var o = KJUR.asn1.ASN1Util.newObject(params.obj);
+ params.hex = o.getEncodedHex();
+ }
+ KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
+ this.hT = "04";
+};
+YAHOO.lang.extend(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Null
+ * @name KJUR.asn1.DERNull
+ * @class class for ASN.1 DER Null
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERNull = function() {
+ KJUR.asn1.DERNull.superclass.constructor.call(this);
+ this.hT = "05";
+ this.hTLV = "0500";
+};
+YAHOO.lang.extend(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER ObjectIdentifier
+ * @name KJUR.asn1.DERObjectIdentifier
+ * @class class for ASN.1 DER ObjectIdentifier
+ * @param {Array} params associative array of parameters (ex. {'oid': '2.5.4.5'})
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERObjectIdentifier = function(params) {
+ var itox = function(i) {
+ var h = i.toString(16);
+ if (h.length == 1) h = '0' + h;
+ return h;
+ };
+ var roidtox = function(roid) {
+ var h = '';
+ var bi = new BigInteger(roid, 10);
+ var b = bi.toString(2);
+ var padLen = 7 - b.length % 7;
+ if (padLen == 7) padLen = 0;
+ var bPad = '';
+ for (var i = 0; i < padLen; i++) bPad += '0';
+ b = bPad + b;
+ for (var i = 0; i < b.length - 1; i += 7) {
+ var b8 = b.substr(i, 7);
+ if (i != b.length - 7) b8 = '1' + b8;
+ h += itox(parseInt(b8, 2));
+ }
+ return h;
+ };
+
+ KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
+ this.hT = "06";
+
+ /**
+ * set value by a hexadecimal string
+ * @name setValueHex
+ * @memberOf KJUR.asn1.DERObjectIdentifier#
+ * @function
+ * @param {String} newHexString hexadecimal value of OID bytes
+ */
+ this.setValueHex = function(newHexString) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.s = null;
+ this.hV = newHexString;
+ };
+
+ /**
+ * set value by a OID string<br/>
+ * @name setValueOidString
+ * @memberOf KJUR.asn1.DERObjectIdentifier#
+ * @function
+ * @param {String} oidString OID string (ex. 2.5.4.13)
+ * @example
+ * o = new KJUR.asn1.DERObjectIdentifier();
+ * o.setValueOidString("2.5.4.13");
+ */
+ this.setValueOidString = function(oidString) {
+ if (! oidString.match(/^[0-9.]+$/)) {
+ throw "malformed oid string: " + oidString;
+ }
+ var h = '';
+ var a = oidString.split('.');
+ var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
+ h += itox(i0);
+ a.splice(0, 2);
+ for (var i = 0; i < a.length; i++) {
+ h += roidtox(a[i]);
+ }
+ this.hTLV = null;
+ this.isModified = true;
+ this.s = null;
+ this.hV = h;
+ };
+
+ /**
+ * set value by a OID name
+ * @name setValueName
+ * @memberOf KJUR.asn1.DERObjectIdentifier#
+ * @function
+ * @param {String} oidName OID name (ex. 'serverAuth')
+ * @since 1.0.1
+ * @description
+ * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
+ * Otherwise raise error.
+ * @example
+ * o = new KJUR.asn1.DERObjectIdentifier();
+ * o.setValueName("serverAuth");
+ */
+ this.setValueName = function(oidName) {
+ var oid = KJUR.asn1.x509.OID.name2oid(oidName);
+ if (oid !== '') {
+ this.setValueOidString(oid);
+ } else {
+ throw "DERObjectIdentifier oidName undefined: " + oidName;
+ }
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+
+ if (params !== undefined) {
+ if (typeof params === "string") {
+ if (params.match(/^[0-2].[0-9.]+$/)) {
+ this.setValueOidString(params);
+ } else {
+ this.setValueName(params);
+ }
+ } else if (params.oid !== undefined) {
+ this.setValueOidString(params.oid);
+ } else if (params.hex !== undefined) {
+ this.setValueHex(params.hex);
+ } else if (params.name !== undefined) {
+ this.setValueName(params.name);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Enumerated
+ * @name KJUR.asn1.DEREnumerated
+ * @class class for ASN.1 DER Enumerated
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>int - specify initial ASN.1 value(V) by integer value</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ * @example
+ * new KJUR.asn1.DEREnumerated(123);
+ * new KJUR.asn1.DEREnumerated({int: 123});
+ * new KJUR.asn1.DEREnumerated({hex: '1fad'});
+ */
+KJUR.asn1.DEREnumerated = function(params) {
+ KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
+ this.hT = "0a";
+
+ /**
+ * set value by Tom Wu's BigInteger object
+ * @name setByBigInteger
+ * @memberOf KJUR.asn1.DEREnumerated#
+ * @function
+ * @param {BigInteger} bigIntegerValue to set
+ */
+ this.setByBigInteger = function(bigIntegerValue) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
+ };
+
+ /**
+ * set value by integer value
+ * @name setByInteger
+ * @memberOf KJUR.asn1.DEREnumerated#
+ * @function
+ * @param {Integer} integer value to set
+ */
+ this.setByInteger = function(intValue) {
+ var bi = new BigInteger(String(intValue), 10);
+ this.setByBigInteger(bi);
+ };
+
+ /**
+ * set value by integer value
+ * @name setValueHex
+ * @memberOf KJUR.asn1.DEREnumerated#
+ * @function
+ * @param {String} hexadecimal string of integer value
+ * @description
+ * <br/>
+ * NOTE: Value shall be represented by minimum octet length of
+ * two's complement representation.
+ */
+ this.setValueHex = function(newHexString) {
+ this.hV = newHexString;
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+
+ if (typeof params != "undefined") {
+ if (typeof params['int'] != "undefined") {
+ this.setByInteger(params['int']);
+ } else if (typeof params == "number") {
+ this.setByInteger(params);
+ } else if (typeof params['hex'] != "undefined") {
+ this.setValueHex(params['hex']);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER UTF8String
+ * @name KJUR.asn1.DERUTF8String
+ * @class class for ASN.1 DER UTF8String
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERUTF8String = function(params) {
+ KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
+ this.hT = "0c";
+};
+YAHOO.lang.extend(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER NumericString
+ * @name KJUR.asn1.DERNumericString
+ * @class class for ASN.1 DER NumericString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERNumericString = function(params) {
+ KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
+ this.hT = "12";
+};
+YAHOO.lang.extend(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER PrintableString
+ * @name KJUR.asn1.DERPrintableString
+ * @class class for ASN.1 DER PrintableString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERPrintableString = function(params) {
+ KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
+ this.hT = "13";
+};
+YAHOO.lang.extend(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER TeletexString
+ * @name KJUR.asn1.DERTeletexString
+ * @class class for ASN.1 DER TeletexString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERTeletexString = function(params) {
+ KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
+ this.hT = "14";
+};
+YAHOO.lang.extend(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER IA5String
+ * @name KJUR.asn1.DERIA5String
+ * @class class for ASN.1 DER IA5String
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERIA5String = function(params) {
+ KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
+ this.hT = "16";
+};
+YAHOO.lang.extend(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER UTCTime
+ * @name KJUR.asn1.DERUTCTime
+ * @class class for ASN.1 DER UTCTime
+ * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
+ * @extends KJUR.asn1.DERAbstractTime
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * <li>date - specify Date object.</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ * <h4>EXAMPLES</h4>
+ * @example
+ * d1 = new KJUR.asn1.DERUTCTime();
+ * d1.setString('130430125959Z');
+ *
+ * d2 = new KJUR.asn1.DERUTCTime({'str': '130430125959Z'});
+ * d3 = new KJUR.asn1.DERUTCTime({'date': new Date(Date.UTC(2015, 0, 31, 0, 0, 0, 0))});
+ * d4 = new KJUR.asn1.DERUTCTime('130430125959Z');
+ */
+KJUR.asn1.DERUTCTime = function(params) {
+ KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
+ this.hT = "17";
+
+ /**
+ * set value by a Date object<br/>
+ * @name setByDate
+ * @memberOf KJUR.asn1.DERUTCTime#
+ * @function
+ * @param {Date} dateObject Date object to set ASN.1 value(V)
+ * @example
+ * o = new KJUR.asn1.DERUTCTime();
+ * o.setByDate(new Date("2016/12/31"));
+ */
+ this.setByDate = function(dateObject) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.date = dateObject;
+ this.s = this.formatDate(this.date, 'utc');
+ this.hV = stohex(this.s);
+ };
+
+ this.getFreshValueHex = function() {
+ if (typeof this.date == "undefined" && typeof this.s == "undefined") {
+ this.date = new Date();
+ this.s = this.formatDate(this.date, 'utc');
+ this.hV = stohex(this.s);
+ }
+ return this.hV;
+ };
+
+ if (params !== undefined) {
+ if (params.str !== undefined) {
+ this.setString(params.str);
+ } else if (typeof params == "string" && params.match(/^[0-9]{12}Z$/)) {
+ this.setString(params);
+ } else if (params.hex !== undefined) {
+ this.setStringHex(params.hex);
+ } else if (params.date !== undefined) {
+ this.setByDate(params.date);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER GeneralizedTime
+ * @name KJUR.asn1.DERGeneralizedTime
+ * @class class for ASN.1 DER GeneralizedTime
+ * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
+ * @property {Boolean} withMillis flag to show milliseconds or not
+ * @extends KJUR.asn1.DERAbstractTime
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * <li>date - specify Date object.</li>
+ * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
+ * </ul>
+ * NOTE1: 'params' can be omitted.
+ * NOTE2: 'withMillis' property is supported from asn1 1.0.6.
+ */
+KJUR.asn1.DERGeneralizedTime = function(params) {
+ KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
+ this.hT = "18";
+ this.withMillis = false;
+
+ /**
+ * set value by a Date object
+ * @name setByDate
+ * @memberOf KJUR.asn1.DERGeneralizedTime#
+ * @function
+ * @param {Date} dateObject Date object to set ASN.1 value(V)
+ * @example
+ * When you specify UTC time, use 'Date.UTC' method like this:<br/>
+ * o1 = new DERUTCTime();
+ * o1.setByDate(date);
+ *
+ * date = new Date(Date.UTC(2015, 0, 31, 23, 59, 59, 0)); #2015JAN31 23:59:59
+ */
+ this.setByDate = function(dateObject) {
+ this.hTLV = null;
+ this.isModified = true;
+ this.date = dateObject;
+ this.s = this.formatDate(this.date, 'gen', this.withMillis);
+ this.hV = stohex(this.s);
+ };
+
+ this.getFreshValueHex = function() {
+ if (this.date === undefined && this.s === undefined) {
+ this.date = new Date();
+ this.s = this.formatDate(this.date, 'gen', this.withMillis);
+ this.hV = stohex(this.s);
+ }
+ return this.hV;
+ };
+
+ if (params !== undefined) {
+ if (params.str !== undefined) {
+ this.setString(params.str);
+ } else if (typeof params == "string" && params.match(/^[0-9]{14}Z$/)) {
+ this.setString(params);
+ } else if (params.hex !== undefined) {
+ this.setStringHex(params.hex);
+ } else if (params.date !== undefined) {
+ this.setByDate(params.date);
+ }
+ if (params.millis === true) {
+ this.withMillis = true;
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Sequence
+ * @name KJUR.asn1.DERSequence
+ * @class class for ASN.1 DER Sequence
+ * @extends KJUR.asn1.DERAbstractStructured
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>array - specify array of ASN1Object to set elements of content</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERSequence = function(params) {
+ KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
+ this.hT = "30";
+ this.getFreshValueHex = function() {
+ var h = '';
+ for (var i = 0; i < this.asn1Array.length; i++) {
+ var asn1Obj = this.asn1Array[i];
+ h += asn1Obj.getEncodedHex();
+ }
+ this.hV = h;
+ return this.hV;
+ };
+};
+YAHOO.lang.extend(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Set
+ * @name KJUR.asn1.DERSet
+ * @class class for ASN.1 DER Set
+ * @extends KJUR.asn1.DERAbstractStructured
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>array - specify array of ASN1Object to set elements of content</li>
+ * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li>
+ * </ul>
+ * NOTE1: 'params' can be omitted.<br/>
+ * NOTE2: sortflag is supported since 1.0.5.
+ */
+KJUR.asn1.DERSet = function(params) {
+ KJUR.asn1.DERSet.superclass.constructor.call(this, params);
+ this.hT = "31";
+ this.sortFlag = true; // item shall be sorted only in ASN.1 DER
+ this.getFreshValueHex = function() {
+ var a = new Array();
+ for (var i = 0; i < this.asn1Array.length; i++) {
+ var asn1Obj = this.asn1Array[i];
+ a.push(asn1Obj.getEncodedHex());
+ }
+ if (this.sortFlag == true) a.sort();
+ this.hV = a.join('');
+ return this.hV;
+ };
+
+ if (typeof params != "undefined") {
+ if (typeof params.sortflag != "undefined" &&
+ params.sortflag == false)
+ this.sortFlag = false;
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER TaggedObject
+ * @name KJUR.asn1.DERTaggedObject
+ * @class class for ASN.1 DER TaggedObject
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
+ * For example, if you find '[1]' tag in a ASN.1 dump,
+ * 'tagNoHex' will be 'a1'.
+ * <br/>
+ * As for optional argument 'params' for constructor, you can specify *ANY* of
+ * following properties:
+ * <ul>
+ * <li>explicit - specify true if this is explicit tag otherwise false
+ * (default is 'true').</li>
+ * <li>tag - specify tag (default is 'a0' which means [0])</li>
+ * <li>obj - specify ASN1Object which is tagged</li>
+ * </ul>
+ * @example
+ * d1 = new KJUR.asn1.DERUTF8String({'str':'a'});
+ * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
+ * hex = d2.getEncodedHex();
+ */
+KJUR.asn1.DERTaggedObject = function(params) {
+ KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
+ this.hT = "a0";
+ this.hV = '';
+ this.isExplicit = true;
+ this.asn1Object = null;
+
+ /**
+ * set value by an ASN1Object
+ * @name setString
+ * @memberOf KJUR.asn1.DERTaggedObject#
+ * @function
+ * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
+ * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
+ * @param {ASN1Object} asn1Object ASN.1 to encapsulate
+ */
+ this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
+ this.hT = tagNoHex;
+ this.isExplicit = isExplicitFlag;
+ this.asn1Object = asn1Object;
+ if (this.isExplicit) {
+ this.hV = this.asn1Object.getEncodedHex();
+ this.hTLV = null;
+ this.isModified = true;
+ } else {
+ this.hV = null;
+ this.hTLV = asn1Object.getEncodedHex();
+ this.hTLV = this.hTLV.replace(/^../, tagNoHex);
+ this.isModified = false;
+ }
+ };
+
+ this.getFreshValueHex = function() {
+ return this.hV;
+ };
+
+ if (typeof params != "undefined") {
+ if (typeof params['tag'] != "undefined") {
+ this.hT = params['tag'];
+ }
+ if (typeof params['explicit'] != "undefined") {
+ this.isExplicit = params['explicit'];
+ }
+ if (typeof params['obj'] != "undefined") {
+ this.asn1Object = params['obj'];
+ this.setASN1Object(this.isExplicit, this.hT, this.asn1Object);
+ }
+ }
+};
+YAHOO.lang.extend(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
+
+/**
+ * Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object.
+ * This object is just a decorator for parsing the key parameter
+ * @param {string|Object} key - The key in string format, or an object containing
+ * the parameters needed to build a RSAKey object.
+ * @constructor
+ */
+var JSEncryptRSAKey = /** @class */ (function (_super) {
+ __extends(JSEncryptRSAKey, _super);
+ function JSEncryptRSAKey(key) {
+ var _this = _super.call(this) || this;
+ // Call the super constructor.
+ // RSAKey.call(this);
+ // If a key key was provided.
+ if (key) {
+ // If this is a string...
+ if (typeof key === "string") {
+ _this.parseKey(key);
+ }
+ else if (JSEncryptRSAKey.hasPrivateKeyProperty(key) ||
+ JSEncryptRSAKey.hasPublicKeyProperty(key)) {
+ // Set the values for the key.
+ _this.parsePropertiesFrom(key);
+ }
+ }
+ return _this;
+ }
+ /**
+ * Method to parse a pem encoded string containing both a public or private key.
+ * The method will translate the pem encoded string in a der encoded string and
+ * will parse private key and public key parameters. This method accepts public key
+ * in the rsaencryption pkcs #1 format (oid: 1.2.840.113549.1.1.1).
+ *
+ * @todo Check how many rsa formats use the same format of pkcs #1.
+ *
+ * The format is defined as:
+ * PublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * PublicKey BIT STRING
+ * }
+ * Where AlgorithmIdentifier is:
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
+ * parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
+ * }
+ * and PublicKey is a SEQUENCE encapsulated in a BIT STRING
+ * RSAPublicKey ::= SEQUENCE {
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER -- e
+ * }
+ * it's possible to examine the structure of the keys obtained from openssl using
+ * an asn.1 dumper as the one used here to parse the components: http://lapo.it/asn1js/
+ * @argument {string} pem the pem encoded string, can include the BEGIN/END header/footer
+ * @private
+ */
+ JSEncryptRSAKey.prototype.parseKey = function (pem) {
+ try {
+ var modulus = 0;
+ var public_exponent = 0;
+ var reHex = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/;
+ var der = reHex.test(pem) ? Hex.decode(pem) : Base64.unarmor(pem);
+ var asn1 = ASN1.decode(der);
+ // Fixes a bug with OpenSSL 1.0+ private keys
+ if (asn1.sub.length === 3) {
+ asn1 = asn1.sub[2].sub[0];
+ }
+ if (asn1.sub.length === 9) {
+ // Parse the private key.
+ modulus = asn1.sub[1].getHexStringValue(); // bigint
+ this.n = parseBigInt(modulus, 16);
+ public_exponent = asn1.sub[2].getHexStringValue(); // int
+ this.e = parseInt(public_exponent, 16);
+ var private_exponent = asn1.sub[3].getHexStringValue(); // bigint
+ this.d = parseBigInt(private_exponent, 16);
+ var prime1 = asn1.sub[4].getHexStringValue(); // bigint
+ this.p = parseBigInt(prime1, 16);
+ var prime2 = asn1.sub[5].getHexStringValue(); // bigint
+ this.q = parseBigInt(prime2, 16);
+ var exponent1 = asn1.sub[6].getHexStringValue(); // bigint
+ this.dmp1 = parseBigInt(exponent1, 16);
+ var exponent2 = asn1.sub[7].getHexStringValue(); // bigint
+ this.dmq1 = parseBigInt(exponent2, 16);
+ var coefficient = asn1.sub[8].getHexStringValue(); // bigint
+ this.coeff = parseBigInt(coefficient, 16);
+ }
+ else if (asn1.sub.length === 2) {
+ // Parse the public key.
+ var bit_string = asn1.sub[1];
+ var sequence = bit_string.sub[0];
+ modulus = sequence.sub[0].getHexStringValue();
+ this.n = parseBigInt(modulus, 16);
+ public_exponent = sequence.sub[1].getHexStringValue();
+ this.e = parseInt(public_exponent, 16);
+ }
+ else {
+ return false;
+ }
+ return true;
+ }
+ catch (ex) {
+ return false;
+ }
+ };
+ /**
+ * Translate rsa parameters in a hex encoded string representing the rsa key.
+ *
+ * The translation follow the ASN.1 notation :
+ * RSAPrivateKey ::= SEQUENCE {
+ * version Version,
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER, -- e
+ * privateExponent INTEGER, -- d
+ * prime1 INTEGER, -- p
+ * prime2 INTEGER, -- q
+ * exponent1 INTEGER, -- d mod (p1)
+ * exponent2 INTEGER, -- d mod (q-1)
+ * coefficient INTEGER, -- (inverse of q) mod p
+ * }
+ * @returns {string} DER Encoded String representing the rsa private key
+ * @private
+ */
+ JSEncryptRSAKey.prototype.getPrivateBaseKey = function () {
+ var options = {
+ array: [
+ new KJUR.asn1.DERInteger({ int: 0 }),
+ new KJUR.asn1.DERInteger({ bigint: this.n }),
+ new KJUR.asn1.DERInteger({ int: this.e }),
+ new KJUR.asn1.DERInteger({ bigint: this.d }),
+ new KJUR.asn1.DERInteger({ bigint: this.p }),
+ new KJUR.asn1.DERInteger({ bigint: this.q }),
+ new KJUR.asn1.DERInteger({ bigint: this.dmp1 }),
+ new KJUR.asn1.DERInteger({ bigint: this.dmq1 }),
+ new KJUR.asn1.DERInteger({ bigint: this.coeff })
+ ]
+ };
+ var seq = new KJUR.asn1.DERSequence(options);
+ return seq.getEncodedHex();
+ };
+ /**
+ * base64 (pem) encoded version of the DER encoded representation
+ * @returns {string} pem encoded representation without header and footer
+ * @public
+ */
+ JSEncryptRSAKey.prototype.getPrivateBaseKeyB64 = function () {
+ return hex2b64(this.getPrivateBaseKey());
+ };
+ /**
+ * Translate rsa parameters in a hex encoded string representing the rsa public key.
+ * The representation follow the ASN.1 notation :
+ * PublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * PublicKey BIT STRING
+ * }
+ * Where AlgorithmIdentifier is:
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
+ * parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
+ * }
+ * and PublicKey is a SEQUENCE encapsulated in a BIT STRING
+ * RSAPublicKey ::= SEQUENCE {
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER -- e
+ * }
+ * @returns {string} DER Encoded String representing the rsa public key
+ * @private
+ */
+ JSEncryptRSAKey.prototype.getPublicBaseKey = function () {
+ var first_sequence = new KJUR.asn1.DERSequence({
+ array: [
+ new KJUR.asn1.DERObjectIdentifier({ oid: "1.2.840.113549.1.1.1" }),
+ new KJUR.asn1.DERNull()
+ ]
+ });
+ var second_sequence = new KJUR.asn1.DERSequence({
+ array: [
+ new KJUR.asn1.DERInteger({ bigint: this.n }),
+ new KJUR.asn1.DERInteger({ int: this.e })
+ ]
+ });
+ var bit_string = new KJUR.asn1.DERBitString({
+ hex: "00" + second_sequence.getEncodedHex()
+ });
+ var seq = new KJUR.asn1.DERSequence({
+ array: [
+ first_sequence,
+ bit_string
+ ]
+ });
+ return seq.getEncodedHex();
+ };
+ /**
+ * base64 (pem) encoded version of the DER encoded representation
+ * @returns {string} pem encoded representation without header and footer
+ * @public
+ */
+ JSEncryptRSAKey.prototype.getPublicBaseKeyB64 = function () {
+ return hex2b64(this.getPublicBaseKey());
+ };
+ /**
+ * wrap the string in block of width chars. The default value for rsa keys is 64
+ * characters.
+ * @param {string} str the pem encoded string without header and footer
+ * @param {Number} [width=64] - the length the string has to be wrapped at
+ * @returns {string}
+ * @private
+ */
+ JSEncryptRSAKey.wordwrap = function (str, width) {
+ width = width || 64;
+ if (!str) {
+ return str;
+ }
+ var regex = "(.{1," + width + "})( +|$\n?)|(.{1," + width + "})";
+ return str.match(RegExp(regex, "g")).join("\n");
+ };
+ /**
+ * Retrieve the pem encoded private key
+ * @returns {string} the pem encoded private key with header/footer
+ * @public
+ */
+ JSEncryptRSAKey.prototype.getPrivateKey = function () {
+ var key = "-----BEGIN RSA PRIVATE KEY-----\n";
+ key += JSEncryptRSAKey.wordwrap(this.getPrivateBaseKeyB64()) + "\n";
+ key += "-----END RSA PRIVATE KEY-----";
+ return key;
+ };
+ /**
+ * Retrieve the pem encoded public key
+ * @returns {string} the pem encoded public key with header/footer
+ * @public
+ */
+ JSEncryptRSAKey.prototype.getPublicKey = function () {
+ var key = "-----BEGIN PUBLIC KEY-----\n";
+ key += JSEncryptRSAKey.wordwrap(this.getPublicBaseKeyB64()) + "\n";
+ key += "-----END PUBLIC KEY-----";
+ return key;
+ };
+ /**
+ * Check if the object contains the necessary parameters to populate the rsa modulus
+ * and public exponent parameters.
+ * @param {Object} [obj={}] - An object that may contain the two public key
+ * parameters
+ * @returns {boolean} true if the object contains both the modulus and the public exponent
+ * properties (n and e)
+ * @todo check for types of n and e. N should be a parseable bigInt object, E should
+ * be a parseable integer number
+ * @private
+ */
+ JSEncryptRSAKey.hasPublicKeyProperty = function (obj) {
+ obj = obj || {};
+ return (obj.hasOwnProperty("n") &&
+ obj.hasOwnProperty("e"));
+ };
+ /**
+ * Check if the object contains ALL the parameters of an RSA key.
+ * @param {Object} [obj={}] - An object that may contain nine rsa key
+ * parameters
+ * @returns {boolean} true if the object contains all the parameters needed
+ * @todo check for types of the parameters all the parameters but the public exponent
+ * should be parseable bigint objects, the public exponent should be a parseable integer number
+ * @private
+ */
+ JSEncryptRSAKey.hasPrivateKeyProperty = function (obj) {
+ obj = obj || {};
+ return (obj.hasOwnProperty("n") &&
+ obj.hasOwnProperty("e") &&
+ obj.hasOwnProperty("d") &&
+ obj.hasOwnProperty("p") &&
+ obj.hasOwnProperty("q") &&
+ obj.hasOwnProperty("dmp1") &&
+ obj.hasOwnProperty("dmq1") &&
+ obj.hasOwnProperty("coeff"));
+ };
+ /**
+ * Parse the properties of obj in the current rsa object. Obj should AT LEAST
+ * include the modulus and public exponent (n, e) parameters.
+ * @param {Object} obj - the object containing rsa parameters
+ * @private
+ */
+ JSEncryptRSAKey.prototype.parsePropertiesFrom = function (obj) {
+ this.n = obj.n;
+ this.e = obj.e;
+ if (obj.hasOwnProperty("d")) {
+ this.d = obj.d;
+ this.p = obj.p;
+ this.q = obj.q;
+ this.dmp1 = obj.dmp1;
+ this.dmq1 = obj.dmq1;
+ this.coeff = obj.coeff;
+ }
+ };
+ return JSEncryptRSAKey;
+}(RSAKey));
+
+/**
+ *
+ * @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
+ * possible parameters are:
+ * - default_key_size {number} default: 1024 the key size in bit
+ * - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
+ * - log {boolean} default: false whether log warn/error or not
+ * @constructor
+ */
+var JSEncrypt = /** @class */ (function () {
+ function JSEncrypt(options) {
+ options = options || {};
+ this.default_key_size = parseInt(options.default_key_size, 10) || 1024;
+ this.default_public_exponent = options.default_public_exponent || "010001"; // 65537 default openssl public exponent for rsa key type
+ this.log = options.log || false;
+ // The private and public key.
+ this.key = null;
+ }
+ /**
+ * Method to set the rsa key parameter (one method is enough to set both the public
+ * and the private key, since the private key contains the public key paramenters)
+ * Log a warning if logs are enabled
+ * @param {Object|string} key the pem encoded string or an object (with or without header/footer)
+ * @public
+ */
+ JSEncrypt.prototype.setKey = function (key) {
+ if (this.log && this.key) {
+ console.warn("A key was already set, overriding existing.");
+ }
+ this.key = new JSEncryptRSAKey(key);
+ };
+ /**
+ * Proxy method for setKey, for api compatibility
+ * @see setKey
+ * @public
+ */
+ JSEncrypt.prototype.setPrivateKey = function (privkey) {
+ // Create the key.
+ this.setKey(privkey);
+ };
+ /**
+ * Proxy method for setKey, for api compatibility
+ * @see setKey
+ * @public
+ */
+ JSEncrypt.prototype.setPublicKey = function (pubkey) {
+ // Sets the public key.
+ this.setKey(pubkey);
+ };
+ /**
+ * Proxy method for RSAKey object's decrypt, decrypt the string using the private
+ * components of the rsa key object. Note that if the object was not set will be created
+ * on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
+ * @param {string} str base64 encoded crypted string to decrypt
+ * @return {string} the decrypted string
+ * @public
+ */
+ JSEncrypt.prototype.decrypt = function (str) {
+ // Return the decrypted string.
+ try {
+ return this.getKey().decrypt(b64tohex(str));
+ }
+ catch (ex) {
+ return false;
+ }
+ };
+ /**
+ * Proxy method for RSAKey object's encrypt, encrypt the string using the public
+ * components of the rsa key object. Note that if the object was not set will be created
+ * on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
+ * @param {string} str the string to encrypt
+ * @return {string} the encrypted string encoded in base64
+ * @public
+ */
+ JSEncrypt.prototype.encrypt = function (str) {
+ // Return the encrypted string.
+ try {
+ return hex2b64(this.getKey().encrypt(str));
+ }
+ catch (ex) {
+ return false;
+ }
+ };
+ /**
+ * Proxy method for RSAKey object's sign.
+ * @param {string} str the string to sign
+ * @param {function} digestMethod hash method
+ * @param {string} digestName the name of the hash algorithm
+ * @return {string} the signature encoded in base64
+ * @public
+ */
+ JSEncrypt.prototype.sign = function (str, digestMethod, digestName) {
+ // return the RSA signature of 'str' in 'hex' format.
+ try {
+ return hex2b64(this.getKey().sign(str, digestMethod, digestName));
+ }
+ catch (ex) {
+ return false;
+ }
+ };
+ /**
+ * Proxy method for RSAKey object's verify.
+ * @param {string} str the string to verify
+ * @param {string} signature the signature encoded in base64 to compare the string to
+ * @param {function} digestMethod hash method
+ * @return {boolean} whether the data and signature match
+ * @public
+ */
+ JSEncrypt.prototype.verify = function (str, signature, digestMethod) {
+ // Return the decrypted 'digest' of the signature.
+ try {
+ return this.getKey().verify(str, b64tohex(signature), digestMethod);
+ }
+ catch (ex) {
+ return false;
+ }
+ };
+ /**
+ * Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
+ * will be created and returned
+ * @param {callback} [cb] the callback to be called if we want the key to be generated
+ * in an async fashion
+ * @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
+ * @public
+ */
+ JSEncrypt.prototype.getKey = function (cb) {
+ // Only create new if it does not exist.
+ if (!this.key) {
+ // Get a new private key.
+ this.key = new JSEncryptRSAKey();
+ if (cb && {}.toString.call(cb) === "[object Function]") {
+ this.key.generateAsync(this.default_key_size, this.default_public_exponent, cb);
+ return;
+ }
+ // Generate the key.
+ this.key.generate(this.default_key_size, this.default_public_exponent);
+ }
+ return this.key;
+ };
+ /**
+ * Returns the pem encoded representation of the private key
+ * If the key doesn't exists a new key will be created
+ * @returns {string} pem encoded representation of the private key WITH header and footer
+ * @public
+ */
+ JSEncrypt.prototype.getPrivateKey = function () {
+ // Return the private representation of this key.
+ return this.getKey().getPrivateKey();
+ };
+ /**
+ * Returns the pem encoded representation of the private key
+ * If the key doesn't exists a new key will be created
+ * @returns {string} pem encoded representation of the private key WITHOUT header and footer
+ * @public
+ */
+ JSEncrypt.prototype.getPrivateKeyB64 = function () {
+ // Return the private representation of this key.
+ return this.getKey().getPrivateBaseKeyB64();
+ };
+ /**
+ * Returns the pem encoded representation of the public key
+ * If the key doesn't exists a new key will be created
+ * @returns {string} pem encoded representation of the public key WITH header and footer
+ * @public
+ */
+ JSEncrypt.prototype.getPublicKey = function () {
+ // Return the private representation of this key.
+ return this.getKey().getPublicKey();
+ };
+ /**
+ * Returns the pem encoded representation of the public key
+ * If the key doesn't exists a new key will be created
+ * @returns {string} pem encoded representation of the public key WITHOUT header and footer
+ * @public
+ */
+ JSEncrypt.prototype.getPublicKeyB64 = function () {
+ // Return the private representation of this key.
+ return this.getKey().getPublicBaseKeyB64();
+ };
+ JSEncrypt.version = "3.0.0-rc.1";
+ return JSEncrypt;
+}());
+
+if(window){
+ window.JSEncrypt = JSEncrypt;
+}
+exports.JSEncrypt = JSEncrypt;
+exports.default = JSEncrypt;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
diff --git a/common/jweixin-1.6.0.js b/common/jweixin-1.6.0.js
new file mode 100644
index 0000000..ba00ce6
--- /dev/null
+++ b/common/jweixin-1.6.0.js
@@ -0,0 +1 @@
+!function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(o,e){if(!o.jWeixin){var n,c={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},a=function(){var e={};for(var n in c)e[c[n]]=n;return e}(),i=o.document,t=i.title,r=navigator.userAgent.toLowerCase(),s=navigator.platform.toLowerCase(),d=!(!s.match("mac")&&!s.match("win")),u=-1!=r.indexOf("wxdebugger"),l=-1!=r.indexOf("micromessenger"),p=-1!=r.indexOf("android"),f=-1!=r.indexOf("iphone")||-1!=r.indexOf("ipad"),m=(n=r.match(/micromessenger\/(\d+\.\d+\.\d+)/)||r.match(/micromessenger\/(\d+\.\d+)/))?n[1]:"",g={initStartTime:L(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},h={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:f?1:p?2:-1,clientVersion:m,url:encodeURIComponent(location.href)},v={},S={_completes:[]},y={state:0,data:{}};O(function(){g.initEndTime=L()});var I=!1,_=[],w={config:function(e){B("config",v=e);var t=!1!==v.check;O(function(){if(t)M(c.config,{verifyJsApiList:C(v.jsApiList),verifyOpenTagList:C(v.openTagList)},function(){S._complete=function(e){g.preVerifyEndTime=L(),y.state=1,y.data=e},S.success=function(e){h.isPreVerifyOk=0},S.fail=function(e){S._fail?S._fail(e):y.state=-1};var t=S._completes;return t.push(function(){!function(){if(!(d||u||v.debug||m<"6.0.2"||h.systemType<0)){var i=new Image;h.appId=v.appId,h.initTime=g.initEndTime-g.initStartTime,h.preVerifyTime=g.preVerifyEndTime-g.preVerifyStartTime,w.getNetworkType({isInnerInvoke:!0,success:function(e){h.networkType=e.networkType;var n="https://open.weixin.qq.com/sdk/report?v="+h.version+"&o="+h.isPreVerifyOk+"&s="+h.systemType+"&c="+h.clientVersion+"&a="+h.appId+"&n="+h.networkType+"&i="+h.initTime+"&p="+h.preVerifyTime+"&u="+h.url;i.src=n}})}}()}),S.complete=function(e){for(var n=0,i=t.length;n<i;++n)t[n]();S._completes=[]},S}()),g.preVerifyStartTime=L();else{y.state=1;for(var e=S._completes,n=0,i=e.length;n<i;++n)e[n]();S._completes=[]}}),w.invoke||(w.invoke=function(e,n,i){o.WeixinJSBridge&&WeixinJSBridge.invoke(e,x(n),i)},w.on=function(e,n){o.WeixinJSBridge&&WeixinJSBridge.on(e,n)})},ready:function(e){0!=y.state?e():(S._completes.push(e),!l&&v.debug&&e())},error:function(e){m<"6.0.2"||(-1==y.state?e(y.data):S._fail=e)},checkJsApi:function(e){M("checkJsApi",{jsApiList:C(e.jsApiList)},(e._complete=function(e){if(p){var n=e.checkResult;n&&(e.checkResult=JSON.parse(n))}e=function(e){var n=e.checkResult;for(var i in n){var t=a[i];t&&(n[t]=n[i],delete n[i])}return e}(e)},e))},onMenuShareTimeline:function(e){P(c.onMenuShareTimeline,{complete:function(){M("shareTimeline",{title:e.title||t,desc:e.title||t,img_url:e.imgUrl||"",link:e.link||location.href,type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareAppMessage:function(n){P(c.onMenuShareAppMessage,{complete:function(e){"favorite"===e.scene?M("sendAppMessage",{title:n.title||t,desc:n.desc||"",link:n.link||location.href,img_url:n.imgUrl||"",type:n.type||"link",data_url:n.dataUrl||""}):M("sendAppMessage",{title:n.title||t,desc:n.desc||"",link:n.link||location.href,img_url:n.imgUrl||"",type:n.type||"link",data_url:n.dataUrl||""},n)}},n)},onMenuShareQQ:function(e){P(c.onMenuShareQQ,{complete:function(){M("shareQQ",{title:e.title||t,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareWeibo:function(e){P(c.onMenuShareWeibo,{complete:function(){M("shareWeiboApp",{title:e.title||t,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareQZone:function(e){P(c.onMenuShareQZone,{complete:function(){M("shareQZone",{title:e.title||t,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},updateTimelineShareData:function(e){M("updateTimelineShareData",{title:e.title,link:e.link,imgUrl:e.imgUrl},e)},updateAppMessageShareData:function(e){M("updateAppMessageShareData",{title:e.title,desc:e.desc,link:e.link,imgUrl:e.imgUrl},e)},startRecord:function(e){M("startRecord",{},e)},stopRecord:function(e){M("stopRecord",{},e)},onVoiceRecordEnd:function(e){P("onVoiceRecordEnd",e)},playVoice:function(e){M("playVoice",{localId:e.localId},e)},pauseVoice:function(e){M("pauseVoice",{localId:e.localId},e)},stopVoice:function(e){M("stopVoice",{localId:e.localId},e)},onVoicePlayEnd:function(e){P("onVoicePlayEnd",e)},uploadVoice:function(e){M("uploadVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadVoice:function(e){M("downloadVoice",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},translateVoice:function(e){M("translateVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},chooseImage:function(e){M("chooseImage",{scene:"1|2",count:e.count||9,sizeType:e.sizeType||["original","compressed"],sourceType:e.sourceType||["album","camera"]},(e._complete=function(e){if(p){var n=e.localIds;try{n&&(e.localIds=JSON.parse(n))}catch(e){}}},e))},getLocation:function(e){},previewImage:function(e){M(c.previewImage,{current:e.current,urls:e.urls},e)},uploadImage:function(e){M("uploadImage",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadImage:function(e){M("downloadImage",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},getLocalImgData:function(e){!1===I?(I=!0,M("getLocalImgData",{localId:e.localId},(e._complete=function(e){if(I=!1,0<_.length){var n=_.shift();wx.getLocalImgData(n)}},e))):_.push(e)},getNetworkType:function(e){M("getNetworkType",{},(e._complete=function(e){e=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e}(e)},e))},openLocation:function(e){M("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){M(c.getLocation,{type:(e=e||{}).type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){M("hideOptionMenu",{},e)},showOptionMenu:function(e){M("showOptionMenu",{},e)},closeWindow:function(e){M("closeWindow",{},e=e||{})},hideMenuItems:function(e){M("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){M("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){M("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){M("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){M("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(f){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){M(c.openAddress,{},(e._complete=function(e){e=function(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}(e)},e))},openProductSpecificView:function(e){M(c.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,i=[],t=0,o=n.length;t<o;++t){var r=n[t],a={card_id:r.cardId,card_ext:r.cardExt};i.push(a)}M(c.addCard,{card_list:i},(e._complete=function(e){var n=e.card_list;if(n){for(var i=0,t=(n=JSON.parse(n)).length;i<t;++i){var o=n[i];o.cardId=o.card_id,o.cardExt=o.card_ext,o.isSuccess=!!o.is_succ,delete o.card_id,delete o.card_ext,delete o.is_succ}e.cardList=n,delete e.card_list}},e))},chooseCard:function(e){M("chooseCard",{app_id:v.appId,location_id:e.shopId||"",sign_type:e.signType||"SHA1",card_id:e.cardId||"",card_type:e.cardType||"",card_sign:e.cardSign,time_stamp:e.timestamp+"",nonce_str:e.nonceStr},(e._complete=function(e){e.cardList=e.choose_card_info,delete e.choose_card_info},e))},openCard:function(e){for(var n=e.cardList,i=[],t=0,o=n.length;t<o;++t){var r=n[t],a={card_id:r.cardId,code:r.code};i.push(a)}M(c.openCard,{card_list:i},e)},consumeAndShareCard:function(e){M(c.consumeAndShareCard,{consumedCardId:e.cardId,consumedCode:e.code},e)},chooseWXPay:function(e){M(c.chooseWXPay,V(e),e)},openEnterpriseRedPacket:function(e){M(c.openEnterpriseRedPacket,V(e),e)},startSearchBeacons:function(e){M(c.startSearchBeacons,{ticket:e.ticket},e)},stopSearchBeacons:function(e){M(c.stopSearchBeacons,{},e)},onSearchBeacons:function(e){P(c.onSearchBeacons,e)},openEnterpriseChat:function(e){M("openEnterpriseChat",{useridlist:e.userIds,chatname:e.groupName},e)},launchMiniProgram:function(e){M("launchMiniProgram",{targetAppId:e.targetAppId,path:function(e){if("string"==typeof e&&0<e.length){var n=e.split("?")[0],i=e.split("?")[1];return n+=".html",void 0!==i?n+"?"+i:n}}(e.path),envVersion:e.envVersion},e)},openBusinessView:function(e){M("openBusinessView",{businessType:e.businessType,queryString:e.queryString||"",envVersion:e.envVersion},(e._complete=function(n){if(p){var e=n.extraData;if(e)try{n.extraData=JSON.parse(e)}catch(e){n.extraData={}}}},e))},miniProgram:{navigateBack:function(e){e=e||{},O(function(){M("invokeMiniProgramAPI",{name:"navigateBack",arg:{delta:e.delta||1}},e)})},navigateTo:function(e){O(function(){M("invokeMiniProgramAPI",{name:"navigateTo",arg:{url:e.url}},e)})},redirectTo:function(e){O(function(){M("invokeMiniProgramAPI",{name:"redirectTo",arg:{url:e.url}},e)})},switchTab:function(e){O(function(){M("invokeMiniProgramAPI",{name:"switchTab",arg:{url:e.url}},e)})},reLaunch:function(e){O(function(){M("invokeMiniProgramAPI",{name:"reLaunch",arg:{url:e.url}},e)})},postMessage:function(e){O(function(){M("invokeMiniProgramAPI",{name:"postMessage",arg:e.data||{}},e)})},getEnv:function(e){O(function(){e({miniprogram:"miniprogram"===o.__wxjs_environment})})}}},T=1,k={};return i.addEventListener("error",function(e){if(!p){var n=e.target,i=n.tagName,t=n.src;if("IMG"==i||"VIDEO"==i||"AUDIO"==i||"SOURCE"==i)if(-1!=t.indexOf("wxlocalresource://")){e.preventDefault(),e.stopPropagation();var o=n["wx-id"];if(o||(o=T++,n["wx-id"]=o),k[o])return;k[o]=!0,wx.ready(function(){wx.getLocalImgData({localId:t,success:function(e){n.src=e.localData}})})}}},!0),i.addEventListener("load",function(e){if(!p){var n=e.target,i=n.tagName;n.src;if("IMG"==i||"VIDEO"==i||"AUDIO"==i||"SOURCE"==i){var t=n["wx-id"];t&&(k[t]=!1)}}},!0),e&&(o.wx=o.jWeixin=w),w}function M(n,e,i){o.WeixinJSBridge?WeixinJSBridge.invoke(n,x(e),function(e){A(n,e,i)}):B(n,i)}function P(n,i,t){o.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),A(n,e,i)}):B(n,t||i)}function x(e){return(e=e||{}).appId=v.appId,e.verifyAppId=v.appId,e.verifySignType="sha1",e.verifyTimestamp=v.timestamp+"",e.verifyNonceStr=v.nonceStr,e.verifySignature=v.signature,e}function V(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function A(e,n,i){"openEnterpriseChat"!=e&&"openBusinessView"!==e||(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=function(e,n){var i=e,t=a[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",v.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function C(e){if(e){for(var n=0,i=e.length;n<i;++n){var t=e[n],o=c[t];o&&(e[n]=o)}return e}}function B(e,n){if(!(!v.debug||n&&n.isInnerInvoke)){var i=a[e];i&&(e=i),n&&n._complete&&delete n._complete,console.log('"'+e+'",',n||"")}}function L(){return(new Date).getTime()}function O(e){l&&(o.WeixinJSBridge?e():i.addEventListener&&i.addEventListener("WeixinJSBridgeReady",e,!1))}});
\ No newline at end of file
diff --git a/common/math.js b/common/math.js
new file mode 100644
index 0000000..57e84fe
--- /dev/null
+++ b/common/math.js
@@ -0,0 +1,24 @@
+const $math = require('mathjs')
+export const math = {
+ add () {
+ return comp('add', arguments)
+ },
+ subtract () {
+ return comp('subtract', arguments)
+ },
+ multiply () {
+ return comp('multiply', arguments)
+ },
+ divide () {
+ return comp('divide', arguments)
+ }
+}
+
+function comp (_func, args) {
+ let t = $math.chain($math.bignumber(args[0]))
+ for (let i = 1; i < args.length; i++) {
+ t = t[_func]($math.bignumber(args[i]))
+ }
+ // 闃叉瓒呰繃6浣嶄娇鐢ㄧ瀛﹁鏁版硶
+ return parseFloat(t.done())
+}
\ No newline at end of file
diff --git a/common/util.js b/common/util.js
index 43a17d8..5b20f88 100644
--- a/common/util.js
+++ b/common/util.js
@@ -1,86 +1,683 @@
+import {
+ log
+} from 'mathjs';
+import JSEncrypt from './jsencrypt';
+import {
+ ACCESSTOKEN,
+ config
+} from '@/common/config.js'
+
+let publicKey =
+ 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCTREknOkrusbeH7kBe3mSw4AwVT438IWmX/jKmcvYxaAWRrBJiMl7gk37L78HBG/ZstLLcdKBYYdj/5cvVWDQfv+uxbv/piZhOmQej98jWIXEA8aFEk724nFRJ7nfcEhHSWfzbTfgZw0KDO1mWdjWHnHIx/MtD0HIFFIyzg3aO7wIDAQAB';
+
+//鏍¢獙閾惰鍗″彿
+export function verifyBankCard(str) {
+ //閾惰鍗″彿闀垮害鍦�16鍒�19涔嬮棿
+ if (str.length < 16 || str.length > 19) {
+ return false;
+ }
+ var num = /^\d*$/;
+ if (!num.exec(str)) {
+ //閾惰鍗″彿蹇呴』鍏ㄤ负鏁板瓧;
+ return false;
+ }
+ //寮�澶�6浣�
+ var strBin =
+ "10,18,30,35,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,62,65,68,69,84,87,88,94,95,98,99";
+ if (strBin.indexOf(str.substring(0, 2)) == -1) { //閾惰鍗″彿寮�澶�6浣嶄笉绗﹀悎瑙勮寖
+ return false;
+ }
+ var lastNum = str.substr(str.length - 1, 1); //鍙栧嚭鏈�鍚庝竴浣嶏紙涓巐uhm杩涜姣旇緝锛�
+ var first15Num = str.substr(0, str.length - 1); //鍓�15鎴�18浣�
+ var newArr = new Array();
+ for (var i = first15Num.length - 1; i > -1; i--) { //鍓�15鎴�18浣嶅�掑簭瀛樿繘鏁扮粍
+ newArr.push(first15Num.substr(i, 1));
+ }
+ var arrJiShu = new Array(); //濂囨暟浣�*2鐨勭Н <9
+ var arrJiShu2 = new Array(); //濂囨暟浣�*2鐨勭Н >9
+
+ var arrOuShu = new Array(); //鍋舵暟浣嶆暟缁�
+ for (var j = 0; j < newArr.length; j++) {
+ if ((j + 1) % 2 == 1) { //濂囨暟浣�
+ if (parseInt(newArr[j]) * 2 < 9)
+ arrJiShu.push(parseInt(newArr[j]) * 2);
+ else
+ arrJiShu2.push(parseInt(newArr[j]) * 2);
+ } else //鍋舵暟浣�
+ arrOuShu.push(newArr[j]);
+ }
+
+ var jishu_child1 = new Array(); //濂囨暟浣�*2 >9 鐨勫垎鍓蹭箣鍚庣殑鏁扮粍涓綅鏁�
+ var jishu_child2 = new Array(); //濂囨暟浣�*2 >9 鐨勫垎鍓蹭箣鍚庣殑鏁扮粍鍗佷綅鏁�
+ for (var h = 0; h < arrJiShu2.length; h++) {
+ jishu_child1.push(parseInt(arrJiShu2[h]) % 10);
+ jishu_child2.push(parseInt(arrJiShu2[h]) / 10);
+ }
+
+ var sumJiShu = 0; //濂囨暟浣�*2 < 9 鐨勬暟缁勪箣鍜�
+ var sumOuShu = 0; //鍋舵暟浣嶆暟缁勪箣鍜�
+ var sumJiShuChild1 = 0; //濂囨暟浣�*2 >9 鐨勫垎鍓蹭箣鍚庣殑鏁扮粍涓綅鏁颁箣鍜�
+ var sumJiShuChild2 = 0; //濂囨暟浣�*2 >9 鐨勫垎鍓蹭箣鍚庣殑鏁扮粍鍗佷綅鏁颁箣鍜�
+ var sumTotal = 0;
+ for (var m = 0; m < arrJiShu.length; m++) {
+ sumJiShu = sumJiShu + parseInt(arrJiShu[m]);
+ }
+
+ for (var n = 0; n < arrOuShu.length; n++) {
+ sumOuShu = sumOuShu + parseInt(arrOuShu[n]);
+ }
+
+ for (var p = 0; p < jishu_child1.length; p++) {
+ sumJiShuChild1 = sumJiShuChild1 + parseInt(jishu_child1[p]);
+ sumJiShuChild2 = sumJiShuChild2 + parseInt(jishu_child2[p]);
+ }
+ //璁$畻鎬诲拰
+ sumTotal = parseInt(sumJiShu) + parseInt(sumOuShu) + parseInt(sumJiShuChild1) + parseInt(sumJiShuChild2);
+
+ //璁$畻Luhm鍊�
+ var k = parseInt(sumTotal) % 10 == 0 ? 10 : parseInt(sumTotal) % 10;
+ var luhm = 10 - k;
+
+ if (lastNum == luhm) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * 鍔犲瘑
+ * @param {Object} pas
+ */
+export function RSAencrypt(pas) {
+ //瀹炰緥鍖杍sEncrypt瀵硅薄
+ let jse = new JSEncrypt();
+ //璁剧疆鍏挜
+ jse.setPublicKey(publicKey);
+ return jse.encrypt(pas);
+}
+
+/**
+ * 鎷兼帴ftp鍥剧墖璺緞
+ * @param {Object} item
+ * @param {Object} src
+ */
+export function getImgPath(item, src) {
+ if (isBlank(item)) {
+ return src
+ }
+ var ftp = config.sftpURL
+ if (typeof item === 'string') {
+ const arr = JSON.parse(item)
+ return ftp + arr[0].path
+ } else if (typeof item === 'object') {
+ return ftp + item.path
+ } else {
+ return ftp + item
+ }
+}
/**
* 鍒ゆ柇瀛楃涓茬┖
* @param {Object} str
*/
export function isBlank(str) {
- if (str === undefined || str === null || str === '' || str === 'null' || str.length == 0) {
- return true
- } else {
- return false
- }
-}
-/**
- * 涓ゆ暟鐩镐箻 arg1 * arg2
- * @Date 2020/5/9 13:19
- **/
-export function accMul(arg1, arg2) {
- let t = 0
- arg1 = arg1 ? arg1.toString() : '0'
- arg2 = arg2 ? arg2.toString() : '0'
- if (arg1.includes('.')) {
- t += arg1.split('.')[1].length
- }
- if (arg2.includes('.')) {
- t += arg2.split('.')[1].length
- }
- const r1 = Number(arg1.replace('.', ''))
- const r2 = Number(arg2.replace('.', ''))
- return (r1 * r2) / Math.pow(10, t)
+ if (str === undefined || str === null || str === '' || str === 'null' || str.length == 0) {
+ return true
+ } else {
+ return false
+ }
}
-/**
- * 涓ゆ暟鐩搁櫎 arg1 / arg2
- * @Date 2020/5/9 13:18
- **/
-export function accDiv(arg1, arg2) {
- let t = 0
- arg1 = arg1 ? arg1.toString() : '0'
- arg2 = arg2 ? arg2.toString() : '0'
- if (arg2.includes('.')) {
- t = arg2.split('.')[1].length
- }
- if (arg1.includes('.')) {
- t -= arg1.split('.')[1].length
- }
- const r1 = Number(arg1.replace('.', ''))
- const r2 = Number(arg2.replace('.', ''))
- return accMul((r1 / r2), Math.pow(10, t))
-}
/**
* 鍒ゆ柇闈炵┖
* @param {Object} str
*/
export function isNotBlank(str) {
- return !isBlank(str)
+ return !isBlank(str)
+}
+
+/**
+ * 鍒ゆ柇token鏄惁瀛樺湪
+ */
+export function getToken() {
+ return uni.getStorageSync(ACCESSTOKEN);
+}
+
+/**
+ * 鍒ゆ柇token鏄惁瀛樺湪
+ */
+export function hasToken() {
+ return !isBlank(getToken());
+}
+
+/**
+ * 鑾峰彇鐢ㄦ埛淇℃伅
+ */
+export function getUserInfo() {
+ return JSON.parse(uni.getStorageSync('userInfo'))
+}
+
+/**
+ * 鍒ゆ柇涓や釜鏁扮粍鐨勫唴瀹规槸鍚︾浉鍚�
+ */
+export function arrEquals(arr1, arr2) {
+ // if the other arr2 is a falsy value, return
+ if (!arr2)
+ return false;
+
+ // compare lengths - can save a lot of time
+ if (arr1.length != arr2.length)
+ return false;
+
+ for (var i = 0, l = arr1.length; i < l; i++) {
+ // Check if we have nested arr2s
+ if (arr1[i] instanceof Array && arr2[i] instanceof Array) {
+ // recurse into the nested arr2s
+ if (!arr1[i].equals(arr2[i]))
+ return false;
+ } else if (arr1[i] != arr2[i]) {
+ // Warning - two different object instances will never be equal: {x:20} != {x:20}
+ return false;
+ }
+ }
+ return true;
+}
+
+/**
+ * 鑾峰彇褰撳墠鏃堕棿
+ */
+export function getDate(type) {
+ const date = new Date();
+ let year = date.getFullYear();
+ let month = date.getMonth() + 1;
+ let day = date.getDate();
+
+ if (type === 'start') {
+ year = year - 60;
+ } else if (type === 'end') {
+ year = year + 2;
+ }
+ month = month > 9 ? month : '0' + month;;
+ day = day > 9 ? day : '0' + day;
+ return `${year}-${month}-${day}`;
+}
+
+/**
+ * 鍒ゆ柇鏄惁涓烘暣鏁�,涓烘暣鏁板垯鎷兼帴'.0'
+ */
+export function rateMark(num) {
+ if (Number.isInteger(num)) {
+ return num + '.0'
+ } else {
+ return num
+ }
+}
+
+/**
+ * 绉掕浆鍒嗛挓
+ * @param {Object} value
+ */
+export function formatSeconds(value) {
+ var secondTime = parseInt(value); // 绉�
+ var minuteTime = 0; // 鍒�
+ var hourTime = 0; // 灏忔椂
+ if (secondTime > 60) { //濡傛灉绉掓暟澶т簬60锛屽皢绉掓暟杞崲鎴愭暣鏁�
+ //鑾峰彇鍒嗛挓锛岄櫎浠�60鍙栨暣鏁帮紝寰楀埌鏁存暟鍒嗛挓
+ minuteTime = parseInt(secondTime / 60);
+ //鑾峰彇绉掓暟锛岀鏁板彇浣橈紝寰楀埌鏁存暟绉掓暟
+ secondTime = parseInt(secondTime % 60);
+ //濡傛灉鍒嗛挓澶т簬60锛屽皢鍒嗛挓杞崲鎴愬皬鏃�
+ if (minuteTime > 60) {
+ //鑾峰彇灏忔椂锛岃幏鍙栧垎閽熼櫎浠�60锛屽緱鍒版暣鏁板皬鏃�
+ hourTime = parseInt(minuteTime / 60);
+ //鑾峰彇灏忔椂鍚庡彇浣樼殑鍒嗭紝鑾峰彇鍒嗛挓闄や互60鍙栦綐鐨勫垎
+ minuteTime = parseInt(minuteTime % 60);
+ }
+ }
+ var result = "" + parseInt(secondTime) + "绉�";
+
+ if (minuteTime > 0) {
+ result = "" + parseInt(minuteTime) + "鍒�" + result;
+ }
+ if (hourTime > 0) {
+ result = "" + parseInt(hourTime) + "灏忔椂" + result;
+ }
+ return result;
+}
+
+/**
+ * 鏃ユ湡鏍煎紡鍖�
+ * @param {Object} date
+ * @param {Object} fmt
+ */
+export function dateFormat(date, fmt) {
+ if (!date) {
+ return
+ }
+ if (!fmt) {
+ fmt = 'yyyy-MM-dd hh:mm'
+ }
+ if (!(date instanceof Date)) {
+ date = new Date(date.replace(/-/g, '/'))
+ }
+
+ if (/(y+)/.test(fmt)) {
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
+ }
+
+ let o = {
+ 'M+': date.getMonth() + 1,
+ 'd+': date.getDate(),
+ 'h+': date.getHours(),
+ 'm+': date.getMinutes(),
+ 's+': date.getSeconds()
+ };
+
+ for (let k in o) {
+ if (new RegExp(`(${k})`).test(fmt)) {
+ let str = o[k] + '';
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
+ }
+ }
+ return fmt;
+}
+
+
+/**
+ * 浼犲叆鏃堕棿鏍煎紡鐨勬椂闂达紝浠ュ綋鍓嶆椂闂翠负鏍囧噯锛岃繑鍥炶窛绂诲綋鍓嶆椂闂翠箣鍓�
+ */
+export function timeago(date) { //dateTimeStamp鏄竴涓椂闂存绉掞紝娉ㄦ剰鏃堕棿鎴虫槸绉掔殑褰㈠紡锛屽湪杩欎釜姣鐨勫熀纭�涓婇櫎浠�1000锛屽氨鏄崄浣嶆暟鐨勬椂闂存埑銆�13浣嶆暟鐨勯兘鏄椂闂存绉掋��
+ if (!date) {
+ return
+ }
+ if (!(date instanceof Date)) {
+ date = new Date(date.replace(/-/g, '/'))
+ }
+
+ var dateTimeStamp = date.getTime()
+
+ var minute = 1000 * 60; //鎶婂垎锛屾椂锛屽ぉ锛屽懆锛屽崐涓湀锛屼竴涓湀鐢ㄦ绉掕〃绀�
+ var hour = minute * 60;
+ var day = hour * 24;
+ var week = day * 7;
+ var halfamonth = day * 15;
+ var month = day * 30;
+ var now = new Date().getTime(); //鑾峰彇褰撳墠鏃堕棿姣
+ var diffValue = now - dateTimeStamp; //鏃堕棿宸�
+
+ if (diffValue < 0) {
+ return;
+ }
+ var minC = diffValue / minute; //璁$畻鏃堕棿宸殑鍒嗭紝鏃讹紝澶╋紝鍛紝鏈�
+ var hourC = diffValue / hour;
+ var dayC = diffValue / day;
+ var weekC = diffValue / week;
+ var monthC = diffValue / month;
+ var result = '';
+ if (monthC >= 1 && monthC <= 3) {
+ result = " " + parseInt(monthC) + "鏈堝墠"
+ } else if (weekC >= 1 && weekC <= 3) {
+ result = " " + parseInt(weekC) + "鍛ㄥ墠"
+ } else if (dayC >= 1 && dayC <= 6) {
+ result = " " + parseInt(dayC) + "澶╁墠"
+ } else if (hourC >= 1 && hourC <= 23) {
+ result = " " + parseInt(hourC) + "灏忔椂鍓�"
+ } else if (minC >= 1 && minC <= 59) {
+ result = " " + parseInt(minC) + "鍒嗛挓鍓�"
+ } else if (diffValue >= 0 && diffValue <= minute) {
+ result = "鍒氬垰"
+ } else {
+ var datetime = new Date();
+ datetime.setTime(dateTimeStamp);
+ var Nyear = datetime.getFullYear();
+ var Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
+ var Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
+ var Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
+ var Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
+ var Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
+ result = Nyear + "-" + Nmonth + "-" + Ndate
+ }
+ return result;
+}
+
+/**
+ * 鏁扮粍鎴彇
+ * @param {Object} data
+ * @param {Object} index
+ * @param {Object} num
+ */
+export function subArray(data, index, num) {
+ return data.slice(index * num, (index * num) + num)
+}
+
+// 鏍规嵁绱㈠紩鏇挎崲瀛楃涓蹭腑鐨勫厓绱狅紝甯哥敤璇瓧绗︿覆鍔犲瘑
+export function stringReplace(content, start, num, str) {
+ var content = content.split("");
+ content.splice(start, num, str)
+ return content.join("");
+}
+
+export function getByteLength(str) {
+ //鍏堟妸涓枃鏇挎崲鎴愪袱涓瓧鑺傜殑鑻辨枃锛屽湪璁$畻闀垮害
+ var aa = str.replace(/[\u0391-\uFFE5]/g, "@@")
+ return aa.length;
+}
+
+export function getDiffDay(date_1, date_2) {
+ // 璁$畻涓や釜鏃ユ湡涔嬮棿鐨勫樊鍊�
+ let totalDays, diffDate
+ let myDate_1 = new Date(date_1.replace(/-/g, '/'))
+ let myDate_2 = new Date(date_2.replace(/-/g, '/'))
+ // 灏嗕袱涓棩鏈熼兘杞崲涓烘绉掓牸寮忥紝鐒跺悗鍋氬樊
+ diffDate = Math.abs(myDate_1 - myDate_2) // 鍙栫浉宸绉掓暟鐨勭粷瀵瑰��
+
+ totalDays = Math.floor(diffDate / (1000 * 3600 * 24)) // 鍚戜笅鍙栨暣
+ // console.log(totalDays)
+
+ return totalDays // 鐩稿樊鐨勫ぉ鏁�
+}
+
+/**
+ * 鑾峰彇涓や釜鏃ユ湡鐩稿樊鐨勬湀鏃ユ椂鍒�
+ * @param {Object} start
+ * @param {Object} end
+ * @param {Object} cha
+ * @param {Object} flag
+ */
+export function timeFn(start, end, cha, flag) {
+ if (!!!cha) {
+ cha = 0
+ }
+ if (!(start instanceof Date)) {
+ start = new Date(start.replace(/-/g, '/'))
+ }
+ start.setSeconds(start.getSeconds() - 1)
+
+ if (!(end instanceof Date)) {
+ end = new Date(end.replace(/-/g, '/'))
+ }
+
+ var dateDiff = end.getTime() - start + cha; //鏃堕棿宸殑姣鏁�
+ if (dateDiff == 0) {
+ return null
+ }
+ var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)); //璁$畻鍑虹浉宸ぉ鏁�
+ var leave1 = dateDiff % (24 * 3600 * 1000) //璁$畻澶╂暟鍚庡墿浣欑殑姣鏁�
+ var hours = Math.floor(leave1 / (3600 * 1000)) //璁$畻鍑哄皬鏃舵暟
+ //璁$畻鐩稿樊鍒嗛挓鏁�
+ var leave2 = leave1 % (3600 * 1000) //璁$畻灏忔椂鏁板悗鍓╀綑鐨勬绉掓暟
+ var minutes = Math.floor(leave2 / (60 * 1000)) //璁$畻鐩稿樊鍒嗛挓鏁�
+ //璁$畻鐩稿樊绉掓暟
+ var leave3 = leave2 % (60 * 1000) //璁$畻鍒嗛挓鏁板悗鍓╀綑鐨勬绉掓暟
+ var seconds = Math.round(leave3 / 1000)
+
+ var leave4 = leave3 % (60 * 1000) //璁$畻鍒嗛挓鏁板悗鍓╀綑鐨勬绉掓暟
+ var minseconds = Math.round(leave4 / 1000)
+ if (seconds * 1 < 10) {
+ seconds = '0' + seconds
+ }
+ if (minutes * 1 < 10) {
+ minutes = '0' + minutes
+ }
+ if (hours * 1 < 10) {
+ hours = '0' + hours
+ }
+ if (flag) {
+ var timeFn = (dayDiff ? dayDiff + "澶�" : '') + hours + "鏃�" + minutes + "鍒�" + seconds + "绉�";
+ return timeFn;
+ }
+ var timeFn = (dayDiff ? dayDiff + "澶�" : '') + hours + ":" + minutes + ":" + seconds;
+ return timeFn;
+}
+
+
+/**
+ * 绠�鍗曠殑uuid
+ */
+export function guid() {
+ return 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = Math.random() * 16 | 0,
+ v = c == 'x' ? r : (r & 0x3 | 0x8);
+ return v.toString(16);
+ });
+}
+
+/**
+ * 鑾峰彇long鍨嬫暟鎹�
+ */
+export function glong() {
+ return 'xxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = Math.floor((Math.random() * 10)) | 0,
+ v = c == 'x' ? r : (r & 0x3);
+ return v.toString();
+ });
+}
+
+/**
+ * 椤甸潰璺宠浆
+ * @param {Object} url
+ * @param {Object} param
+ */
+export function go(url, param) {
+ var pm = '';
+ if (param != undefined) {
+ if (typeof param === 'string') {
+ param = JSON.parse(param)
+ }
+ for (var p in param) {
+ //閬嶅巻json瀵硅薄鐨勬瘡涓猭ey/value瀵�,p涓簁ey
+ pm += '&' + p + '=' + param[p];
+ }
+ }
+ pm = pm.substr(1);
+ uni.navigateTo({
+ url: url + '?' + pm
+ });
+}
+
+/**
+ * 椤甸潰璺宠浆
+ * @param {Object} url
+ * @param {Object} param
+ */
+export function redirect(url, param) {
+ var pm = '';
+ if (param != undefined) {
+ if (typeof param === 'string') {
+ param = JSON.parse(param)
+ }
+ for (var p in param) {
+ //閬嶅巻json瀵硅薄鐨勬瘡涓猭ey/value瀵�,p涓簁ey
+ pm += '&' + p + '=' + param[p];
+ }
+ }
+ pm = pm.substr(1);
+ uni.redirectTo({
+ url: url + '?' + pm
+ });
+}
+
+/**
+ * 璺宠浆棣栭〉
+ */
+export function goIndex() {
+ uni.reLaunch({
+ url: '/pages/index/index'
+ });
+}
+
+/**
+ * 璺宠浆鐧诲綍椤�
+ */
+export function goLogin(callbackUrl) {
+ if (callbackUrl) {
+ uni.redirectTo({
+ url: `/pages/user/login/index?callbackUrl=/${callbackUrl}`
+ });
+ } else {
+ uni.redirectTo({
+ url: `/pages/user/login/index`
+ });
+ }
+
+}
+
+/**
+ * 杩斿洖
+ */
+export function goBack() {
+ uni.navigateBack()
+}
+
+/**
+ * 棰滆壊16杩涘埗杞琑GB鏂规硶
+ * @param {Object} c
+ */
+export function colorRgb(c) {
+ var sColor = c.toLowerCase();
+ //鍗佸叚杩涘埗棰滆壊鍊肩殑姝e垯琛ㄨ揪寮�
+ var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
+ // 濡傛灉鏄�16杩涘埗棰滆壊
+ if (sColor && reg.test(sColor)) {
+ if (sColor.length === 4) {
+ var sColorNew = "#";
+ for (var i = 1; i < 4; i += 1) {
+ sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
+ }
+ sColor = sColorNew;
+ }
+ //澶勭悊鍏綅鐨勯鑹插��
+ var sColorChange = [];
+ for (var i = 1; i < 7; i += 2) {
+ sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
+ }
+ return "(" + sColorChange.join(",") + ",.08)";
+ }
+ return sColor;
+};
+
+/**
+ * 楠岃瘉鎵嬫満鍙�
+ * @param {Object} mobile
+ */
+export function checkMobile(mobile) {
+ return /^1[3456789]\d{9}$/.test(mobile);
+}
+
+/**
+ * 楠岃瘉韬唤璇佸彿
+ * @param {Object} cardNo
+ */
+export function checkCardNo(cardNo) {
+ return /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
+ .test(cardNo);
+}
+
+/**
+ * 楠岃瘉閭
+ * @param {Object} email
+ */
+export function checkEmail(email) {
+ return /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(email);
+}
+
+/**
+ * 闃挎媺浼暟瀛楄浆涓枃鏁板瓧
+ * @param {Object} num
+ */
+export function NoToChinese(num) {
+ var AA = new Array("闆�", "涓�", "浜�", "涓�", "鍥�", "浜�", "鍏�", "涓�", "鍏�", "涔�");
+ var BB = new Array("", "鍗�", "鐧�", "鍗�", "涓�", "浜�", "鐐�", "");
+ var a = ("" + num).replace(/(^0*)/g, "").split("."),
+ k = 0,
+ re = "";
+ for (var i = a[0].length - 1; i >= 0; i--) {
+ switch (k) {
+ case 0:
+ re = BB[7] + re;
+ break;
+ case 4:
+ if (!new RegExp("0{4}\\d{" + (a[0].length - i - 1) + "}$").test(a[0]))
+ re = BB[4] + re;
+ break;
+ case 8:
+ re = BB[5] + re;
+ BB[7] = BB[5];
+ k = 0;
+ break;
+ }
+ if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = AA[0] + re;
+ if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re;
+ k++;
+ }
+ if (a.length > 1) //鍔犱笂灏忔暟閮ㄥ垎(濡傛灉鏈夊皬鏁伴儴鍒�)
+ {
+ re += BB[6];
+ for (var i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
+ }
+ return re;
+};
+
+/**
+ * 鍚堝苟瀵硅薄鐩稿悓灞炴��
+ * chenlong
+ * @param obj1 鐩爣瀵硅薄
+ * @param obj2 婧愬璞�
+ */
+export function mergeObj(obj1, obj2) {
+ const res = {}
+ Object.keys(obj2).map(key => {
+ if (key in obj1) {
+ res[key] = obj2[key]
+ }
+ })
+ return res
+}
+
+/**
+ * 鑾峰彇杩斿洖鍊�
+ * @param {Object} res
+ * @param {Object} fun
+ */
+export function getContent(res, fun) {
+ if (res.code === 10000) {
+ fun(res.data)
+ } else {
+ uni.showToast({
+ title: res.msg,
+ duration: 1500,
+ icon: 'none'
+ });
+ }
}
/* 姝f暣鏁� */
export function isInteger(number) {
- const reg = /^[1-9]\d*$/
- if (reg.test(number)) {
- return true
- } else {
- return false
- }
+ const reg = /^[1-9]\d*$/
+ if (reg.test(number)) {
+ return true
+ } else {
+ return false
+ }
}
/* 鍒ゆ柇鏄惁涓虹┖ */
export function isEmpty(item) {
- if (item === undefined || item === null || item === '') {
- return true
- }
- return false
+ if (item === undefined || item === null || item === '') {
+ return true
+ }
+ return false
}
/* 鏍¢獙浠锋牸锛屾渶澶氫袱浣嶅皬鏁扮偣 */
export function isPrice(price) {
- const reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
- if (reg.test(price)) {
- return true
- } else {
- return false
- }
+ const reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
+ if (reg.test(price)) {
+ return true
+ } else {
+ return false
+ }
}
/**
@@ -89,10 +686,10 @@
* @returns {number|*}
*/
export function formatYuanToFen(val) {
- if (isEmpty(val) || !isPrice(val)) {
- return val
- }
- return parseFloat(val) * 100
+ if (isEmpty(val) || !isPrice(val)) {
+ return val
+ }
+ return parseFloat(val) * 100
}
/**
@@ -101,57 +698,244 @@
* @returns {number|*}
*/
export function formatFenToYuan(val) {
- if (isEmpty(val) || !isInteger(val)) {
- return val
- }
- return parseFloat(val) / 100
+ if (isEmpty(val) || !isInteger(val)) {
+ return val
+ }
+ return parseFloat(val) / 100
}
-/* 鍏冭浆鍒� */
-export function yuanToFen(amount) {
- let fen = 0
- if (!amount) {
- return fen;
- }
- fen = accMul(amount,100)
- console.log(amount,fen);
- return fen
+
+
+/**
+ * 鎻愮ず閿欒淇℃伅
+ */
+export function showErrorMsg(msg) {
+ uni.showToast({
+ title: msg,
+ icon: 'none'
+ });
+ return false;
}
-/* 鍒嗚浆鍏� */
-export function fenToYuan(amount) {
- if (!amount) {
- return "0";
- }
- amount = amount.toString();
- if (amount.length == 1) {
- return parseFloat("0.0" + amount);
- } else if (amount.length == 2) {
- return parseFloat("0." + amount);
- } else {
- return parseFloat(amount.substring(0, amount.length - 2) + "." + amount.substring(amount.length - 2));
- }
+
+/**
+ * 鎻愮ず鎴愬姛淇℃伅
+ */
+export function showSuccessMsg(msg) {
+ uni.showToast({
+ title: msg,
+ icon: 'none'
+ });
}
-// 鍒ゆ柇寰俊銆佹敮浠樺疂 2寰俊 5鏀粯瀹� 3鍏朵粬
+
+
+/**
+ * 璁$畻鏃堕棿宸�
+ */
+export function timeDiff(startTime, endTime) {
+ // 璁$畻鐩稿樊鐨勬椂闂�
+ const timeDiff = endTime.getTime() - startTime.getTime();
+ if (timeDiff <= 0) return false;
+
+ const totalSeconds = Math.floor(timeDiff / 1000);
+ const hours = Math.floor(totalSeconds / 60 / 60);
+ const minutes = Math.floor((totalSeconds - hours * 60 * 60) / 60);
+ const seconds = Math.floor(totalSeconds - hours * 60 * 60 - minutes * 60);
+ const timeDiffArray = [hours, minutes, seconds].map(e => {
+ return e < 10 ? '0' + e : e;
+ });
+ return timeDiffArray;
+}
+
+/**
+ * 涓ゆ暟鐩稿姞 arg1 + arg2
+ * @param arg1
+ * @param arg2
+ * @returns {number}
+ */
+export function add(arg1, arg2) {
+ var t = 0
+ arg1 = arg1 ? arg1.toString() : '0'
+ arg2 = arg2 ? arg2.toString() : '0'
+ if (arg1.includes('.')) {
+ t = arg1.split('.')[1].length
+ }
+ if (arg2.includes('.')) {
+ t = Math.max(arg2.split('.')[1].length, t)
+ }
+ var m = Math.pow(10, t)
+ return Number(((this.mul(arg1, m) + this.mul(arg2, m)) / m))
+}
+
+/**
+ * 涓ゆ暟鐩稿噺 arg1 - arg2
+ * @param arg1
+ * @param arg2
+ * @returns {number}
+ */
+export function sub(arg1, arg2) {
+ var t = 0
+ arg1 = arg1 ? arg1.toString() : '0'
+ arg2 = arg2 ? arg2.toString() : '0'
+ if (arg1.includes('.')) {
+ t = arg1.split('.')[1].length
+ }
+ if (arg2.includes('.')) {
+ t = Math.max(arg2.split('.')[1].length, t)
+ }
+ var m = Math.pow(10, t)
+ return Number(((this.mul(arg1, m) - this.mul(arg2, m)) / m))
+}
+
+/**
+ * 涓ゆ暟鐩镐箻 arg1 * arg2
+ * @param arg1
+ * @param arg2
+ * @returns {number}
+ */
+export function mul(arg1, arg2) {
+ var t = 0
+ arg1 = arg1 ? arg1.toString() : '0'
+ arg2 = arg2 ? arg2.toString() : '0'
+ if (arg1.includes('.')) {
+ t += arg1.split('.')[1].length
+ }
+ if (arg2.includes('.')) {
+ t += arg2.split('.')[1].length
+ }
+ var r1 = Number(arg1.replace('.', ''))
+ var r2 = Number(arg2.replace('.', ''))
+ return (r1 * r2) / Math.pow(10, t)
+}
+
+/**
+ * 涓ゆ暟鐩搁櫎 arg1 / arg2
+ * @param arg1
+ * @param arg2
+ * @returns {number}
+ */
+export function abs(arg1, arg2) {
+ var t = 0
+ arg1 = arg1 ? arg1.toString() : '0'
+ arg2 = arg2 ? arg2.toString() : '0'
+ if (arg2.includes('.')) {
+ t = arg2.split('.')[1].length
+ }
+ if (arg1.includes('.')) {
+ t -= arg1.split('.')[1].length
+ }
+ var r1 = Number(arg1.replace('.', ''))
+ var r2 = Number(arg2.replace('.', ''))
+ return this.mul((r1 / r2), Math.pow(10, t))
+}
+
+/**
+ * arg1*100/(arg1+arg2)
+ * @param {Object} arg2
+ * @param {Object} arg1
+ */
+export function percentage(arg1, arg2) {
+ var add = this.add(arg1, arg2)
+ return this.mul(this.abs(arg1, add), 100)
+}
+
+/**
+ * 鏌ョ湅缃戠粶鐘舵��
+ * false 娌℃湁缃戠粶 true 鏈夌綉缁�
+ */
+export function getNetworkStatus() {
+ var result = ''
+ uni.getNetworkType({
+ success: (res) => {
+ if (res.networkType == 'none') {
+ // this.$u.toast("娌℃湁缃戠粶");
+ result = false
+ } else {
+ // this.$u.toast("鏈夌綉缁�");
+ result = true
+ }
+ }
+ })
+ return result
+}
+
+/**
+ * @param {Object} key 缂撳瓨鐨刱ey
+ * @param {Object} param 瑕佺紦瀛樼殑瀵硅薄
+ * 灏唒aram push鍒扮紦瀛樻暟缁勪腑
+ */
+export function setArrayStorageSync(key, param) {
+ const data = uni.getStorageSync(key) || []
+ data.push(param)
+ uni.setStorageSync(key, data)
+}
+
+// 鑾峰彇杞挱鍥惧垪琛�
+export function getBannerImg(val, state) {
+ let list = []
+ if (!isBlank(val) && state === '2') {
+ let arr = JSON.parse(val)
+ arr.map(x => {
+ list.push(config.sftpURL + x.path)
+ })
+ } else {
+ list = [config.imgUrl + 'no-book.png']
+ }
+ return list
+}
+
+// 鍟嗗搧鍥剧墖璺緞
+export function getGoodsImg(val, state) {
+ let headImg = ""
+ if (!isBlank(val) && state === '2') {
+ headImg = config.sftpURL + JSON.parse(val)[0].path
+ } else {
+ headImg = config.imgUrl + 'no-book.png'
+ }
+ return headImg
+}
+
+// 鍥剧墖璺緞
+export function GoodsImg(val) {
+ let headImg = ""
+ if (!isBlank(val)) {
+ headImg = config.sftpURL + val
+ } else {
+ headImg = config.imgUrl + 'no-book.png'
+ }
+ return headImg
+}
+
+// 淇濈暀涓変綅灏忔暟 鏈熬瓒呰繃鍚戜笂杩�1
+export function getDiscountPrice(price, discount) {
+ let newPrice = ""
+ let a = Number(price) * Number(discount) / 100
+ let b = a.toFixed(4)
+ let c = b[b.length - 1]
+ newPrice = c != 0 ? Number(b) + 0.01 : b.slice(0, -1)
+ return newPrice
+}
+
+// 鍒ゆ柇寰俊銆佹敮浠樺疂 2寰俊 5鏀粯瀹� 15浜戦棯浠� 3鍏朵粬
export function getPlat() {
- // #ifdef H5
- var ua = window.navigator.userAgent.toLowerCase();
- //鍒ゆ柇鏄笉鏄井淇�
- if (ua.match(/MicroMessenger/i) == 'micromessenger') {
- return 2;
- }
- //鍒ゆ柇鏄笉鏄敮浠樺疂
- if (ua.match(/AlipayClient/i) == 'alipayclient') {
- return 5;
- }
- //鍒ゆ柇鏄笉鏄簯闂粯
- if (ua.indexOf('unionpay/1.0') !== -1) {
- return 15;
- }
- // #endif
- // #ifdef MP-WEIXIN
- return 2;
- // #endif
- // #ifdef MP-ALIPAY
- return 5;
- // #endif
- return 3;
-}
+ // #ifdef H5
+ var ua = window.navigator.userAgent.toLowerCase();
+ //鍒ゆ柇鏄笉鏄井淇�
+ if (ua.match(/MicroMessenger/i) == 'micromessenger') {
+ return 2;
+ }
+ //鍒ゆ柇鏄笉鏄敮浠樺疂
+ if (ua.match(/AlipayClient/i) == 'alipayclient') {
+ return 5;
+ }
+ //鍒ゆ柇鏄笉鏄簯闂粯
+ if (ua.indexOf('unionpay/1.0') !== -1) {
+ return 15;
+ }
+ // #endif
+ // #ifdef MP-WEIXIN
+ return 2;
+ // #endif
+ // #ifdef MP-ALIPAY
+ return 5;
+ // #endif
+ return 3;
+}
\ No newline at end of file
diff --git a/components/bind-card-activity/bind-card-activity.vue b/components/bind-card-activity/bind-card-activity.vue
new file mode 100644
index 0000000..3648605
--- /dev/null
+++ b/components/bind-card-activity/bind-card-activity.vue
@@ -0,0 +1,161 @@
+<template>
+ <view>
+ <view class="bg-fff u-br-20 box">
+ <image src="/static/bind-card-modal.png" class="top-bg"></image>
+ <view class="title">缁戝崱鎴愬姛</view>
+ <view class="u-flex u-row-center u-m-t-40 u-m-b-30">
+ <image class="title-bg" src="/static/title-left.png" mode=""></image>
+ <view class="title-txt">宸茶幏<text>{{couponList.length}}</text>寮犱紭鎯犲埜</view>
+ <image class="title-bg" src="/static/title-right.png" mode=""></image>
+ </view>
+ <view v-for="(item,i) in couponList" :key="i" class="coupon">
+ <view class="num-box">
+ <view v-if="item.discount_type==1"><text class="unit">锟�</text><text class="money">{{item.discount / 100}}</text></view>
+ <view v-else><text class="money">{{item.item.discount}}</text><text class="unit">鎶�</text></view>
+ <view v-if="item.threshold == 0" class="cont">鏃犻棬妲�</view>
+ <view v-else class="cont">婊{item.threshold_value / 100}}鍏冧娇鐢�</view>
+ </view>
+ <view class="info-box">
+ <view class="coupon-name">{{item.name}}</view>
+ <view class="coupon-date">鏈夋晥鏈熻嚦锛歿{$u.timeFormat(item.out_time, 'yyyy-mm-dd hh:MM')}}</view>
+ </view>
+ </view>
+ <navigator open-type="navigateBack" class="btn">鍘讳娇鐢�</navigator>
+ </view>
+ <!-- <image @click="$emit('close')" class="close" src="/static/close-icon.png" mode=""></image> -->
+ </view>
+
+</template>
+
+<script>
+ export default {
+ name: "bind-card-activity",
+ props:{
+ couponList:{
+ type:Array,
+ default: []
+ }
+ },
+ data() {
+ return {
+
+ };
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ .box {
+ background-image: linear-gradient(180deg, rgba(254, 254, 252, 1) 0%, rgba(253, 242, 225, 1) 100%);
+ width: 600rpx;
+ padding-bottom: 35rpx;
+ }
+
+ .top-bg {
+ width: 628rpx;
+ height: 385rpx;
+ position: absolute;
+ top: -225rpx;
+ left: -16rpx;
+ }
+
+ .title {
+ font-size: 36rpx;
+ color: #C6774B;
+ font-weight: bold;
+ width: 337rpx;
+ height: 76rpx;
+ background-image: url(~@/static/bind-card-title.png);
+ background-size: contain;
+ text-align: center;
+ line-height: 76rpx;
+ position: relative;
+ left: 141.5rpx;
+ }
+
+ .title-bg {
+ width: 131rpx;
+ height: 21rpx;
+ }
+
+ .title-txt {
+ font-size: 28rpx;
+ color: #B36C44;
+ }
+
+ .title-txt text {
+ color: #D31F28;
+ }
+
+ .coupon {
+ width: 508rpx;
+ height: 145rpx;
+ background-image: url(~@/static/coupon-bg2.png);
+ background-size: 100% 100%;
+ margin: 0 auto 10rpx;
+ display: flex;
+ }
+
+ .num-box {
+ width: 140rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .unit {
+ font-size: 24rpx;
+ font-weight: bold;
+ color: #D31F28;
+ }
+
+ .money {
+ font-size: 50rpx;
+ font-weight: bold;
+ color: #D31F28;
+ }
+
+ .cont {
+ font-size: 20rpx;
+ color: #D31F28;
+ }
+
+ .info-box {
+ flex: 1;
+ padding: 0 15rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ }
+
+ .coupon-name {
+ font-size: 24rpx;
+ color: #333333;
+ }
+
+ .coupon-date {
+ margin-top: 10rpx;
+ font-size: 20rpx;
+ color: #999;
+ }
+
+ .btn {
+ width: 476rpx;
+ height: 88rpx;
+ border-radius: 44rpx;
+ background-color: rgba(238, 68, 82, 1);
+ margin: 30rpx auto 0;
+ font-size: 36rpx;
+ color: #fff;
+ font-weight: bold;
+ line-height: 88rpx;
+ text-align: center;
+ }
+ .close{
+ display: block;
+ width: 64rpx;
+ height: 64rpx;
+ margin: 30rpx auto 0;
+ }
+</style>
diff --git a/components/card-agreement/card-agreement.vue b/components/card-agreement/card-agreement.vue
new file mode 100644
index 0000000..3ee022e
--- /dev/null
+++ b/components/card-agreement/card-agreement.vue
@@ -0,0 +1,106 @@
+<template>
+ <view class="agreement-main">
+ <h1>鍗忚璇︽儏</h1>
+ <scroll-view class="con" scroll-y>
+
+ <p>
+ XXXXX鏈夐檺鍏徃锛堜互涓嬪潎绠�绉扳�淴XX鈥濓級鍦ㄦ鎻愰啋鎮紙浠ヤ笅绉扳�滄偍鈥濇垨绉扳�滅敤鎴封�濓級璁ょ湡闃呰鐞嗚В鏈崗璁紝鍖呮嫭鍏嶉櫎鎴栬�呴檺鍒禭XX璐d换鐨勫厤璐f潯娆惧強瀵规偍鐨勬潈鍒╅檺鍒舵潯娆撅紱鎮ㄧ‘璁わ紝鍦ㄦ偍浣跨敤XXX鐨勫悇椤规湇鍔′箣鍓嶏紝鎮ㄥ凡鍏呭垎闃呰銆佺悊瑙e苟鎺ュ彈鏈崗璁殑鍏ㄩ儴鍐呭锛屼竴鏃︽偍鍦ㄢ�滄垜宸查槄璇诲苟鍚屾剰鈥濆墠鍕鹃�夛紝鎴栫偣鍑烩�滄垜宸查槄璇诲苟鍚屾剰鈥濇寜閽紝鍗宠〃绀烘偍鍚屾剰閬靛惊鏈崗璁箣鎵�鏈夌害瀹氾紝涓�鏃︽偍浣跨敤XXX鐨勫叏閮ㄦ垨閮ㄥ垎鏈嶅姟,浜﹁〃绀烘偍鍚屾剰閬靛惊鏈崗璁箣鎵�鏈夌害瀹氥�傛湰鍗忚鍦ㄦ偍鍜孹XX涔嬮棿鍏锋湁鍚堝悓涓婄殑娉曞緥鏁堝姏
+ </p>
+ <p>鐢叉柟锛氬叏浣揦XX娉ㄥ唽鐢ㄦ埛锛堜互涓婁互涓嬬畝绉扳�滀綘鈥濇垨绉扳�滅敤鎴封�濓級</p>
+ <p>涔欐柟锛歑XXXX鏈夐檺鍏徃锛堜互涓婁互涓嬪潎绠�绉扳�淴XX鈥濓級</p>
+ <p><strong>涓�銆�</strong>
+ 鎮ㄥ悓鎰忛�氳繃鏈崗璁�夊畾鐨勬偍閾惰鍗★紙浠ヤ笅绠�绉扳�滈摱琛屽崱鈥濓級鍦╔XX骞冲彴涓庢偍鍦ㄧ涓夋柟鏀粯鏈烘瀯鐨勬墭绠¤处鎴蜂笂杩涜缁戝畾銆佸紑閫氬揩鎹锋敮浠樹笟鍔★紝鍗虫湰鍗忚鎵�杩扮殑鈥滅粦瀹氣�濅负鎵f閾惰鍗$殑纭畾锛屼竴鏃︾粦瀹氭垚鍔燂紝绗笁鏂规敮浠樻満鏋勬瘡娆℃墸娆惧墠鏃犻渶杈撳叆鎮ㄧ粦瀹氱殑閾惰鍗¤处鍙枫�佸瘑鐮佺瓑淇℃伅锛屼篃鏃犻渶鎮ㄦ彁浜ょ粦瀹氱殑閾惰鍗¤繘琛屽埛鍗�
+ </p>
+ <p></p>
+ <p><strong>浜屻��</strong> 鎮ㄦ壙璇轰笂杩伴�夊畾鐨勯摱琛屽崱鐨勫紑鎴疯瘉浠朵俊鎭笌鎮ㄨ韩浠借瘉浠朵俊鎭畬鍏ㄤ竴鑷淬��</p>
+ <p></p>
+ <p><strong>涓夈��</strong> 鎮ㄥ厑璁竂XX鍚戝揩鎹锋敮浠樼涓夋柟鏀粯鏈烘瀯鍙戦�佹偍鐨勪俊鎭紙鍖呮嫭浣嗕笉闄愪簬鎮ㄧ殑韬唤淇℃伅銆侀摱琛屼俊鎭�乆XX娉ㄥ唽淇℃伅绛夋秹鍙婃偍涓汉鐨勫悇椤逛俊鎭級浠ヤ究瀹屾垚蹇嵎鏀粯涓氬姟銆�</p>
+ <p></p>
+ <p><strong>鍥涖��</strong>
+ XXX鍚戠涓夋柟鏀粯鏈烘瀯鍙戦�佺殑鎮ㄧ殑涓�鍒囦俊鎭槸渚濇嵁鎮ㄨ嚜宸变富鍔ㄥ~鍐欑殑淇℃伅锛孹XX鏈夋潈鍒╀絾鏃犱箟鍔″鏌ユ偍鐨勯摱琛屽崱淇℃伅涓庤韩浠借瘉浠朵俊鎭�俋XX涓嶅鏄惁杩涜瀹℃煡鏍稿疄鍋氬嚭浠讳綍鎵胯锛屼竴鍒囦互鎮ㄥ~鍐欑殑淇℃伅涓哄噯銆�</p>
+ <p></p>
+ <p><strong>浜斻��</strong>鎮ㄥ繀椤绘寜鐓х涓夋柟鏀粯鏈烘瀯鐨勫揩鎹锋敮浠樺崗璁殑瑕佹眰缁戝畾绗﹀悎绗笁鏂规敮浠樻満鏋勮姹傜殑閾惰鍗★紝骞朵笖鎮ㄦ壙璇烘槸缁戝畾鐨勯摱琛屽崱鐨勫悎娉曟寔鍗′汉锛堟寚閾惰鍗¤处鎴风殑寮�鎴蜂富浣擄紝涓嬪悓锛夈��</p>
+ <p></p>
+ <p><strong>鍏��</strong> 鍏朵粬鏈夊叧缁戝畾閾惰鍗°�佸紑閫氬揩鎹锋敮浠樼殑鏉冨埄涔夊姟璇﹁鎮ㄤ笌绗笁鏂规敮浠樻満鏋勮揪鎴愮殑蹇嵎鏀粯鍗忚鐨勫悇椤圭害瀹氥��</p>
+ <p></p>
+ <p><strong>涓冦��</strong> 鎮ㄤ笌绗笁鏂规敮浠樻満鏋勫洜蹇嵎鏀粯鐩稿叧浜嬪疁鍙戠敓鐨勪簤璁笌绾犵悍锛岃鎮ㄦ寜鐓ф偍涓庣涓夋柟鏀粯鏈烘瀯涔嬮棿鐨勫揩鎹锋敮浠樺崗璁殑绾﹀畾瑙e喅锛孹XX涓嶅鎮ㄤ笌绗笁鏂规敮浠樻満鏋勪箣闂寸殑浜夎鎵挎媴浠讳綍璐d换銆�</p>
+ <p></p>
+ <p><strong>鍏��</strong>
+ 鎮ㄧ殑涓汉璧勬枡鍙楀埌涓ユ牸淇濇姢锛屼笉鎺ュ彈XXX銆佺涓夋柟鏀粯鏈烘瀯銆佹偍閾惰鍗″紑鎴疯鍙婃偍涔嬪鐨勪换浣曚釜浜烘垨鍗曚綅鐨勬煡璇㈣姹傘�備絾娉曞緥娉曡锛堝惈琛屾斂瑙勭珷銆佹皯鏃忚嚜娌诲湴鏂圭殑鑷不鏉′緥鍜屽崟琛屾潯渚嬶紝涓嬪悓锛夈�佸徃娉曟満鍏炽�佺洃绠℃満鏋勩�佷綘涓庣涓夋柟鏀粯鏈烘瀯涔嬪墠鐨勫揩鎹锋敮浠樺崗璁彟鏈夎瀹氭垨瑕佹眰锛屾垨涓哄紑閫氬揩鎹锋敮浠樹箣闇�瑕佺‘鏈夊繀瑕佹姭闇茬殑闄ゅ銆�
+ </p>
+ <p></p>
+ <p><strong>涔濄��</strong> 鎮ㄦ壙璇哄鏋滃洜鎮ㄨ繚鍙嶆湰鍗忚鎴栬�呬笌绗笁鏂规敮浠樻満鏋勪箣闂寸殑鍗忚閫犳垚XXX鎹熷け鐨勶紝XXX鏈夋潈鍚戜綘杩界┒娉曞緥璐d换銆�</p>
+ <p></p>
+ <p>鏈崗璁増鏈簬2023骞�6鏈�30鏃ユ洿鏂帮紝浜�2023骞�7鏈�1鏃ョ敓鏁堛��</p>
+ </scroll-view>
+ <div @click="$emit('confirm')">鎴戝凡闃呰骞跺悓鎰�</div>
+ </view>
+</template>
+
+<script>
+ export default {
+ name: "card-agreement",
+ data() {
+ return {
+
+ };
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ .agreement-main {
+ padding: 30rpx;
+ background: #fff;
+ border-radius: 30rpx;
+ }
+
+ .agreement-main h1 {
+ text-align: center;
+ font-size: 32rpx;
+ color: #333333;
+ }
+
+ .agreement-main i {
+ position: absolute;
+ right: 30rpx;
+ top: 30rpx;
+ background: url('https://zhkj.jinmingyuan.com:8443/sftpxcx/jrstq/icon-close.png') no-repeat;
+ background-size: 100% 100%;
+ width: 42rpx;
+ height: 42rpx;
+ }
+
+ .agreement-main .con {
+ color: #545454;
+ font-size: 26rpx;
+ margin: 30rpx 0;
+ height: 630rpx;
+ width: 550rpx;
+ }
+
+ .agreement-main .con p {
+ line-height: 1.65;
+ margin-bottom: 5rpx;
+ }
+
+ .agreement-main>div {
+ height: 66rpx;
+ text-align: center;
+ line-height: 66rpx;
+ color: #fff;
+ font-size: 30rpx;
+ margin: 0 auto;
+ background: #e93b3d;
+ border-radius: 33rpx;
+ }
+
+ strong {
+ margin-right: 5rpx;
+ }
+
+ .mask {
+ position: fixed;
+ z-index: 9
+ }
+</style>
diff --git a/components/input-number/input-number.vue b/components/input-number/input-number.vue
new file mode 100644
index 0000000..837e849
--- /dev/null
+++ b/components/input-number/input-number.vue
@@ -0,0 +1,171 @@
+<template>
+ <view class="count-box" :class="status ? 'count-box-light' : 'count-box-gray'">
+
+ <view class="count-less count-pub" :class="[myValue <= min ? 'light' : '']" @tap.stop="less"></view>
+ <view class="u-rela u-flex u-col-center">
+ <view class="plc">{{myValue}}</view>
+ <input type="number" v-model="myValue" @focus="onFocus" @blur="onBlue" class="count-input" />
+ </view>
+
+ <view class="count-add count-pub" :class="[myValue >= max ? 'light' : '']" @tap.stop="add"></view>
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+ myValue: 0,
+ status: false
+ }
+ },
+ props: {
+ // 璁℃暟鍣ㄤ腑鐨勫��
+ value: {
+ type: Number,
+ default: 0
+ },
+ max: {
+ type: Number,
+ default: 10000
+ },
+ min: {
+ type: Number,
+ default: 0
+ },
+ type: {
+ type: String,
+ default: 'small'
+ }
+ },
+ created() {
+ this.myValue = this.value
+ },
+ watch: {
+ value(val) {
+ this.myValue = val
+ }
+ },
+ methods: {
+ onBlue() {
+ if (+this.myValue >= this.max) {
+ this.myValue = this.max
+ this.status = false
+ } else if (+this.myValue <= this.min) {
+ this.myValue = this.min
+ this.status = false
+ } else {
+ this.status = true
+ this.myValue = +this.myValue
+ }
+ if (!isNaN(this.myValue)) {
+ this.$emit('handleCount', this.myValue)
+ } else {
+ this.$emit('handleCount', 0)
+ }
+
+ },
+ onFocus() {
+ this.status = true
+ },
+ add() {
+ if (this.myValue >= this.max) {
+ this.status = false
+ this.myValue = this.max
+ uni.showToast({
+ title: "宸茶秴杩囨渶澶хН鍒�",
+ icon: "none"
+ })
+ this.myValue = this.max
+ } else {
+ this.status = true
+ this.myValue++
+ }
+ this.$emit('handleCount', this.myValue)
+ },
+ less() {
+ if (this.myValue <= this.min) {
+ this.status = false
+ this.myValue = this.min
+ uni.showToast({
+ title: "涓嶈兘鍐嶅皯浜�",
+ icon: "none"
+ })
+ this.myValue = this.min
+ } else {
+ this.status = true
+ this.myValue--
+ }
+ this.$emit('handleCount', this.myValue)
+ }
+ }
+ }
+</script>
+<style lang="less" scoped>
+ .gray {
+ color: #555555;
+ }
+
+ .light {
+ color: #C8C7CC;
+ }
+
+ .count-box {
+ display: flex;
+ align-items: center;
+ height: 60rpx;
+ }
+
+ .count-pub {
+ width: 42rpx;
+ height: 42rpx;
+ }
+
+ .count-less {
+ left: 0;
+ width: 42rpx;
+ height: 42rpx;
+ background: url(../../static/cart/icon_less.png) no-repeat;
+ background-size: 42rpx;
+ }
+
+ .count-add {
+ right: 0;
+ width: 42rpx;
+ height: 42rpx;
+ background: url(../../static/cart/icon_add.png) no-repeat;
+ background-size: 42rpx;
+ }
+
+ .count-less.light {
+ background: url(../../static/cart/icon_lessLight.png) no-repeat;
+ background-size: 42rpx;
+ }
+
+ .count-add.light {
+ background: url(../../static/cart/icon_addLight.png) no-repeat;
+ background-size: 42rpx;
+ }
+
+ .count-input {
+ position: absolute;
+ width: 100%;
+ height: 42rpx;
+ line-height: 42rpx;
+ padding: 0 10rpx;
+ box-sizing: border-box;
+ color: #333;
+ font-size: 30rpx;
+ text-align: center;
+ }
+
+ .plc {
+ height: 42rpx;
+ line-height: 1;
+ text-align: center;
+ min-width: 70rpx;
+ font-size: 30rpx;
+ padding: 0 12rpx;
+ visibility: hidden;
+ }
+</style>
diff --git a/components/key-bord/key-bord.vue b/components/key-bord/key-bord.vue
index 8b613f8..86b3693 100644
--- a/components/key-bord/key-bord.vue
+++ b/components/key-bord/key-bord.vue
@@ -1,144 +1,136 @@
<template>
- <view class="box">
- <view class="u-text-right u-font-30 color-666 u-p-h-20 u-p-t-10" @click="close">鍏抽棴</view>
- <view class="u-p-10 u-flex u-row-between">
- <view class="u-flex u-flex-wrap">
- <view v-for="(num,index) in numList" :key="index" class="num-item" hover-class="num-hover" @click="inputStr(num)">{{num}}</view>
- </view>
- <view class="flex-1 u-flex-col">
- <view hover-class="num-hover" class="del-item u-flex u-row-center" @click="delStr">
- <image src="@/static/del-icon.png" class="del-btn"></image>
- </view>
- <view hover-class="num-hover" class="flex-1 pay-btn u-font-30 color-fff font-bold" @click="pay">浠樻</view>
- </view>
- </view>
- </view>
-
+ <view>
+ <view class="u-text-right u-font-30 color-666 u-p-20" @click="close">鍏抽棴</view>
+ <view class="u-p-10 bord-box u-flex u-row-between">
+ <view class="u-flex u-flex-wrap">
+ <view v-for="(num,index) in numList" :key="index" class="num-item" hover-class="num-hover"
+ @click="inputStr(num)">{{num}}</view>
+ </view>
+ <view class="flex-1 u-flex-col">
+ <view hover-class="num-hover" class="del-item u-flex u-row-center" @click="delStr">
+ <image src="@/static/imgs/del-icon.png" class="del-btn"></image>
+ </view>
+ <view hover-class="num-hover" class="flex-1 pay-btn u-font-30 color-fff font-bold" @click="pay">浠樻
+ </view>
+ </view>
+ </view>
+ </view>
</template>
<script>
-export default {
- props: {
- num: {
- type: String,
- default: ''
- }
- },
- watch: {
- num(val) {
- this.emitNum = val
- }
- },
- data() {
- return {
- emitNum: '',
- numList: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.']
- }
- },
- methods: {
- // 杈撳叆妗�
- inputStr(num) {
- var dotinx = this.emitNum.indexOf('.');
- if (dotinx != -1) {
- if (num == '.') {
- // 灏忔暟鐐逛笉鑳介噸澶嶆坊鍔�
- return;
- }
- if (dotinx == this.emitNum.length - 3) {
- //灏忔暟鐐瑰悗闈㈡渶澶氫袱浣�
- return;
- }
- if (this.emitNum == '0.0' && num == '0') {
- //灏忔暟鐐瑰悗闈㈡渶澶氫袱浣�
- return;
- }
- } else if (num == '0' && this.emitNum == '0') {
- // 棣栦綅鐨�0鏈�澶�1涓�
- return;
- } else {
- if (num != '.' && this.emitNum.length > 7) {
- //鏁存暟涓嶈兘瓒呰繃10浣�
- return;
- }
- }
- if (this.emitNum == '' && num == '.') {
- this.emitNum = '0.';
- } else if (this.emitNum == '0' && num != '.') {
- this.emitNum = num;
- } else {
- this.emitNum += num;
- }
- this.$emit('changeMoney', this.emitNum)
- },
- // 鍒犻櫎
- delStr() {
- this.emitNum = this.emitNum.slice(0, -1)
- this.$emit('changeMoney', this.emitNum)
- },
- // 鏀粯
- pay() {
- this.$emit('pay')
- },
- // 鍏抽棴杈撳叆妗�
- close() {
- this.$emit('close')
- }
- }
-}
+ export default {
+ props: {
+ num: {
+ type: String,
+ default: ''
+ }
+ },
+ watch: {
+ num(val) {
+ this.emitNum = val
+ }
+ },
+ data() {
+ return {
+ emitNum: '',
+ numList: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.']
+ }
+ },
+ methods: {
+ // 杈撳叆妗�
+ inputStr(num) {
+ var dotinx = this.emitNum.indexOf('.');
+ if (dotinx != -1) {
+ if (num == '.') {
+ // 灏忔暟鐐逛笉鑳介噸澶嶆坊鍔�
+ return;
+ }
+ if (dotinx == this.emitNum.length - 3) {
+ //灏忔暟鐐瑰悗闈㈡渶澶氫袱浣�
+ return;
+ }
+ } else if (num == '0' && this.emitNum == '0') {
+ // 棣栦綅鐨�0鏈�澶�1涓�
+ return;
+ } else {
+ if (num != '.' && this.emitNum.length > 7) {
+ //鏁存暟涓嶈兘瓒呰繃10浣�
+ return;
+ }
+ }
+ if (num == '.' && this.emitNum == '') {
+ this.emitNum = '0.';
+ } else if (num != '.' && this.emitNum == '0') {
+ this.emitNum = num;
+ } else {
+ this.emitNum += num;
+ }
+ this.$emit('changeMoney', this.emitNum)
+ },
+ // 鍒犻櫎
+ delStr() {
+ this.emitNum = this.emitNum.slice(0, -1)
+ this.$emit('changeMoney', this.emitNum)
+ },
+ // 鏀粯
+ pay() {
+ this.$emit('pay')
+ },
+ // 鍏抽棴杈撳叆妗�
+ close() {
+ this.$emit('close')
+ }
+ }
+ }
</script>
-<style lang="scss" scoped>
-.box {
- background-color: #F5F5F5;
- transition: all 0.3s;
- padding-bottom: constant(safe-area-inset-bottom); /*鍏煎 IOS<11.2*/
- padding-bottom: env(safe-area-inset-bottom); /*鍏煎 IOS>11.2*/
-}
+<style lang="scss">
+ .bord-box {
+ background-color: #F5F5F5;
+ }
-.num-item {
- width: 175rpx;
- height: 90rpx;
- line-height: 90rpx;
- color: #333333;
- font-size: 36rpx;
- font-weight: bold;
- text-align: center;
- margin: 0 10rpx 10rpx 0;
- background-color: #FFFFFF;
-}
+ .num-item {
+ width: 175rpx;
+ height: 80rpx;
+ line-height: 80rpx;
+ color: #333333;
+ font-size: 32rpx;
+ font-weight: bold;
+ text-align: center;
+ margin: 0 10rpx 10rpx 0;
+ background-color: #FFFFFF;
+ }
-.num-hover {
- opacity: 0.7;
-}
+ .num-hover {
+ opacity: 0.7;
+ }
-.num-item:nth-child(10n) {
- width: 356rpx;
-}
+ .num-item:nth-child(10n) {
+ width: 356rpx;
+ }
-.h-100 {
- height: 100%;
-}
+ .h-100 {
+ height: 100%;
+ }
-.pay-btn {
- background-color: #D45159;
- border-radius: 16rpx;
- text-align: center;
- height: 290rpx;
- line-height: 290rpx;
- vertical-align: middle;
- color: white;
- margin-bottom: 10rpx;
-}
+ .pay-btn {
+ background-color: #D45159;
+ border-radius: 16rpx;
+ text-align: center;
+ height: 270rpx;
+ line-height: 270rpx;
+ vertical-align: middle;
+ }
-.del-item {
- width: 175rpx;
- height: 90rpx;
- margin-bottom: 10rpx;
- background-color: #FFFFFF;
-}
+ .del-item {
+ width: 175rpx;
+ height: 80rpx;
+ margin-bottom: 10rpx;
+ background-color: #FFFFFF;
+ }
-.del-btn {
- width: 40rpx;
- height: 40rpx;
-}
-</style>
+ .del-btn {
+ width: 40rpx;
+ height: 40rpx;
+ }
+</style>
\ No newline at end of file
diff --git a/components/user-agreement/user-agreement.vue b/components/user-agreement/user-agreement.vue
new file mode 100644
index 0000000..884e848
--- /dev/null
+++ b/components/user-agreement/user-agreement.vue
@@ -0,0 +1,261 @@
+<template>
+ <view class="con">
+ <p>娆㈣繋鎮ㄤ笌涓偖閭斂闆嗗洟鍏徃鍥涘窛鐪佸垎鍏徃(浠ヤ笅绠�绉扳�滄湰鍏徃鈥濇垨鈥滃洓宸濋偖鏀库��)鍏卞悓绛剧讲銆婄敤鎴峰崗璁�嬨�傛湰鍗忚璇﹁堪鎮ㄥ湪閲戣瀺鐢熸�佸湀骞冲彴浣跨敤閭斂鏈嶅姟浜彈鐨勬潈鐩婂拰鎵�椤婚伒瀹堢殑鏉℃鍜屾潯浠躲��</p>
+ <p></p>
+ <p>
+ <strong>1</strong>
+ <strong>銆佹湇鍔℃潯娆剧殑纭鍜屾帴绾�</strong>
+ </p>
+ <p>
+ <strong>1.1</strong>鎮ㄦ垚涓洪噾铻嶇敓鎬佸湀骞冲彴鐢ㄦ埛鍓嶏紝蹇呴』闃呰銆佸悓鎰忓苟鎺ュ彈鏈崗璁腑鎵�鍚殑鎵�鏈夋潯娆惧拰鏉′欢銆傛湰鍗忚鍦ㄧ敤鎴锋帴鍙楁敞鍐屾椂鐢熸晥銆傞噾铻嶇敓鎬佸湀骞冲彴瑙勫垯銆佽鏄庛�佸叕鍛婂拰闅愮鏉冩斂绛栦篃鏄湰鍗忚涓嶅彲鍒嗗壊鐨勪竴閮ㄥ垎锛屽鎮ㄧ户缁娇鐢ㄩ噾铻嶇敓鎬佸湀骞冲彴鏈嶅姟锛岃涓烘偍鍚屾剰锛屽苟鍙楀叾绾︽潫銆傚洓宸濋偖鏀垮缓璁偍闃呰鏈崗璁椂锛屼篃搴旈槄璇绘湰鏂囦欢鎵�鎻愬強鐨勫叾浠栫綉椤典腑鎵�鍖呭惈鐨勮祫鏂欙紝鍥犱负鍏跺彲鑳藉寘鍚浣滀负閲戣瀺鐢熸�佸湀骞冲彴鐢ㄦ埛鐨勬偍閫傜敤鐨勮繘涓�姝ユ潯娆惧拰鏉′欢銆�
+ </p>
+ <p>
+ <strong>1.2</strong>
+ <strong>鍥涘窛閭斂鍙兘鏍规嵁瀹為檯鎯呭喌闅忔椂閫氳繃鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴绔欎笂鍏竷缁忎慨璁㈢殑鏉℃浠ュ鏈崗璁拰瑙勫垯杩涜淇銆傛墍鏈夌粡淇鐨勬潯娆捐嚜鍏朵簬缃戠珯鍏竷璧疯嚜鍔ㄧ敓鏁堛�傚鎮ㄤ笉鍚屾剰璇ョ瓑淇锛屾偍蹇呴』缁堟鎮ㄤ笌閲戣瀺鐢熸�佸湀骞冲彴鐨勭敤鎴峰叧绯汇��</strong>
+ <strong>濡傛偍缁х画浣跨敤閲戣瀺鐢熸�佸湀骞冲彴锛屽嵆瑙嗕负鐭ユ倝鍙樺姩鍐呭骞跺悓鎰忔帴鍙椼��</strong>
+ </p>
+ <p>
+ <strong>1.3</strong>閲戣瀺鐢熸�佸湀骞冲彴鐨勬湇鍔′粎鍚戦�傜敤娉曞緥涓嬭兘澶熺璁㈠叿鏈夋硶寰嬬害鏉熷姏鐨勫悎鍚岀殑涓汉鎻愪緵骞朵粎鐢卞叾浣跨敤銆傚湪涓嶉檺鍒跺墠杩拌瀹氱殑鍓嶆彁涓嬶紝
+ <strong>閲戣瀺鐢熸�佸湀骞冲彴鐨勬湇鍔′笉鍚�18鍛ㄥ瞾浠ヤ笅鎴栬涓存椂鎴栨棤闄愭湡涓浣跨敤閲戣瀺鐢熸�佸湀骞冲彴鏈嶅姟鐨勭敤鎴锋彁渚涖��</strong>鍦ㄧ數瀛愬晢鍔℃椿鍔ㄤ腑鎴戜滑鎺ㄥ畾浣犲叿鏈夌浉搴旂殑姘戜簨琛屼负鑳藉姏锛屽鎮ㄤ笉鍚堣祫鏍硷紝璇峰嬁浣跨敤閲戣瀺鐢熸�佸湀骞冲彴鐨勬湇鍔°��
+ </p>
+ <p>
+ <strong>1.4</strong>
+ <strong>褰撴偍瀹屾垚娉ㄥ唽鍚庯紝鎮ㄥ彲鑾峰緱閲戣瀺鐢熸�佸湀骞冲彴璐︽埛锛屾偍鐨勮处鎴峰瘑鐮佺敱鎮ㄨ嚜琛岃缃苟鐢辨偍淇濈锛岃鍔″繀淇濈濂芥偍鐨勮处鎴枫�傝处鎴峰洜鎮ㄤ富鍔ㄦ硠闇叉垨鍥犳偍閬彈浠栦汉鏀诲嚮銆佽瘓楠楃瓑琛屼负瀵艰嚧鐨勬崯澶卞強鍚庢灉锛屽洓宸濋偖鏀垮苟涓嶆壙鎷呰矗浠汇��</strong>
+ </p>
+ <p>
+ <strong>1.5</strong>涓轰簡鎻愬崌鐢ㄦ埛浣撻獙銆佸鍔犳湇鍔″唴瀹癸紝閲戣瀺鐢熸�佸湀骞冲彴灏嗕笉鏂帹鍑烘柊鐨勬湇鍔★紝閲戣瀺鐢熸�佸湀骞冲彴鏈夋潈涓诲姩瀵硅蒋浠惰繘琛屾洿鏂版垨鐗堟湰鍗囩骇锛屾洿鏂版垨鐗堟湰鍗囩骇鍚庯紝鐢ㄦ埛鍦ㄤ笅娆$櫥褰曚娇鐢ㄦ椂闇�瑕佷笅杞姐�佸畨瑁呭苟浣跨敤鏈�鏂扮増鏈��
+ </p>
+ <p></p>
+ <p>
+ <strong>2</strong>
+ <strong>銆佽鍗曘�佷环鏍煎拰鏁伴噺</strong>
+ </p>
+ <p>
+ <strong>2.1</strong>浣跨敤閲戣瀺鐢熸�佸湀骞冲彴涓嬭鍗曪紝鎮ㄥ簲鍏峰璐拱鐩稿叧鍟嗗搧鐨勬潈鍒╄兘鍔涘拰琛屼负鑳藉姏锛屽湪涓嬭鍗曠殑鍚屾椂锛屽嵆瑙嗕负鎮ㄦ弧瓒冲墠杩版潯浠讹紝骞跺鎮ㄥ湪璁㈠崟涓彁渚涚殑鎵�鏈変俊鎭殑鐪熷疄鎬ц礋璐c��
+ </p>
+ <p>
+ <strong>2.2</strong>閲戣瀺鐢熸�佸湀骞冲彴涓婇攢鍞晢灞曠ず鐨勫晢鍝佸拰浠锋牸绛変俊鎭粎浠呮槸瑕佺害閭�璇凤紝鎮ㄤ笅鍗曟椂椤诲~鍐欐偍甯屾湜璐拱鐨勫晢鍝佹暟閲忋�佷环娆惧強鏀粯鏂瑰紡銆佹敹璐т汉銆佽仈绯绘柟寮忋�佹敹璐у湴鍧�绛夊唴瀹癸紱绯荤粺鐢熸垚鐨勮鍗曚俊鎭槸璁$畻鏈轰俊鎭郴缁熸牴鎹偍濉啓鐨勫唴瀹硅嚜鍔ㄧ敓鎴愮殑鏁版嵁锛屼粎鏄偍鍚戦攢鍞晢鍙戝嚭鐨勫悎鍚岃绾︺�傚湪鎮ㄤ粯娆惧畬姣曚笖閿�鍞晢纭鍚庯紝鎮ㄤ笌閿�鍞晢涔嬮棿灏卞墠杩拌鍗曞缓绔嬩簡鍚堝悓鍏崇郴銆傚鎮ㄤ笌閿�鍞晢鏈夌壒娈婄害瀹氱殑锛屼互鐗规畩绾﹀畾涓哄噯銆�
+ </p>
+ <h4>2.3鍦ㄦ偍涓嬭鍗曟椂锛岃鎮ㄤ粩缁嗙‘璁ゆ墍璐晢鍝佺殑鍚嶇О銆佷环鏍笺�佹暟閲忋�佸瀷鍙枫�佽鏍笺�佸昂瀵搞�佽仈绯诲湴鍧�銆佺數璇濄�佹敹璐т汉绛変俊鎭�傛敹璐т汉涓庢偍鏈汉涓嶄竴鑷寸殑锛屾敹璐т汉鐨勮涓哄拰鎰忔�濊〃绀鸿涓烘偍鐨勮涓哄拰鎰忔�濊〃绀猴紝鎮ㄥ簲瀵规敹璐т汉鐨勮涓哄強鎰忔�濊〃绀虹殑娉曞緥鍚庢灉鎵挎媴杩炲甫璐d换銆�
+ </h4>
+ <p>
+ <strong>2.4</strong>閲戣瀺鐢熸�佸湀骞冲彴灏嗗敖鏈�澶у姫鍔涗繚璇佹偍鎵�璐晢鍝佷笌缃戠珯涓婂叕甯冪殑浠锋牸涓�鑷达紝浣嗕环鐩〃鍜屽0鏄庡苟涓嶆瀯鎴愯绾︺�傚悓鏃讹紝閲戣瀺鐢熸�佸湀骞冲彴淇濈暀瀵逛骇鍝佽璐殑鏁伴噺绛夌殑闄愬埗鏉冦�傛湰缃戠珯鏃犳硶瀹屽叏閬垮厤鎮ㄦ彁浜ょ殑璁㈠崟淇℃伅涓殑鍟嗗搧鍑虹幇缂鸿揣銆佷环鏍兼爣绀洪敊璇瓑鎯呭喌锛涘鎮ㄤ笅鍗曟墍璐拱鐨勫晢鍝佸嚭鐜拌绛夋儏鍐碉紝鎮ㄦ湁鏉冨彇娑堣鍗曘��
+ </p>
+ <p>
+ <strong>2.5</strong>浜у搧鐨勪环鏍煎拰鍙幏鎬ч兘鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴涓婃寚鏄庛�傝繖绫讳俊鎭皢闅忔椂鏇存敼涓斾笉鍙戜换浣曢�氱煡銆傚鏃犵壒娈婅鏄庯紝鍟嗗搧鐨勪环鏍兼槸鍚◣浠枫��
+ <strong>濡傛灉鍙戠敓浜嗘剰澶栨儏鍐碉紝鍦ㄧ‘璁や簡鎮ㄧ殑璁㈠崟鍚庯紝鐢变簬绋庨鍙樺寲寮曡捣鐨勪环鏍煎彉鍖栵紝鎴栨槸鐢变簬缃戠珯鐨勯敊璇垨閲嶅ぇ璇В绛夐�犳垚鍟嗗搧浠锋牸鍙樺寲锛屾偍鏈夋潈鍙栨秷鎮ㄧ殑璁㈠崟锛岄攢鍞晢鎴栭噾铻嶇敓鎬佸湀骞冲彴浜︽湁鏉冨彇娑堣鍗曞苟閫氱煡鎮ㄣ��</strong>
+ </p>
+ <p></p>
+ <p>
+ <strong>3</strong>
+ <strong>銆侀�佽揣銆佽垂鐢�</strong>
+ </p>
+ <p>
+
+ <strong>3.1</strong>閲戣瀺鐢熸�佸湀骞冲彴灏嗕細鎶婁骇鍝侀�佸埌鎮ㄦ墍鎸囧畾鐨勯�佽揣鍦板潃銆傛墍鏈夊湪閲戣瀺鐢熸�佸湀骞冲彴涓婂垪鍑虹殑閫佽揣鏃堕棿涓哄弬鑰冩椂闂达紝鍙傝�冩椂闂寸殑璁$畻鏄牴鎹簱瀛樼姸鍐点�佹甯哥殑澶勭悊杩囩▼鍜岄�佽揣鏃堕棿銆侀�佽揣鍦扮偣鐨勫熀纭�涓婁及璁″緱鍑虹殑銆傞�佽揣璐圭敤鏍规嵁鎮ㄩ�夋嫨鐨勯厤閫佹柟寮忔垨閲戣瀺鐢熸�佸湀骞冲彴鐨勮瀹氫笉鍚岃�屽紓銆�
+ </p>
+ <p>
+ <strong>3.2</strong>璇锋竻妤氬噯纭湴濉啓鎮ㄧ殑鐪熷疄濮撳悕銆侀�佽揣鍦板潃銆佽仈绯讳汉鍙婅仈绯绘柟寮忋�傚洜濡備笅鎯呭喌閫犳垚璁㈠崟寤惰繜銆侀敊璇氦浠樻垨鏃犳硶閰嶉�佺瓑锛岄噾铻嶇敓鎬佸湀骞冲彴灏嗕笉鎵挎媴璐d换锛�
+ <div></div>
+ <strong>3.2.1</strong>瀹㈡埛鎻愪緵閿欒淇℃伅鍜屼笉璇︾粏鐨勫湴鍧�锛�
+ <div></div>
+ <strong>3.2.2</strong>璐х墿閫佽揪鏃犱汉绛炬敹锛岀敱姝ら�犳垚鐨勯噸澶嶉厤閫佹墍浜х敓鐨勮垂鐢ㄥ強鐩稿叧鐨勫悗鏋溿��
+ <div></div>
+ <strong>3.2.3</strong>涓嶅彲鎶楀姏锛屼緥濡傦細鑷劧鐏惧銆佹伓鍔eぉ姘斻�佷氦閫氭垝涓ャ�佺舰宸ャ�佹亹鎬栦簨浠躲�佺獊鍙戞垬浜夌瓑銆�
+ </p>
+ <p></p>
+ <p>
+ <strong>5</strong>
+ <strong>銆佹嫆缁濇彁渚涙媴淇�</strong>
+ </p>
+ <p>
+ <strong>鐢ㄦ埛涓汉瀵圭綉缁滄湇鍔$殑浣跨敤鎵挎媴椋庨櫓銆傞噾铻嶇敓鎬佸湀骞冲彴瀵规涓嶄綔浠讳綍绫诲瀷鐨勬媴淇濓紝涓嶈鏄槑纭殑鎴栭殣鍚殑銆�</strong>閲戣瀺鐢熸�佸湀骞冲彴涓嶆媴淇濇湇鍔′竴瀹氳兘婊¤冻鐢ㄦ埛鐨勮姹傦紝涔熶笉鎷呬繚鏈嶅姟涓嶄細鍙椾腑鏂紝瀵规湇鍔$殑鍙婃椂鎬с�佸畨鍏ㄦ�с�佸嚭閿欏彂鐢熼兘涓嶄綔鎷呬繚銆傚洓宸濋偖鏀垮鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴涓婂緱鍒扮殑浠讳綍鍟嗗搧璐墿鏈嶅姟鎴栦氦鏄撹繘绋嬩笉浣滄媴淇濄��
+ </p>
+ <p></p>
+ <p>
+ <strong>6</strong>
+ <strong>銆佹湁闄愯矗浠�</strong>
+ </p>
+ <p>
+ <strong>6.1</strong>閲戣瀺鐢熸�佸湀骞冲彴瀵逛换浣曢潪鍥涘窛閭斂鏁呮剰鎴栭噸澶ц繃澶辩洿鎺ャ�侀棿鎺ャ�佸伓鐒躲�佺壒娈婂強缁ц捣缁欐偍甯︽潵鐨勬崯瀹充笉璐熻矗浠伙紝杩欎簺鎹熷鍙兘鏉ヨ嚜锛氫笉姝e綋浣跨敤缃戠粶鏈嶅姟锛屽湪缃戜笂璐拱鍟嗗搧鎴栬繘琛屽悓绫诲瀷鏈嶅姟锛屽湪缃戜笂杩涜浜ゆ槗锛岄潪娉曚娇鐢ㄧ綉缁滄湇鍔℃垨鐢ㄦ埛浼犻�佺殑淇℃伅鏈夋墍鍙樺姩銆備笂杩版儏鍐靛彲鑳戒細瀵艰嚧閲戣瀺鐢熸�佸湀骞冲彴鐨勫舰璞″彈鎹燂紝鎵�浠ラ噾铻嶇敓鎬佸湀骞冲彴浜嬪厛鍛婄煡鐢ㄦ埛姝ょ鎹熷瀛樺湪鐨勫彲鑳芥�с��
+ </p>
+ <p>
+ <strong>6.2</strong>鍥涘窛閭斂灏嗚嚧鍔涗簬涓嶆柇鎻愬崌閲戣瀺鐢熸�佸湀骞冲彴鐨勮喘鐗╀綋楠岋紝浣嗛壌浜庣綉缁滅幆澧冧笅淇℃伅涓庡疄鐗╃浉鍒嗙绛夌壒鐐癸紝
+ <strong>鍥涘窛閭斂鏃犳硶閫愪竴瀹℃煡鍜屾牳瀹炲晢瀹朵笂杞芥垨鍙戝竷鐨勫晢鍝佸強</strong>
+ <strong>/</strong>
+ <strong>鎴栨湇鍔$殑淇℃伅锛屾棤娉曢�愪竴瀹℃煡浜ゆ槗鎵�娑夊強鐨勫晢鍝佸強</strong>
+ <strong>/</strong>
+ <strong>鎴栨湇鍔$殑璐ㄩ噺銆佸畨鍏ㄤ互鍙婂悎娉曟�с�佺湡瀹炴�с�佸噯纭�э紝鍥犳锛屽鎮ㄥ閫夎喘鍟嗗搧鎴栨湇鍔℃湁浠讳綍鐤戦棶锛岃鎮ㄨ皑鎱庡垽鏂苟涓庡晢瀹跺強鏃舵矡閫氳В鍐筹紝鍥涘窛閭斂灏嗘彁渚涘崗鍔╂敮鎸併��</strong>
+ </p>
+ <p></p>
+ <p>
+ <strong>7</strong>
+ <strong>銆佸鐢ㄦ埛淇℃伅鐨勫瓨鍌ㄥ拰闄愬埗</strong>
+ </p>
+ <p>閲戣瀺鐢熸�佸湀骞冲彴涓嶅鐢ㄦ埛鎵�鍙戝竷淇℃伅鐨勫垹闄ゆ垨鍌ㄥ瓨澶辫触璐熻矗銆傞噾铻嶇敓鎬佸湀骞冲彴鏈夊垽瀹氱敤鎴风殑琛屼负鏄惁绗﹀悎閲戣瀺鐢熸�佸湀骞冲彴鏈嶅姟鏉℃鐨勮姹傚拰绮剧鐨勪繚鐣欐潈鍒╋紝濡傛灉鐢ㄦ埛杩濊儗浜嗘湇鍔℃潯娆剧殑瑙勫畾锛岄噾铻嶇敓鎬佸湀骞冲彴鏈変腑鏂鍏舵彁渚涚綉缁滄湇鍔$殑鏉冨埄銆�
+ </p>
+ <p></p>
+ <p>
+ <strong>8</strong>
+ <strong>銆佺敤鎴风鐞�</strong>
+ </p>
+ <p>
+
+ <strong>8.1</strong>鐢ㄦ埛鍗曠嫭鎵挎媴鍙戝竷鍐呭鐨勮矗浠汇�傜敤鎴峰鏈嶅姟鐨勪娇鐢ㄦ槸鏍规嵁鎵�鏈夐�傜敤浜庨噾铻嶇敓鎬佸湀骞冲彴鐨勫浗瀹舵硶寰嬨�佸湴鏂规硶寰嬪拰鍥介檯娉曞緥鏍囧噯銆傜敤鎴峰繀椤婚伒寰細
+ <div></div>
+ <strong>8.1.1</strong>浠庝腑鍥藉鍐呭悜澶栦紶杈撴妧鏈�ц祫鏂欐椂蹇呴』绗﹀悎涓浗鏈夊叧娉曡銆�
+ <div></div>
+ <strong>8.1.2</strong>浣跨敤缃戠粶鏈嶅姟涓嶄綔闈炴硶鐢ㄩ�斻��
+ <div></div>
+ <strong>8.1.3</strong>涓嶅共鎵版垨娣蜂贡缃戠粶鏈嶅姟銆備笉瀵归噾铻嶇敓鎬佸湀骞冲彴鐩稿叧杞欢杩涜鍙嶅悜宸ョ▼銆佸弽鍚戞眹缂栥�佸弽鍚戠紪璇戯紝鎴栬�呬互鍏朵粬鏂瑰紡灏濊瘯鍙戠幇婧愪唬鐮佹垨閲囧彇榛戝銆佹湪椹瓑鏂瑰紡渚靛杞欢姝e父杩愯惀鎴栧悗鍙版暟鎹��
+ </p>
+ <p>
+ <strong>8.1.4</strong>閬靛畧鎵�鏈変娇鐢ㄧ綉缁滄湇鍔$殑缃戠粶鍗忚銆佽瀹氥�佺▼搴忓拰鎯緥銆�
+ <div></div>
+ <strong>8.2</strong>鐢ㄦ埛椤绘壙璇轰笉浼犺緭浠讳綍闈炴硶鐨勩�侀獨鎵版�х殑銆佷腑浼や粬浜虹殑銆佽颈楠傛�х殑銆佹亹鍚撴�х殑銆佷激瀹虫�х殑銆佸焊淇楃殑锛屾帆绉界瓑淇℃伅璧勬枡銆傚彟澶栵紝鐢ㄦ埛涔熶笉鑳戒紶杈撲綍鏁欏攩浠栦汉鏋勬垚鐘姜琛屼负鐨勮祫鏂欙紱涓嶈兘浼犺緭鍔╅暱鍥藉唴涓嶅埄鏉′欢鍜屾秹鍙婂浗瀹跺畨鍏ㄧ殑璧勬枡锛涗笉鑳戒紶杈撲换浣曚笉绗﹀悎褰撳湴娉曡銆佸浗瀹舵硶寰嬪拰鍥介檯娉曞緥鐨勮祫鏂欍�傛湭缁忚鍙�岄潪娉曡繘鍏ュ叾瀹冪數鑴戠郴缁熸槸绂佹鐨勩��
+ <div></div>
+ <strong>8.3</strong>鑻ョ敤鎴风殑琛屼负涓嶇鍚堜互涓婃彁鍒扮殑鏈嶅姟鏉℃锛岄噾铻嶇敓鎬佸湀骞冲彴灏嗕綔鍑虹嫭绔嬪垽鏂珛鍗冲彇娑堢敤鎴锋湇鍔¤处鍙枫�傜敤鎴烽渶瀵硅嚜宸卞湪缃戜笂鐨勮涓烘壙鎷呮硶寰嬭矗浠汇�傜敤鎴疯嫢鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴涓婃暎甯冨拰浼犳挱鍙嶅姩銆佽壊鎯呮垨鍏朵粬杩濆弽鍥藉娉曞緥鐨勪俊鎭紝閲戣瀺鐢熸�佸湀骞冲彴鐨勭郴缁熻褰曟湁鍙兘浣滀负鐢ㄦ埛杩濆弽娉曞緥鐨勮瘉鎹��
+ </p>
+ <p>
+ <strong>8.4</strong>鎮ㄥ彲鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴涓婂涓庢偍杈炬垚浜ゆ槗鐨勫晢瀹跺晢鍝佹垨鏈嶅姟杩涜璇勪环銆傛偍鐨勮瘎浠疯涓哄簲閬靛畧閲戣瀺鐢熸�佸湀骞冲彴鐩稿叧瑙勫垯锛岃瘎浠峰唴瀹逛笉搴斿惈鏈夋硶寰嬬姝㈠拰鏈崗璁姝俊鎭�傚洓宸濋偖鏀垮彲鑷鍒ゆ柇骞跺璇ョ瓑璇勪环淇℃伅杩涜鍒犻櫎鎴栧睆钄界瓑銆�
+ </p>
+ <p></p>
+ <p>
+ <strong>9</strong>
+ <strong>銆佺粨鏉熸湇鍔�</strong>
+ </p>
+ <p>
+
+ <strong>9.1</strong>鐢ㄦ埛鎴栭噾铻嶇敓鎬佸湀骞冲彴鍙殢鏃舵牴鎹疄闄呮儏鍐典腑鏂竴椤规垨澶氶」缃戠粶鏈嶅姟銆傞噾铻嶇敓鎬佸湀骞冲彴涓嶉渶瀵逛换浣曚釜浜烘垨绗笁鏂硅礋璐h�岄殢鏃朵腑鏂湇鍔°�傜敤鎴峰鍚庢潵鐨勬潯娆句慨鏀规湁寮傝锛屾垨瀵归噾铻嶇敓鎬佸湀骞冲彴鐨勬湇鍔′笉婊★紝鍙互琛屼娇濡備笅鏉冨埄锛�
+ <div></div>
+ <strong>9.1.1</strong>鍋滄浣跨敤閲戣瀺鐢熸�佸湀骞冲彴鐨勭綉缁滄湇鍔°��
+ <div></div>
+ <strong>9.1.2</strong>閫氬憡閲戣瀺鐢熸�佸湀骞冲彴鍋滄瀵硅鐢ㄦ埛鐨勬湇鍔°��
+ </p>
+ <p>
+ <strong>9.1.3</strong>鍦ㄦ弧瓒抽噾铻嶇敓鎬佸湀骞冲彴璐︽埛娉ㄩ攢鏉′欢鏃舵敞閿�鎮ㄧ殑璐︽埛銆�
+ <div></div>
+ <strong>9.2</strong>
+ <strong style='display:inline'>缁撴潫鐢ㄦ埛鏈嶅姟鍚庯紝鐢ㄦ埛浣跨敤缃戠粶鏈嶅姟鐨勬潈鍒╅┈涓婁腑姝€�備粠閭f椂璧凤紝閲戣瀺鐢熸�佸湀骞冲彴涔熸病鏈変箟鍔′紶閫佷换浣曟湭澶勭悊鐨勪俊鎭垨鏈畬鎴愮殑鏈嶅姟缁欑敤鎴锋垨绗笁鏂广��</strong>
+ </p>
+ <p>
+ <strong>9.3</strong>濡傛偍杩濆弽鏈崗璁�侀噾铻嶇敓鎬佸湀骞冲彴鍏ず鐨勫钩鍙拌鍒欍�佸彂甯冭繚绂佷俊鎭�侀獥鍙栧嫆绱粬浜鸿储鐗┿�侀噰鍙栦笉姝e綋鎵嬫鐗熷埄銆佷镜鐘粬浜哄悎娉曟潈鐩婄瓑琛屼负鐨勶紝閲戣瀺鐢熸�佸湀骞冲彴鏈夋潈涓嶇粡閫氱煡鍙婃椂鍒犻櫎銆佸睆钄界浉鍏冲唴瀹癸紝骞跺鎮ㄧ殑璐︽埛杩涜闄愬埗閮ㄥ垎鎴栧叏閮ㄥ姛鑳斤紝鎴栦簣浠ヨ处鎴峰喕缁撱��
+ </p>
+ <p>
+ <strong>9.4</strong>濡傛偍鐨勮处鎴峰瓨鍦ㄨ鐩楃敤銆侀粦瀹㈡敾鍑汇�佸共鎵版垨缁忓洓宸濋偖鏀垮垎鏋愬瓨鍦ㄥ叾浠栧紓甯哥殑锛屼负淇濇姢鎮ㄧ殑鏉冪泭鍜屽洓宸濋偖鏀跨殑鍒╃泭锛岄噾铻嶇敓鎬佸湀骞冲彴鏈夋潈瀵规偍鐨勮处鎴疯繘琛岄檺鍒堕儴鍒嗘垨鍏ㄩ儴鍔熻兘锛屾垨浜堜互鏆傛椂璐︽埛鍐荤粨銆�
+ </p>
+ <p>
+ <strong>9.5</strong>鍥犳偍杩濆弽鏈崗璁垨鐩稿叧鏈嶅姟鏉℃鐨勮瀹氾紝瀵艰嚧鎴栦骇鐢熺涓夋柟涓诲紶鐨勪换浣曠储璧斻�佷富寮犳垨鎹熷け锛屾偍搴斿綋鐙珛鎵挎媴璐d换锛涘洓宸濋偖鏀垮洜姝ら伃鍙楁崯澶辩殑锛屾偍涔熷簲褰撲竴骞惰禂鍋裤��
+ </p>
+ <p></p>
+ <p>
+ <strong>10</strong>
+ <strong>銆侀�氱煡</strong>
+ </p>
+ <p>
+ 闄ら潪鍙﹁鏄庣ず杞芥槑锛屼换浣曢�氱煡灏嗗彂寰�鎮ㄥ湪娉ㄥ唽杩囩▼涓悜閲戣瀺鐢熸�佸湀骞冲彴鎻愪緵鐨勭數閭湴鍧�鎴栬�呴�氳繃鐭俊銆佸僵淇$瓑鏂瑰紡鍙戦�佽嚦鎮ㄥ湪娉ㄥ唽杩囩▼涓悜鍥涘窛閭斂鎻愪緵鐨勬墜鏈哄彿鐮佷笂銆傛垨鑰咃紝閲戣瀺鐢熸�佸湀骞冲彴鍙�氳繃宸查浠橀偖璧勫拰瑕佹眰鍥炴墽鐨勪繚璇佽埅绌轰俊锛屽皢閫氱煡鍙戝線鎮ㄥ湪娉ㄥ唽杩囩▼涓悜閲戣瀺鐢熸�佸湀骞冲彴鎻愪緵鎴栨偍浣滃嚭鐩稿叧鏇存柊鐨勫湴鍧�銆傛偍纭鎺ュ彈浠ヤ笂閲戣瀺鐢熸�佸湀骞冲彴浣跨敤鐨勯�氱煡鏂瑰紡銆備换浣曢�氱煡搴旇涓轰簬浠ヤ笅鏃堕棿鍙戝嚭锛�
+ <div> </div>
+ <strong>(a)</strong>濡傞�氳繃鐢甸偖鎴栬�呯煭淇°�佸僵淇$瓑鏂瑰紡鍙戦�侊紝鍒欑數閭垨鑰呯煭淇°�佸僵淇$瓑鍙戦�佸悗24涓皬鏃讹紝浣嗗彂閫佹柟琚憡鐭ョ數閭湴鍧�鎴栬�呮墜鏈哄彿鐮佹棤鏁堢殑锛屽垯灞炰緥澶栵紱
+ <div></div>
+ <strong>(b)</strong>濡備互棰勪粯閭祫鐨勪俊浠跺彂閫侊紝鍒欐姇閭箣鏃ュ悗鍙佷釜钀ヤ笟鏃ャ��
+ </p>
+ <p></p>
+ <p>
+ <strong>11</strong>
+ <strong>銆佸箍鍛�</strong>
+ </p>
+ <p>鐢ㄦ埛鍦ㄤ粬浠彂琛ㄧ殑淇℃伅涓姞鍏ュ浼犺祫鏂欐垨鍙備笌骞垮憡绛栧垝锛屽湪閲戣瀺鐢熸�佸湀骞冲彴鐨勫厤璐规湇鍔′笂灞曠ず浠栦滑鐨勪骇鍝侊紝浠讳綍杩欑被淇冮攢鏂规硶锛屽寘鎷繍杈撹揣鐗┿�佷粯娆俱�佹湇鍔°�佸晢涓氭潯浠躲�佹媴淇濆強涓庡箍鍛婃湁鍏崇殑鎻忚堪閮藉彧鏄湪鐩稿簲鐨勭敤鎴峰拰骞垮憡鍙戝竷鑰呬箣闂村彂鐢熴�傞噾铻嶇敓鎬佸湀骞冲彴涓嶆壙鎷呬换浣曡矗浠伙紝閲戣瀺鐢熸�佸湀骞冲彴娌℃湁涔夊姟涓鸿繖绫诲箍鍛婇攢鍞壙鎷呬换浣曡矗浠汇��
+ </p>
+ <p></p>
+ <p>
+ <strong>12</strong>
+ <strong>銆佺増鏉冨0鏄�</strong>
+ </p>
+ <p>閲戣瀺鐢熸�佸湀骞冲彴瀹氫箟鐨勭綉缁滄湇鍔″唴瀹瑰寘鎷細鏂囧瓧銆佽蒋浠躲�佸0闊炽�佸浘鐗囥�佸綍鍍忋�佸浘琛ㄣ�佸箍鍛婁腑鐨勫叏閮ㄥ唴瀹癸紱鐢靛瓙閭欢鐨勫叏閮ㄥ唴瀹癸紱閲戣瀺鐢熸�佸湀骞冲彴涓虹敤鎴锋彁渚涚殑鍏朵粬淇℃伅銆傛墍鏈夎繖浜涘唴瀹瑰彈鐗堟潈銆佸晢鏍囥�佹爣绛惧拰鍏跺畠璐骇鎵�鏈夋潈娉曞緥鐨勪繚鎶ゃ�傛墍浠ワ紝鐢ㄦ埛鍙兘鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴鍜屽師浣滆�呮巿鏉冧笅鎵嶈兘浣跨敤杩欎簺鍐呭锛岃�屼笉鑳芥搮鑷鍒躲�佸啀閫犺繖浜涘唴瀹广�佹垨鍒涢�犱笌鍐呭鏈夊叧鐨勬淳鐢熶骇鍝併�傞噾铻嶇敓鎬佸湀骞冲彴鎵�鏈夌殑鍐呭鐗堟潈褰掑師鏂囦綔鑰呭拰閲戣瀺鐢熸�佸湀骞冲彴鍏卞悓鎵�鏈夛紝浠讳綍浜洪渶瑕佽浆杞介噾铻嶇敓鎬佸湀骞冲彴鐨勬枃绔狅紝蹇呴』寰佸緱鍘熸枃浣滆�呮垨閲戣瀺鐢熸�佸湀骞冲彴鎺堟潈銆�
+ </p>
+ <p></p>
+ <p>
+ <strong>13</strong>
+ <strong>銆佽鍙�</strong>
+ </p>
+ <p>
+ <strong>鎮ㄤ负浣块噾铻嶇敓鎬佸湀骞冲彴鑳藉浣跨敤鎮ㄥ悜閲戣瀺鐢熸�佸湀骞冲彴鎻愪氦鐨勮祫鏂欙紝浣块噾铻嶇敓鎬佸湀骞冲彴涓嶈繚鍙嶆偍鍙兘鍦ㄨ璧勬枡涓嫢鏈夌殑浠讳綍鏉冨埄涔嬬洰鐨勶紝鍚屾剰鍚戦噾铻嶇敓鎬佸湀骞冲彴鎺堜簣闈炵嫭鍗犮�佸叏鐞冩�с�佹案涔呫�佷笉鍙挙娑堛�佸厤浣跨敤璐广�佸彲鍒嗚鍙�</strong>
+ <strong>(閫氳繃澶氬眰璁稿彲鐨勬柟寮�)</strong>
+ <strong>鐨勬潈鍒╋紝浠ヨ浣挎偍鍦ㄦ偍鐨勮祫鏂�</strong>
+ <strong>(鍦ㄤ换浣曞凡鐭ユ垨鐩墠涓烘湭鐭ュ獟浣撲腑)</strong>
+ <strong>浜湁鐨勪笌鎮ㄧ殑璧勬枡鏈夊叧鐨勮憲浣滄潈銆佸彂琛ㄦ潈鍜屾暟鎹潈(浣嗘棤鍏跺畠鏉冨埄)銆�</strong>閲戣瀺鐢熸�佸湀骞冲彴灏嗘牴鎹殣绉佹潈淇濇姢瑙勫垯浣跨敤鎮ㄧ殑璧勬枡銆�
+ </p>
+ <p>
+ <strong>14</strong>
+ <strong>銆佽矗浠婚檺鍒�</strong>
+ </p>
+ <p>
+
+ <strong>14.1</strong>濡傚洜涓嶅彲鎶楀姏鎴栧叾浠栭噾铻嶇敓鎬佸湀骞冲彴鏃犳硶鎺у埗鐨勫師鍥犱娇閲戣瀺鐢熸�佸湀骞冲彴绯荤粺宕╂簝鎴栨棤娉曟甯镐娇鐢ㄥ鑷寸綉涓婁氦鏄撴棤娉曞畬鎴愭垨涓㈠け鏈夊叧鐨勪俊鎭�佽褰曠瓑锛岄噾铻嶇敓鎬佸湀骞冲彴涓嶆壙鎷呰矗浠汇�備絾鏄噾铻嶇敓鎬佸湀骞冲彴浼氬敖鍙兘鍚堢悊鍦板崗鍔╁鐞嗗杽鍚庝簨瀹滐紝骞跺姫鍔涗娇瀹㈡埛鍏嶅彈缁忔祹鎹熷け銆�
+ <div></div>
+ <strong>14.2</strong>闄や簡閲戣瀺鐢熸�佸湀骞冲彴鐨勪娇鐢ㄦ潯浠朵腑瑙勫畾鐨勫叾瀹冮檺鍒跺拰闄ゅ鎯呭喌涔嬪锛屽湪涓浗娉曞緥娉曡鎵�鍏佽鐨勯檺搴﹀唴锛屽浜庡洜浜ゆ槗鑰屽紩璧风殑鎴栦笌涔嬫湁鍏崇殑浠讳綍鐩存帴鐨勩�侀棿鎺ョ殑銆佺壒娈婄殑銆侀檮甯︾殑銆佸悗鏋滄�х殑鎴栨儵缃氭�х殑鎹熷锛屾垨浠讳綍鍏跺畠鎬ц川鐨勬崯瀹筹紝閲戣瀺鐢熸�佸湀骞冲彴銆侀噾铻嶇敓鎬佸湀骞冲彴鐨勮懀浜嬨�佺鐞嗕汉鍛樸�侀泧鍛樸�佷唬鐞嗘垨鍏跺畠浠h〃鍦ㄤ换浣曟儏鍐典笅閮戒笉鎵挎媴璐d换銆傞噾铻嶇敓鎬佸湀骞冲彴鐨勫叏閮ㄨ矗浠伙紝涓嶈鏄悎鍚屻�佷繚璇併�佷镜鏉�(鍖呮嫭杩囧け)椤逛笅鐨勮繕鏄叾瀹冪殑璐d换锛屽潎涓嶈秴杩囨偍鎵�璐拱鐨勫晢鍝佹垨涓庤绱㈣禂鏈夊叧鍟嗗搧鐨勯噾棰濄��
+ </p>
+ <p>
+ <strong>15</strong>
+ <strong>銆佺敤鎴烽殣绉佸埗搴�</strong>
+ </p>
+ <p>閲戣瀺鐢熸�佸湀骞冲彴璁炬湁閫傜敤浜庢墍鏈夌敤鎴峰苟绾冲叆鐢ㄦ埛鍗忚鐨勯殣绉佹潈淇濇姢瑙勫垯銆傛偍鍦ㄤ綔涓洪噾铻嶇敓鎬佸湀骞冲彴鐢ㄦ埛鏈熼棿灏嗗彈鍏惰瀹�(鍙婇噾铻嶇敓鎬佸湀骞冲彴瀵归殣绉佹潈淇濇姢瑙勫垯浣滃嚭鐨勪换浣曚慨璁�)鐨勭害鏉熴��</p>
+ <p></p>
+ <p>
+ <strong>16</strong>
+ <strong>銆佷竴鑸瀹�</strong>
+ </p>
+ <p>
+ <strong>16.1</strong>
+ <strong>鏈崗璁湪鎵�鏈夋柟闈㈠潎鍙椾腑鍗庝汉姘戝叡鍜屽浗娉曞緥绠¤緰銆備换浣曚簤璁紝濡傚崗鍟嗕笉鑳借В鍐筹紝鍧囧簲鎻愪氦涓婃捣甯傛郸涓滄柊鍖烘湁绠¤緰鏉冪殑娉曢櫌璇夎瑙e喅銆�</strong>
+ <div></div>
+ <strong>16.2</strong>鏈崗璁殑瑙勫畾鏄彲鍒嗗壊鐨勶紝濡傛湰鍗忚浠讳綍瑙勫畾琚瀹氫负鏃犳晥鎴栦笉鍙墽琛岋紝璇ヨ瀹氬彲琚垹闄よ�屽叾浣欐潯娆惧簲浜堜互鎵ц銆�
+ <div></div>
+ <strong>16.3</strong>鎮ㄥ悓鎰忥紝鍦ㄥ彂鐢熷苟璐椂锛屾湰鍗忚鍜屾墍鏈夌撼鍏ュ崗璁殑鏉℃鍜岃鍒欏彲鐢遍噾铻嶇敓鎬佸湀骞冲彴鑷閰屾儏鍐冲畾鍚戠鍙佹柟鑷姩杞銆�
+ <div></div>
+ <strong>16.4</strong>鏍囬浠呬负鍙傝�冧箣鐢紝鍦ㄤ换浣曟柟闈㈠潎涓嶇晫瀹氥�侀檺鍒躲�佽В閲婃垨鎻忚堪璇ユ潯鐨勮寖鍥存垨闄愬害銆�
+ <div></div>
+ <strong>16.5</strong>閲戣瀺鐢熸�佸湀骞冲彴鏈氨鎮ㄦ垨鍏朵粬鏂圭殑杩濈害閲囧彇琛屽姩骞朵笉绛変簬閲戣瀺鐢熸�佸湀骞冲彴鏀惧純灏遍殢鍚庢垨绫讳技鐨勮繚绾﹂噰鍙栬鍔ㄧ殑鏉冨埄銆傛偍鍚屾剰锛屾湰鍗忚涓嶅緱浠呯敱浜庣郴閲戣瀺鐢熸�佸湀骞冲彴鍒惰鑰屼互瀵归噾铻嶇敓鎬佸湀骞冲彴涓嶅埄鐨勬柟寮忎簣浠ヨВ閲娿�傛湰鍗忚鍜屾湰鍗忚鎵�鍚潯娆惧拰鏉′欢杞芥槑鎴戜滑鍙屾柟涔嬮棿灏辨湰鍗忚鏍囩殑涔嬪叏閮ㄨ皡瑙e拰鍗忚銆�
+ </p>
+ <p></p>
+ <p>
+ <strong>17</strong>
+ <strong>銆佹彁渚涘钩鍙版湇鍔�</strong>
+ </p>
+ <p>閲戣瀺鐢熸�佸湀骞冲彴鍙婂叾鍏宠仈浼佷笟涔嬪鐨勫叾浠栦汉鍙兘鍦ㄩ噾铻嶇敓鎬佸湀骞冲彴涓婄粡钀ュ簵閾恒�佹彁渚涙湇鍔℃垨鑰呴攢鍞骇鍝併�傚彟澶栵紝鎴戜滑鎻愪緵涓庡叧鑱斿叕鍙稿拰鍏朵粬浼佷笟鐨勯摼鎺ャ�傛垜浠笉璐熻矗瀹℃煡鍜岃瘎浼颁篃涓嶆媴淇濅换浣曡繖浜涗紒涓氭垨涓汉鐨勫緟鍞晢鍝佸強瀹冧滑缃戠珯鐨勫唴瀹广�傛垜浠鎵�鏈夎繖浜涗紒涓氭垨浠讳綍鍏朵粬绗笁浜烘垨鍏剁綉绔欑殑琛屼负銆佷骇鍝佸拰鍐呭涓嶆壙鎷呰矗浠汇�傛偍搴斾粩缁嗛槄璇诲畠浠嚜宸辩殑闅愮鏀跨瓥鍙婁娇鐢ㄦ潯浠躲��
+ </p>
+ <p></p>
+ <p>鏈崗璁増鏈簬2019骞�2鏈�19鏃ユ洿鏂帮紝浜�2019骞�3鏈�1鏃ョ敓鏁堛��</p>
+ </view>
+</template>
+
+<script>
+ export default {
+ name: "user-agreement",
+ data() {
+ return {
+
+ };
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ .con {
+ color: #333;
+ font-size: 26rpx;
+ margin: 30rpx 0;
+ height: 630rpx;
+ width: 550rpx;
+ }
+
+ .con p {
+ line-height: 1.65;
+ margin-bottom: 5rpx;
+ text-indent: 2em;
+ }
+
+ strong {
+ margin-right: 5rpx;
+ }
+</style>
diff --git a/index.html b/index.html
index b7f7362..6925918 100644
--- a/index.html
+++ b/index.html
@@ -1,22 +1,27 @@
<!DOCTYPE html>
<html lang="zh-CN">
-<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
- <meta http-equiv="Content-Security-Policy" content="frame-src https://*.qq.com webcompt:;">
- <title>
- <%= htmlWebpackPlugin.options.title %>
- </title>
- <link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css"/>
- <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>
-<!-- <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>-->
-</head>
-<body>
-<noscript>
- <strong>Please enable JavaScript to continue.</strong>
-</noscript>
-<div id="app"></div>
-<!-- built files will be auto injected -->
-</body>
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+ <title>
+ <%= htmlWebpackPlugin.options.title %>
+ </title>
+ <!-- Open Graph data -->
+ <!-- <meta property="og:title" content="Title Here" /> -->
+ <!-- <meta property="og:url" content="http://www.example.com/" /> -->
+ <!-- <meta property="og:image" content="http://example.com/image.jpg" /> -->
+ <!-- <meta property="og:description" content="Description Here" /> -->
+ <link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
+ <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>
+ <!-- <script src="<%= BASE_URL %>common/jweixin-1.6.0.js"></script> -->
+ <!-- <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
+ </head>
+ <body>
+ <noscript>
+ <strong>Please enable JavaScript to continue.</strong>
+ </noscript>
+ <div id="app"></div>
+ <!-- built files will be auto injected -->
+ </body>
</html>
diff --git a/main.js b/main.js
index f45a33f..e4f0932 100644
--- a/main.js
+++ b/main.js
@@ -1,8 +1,7 @@
import App from './App'
import Vue from 'vue'
-/*import Vconsole from 'vconsole';
+/*import Vconsole from 'vconsole'
new Vconsole();*/
-
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
@@ -13,6 +12,8 @@
App.mpType = 'app'
uni.$u.props.text.color = '#333333'
+// import store from '@/store/index.js'
+// Vue.prototype.$store = store
Vue.config.ignoredElements.push('wx-open-launch-weapp')
diff --git a/manifest.json b/manifest.json
index 1088a6e..5efa53a 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
- "name" : "鍐�椹夸粯",
- "appid" : "__UNI__3E21AAD",
- "description" : "鍐�椹夸粯",
+ "name" : "鏀粯",
+ "appid" : "__UNI__895EB4F",
+ "description" : "鏀粯",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
@@ -50,6 +50,11 @@
"quickapp" : {},
/* 灏忕▼搴忕壒鏈夌浉鍏� */
"mp-weixin" : {
+ "appid" : "wxfc579973fbdde096",
+ "setting" : {
+ "urlCheck" : false,
+ "minified" : true
+ },
"usingComponents" : true
},
"mp-alipay" : {
@@ -66,23 +71,14 @@
},
"vueVersion" : "2",
"h5" : {
- "title" : "鍐�椹夸粯",
+ "title" : "鏀粯",
"router" : {
- "base" : "/",
+ "base" : "/pay/",
"mode" : "history"
},
"devServer" : {
- "proxy" : {
- "/dev-api" : {
- "target" : "http://172.16.2.121:8080",
- "changeOrigin" : true,
- "secure" : false,
- "pathRewrite" : {
- "^/dev-api" : ""
- }
- }
- },
- "port" : ""
+ "https" : false,
+ "disableHostCheck" : true
},
"optimization" : {
"treeShaking" : {
diff --git a/package.json b/package.json
index e8f2ccf..a9b14f1 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
+ "mathjs": "^11.5.0",
"vconsole": "^3.14.7",
"weixin-js-sdk": "^1.6.0"
},
diff --git a/pages.json b/pages.json
index 79ca066..9c049f4 100644
--- a/pages.json
+++ b/pages.json
@@ -2,31 +2,47 @@
"easycom": {
"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
},
- "pages": [
- {
- "path": "pay/index",
+ "pages": [{
+ "path": "pages/pay/scanpay",
"style": {
- "navigationBarTitleText": "鍐�椹夸粯",
+ "navigationBarTitleText": "鏀粯",
"enablePullDownRefresh": false
// #ifdef H5
,
"navigationStyle": "custom"
// #endif
}
- },
- {
- "path": "pay/scanpay",
+ }, {
+ "path": "pages/pay/discountpay",
"style": {
- "navigationBarTitleText": "鍚戝晢瀹朵粯娆�",
+ "navigationBarTitleText": "浼樻儬",
"enablePullDownRefresh": false
// #ifdef H5
,
"navigationStyle": "custom"
// #endif
}
- },
- {
- "path": "pay/paySuccess",
+
+ },{
+ "path": "pages/pay/wxpay",
+ "style": {
+ // #ifdef H5
+ "navigationStyle": "custom"
+ // #endif
+ }
+ }, {
+ "path": "pages/pay/register",
+ "style": {
+ "navigationBarTitleText": "娉ㄥ唽",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/paySuccess",
"style": {
"navigationBarTitleText": "鏀粯鎴愬姛",
"enablePullDownRefresh": false
@@ -35,13 +51,96 @@
"navigationStyle": "custom"
// #endif
}
+
+ }, {
+ "path": "pages/pay/scanRes",
+ "style": {
+ "navigationStyle": "custom"
+ }
+ }, {
+ "path": "pages/pay/login",
+ "style": {
+ "navigationBarTitleText": "鐧诲綍",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/addCardFirst",
+ "style": {
+ "navigationBarTitleText": "娣诲姞閾惰鍗�",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/addCardSecond",
+ "style": {
+ "navigationBarTitleText": "娣诲姞閾惰鍗�",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/addCardCode",
+ "style": {
+ "navigationBarTitleText": "閾惰鍗¢獙璇佺爜",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/bindCard/bindCard",
+ "style": {
+ "navigationBarTitleText": "缁戝畾閾惰鍗�",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/shuaKa/shuaKa",
+ "style": {
+ "navigationBarTitleText": "鍒峰崱娲诲姩",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
+ }, {
+ "path": "pages/pay/shuaKa/introduce",
+ "style": {
+ "navigationBarTitleText": "娲诲姩璇︽儏",
+ "enablePullDownRefresh": false
+ // #ifdef H5
+ ,
+ "navigationStyle": "custom"
+ // #endif
+ }
+
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
- "navigationBarTitleText": "鍐�椹夸粯",
- "navigationBarBackgroundColor": "#EDEDED",
- "backgroundColor": "#EDEDED"
+ "navigationBarTitleText": "鏀粯",
+ "navigationBarBackgroundColor": "#FFFFFF",
+ "backgroundColor": "#FFFFFF"
},
"uniIdRouter": {}
}
diff --git a/pages/pay/addCardCode.vue b/pages/pay/addCardCode.vue
new file mode 100644
index 0000000..1d72a36
--- /dev/null
+++ b/pages/pay/addCardCode.vue
@@ -0,0 +1,141 @@
+<template>
+ <view>
+ <view class="u-p-30 color-666">宸插彂閫佽嚦鎵嬫満鍙穥{form.mobile|mobile_asterisk}}</view>
+ <u--form class="bg-fff u-p-h-30" labelWidth="80" :model="form" :rules="rules" ref="uForm">
+ <u-form-item label="楠岃瘉鐮�" prop="code">
+ <u--input v-model="form.code" border="none" placeholder="璇疯緭鍏ユ墜鏈洪獙璇佺爜"></u--input>
+ <u-button slot="right" @click="getCode" type="error" size="mini" plain :text="tips"></u-button>
+ </u-form-item>
+ </u--form>
+ <view class="u-p-40">
+ <u-button @click="doBind" :loading="loading" :disabled="loading" type="error" text="纭缁戝崱"></u-button>
+ </view>
+ <u-toast ref="uToast"></u-toast>
+ <u-code :seconds="seconds" ref="uCode" @change="codeChange"></u-code>
+ </view>
+</template>
+
+<script>
+ import {
+ signUpToApply,
+ bindCard
+ } from '@/common/api/index'
+ const bankName = require("@/common/bankName.js");
+ export default {
+ data() {
+ return {
+ tips: '',
+ seconds: 60,
+ loading: false,
+ form: {
+ acctName: '',
+ cardNo: '',
+ bankName: '',
+ cardType: 'DC',
+ validdate: '',
+ cvv2: '',
+ idNo: '',
+ mobile: '18737516907',
+ thpinfo: '',
+ code: ''
+ },
+ rules: {
+ code: [{
+ required: true,
+ message: '楠岃瘉鐮佷笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.code(value, 6);
+ },
+ message: '楠岃瘉鐮佹牸寮忎笉姝g‘',
+ trigger: 'change'
+ }]
+ }
+ };
+ },
+ filters: {
+ mobile_asterisk(mobile) {
+ if (uni.$u.test.isEmpty(mobile)) {
+ return ''
+ }
+ return mobile.substr(0, 4) +
+ "****" + mobile.substr(8, 3);
+ }
+ },
+ onLoad(opt) {
+ opt.acctName = decodeURIComponent(opt.acctName || '')
+ opt.bankName = decodeURIComponent(opt.bankName || '')
+ this.form = opt
+ },
+ onReady() {
+ //濡傛灉闇�瑕佸吋瀹瑰井淇″皬绋嬪簭锛屽苟涓旀牎楠岃鍒欎腑鍚湁鏂规硶绛夛紝鍙兘閫氳繃setRules鏂规硶璁剧疆瑙勫垯銆�
+ this.$refs.uForm.setRules(this.rules)
+ this.$refs.uCode.start();
+ },
+ methods: {
+ codeChange(text) {
+ this.tips = text;
+ },
+ getCode() {
+ if (this.$refs.uCode.canGetCode) {
+ // 妯℃嫙鍚戝悗绔姹傞獙璇佺爜
+ uni.showLoading({
+ title: '姝e湪鑾峰彇楠岃瘉鐮�'
+ })
+ const params = uni.$u.deepClone(this.form);
+ delete params.thpinfo
+ delete params.code
+ delete params.bankName
+ delete params.cardType
+ signUpToApply(params).then(res => {
+ this.form.thpinfo = res
+ uni.hideLoading();
+ uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+ // 閫氱煡楠岃瘉鐮佺粍浠跺唴閮ㄥ紑濮嬪�掕鏃�
+ this.$refs.uCode.start();
+ }).catch(() => {
+ uni.$u.toast('楠岃瘉鐮佸彂閫佸け璐�');
+ uni.hideLoading();
+ })
+ } else {
+ uni.$u.toast('鍊掕鏃剁粨鏉熷悗鍐嶅彂閫�');
+ }
+ },
+ doBind() {
+ this.$refs.uForm.validate().then(res => {
+ this.loading = true
+ const params = uni.$u.deepClone(this.form);
+ delete params.bankName
+ delete params.cardType
+ bindCard(params).then(res => {
+ this.loading = false
+ this.$refs.uToast.show({
+ type: 'success',
+ title: '鎴愬姛',
+ message: "缁戝崱鎴愬姛",
+ iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png',
+ complete: () => {
+ uni.navigateBack({
+ delta: 3
+ })
+ }
+ })
+
+ }).catch(() => {
+ this.loading = false
+ })
+ }).catch(errors => {
+
+ })
+ }
+ }
+ }
+</script>
+
+<style lang="scss">
+
+</style>
diff --git a/pages/pay/addCardFirst.vue b/pages/pay/addCardFirst.vue
new file mode 100644
index 0000000..cbd756e
--- /dev/null
+++ b/pages/pay/addCardFirst.vue
@@ -0,0 +1,113 @@
+<template>
+ <view>
+ <view class="u-p-30 color-666">璇风粦瀹氭寔鍗′汉鏈汉鐨勯摱琛屽崱</view>
+ <u--form class="bg-fff u-p-h-30" labelWidth="80" :model="form" :rules="rules" ref="uForm">
+ <u-form-item label="鎸佸崱浜�" prop="acctName" borderBottom>
+ <u--input v-model="form.acctName" border="none" placeholder="璇疯緭鍏ユ寔鍗′汉濮撳悕"></u--input>
+ </u-form-item>
+ <u-form-item label="鍗″彿" prop="cardNo">
+ <u--input v-model="form.cardNo" border="none" placeholder="璇疯緭鍏ュ崱鍙�"></u--input>
+ </u-form-item>
+ </u--form>
+ <view class="u-p-40">
+ <u-button @click="doNext" :loading="loading" :disabled="loading" type="error" text="涓嬩竴姝�"></u-button>
+ </view>
+
+ </view>
+</template>
+
+<script>
+ import {
+ isContain,
+ } from '@/common/api/index'
+ const bankName = require("@/common/bankName.js");
+ export default {
+ data() {
+ return {
+ loading: false,
+ form: {
+ acctName: '',
+ cardNo: ''
+ },
+ rules: {
+ acctName: [{
+ required: true,
+ message: '鎸佸崱浜哄鍚嶄笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.rangeLength(value, [2, 6]) && uni.$u.test.chinese(value);
+ },
+ message: '鎸佸崱浜哄鍚嶄笉姝g‘',
+ trigger: 'change'
+ }],
+ cardNo: [{
+ required: true,
+ message: '鍗″彿涓嶈兘涓虹┖',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return this.$utils.verifyBankCard(value);
+ },
+ message: '鍗″彿涓嶆纭�',
+ trigger: 'change'
+ }]
+ }
+ };
+ },
+ onReady() {
+ //濡傛灉闇�瑕佸吋瀹瑰井淇″皬绋嬪簭锛屽苟涓旀牎楠岃鍒欎腑鍚湁鏂规硶绛夛紝鍙兘閫氳繃setRules鏂规硶璁剧疆瑙勫垯銆�
+ this.$refs.uForm.setRules(this.rules)
+ },
+ methods: {
+ doNext() {
+ this.$refs.uForm.validate().then(res => {
+ this.loading = true
+ isContain({
+ cardNum: this.form.cardNo
+ }).then(res => {
+ uni.request({
+ url: 'https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardBinCheck=true&cardNo=' +
+ this.form.cardNo,
+ method: "GET",
+ complete: (res) => {
+ this.loading = false
+ if (res.statusCode == 200) {
+ if (res.data.validated) {
+ const bank = bankName.bankName[res.data.bank]
+ const params = uni.$u.deepClone(this.form);
+ params.cardType = res.data.cardType
+ params.bankName = bank
+ uni.$u.route({
+ url: '/pages/pay/addCardSecond',
+ params: params
+ })
+ } else {
+ uni.$u.toast("鍗″彿涓嶆纭紒");
+ }
+ } else {
+ uni.$u.toast("鍗$被鍨嬭幏鍙栧け璐ワ紒");
+ }
+ }
+ })
+ }).catch(() => {
+ this.loading = false
+ })
+
+ }).catch(errors => {
+
+ })
+ }
+ }
+ }
+</script>
+
+<style lang="scss">
+
+</style>
diff --git a/pages/pay/addCardSecond.vue b/pages/pay/addCardSecond.vue
new file mode 100644
index 0000000..257877d
--- /dev/null
+++ b/pages/pay/addCardSecond.vue
@@ -0,0 +1,151 @@
+<template>
+ <view>
+ <u--form class="" labelWidth="80" :model="form" :rules="rules" ref="uForm">
+ <view class="u-p-h-30">
+ <u-form-item label="鎸佸崱浜�">
+ <u--input v-model="form.acctName" readonly border="none"></u--input>
+ </u-form-item>
+ <u-form-item label="閾惰鍗″彿">
+ <u--input v-model="form.cardNo" readonly border="none"></u--input>
+ </u-form-item>
+ <u-form-item label="鎵�灞為摱琛�">
+ <u--input v-model="form.bankName" readonly border="none"></u--input>
+ </u-form-item>
+ </view>
+
+ <view class="bg-fff u-p-h-30 u-m-t-30">
+ <block v-if="form.cardType=='CC'">
+ <u-form-item label="鏈夋晥鏈�" borderBottom prop="validdate">
+ <u--input v-model="form.validdate" border="none" placeholder="璇疯緭鍏ヤ俊鐢ㄥ崱鏈夋晥鏈�">
+ </u--input>
+ </u-form-item>
+ <u-form-item label="瀹夊叏鐮�" borderBottom prop="cvv2">
+ <u--input v-model="form.cvv2" border="none" placeholder="璇疯緭鍏ヤ俊鐢ㄥ崱瀹夊叏鐮�"></u--input>
+ </u-form-item>
+ </block>
+ <u-form-item label="韬唤璇佸彿" borderBottom prop="idNo">
+ <u--input v-model="form.idNo" border="none" placeholder="璇疯緭鍏ユ寔鍗′汉韬唤璇佸彿"></u--input>
+ </u-form-item>
+ <u-form-item label="鎵嬫満鍙�" prop="mobile">
+ <u--input v-model="form.mobile" border="none" placeholder="璇疯緭鍏ユ寔鍗′汉鎵嬫満鍙�"></u--input>
+ </u-form-item>
+ </view>
+
+ </u--form>
+ <label @click="checked=!checked" class="u-flex u-font-24 color-999 u-m-h-30 u-m-t-30">
+ <radio style="transform: scale(0.7);" color="#e93b3d" @change="radioChange" :checked="checked" />鎴戝凡闃呰骞跺悓鎰�
+ <view @click.stop="showAgreement=true" class="" style="color: #e93b3d;">銆婄敤鎴峰崗璁��</view>
+ </label>
+ <view class="u-p-40">
+ <u-button @click="doNext" :loading="loading" :disabled="loading" type="error" text="涓嬩竴姝�"></u-button>
+ </view>
+ <u-popup :show="showAgreement" mode="center" :round="30">
+ <card-agreement @confirm="checked=true;showAgreement=false;doNext()"></card-agreement>
+ </u-popup>
+
+ </view>
+</template>
+
+<script>
+ import {
+ signUpToApply,
+ } from '@/common/api/index'
+ export default {
+ data() {
+ return {
+ showAgreement: false,
+ checked: true,
+ loading: false,
+ form: {
+ acctName: '',
+ cardNo: '',
+ bankName: '',
+ cardType: 'DC',
+ validdate: '',
+ cvv2: '',
+ idNo: '',
+ mobile: ''
+ },
+ rules: {
+ validdate: [{
+ required: true,
+ message: '鏈夋晥鏈熶笉鑳戒负绌�',
+ trigger: 'blur'
+ }],
+ cvv2: [{
+ required: true,
+ message: '瀹夊叏鐮佷笉鑳戒负绌�',
+ trigger: 'blur'
+ }],
+ idNo: [{
+ required: true,
+ message: '韬唤璇佸彿涓嶈兘涓虹┖',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.idCard(value);
+ },
+ message: '韬唤璇佸彿涓嶆纭�',
+ trigger: 'change'
+ }],
+ mobile: [{
+ required: true,
+ message: '鎵嬫満鍙蜂笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.mobile(value);
+ },
+ message: '鎵嬫満鍙蜂笉姝g‘',
+ trigger: 'change'
+ }],
+ }
+ };
+ },
+ onLoad(opt) {
+ opt.acctName = decodeURIComponent(opt.acctName || '')
+ opt.bankName = decodeURIComponent(opt.bankName || '')
+ this.form = opt
+ },
+ onReady() {
+ //濡傛灉闇�瑕佸吋瀹瑰井淇″皬绋嬪簭锛屽苟涓旀牎楠岃鍒欎腑鍚湁鏂规硶绛夛紝鍙兘閫氳繃setRules鏂规硶璁剧疆瑙勫垯銆�
+ this.$refs.uForm.setRules(this.rules)
+ },
+ methods: {
+ doNext() {
+ this.$refs.uForm.validate().then(res => {
+ if (!this.checked) {
+ this.showAgreement = true
+ return
+ }
+ this.loading = true
+ const param = uni.$u.deepClone(this.form);
+ delete param.bankName
+ delete param.cardType
+ signUpToApply(param).then(res => {
+ const params = uni.$u.deepClone(this.form);
+ params.thpinfo = res
+ uni.$u.route({
+ url: '/pages/pay/addCardCode',
+ params: params
+ })
+ }).catch(() => {
+ this.loading = false
+ })
+ }).catch(errors => {
+
+ })
+ }
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+
+</style>
diff --git a/pages/pay/bindCard/bindCard.vue b/pages/pay/bindCard/bindCard.vue
new file mode 100644
index 0000000..5b2bdd6
--- /dev/null
+++ b/pages/pay/bindCard/bindCard.vue
@@ -0,0 +1,392 @@
+<template>
+ <view>
+ <view class="u-font-42 font-bold u-text-center u-m-t-30">娣诲姞閾惰鍗�</view>
+ <view class="u-font-28 u-text-center u-m-t-10 u-m-b-60">濉啓浠ヤ笅淇℃伅杩涜缁戝崱</view>
+ <u--form class="" labelWidth="80" :model="form" :rules="rules" ref="uForm">
+ <u-form-item class="form-item u-m-b-24" label="鎸佸崱浜�" prop="acctName">
+ <u--input v-model="form.acctName" inputAlign="right" border="none" :readonly="userInfo.tlAuthName" placeholder="璇疯緭鍏ユ寔鍗′汉濮撳悕"></u--input>
+ </u-form-item>
+ <u-form-item class="form-item u-m-b-24" label="韬唤璇佸彿" prop="idNo">
+ <u--input v-model="form.idNo" inputAlign="right" border="none" :readonly="userInfo.tlAuthIdentityNo" placeholder="璇疯緭鍏ユ寔鍗′汉韬唤璇佸彿"></u--input>
+ </u-form-item>
+ <u-form-item class="form-item u-m-b-24" label="鎵嬫満鍙�" prop="mobile">
+ <u--input v-model="form.mobile" inputAlign="right" border="none" placeholder="璇疯緭鍏ユ墜鏈哄彿"></u--input>
+ </u-form-item>
+
+ <view class="u-font-30 color-333 u-m-t-60 u-m-b-24">閾惰鍗$被鍒�</view>
+ <view class="u-flex u-row-between u-m-b-24">
+ <view @click="chooseType('DC')" :class="['type-btn',{'type-act':cardType=='DC'}]">鍌ㄨ搫鍗�
+ </view>
+ <view @click="chooseType('CC')" :class="['type-btn',{'type-act':cardType=='CC'}]">淇$敤鍗�
+ </view>
+ </view>
+ <u-form-item class="form-item u-m-b-24" label="鍗″彿" prop="cardNo">
+ <u--input v-model="form.cardNo" inputAlign="right" border="none" placeholder="璇疯緭鍏ユ寔鍗′汉鏈汉閾惰鍗″彿"></u--input>
+ </u-form-item>
+ <block v-if="cardType=='CC'">
+ <u-form-item class="form-item u-m-b-24" label="鏈夋晥鏈�" prop="validdate">
+ <u--input v-model="form.validdate" inputAlign="right" border="none" placeholder="璇疯緭鍏ヤ俊鐢ㄥ崱鏈夋晥鏈�">
+ </u--input>
+ </u-form-item>
+ <u-form-item class="form-item u-m-b-24" label="瀹夊叏鐮�" prop="cvv2">
+ <u--input v-model="form.cvv2" inputAlign="right" border="none" placeholder="璇疯緭鍏ヤ俊鐢ㄥ崱瀹夊叏鐮�"></u--input>
+ </u-form-item>
+ </block>
+ <view class="u-flex u-m-b-24">
+ <u-form-item class="form-item" label="楠岃瘉鐮�" prop="code">
+ <u--input v-model="form.code" maxlength="6" inputAlign="right" border="none" placeholder="璇疯緭鍏ラ獙璇佺爜">
+ </u--input>
+ </u-form-item>
+ <view @click="getCode" class="code-btn" :class="codeAct?'code-act':''">{{tips}}</view>
+ </view>
+ </u--form>
+ <label @click="checked=!checked" class="u-flex u-font-24 color-999 u-m-t-30">
+ <radio style="transform: scale(0.7);" color="#e93b3d" @change="radioChange" :checked="checked" />鎴戝凡闃呰骞跺悓鎰�
+ <view @click.stop="showAgreement=true" class="" style="color: #e93b3d;">銆婄敤鎴峰崗璁��</view>
+ </label>
+ <view class="u-m-b-60" style="opacity: 0;">
+ <button class="bind-btn">绔嬪嵆缁戝崱</button>
+ </view>
+ <view class="btn-box">
+ <button @click="doBind" :loading="loading" :disabled="loading" class="bind-btn">绔嬪嵆缁戝崱</button>
+ </view>
+ <!-- 鐢ㄦ埛鍗忚 -->
+ <u-popup @close="showAgreement=false" :show="showAgreement" mode="center" :round="30" closeable
+ :safeAreaInsetBottom="false">
+ <card-agreement @confirm="checked=true;showAgreement=false;doBind()"></card-agreement>
+ </u-popup>
+ <!-- 棣栫粦鏈夌ぜ娲诲姩 -->
+ <u-popup bgColor="transparent" @close="showAct=false" :show="showAct" mode="center" :round="30"
+ :safeAreaInsetBottom="false">
+ <bind-card-activity :couponList="couponList" @close="showAct = false"></bind-card-activity>
+ </u-popup>
+
+ <u-toast ref="uToast"></u-toast>
+ <u-code :seconds="seconds" @end="end" @start="start" ref="uCode" keepRunning changeText="宸插彂閫�(x)"
+ @change="codeChange"></u-code>
+ </view>
+</template>
+
+<script>
+ import {
+ isContain,
+ signUpToApply,
+ bindCard,
+ getMyCoupUseDetail,
+ getUserInfo
+ } from '@/common/api/index'
+ export default {
+ data() {
+ return {
+ showAct: false,
+ couponList: [],
+ bankName: '',
+ cardType: 'DC',
+ tips: '',
+ seconds: 60,
+ codeAct: true,
+ showAgreement: false,
+ checked: true,
+ loading: false,
+ userInfo: {
+ tlAuthIdentityNo: '',
+ tlAuthName: ''
+ },
+ form: {
+ acctName: '',
+ idNo: '',
+ cardNo: '',
+ validdate: '',
+ cvv2: '',
+ mobile: '',
+ code: ''
+ },
+ rules: {
+ acctName: [{
+ required: true,
+ message: '鎸佸崱浜哄鍚嶄笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.rangeLength(value, [2, 6]) && uni.$u.test.chinese(value);
+ },
+ message: '鎸佸崱浜哄鍚嶄笉姝g‘',
+ trigger: 'change'
+ }],
+ idNo: [{
+ required: true,
+ message: '韬唤璇佸彿涓嶈兘涓虹┖',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.idCard(value);
+ },
+ message: '韬唤璇佸彿涓嶆纭�',
+ trigger: 'blur'
+ }],
+ mobile: [{
+ required: true,
+ message: '鎵嬫満鍙蜂笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.mobile(value);
+ },
+ message: '鎵嬫満鍙蜂笉姝g‘',
+ trigger: 'blur'
+ }],
+ cardNo: [{
+ required: true,
+ message: '鍗″彿涓嶈兘涓虹┖',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return this.$utils.verifyBankCard(value);
+ },
+ message: '鍗″彿涓嶆纭�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ asyncValidator: (rule, value, callback) => {
+ isContain({
+ params: {
+ cardNum: value
+ }
+ }).then(res => {
+ if (res) {
+ callback();
+ } else {
+ callback(new Error('鍗″彿涓嶅湪鍗℃鍐�'));
+ }
+ }).catch(() => {
+ callback(new Error('鍗″彿涓嶅湪鍗℃鍐�'));
+ })
+ },
+ trigger: 'blur'
+ }],
+ validdate: [{
+ required: true,
+ message: '鏈夋晥鏈熶笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ len: 4,
+ message: '鏈夋晥鏈熶笉姝g‘',
+ trigger: 'blur'
+ }],
+ cvv2: [{
+ required: true,
+ message: '瀹夊叏鐮佷笉鑳戒负绌�',
+ trigger: ['blur']
+ }, {
+ min: 3,
+ max: 4,
+ message: '瀹夊叏鐮侀暱搴︿负3-4',
+ trigger: 'blur'
+ }]
+ }
+ };
+ },
+ onLoad() {
+ const IS_NEW = uni.getStorageSync('IS_NEW')
+ if(!IS_NEW){
+ getUserInfo().then(res=>{
+ if(res){
+ this.userInfo = res
+ this.form.mobile = res.mobile
+ this.form.acctName = res.tlAuthName||res.memberName
+ this.form.idNo = res.tlAuthIdentityNo||res.idcard
+ }
+ })
+ }
+ },
+ onReady() {
+ //濡傛灉闇�瑕佸吋瀹瑰井淇″皬绋嬪簭锛屽苟涓旀牎楠岃鍒欎腑鍚湁鏂规硶绛夛紝鍙兘閫氳繃setRules鏂规硶璁剧疆瑙勫垯銆�
+ this.$refs.uForm.setRules(this.rules)
+ },
+ methods: {
+ codeChange(text) {
+ this.tips = text;
+ },
+ end() {
+ this.codeAct = true
+ },
+ start() {
+ this.codeAct = false
+ },
+ // 鍙戦�侀獙璇佺爜
+ getCode() {
+ if (this.$refs.uCode.canGetCode) {
+ delete this.rules.code
+ this.$refs.uForm.clearValidate();
+ this.$refs.uForm.setRules(this.rules);
+ this.$nextTick(() => {
+ this.$refs.uForm.validate().then(() => {
+ uni.showLoading({
+ title: '姝e湪鑾峰彇楠岃瘉鐮�'
+ })
+ const params = uni.$u.deepClone(this.form);
+ delete params.thpinfo
+ delete params.code
+ signUpToApply(params).then(res => {
+ this.form.thpinfo = JSON.stringify(res.thpinfo)
+ uni.hideLoading();
+ uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+ // 閫氱煡楠岃瘉鐮佺粍浠跺唴閮ㄥ紑濮嬪�掕鏃�
+ this.$refs.uCode.start();
+ }).catch(() => {
+ uni.hideLoading();
+ })
+ })
+ })
+ } else {
+ uni.$u.toast('鍊掕鏃剁粨鏉熷悗鍐嶅彂閫�');
+ }
+ },
+ //閫夋嫨閾惰鍗$被鍨�
+ chooseType(type) {
+ this.cardType = type
+ },
+ //缁戝畾閾惰鍗�
+ doBind() {
+ if (!this.checked) {
+ this.showAgreement = true
+ return
+ }
+ this.rules.code = [{
+ required: true,
+ message: '楠岃瘉鐮佷笉鑳戒负绌�',
+ trigger: 'blur'
+ }, {
+ // 鑷畾涔夐獙璇佸嚱鏁帮紝瑙佷笂璇存槑
+ validator: (rule, value, callback) => {
+ // 涓婇潰鏈夎锛岃繑鍥瀟rue琛ㄧず鏍¢獙閫氳繃锛岃繑鍥瀎alse琛ㄧず涓嶉�氳繃
+ // uni.$u.test.mobile()灏辨槸杩斿洖true鎴栬�協alse鐨�
+ return uni.$u.test.code(value, 6);
+ },
+ message: '楠岃瘉鐮佹牸寮忎笉姝g‘',
+ trigger: 'blur'
+ }]
+ this.$refs.uForm.setRules(this.rules)
+ this.$nextTick(() => {
+ this.$refs.uForm.validate().then(() => {
+ this.loading = true
+ const params = uni.$u.deepClone(this.form);
+ if (this.cardType == 'DC') {
+ delete params.validdate
+ delete params.cvv2
+ }
+ bindCard(params).then(res => {
+ getMyCoupUseDetail().then(res => {
+ this.loading = false
+ if (res && res.length > 0) {
+ this.showAct = true
+ this.couponList = res
+ } else {
+ uni.showToast({
+ icon: 'success',
+ title: '缁戝崱鎴愬姛',
+ mask: true
+ })
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1000)
+ }
+ }).catch(() => {
+ this.loading = false
+ })
+ }).catch(() => {
+ this.loading = false
+ })
+ }).catch(errors => {
+
+ })
+ })
+ }
+ },
+
+ }
+</script>
+<style>
+ page {
+ background-color: #fff;
+ padding: 32rpx;
+ color: #333;
+ }
+</style>
+<style lang="scss" scoped>
+ .form-item {
+ border: 1px solid #D9D9D9;
+ border-radius: 10rpx;
+ padding: 4rpx 32rpx;
+ }
+
+ ::v-deep .u-form-item__body__right__message {
+ text-align: right;
+ }
+
+ .btn-box {
+ width: 686rpx;
+ position: fixed;
+ bottom: 30rpx;
+ }
+
+ .bind-btn {
+ width: 686rpx;
+ height: 98rpx;
+ border-radius: 10rpx;
+ background: #d31f28;
+ color: #fff;
+ font-size: 34rpx;
+ }
+
+ .code-btn {
+ background-color: #F2F2F2;
+ border-radius: 10rpx;
+ color: #999;
+ width: 290rpx;
+ height: 88rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin-left: 20rpx;
+ }
+
+ .code-act {
+ background-color: #D31F28;
+ color: #fff;
+ }
+
+ .type-btn {
+ width: 333rpx;
+ height: 88rpx;
+ border-radius: 10rpx;
+ border: 1px solid #d9d9d9;
+ background-color: #ffffff;
+ font-size: 30rpx;
+ color: #333;
+ text-align: center;
+ line-height: 88rpx;
+ }
+
+ .type-act {
+ font-weight: bold;
+ border-color: #D31F28;
+ color: #D31F28;
+ background-image: url('~@/static/check-type.png');
+ background-position: right bottom;
+ background-repeat: no-repeat;
+ background-size: 42rpx 38rpx;
+ }
+</style>
diff --git a/pages/pay/discountpay.vue b/pages/pay/discountpay.vue
new file mode 100644
index 0000000..a531920
--- /dev/null
+++ b/pages/pay/discountpay.vue
@@ -0,0 +1,616 @@
+<!-- 鎵爜鏀粯 -->
+<template>
+ <view class="page">
+ <u-alert type="warning" closable description="瀹夊叏鎻愰啋锛氳璋ㄦ厧鏍稿鍟嗗銆佽鍗曚俊鎭紝淇濇姢鑷繁璧勯噾瀹夊叏!"></u-alert>
+ <view class="pay-box">
+ <view class="u-font-26 color-666">搴斾粯閲戦</view>
+ <view class="u-m-t-14">
+ <text class="u-font-36 color-333 u-m-r-8">楼</text>
+ <text class="money">{{money.split(".")[0]}}</text>
+ <text class="u-font-40">.{{money.split(".")[1]}}</text>
+ </view>
+ </view>
+
+ <view v-if="discountInfo.shopDiscount!=1&&money*(1-discountInfo.shopDiscount)>=0.01" class="bg-fff u-m-h-32 u-m-t-20 u-p-h-32 u-br-10">
+ <view class="u-p-v-32 u-flex u-row-between u-border-bottom u-font-30 color-333">
+ <view>{{discountInfo.memberGradeName}}涓撳睘鎶樻墸</view>
+ <view>-{{ money*(1-discountInfo.shopDiscount).toFixed(2) }}</view>
+ </view>
+ </view>
+ <view v-if="canUseIntegral||canUseCoupon" class="u-p-h-32 bg-fff u-m-h-32 u-br-10">
+ <view class="u-font-28 u-m-t-32">閫夋嫨浼樻儬鏂瑰紡</view>
+ <view v-if="canUseIntegral" class="u-p-v-24 u-border-bottom u-flex u-m-t-10">
+ <image class="item-icon" style="align-self: flex-start;position: relative;top: -3rpx;" src="/static/integral.png" mode=""></image>
+ <view class="u-flex-1 u-m-h-16">
+ <view class="u-font-30">绉垎鎶垫墸</view>
+ <view class="u-font-24 color-999 u-m-t-20">鍙敤<text style="color: #D31F28;">{{integral}}</text>绉垎
+ </view>
+ </view>
+ <input-number @handleCount="changeInt" :value="canUseInt" :min="0" :max="maxIntegral">
+ </input-number>
+ </view>
+ <view v-if="canUseCoupon" class="u-flex u-p-v-32">
+ <image class="item-icon" src="/static/coupon-icon.png" mode=""></image>
+ <view class="u-font-30 u-flex-1 u-m-h-16">浼樻儬鍒�</view>
+ <view @click="showCoupon" class="u-flex">
+ <view v-if="couponInfo.id" class="tag-pain">
+ 婊{parseFloat((couponInfo.thresholdValue/100).toFixed(2))}}鍏冨噺{{parseFloat((couponInfo.discount/100).toFixed(2))}}鍏�
+ </view>
+ <text v-else class="u-font-26">璇烽�夋嫨</text>
+ <u-icon class="u-m-l-10" name="arrow-right" color="#333" size="13"></u-icon>
+ </view>
+ </view>
+ </view>
+ <view class="bg-fff u-m-h-32 u-m-t-20 u-p-h-32 u-br-10">
+ <view v-if="discount" class="u-p-v-32 u-flex u-row-between u-border-bottom u-font-30 color-333">
+ <view>瀹為檯鎶垫墸</view>
+ <view>-{{ discount }}</view>
+ </view>
+ <view class="u-p-v-32 u-flex u-row-between">
+ <view class="u-font-30 color-333">瀹炰粯閲戦</view>
+ <view class="color-red">
+ <text class="u-font-26 u-m-r-6">楼</text>
+ <text class="u-font-34">{{ price }}</text>
+ </view>
+ </view>
+ </view>
+
+ <button class="pay-it" @click="pay">纭畾鏀粯</button>
+ <!-- 浼樻儬鍒稿脊绐� -->
+ <u-popup mode="bottom" :closeable="true" :show="couponShow" @close="couponShow = false" :round="10">
+ <view class="u-font-32 color-333 u-text-center u-p-t-30">浼樻儬鍒�</view>
+ <view v-if="checkCoupon.id" class="choose-coupon">
+ 宸查�夋嫨浼樻儬鍒�1寮狅紝鍏辨姷鎵o骏{{parseFloat((checkCoupon.discount/100).toFixed(2))}}</view>
+ <!-- <view class="choose-coupon">閫夋嫨浼樻儬鍒�</view> -->
+ <scroll-view scroll-y class="u-p-30 coupon-list">
+ <view @click="clickCoupon(item)" class="u-m-b-24 u-flex coupon" v-for="(item, index) in couponList" :key="index">
+ <view style="color: #D31F28;" class="u-p-h-28">
+ <view class="font-bold">
+ <text class="u-font-36">锟�</text>
+ <text class="money">{{parseFloat(item.discount/100)}}</text>
+ </view>
+ <view class="u-font-24 u-m-t-20">婊{parseFloat(item.thresholdValue/100)}}鍏冧娇鐢�</view>
+ </view>
+ <view class="butt"></view>
+ <view class="u-p-30 u-flex-1 u-flex">
+ <view class="u-flex-1">
+ <view class="u-font-28 color-333 u-line-2">{{item.name}}</view>
+ <view class="u-font-22 color-999 u-m-t-20">
+ 鏈夋晥鏈熻嚦锛歿{$u.timeFormat(item.outTime, 'yyyy-mm-dd hh:MM')}}
+ </view>
+ </view>
+ <u-icon v-if="item.id==checkCoupon.id" name="checkmark-circle-fill" color="#D31F28" size="20">
+ </u-icon>
+ </view>
+
+ </view>
+ </scroll-view>
+ <view @click="getCoupon" class="coupon-btn">纭畾</view>
+ </u-popup>
+ <!-- 鏁板瓧閿洏 -->
+ <u-popup :show="bordShow" :overlay="false" @close="bordShow = false">
+ <key-bord @changeMoney="changeMoney" :num.sync="money" @close="bordShow = false" @pay="pay"></key-bord>
+ </u-popup>
+ <!-- 鏀粯楠岃瘉鐮� -->
+ <u-popup :show="codeShow" closeable mode="center" @close="codeShow = false">
+ <view class="u-p-h-40 u-p-b-40">
+ <view class="u-text-center u-p-t-20 u-m-b-30 u-font-34">璇疯緭鍏ユ墜鏈洪獙璇佺爜</view>
+ <view class="u-text-center u-m-b-20 color-666">{{ shopInfo.shop_name }}</view>
+ <view class="u-flex u-row-center font-bold u-m-b-40"><text class="u-font-42">锟�</text><text class="u-font-money">{{ price }}</text>
+ </view>
+ <u-code-input @finish="bankPay" v-model="smscode" mode="box" :focus="true"></u-code-input>
+ </view>
+
+ </u-popup>
+ </view>
+</template>
+
+<script>
+ import {
+ ACCESSTOKEN
+ } from '@/common/config.js';
+ import {
+ queryMyUseSweepPayMaxCoupon,
+ queryUseSweepPayCoupon,
+ getWechatConfigInfo,
+ saveWxOrder,
+ tlPay
+ } from '@/common/api/index'
+ import wx from 'weixin-js-sdk'; // 浣跨敤js-sdk
+ export default {
+ data() {
+ return {
+ cid: null,
+ bordShow: false, // 鏄剧ず閿洏
+ scoreWorth: 0,
+ shopInfo: {
+ shop_name: '',
+ scan_flag: '',
+ use_score_flag: 0, //鍟嗛摵鏄惁鍙敤绉垎 0鍚� 1鏄�
+ user_coupon_flag: 0, //鍟嗛摵鏄惁鍙敤浼樻儬鍒� 0鍚� 1鏄�
+ app_pay_use_score_flag: 0, //寰俊/鏀粯瀹濇槸鍚﹀彲鐢ㄧН鍒� 0鍚� 1鏄�
+ app_pay_use_coupon_flag: 0, //寰俊/鏀粯瀹濇槸鍚﹀彲鐢ㄤ紭鎯犲埜 0鍚� 1鏄�
+ bank_pay_use_score_flag: 0, //閾惰鍗℃敮浠樻槸鍚﹀彲鐢ㄧН鍒� 0鍚� 1鏄�
+ bank_pay_use_coupon_flag: 0, //閾惰鍗℃敮浠樻槸鍚﹀彲鐢ㄤ紭鎯犲埜 0鍚� 1鏄�
+ },
+ money: 0.00, // 閲戦
+ integral: 0, // 浣跨敤绉垎
+ canUseInt: 0, // 鍙敤绉垎
+ couponList: [], // 浼樻儬鍒�
+ couponShow: false, // 浼樻儬鍒稿脊绐�
+ couponInfo: {
+ id: '',
+ discount: 0,
+ thresholdValue: 0
+ }, // 浼樻儬鍒稿唴瀹�
+ payWay: 3, // 5鏀粯瀹� 2寰俊 3閾惰鍗�
+ isNew: false,
+ codeShow: false,
+ smscode: '',
+ thpinfo: null,
+ canReset: false,
+ checkCoupon: {
+ id: null,
+ discount: 0,
+ thresholdValue: 0
+ },
+ discountInfo: {
+ memberGradeName: '',
+ shopDiscount: 10
+ }
+ };
+ },
+ watch: {
+ integralDiscount(val) {
+ if (this.couponInfo.id && val < this.couponInfo.thresholdValue) {
+ this.couponInfo = {
+ id: '',
+ discount: 0,
+ thresholdValue: 0
+ }
+ this.checkCoupon = {
+ id: '',
+ discount: 0,
+ thresholdValue: 0
+ }
+ }
+ }
+ },
+ computed: {
+ canUseIntegral() {
+ if (this.payWay == 3) { //閾惰鍗�
+ return this.shopInfo.use_score_flag && this.shopInfo.bank_pay_use_score_flag
+ } else {
+ return this.shopInfo.use_score_flag && this.shopInfo.app_pay_use_score_flag
+ }
+
+ },
+ canUseCoupon() {
+ if (this.payWay == 3) { //閾惰鍗�
+ return this.shopInfo.user_coupon_flag && this.shopInfo.bank_pay_use_coupon_flag
+ } else {
+ return this.shopInfo.user_coupon_flag && this.shopInfo.app_pay_use_coupon_flag
+ }
+ },
+ maxIntegral() {
+ if (this.couponInfo.id) {
+ const num = Math.ceil((this.money * this.discountInfo.shopDiscount - this.couponInfo.thresholdValue / 100) / (
+ this.scoreWorth / 100))
+ if (num < 0) {
+ return 0
+ }
+ return num
+ } else {
+ const num = Math.ceil((this.money * this.discountInfo.shopDiscount - this.couponInfo.thresholdValue / 100) / (
+ this.scoreWorth / 100))
+ if (num < 0) {
+ return 0
+ }
+ return num
+ }
+ },
+ integralDiscount() {
+ let num = 0;
+ num = parseInt(parseFloat((this.money * this.discountInfo.shopDiscount * 100).toPrecision(12)) - this.canUseInt *
+ this.scoreWorth);
+ return num;
+ },
+ discount() {
+ let num = 0;
+ num = ((this.canUseInt * this.scoreWorth + parseFloat(this.couponInfo.discount)) / 100).toFixed(2);
+ if (parseFloat(num) > parseFloat(this.money * this.discountInfo.shopDiscount)) {
+ return this.money * this.discountInfo.shopDiscount
+ }
+ return num;
+ },
+ price() {
+ let num = 0;
+ num = parseFloat((this.money * this.discountInfo.shopDiscount * 100).toPrecision(12)) - this.canUseInt * this
+ .scoreWorth - this.couponInfo
+ .discount;
+ num = num > 0 ? (num / 100).toFixed(2) : '0.00';
+ return num;
+ }
+ },
+ onLoad(opt) {
+ this.isNew = uni.getStorageSync('IS_NEW')
+ this.cid = uni.getStorageSync('CID')
+ this.discountInfo = uni.getStorageSync('DISCOUNT_INFO') || {
+ shopDiscount: 1
+ }
+ const token = uni.getStorageSync(ACCESSTOKEN) || null
+ this.shopInfo = uni.getStorageSync('SHOP_INFO')
+ if (opt.scoreWorth) {
+ this.scoreWorth = Number(opt.scoreWorth)
+ }
+ if (opt.integral) {
+ this.integral = Number(opt.integral)
+ }
+ if (opt.money) {
+ this.money = parseFloat(opt.money).toFixed(2)
+ let ds = parseFloat(this.discountInfo.shopDiscount)
+ let dis = this.money * 100 * (1 - ds)
+ let money = parseInt((this.money * 100 * ds))
+ if (dis < 1) {
+ money = parseInt((this.money * 100))
+ }
+ queryMyUseSweepPayMaxCoupon({
+ params: {
+ shopId: this.shopInfo.id,
+ money: money < 1 ? 1 : money
+ }
+ }).then(res => {
+ if (res && this.canUseCoupon) {
+ this.couponInfo = res
+ this.checkCoupon = res
+ }
+
+ })
+ }
+ if (opt.payWay) {
+ this.payWay = opt.payWay
+ }
+ if (opt.bankCardId) {
+ this.bankCardId = opt.bankCardId
+ }
+ this.init()
+ },
+ methods: {
+ // 鏇存柊閲戦
+ changeMoney(str) {
+ this.money = str;
+ },
+ // 灞曠ず閿洏
+ showBord() {
+ this.bordShow = true;
+ },
+ init() {
+ uni.showLoading()
+ if (this.payWay == 2) {
+ const uri = encodeURIComponent(window.location)
+ getWechatConfigInfo({
+ url: uri
+ }).then(res => {
+ uni.hideLoading()
+ wx.config({
+ debug: false, // 寮�鍚皟璇曟ā寮�
+ appId: res.appId, // 蹇呭~锛屽叕浼楀彿鐨勫敮涓�鏍囪瘑
+ timestamp: res.timestamp, // 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴�
+ nonceStr: res.nonceStr, // 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓�
+ signature: res.signature, // 蹇呭~锛岀鍚�
+ jsApiList: ['chooseWXPay'], // 蹇呭~锛岄渶瑕佷娇鐢ㄧ殑 JS 鎺ュ彛鍒楄〃
+ // openTagList: ['wx-open-launch-weapp'] //鍙�夛紝闇�瑕佷娇鐢ㄧ殑寮�鏀炬爣绛惧垪琛�
+ });
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+ },
+ // 鏇存敼绉垎
+ changeInt(num) {
+ this.canUseInt = num;
+ },
+ pay() {
+ this.bordShow = false
+ uni.showLoading()
+ const params = {
+ money: parseFloat((this.money * 100).toPrecision(12)),
+ shopId: this.shopInfo.id,
+ cid: this.cid,
+ payWay: this.payWay,
+ score: this.canUseInt,
+ couponDetailId: this.couponInfo.id
+ }
+ if (this.payWay == 3) {
+ params.bankCardId = this.bankCardId
+ }
+ saveWxOrder(params).then(res => {
+ uni.hideLoading()
+ try {
+ this.orderId = res.orderId
+ res.youHuiInfo.shopName = this.shopInfo.shop_name
+ this.youHuiInfo = res.youHuiInfo
+ if (res.isOk == 1) {
+ uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })
+ } else {
+ if (res.toPayMethod == 1) {
+ if (this.payWay == 3) {
+ this.smscode = ''
+ this.codeShow = true
+ }
+ } else if (res.toPayMethod == 2) {
+ if (this.payWay == 2) {
+ this.wxPay(res.paymentData)
+ }
+ if (this.payWay == 5) {
+ this.aliPay(res.paymentData)
+ }
+ } else if (res.toPayMethod == 3) {
+ window.location.href = res.paymentUrl
+ }
+ }
+ } catch (e) {
+ //TODO handle the exception
+ console.error(e);
+ }
+
+
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ },
+ // 寰俊鏀粯
+ wxPay(res) {
+ /*setTimeout(() => {
+ wx.chooseWXPay({
+ timestamp: res.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴�
+ nonceStr: res.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣�
+ package: res.package, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_id鍙傛暟鍊硷紝鎻愪氦鏍煎紡濡傦細prepay_id=\*\*\*锛�
+ signType: res.signType, // 寰俊鏀粯V3鐨勪紶鍏� RSA ,寰俊鏀粯V2鐨勪紶鍏ユ牸寮忎笌V2缁熶竴涓嬪崟鐨勭鍚嶆牸寮忎繚鎸佷竴鑷�
+ paySign: res.paySign, // 鏀粯绛惧悕
+ success: function(res) {
+ // 鏀粯鎴愬姛鍚庣殑鍥炶皟鍑芥暟
+ uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })
+ }
+ });
+ }, 200)*/
+ setTimeout(() => {
+ WeixinJSBridge.invoke(
+ 'getBrandWCPayRequest', {
+ "appId": res.appId, //鍏紬鍙稩D锛岀敱鍟嗘埛浼犲叆
+ "timeStamp": res.timeStamp, //鏃堕棿鎴筹紝鑷�1970骞翠互鏉ョ殑绉掓暟
+ "nonceStr": res.nonceStr, //闅忔満涓�
+ "package": res.package,
+ "signType": res.signType, //寰俊绛惧悕鏂瑰紡锛�
+ "paySign": res.paySign //寰俊绛惧悕
+ },
+ (res) => {
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
+ // 浣跨敤浠ヤ笂鏂瑰紡鍒ゆ柇鍓嶇杩斿洖,寰俊鍥㈤槦閮戦噸鎻愮ず锛�
+ //res.err_msg灏嗗湪鐢ㄦ埛鏀粯鎴愬姛鍚庤繑鍥瀘k锛屼絾骞朵笉淇濊瘉瀹冪粷瀵瑰彲闈犮��
+ /*uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })*/
+ }
+ });
+ }, 200)
+ },
+ //鏀粯瀹濇敮浠�
+ aliPay(res) {
+ ap.tradePay({
+ tradeNO: res.tradeNO
+ }, (res) => {
+ if (res.resultCode == 9000) {
+ /*uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })*/
+ // 鏀粯鎴愬姛
+ } else if (res.resultCode == 8000 || res.resultCode == 6001) {
+ // 姝e湪澶勭悊涓� || 鍙栨秷
+ } else {
+ // 鏀粯澶辫触
+ }
+ });
+ },
+ //閾惰鍗℃敮浠�
+ bankPay(e) {
+ uni.showLoading()
+ tlPay({
+ orderId: this.orderId,
+ payWay: 3,
+ bankCardId: this.bankCardId,
+ smscode: e
+ }).then(res => {
+ uni.hideLoading()
+ uni.hideKeyboard()
+ this.codeShow = false
+ uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ },
+ //鏄剧ず浼樻儬鍒�
+ showCoupon() {
+ uni.showLoading()
+ queryUseSweepPayCoupon({
+ params: {
+ cusid: this.shopInfo.cusid,
+ c: this.shopInfo.c,
+ money: parseFloat((this.money * 100).toPrecision(12)),
+ score: this.canUseInt
+ }
+ }).then(res => {
+ uni.hideLoading()
+ if (res.length > 0) {
+ this.couponList = res
+ this.checkCoupon = this.couponInfo
+ this.couponShow = true;
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: '鏆傛棤鍙敤浼樻儬鍒�'
+ })
+ }
+
+ }).catch(() => {
+ uni.hideLoading()
+ })
+
+ },
+ clickCoupon(item) {
+ if (this.checkCoupon.id == item.id) {
+ this.checkCoupon = {
+ id: '',
+ discount: 0,
+ thresholdValue: 0
+ }
+ } else {
+ this.checkCoupon = item
+ }
+ },
+ getCoupon() {
+ // item 涓轰紭鎯犲埜淇℃伅
+ this.couponInfo = this.checkCoupon;
+ this.couponShow = false;
+ }
+ }
+ };
+</script>
+
+<style scoped lang="scss">
+ .page {
+ height: calc(100vh - 0px);
+ display: flex;
+ flex-direction: column;
+ line-height: 1;
+ }
+
+ .avg-img {
+ width: 80rpx;
+ height: 80rpx;
+ }
+
+ .pay-box {
+ text-align: center;
+ padding: 65rpx 0 42rpx;
+ }
+
+ .money {
+ font-size: 64rpx;
+ }
+
+ .tag-pain {
+ border: 1px solid #D31F28;
+ font-size: 22rpx;
+ color: #D31F28;
+ border-radius: 4rpx;
+ line-height: 1;
+ padding: 8rpx 4rpx;
+ }
+
+ .item-icon {
+ width: 38rpx;
+ height: 38rpx;
+ }
+
+ .pay-it {
+ position: absolute;
+ width: 686rpx;
+ height: 98rpx;
+ bottom: 0;
+ border-radius: 10rpx;
+ font-size: 34rpx;
+ color: #ffffff;
+ background-color: #de2d35;
+ margin: 32rpx;
+ }
+
+ .choose-coupon {
+ margin: 32rpx 32rpx 0;
+ border-radius: 10rpx;
+ background: #fff1f1;
+ padding: 26rpx 16rpx;
+ color: #D31F28;
+ font-size: 28rpx;
+ }
+
+ .coupon-list {
+ box-sizing: border-box;
+ height: calc(50vh - 44px);
+ }
+
+ .coupon {
+ background-color: rgba(255, 241, 241, 0.47);
+ height: 171rpx;
+ border: solid 1rpx #f85d64;
+ border-radius: 10rpx;
+ position: relative;
+ overflow: hidden;
+ }
+
+ .butt {
+ width: 1rpx;
+ height: 100%;
+ position: relative;
+ z-index: 9;
+ border-left: 1rpx dashed #f85d64;
+ }
+
+ .butt:before {
+ z-index: 10;
+ box-sizing: border-box;
+ position: absolute;
+ content: "";
+ width: 24rpx;
+ height: 12rpx;
+ border-bottom: 1rpx solid #f85d64;
+ border-right: 1rpx solid #f85d64;
+ border-left: 1rpx solid #f85d64;
+ border-radius: 0 0 24rpx 24rpx;
+ left: -12rpx;
+ background-color: #ffffff;
+ }
+
+ .butt:after {
+ box-sizing: border-box;
+ position: absolute;
+ content: "";
+ width: 24rpx;
+ height: 12rpx;
+ bottom: 0;
+ border-bottom: 1rpx solid #ffff;
+ border-right: 1rpx solid #f85d64;
+ border-left: 1rpx solid #f85d64;
+ border-top: 1rpx solid #f85d64;
+ border-radius: 24rpx 24rpx 0 0;
+ left: -12rpx;
+ background-color: #ffffff;
+ }
+
+
+ .coupon-btn {
+ margin: 0 32rpx;
+ height: 98rpx;
+ border-radius: 10rpx;
+ background-color: #D31F28;
+ font-size: 34rpx;
+ color: #fff;
+ line-height: 98rpx;
+ text-align: center;
+ }
+
+ .u-font-money {
+ font-size: 60rpx;
+ }
+</style>
diff --git a/pages/pay/login.vue b/pages/pay/login.vue
new file mode 100644
index 0000000..b2c943d
--- /dev/null
+++ b/pages/pay/login.vue
@@ -0,0 +1,42 @@
+<template>
+ <view>
+
+ </view>
+</template>
+
+<script>
+ import {
+ config,
+ ACCESSTOKEN
+ } from '@/common/config.js';
+ export default {
+ data() {
+ return {
+ platform: this.$utils.getPlat()
+ };
+ },
+ onLoad(opt) {
+ uni.clearStorage()
+ const redirect_uri = encodeURIComponent(`${config.webURL}/pages/pay/scanpay?cid=${opt.cid}`)
+ if (this.platform == 2) {
+ window.location.href =
+ `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.wx_appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
+ } else if (this.platform == 5) {
+ window.location.href =
+ `https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${config.ali_appid}&scope=auth_base&redirect_uri=${redirect_uri}&state=STATE`
+ } else if (this.platform == 15) {
+ window.location.href =
+ `https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=${redirect_uri}`
+ } else {
+ uni.reLaunch({
+ url: `/pages/pay/scanpay?cid=${opt.cid}`
+ })
+ }
+
+ }
+ }
+</script>
+
+<style lang="scss">
+
+</style>
\ No newline at end of file
diff --git a/pay/paySuccess.vue b/pages/pay/paySuccess.vue
similarity index 81%
rename from pay/paySuccess.vue
rename to pages/pay/paySuccess.vue
index 3afcd17..51aa576 100644
--- a/pay/paySuccess.vue
+++ b/pages/pay/paySuccess.vue
@@ -7,10 +7,10 @@
<view class="u-font-32 font-bold u-m-t-10" style="color: #14AF0D;">鏀粯鎴愬姛</view>
</view>
<view class="shop-info">
- <view class="u-text-center u-font-32 color-666">{{youHuiInfo.shopName}}</view>
- <view class="u-text-center u-m-t-20">
- <text class="u-font-30 lh-1">锟�</text>
- <text class="u-font-money lh-1">{{$u.priceFormat(youHuiInfo.payMoney/100, 2)}}</text>
+ <view class="u-text-center u-font-32 color-666">{{youHuiInfo.shopName}}娴嬭瘯闂ㄥ簵</view>
+ <view class="u-flex u-col-top u-row-center">
+ <view class="u-font-24 lh-1">锟�</view>
+ <view class="u-font-money lh-1">{{$u.priceFormat(youHuiInfo.payMoney/100, 2)}}</view>
</view>
</view>
<view class="u-flex u-m-t-30 u-font-30">
@@ -19,15 +19,15 @@
</view>
<view class="u-flex-1 u-text-right">锟{$u.priceFormat(youHuiInfo.money/100, 2)}}</view>
</view>
-<!-- <view class="u-flex u-m-t-16 u-font-30">
+ <view class="u-flex u-m-t-16 u-font-30">
<view class="color-999 u-flex">
<view class="label" style="color: #F69249;">浣跨敤绉垎</view>
</view>
<view class="u-flex-1 u-text-right" style="color: #F69249;">{{youHuiInfo.score}}绉垎<text
v-if="youHuiInfo.score>0">鎶垫墸{{$u.priceFormat(youHuiInfo.scoreDkPrice/100, 2)}}鍏�</text>
</view>
- </view>-->
- <view v-if="youHuiInfo.couponDkPrice!=0" class="u-flex u-m-t-16 u-font-30">
+ </view>
+ <view class="u-flex u-m-t-16 u-font-30">
<view class="color-999 u-flex">
<view class="label">浼樻儬鍒�</view>
</view>
@@ -62,6 +62,20 @@
</view>
</view>
+ <view v-else-if="!join" class="box bg-fff u-m-t-20">
+ <navigator class="u-flex" url="/pages/pay/shuaKa/shuaKa">
+ <image class="card-logo" :src="bankCardStyle.logo"></image>
+ <view class="u-flex-1">
+ <view class="u-font-30">棰嗗埛{{info.bankCardName}}{{info.totalDiscount/100}}鍏冪珛鍑忛噾</view>
+ <view class="u-font-24 color-999">鍙備笌鍒峰崱鏈夌ぜ锛岄鏇村浼樻儬</view>
+ </view>
+ <view>
+ <u-button type="success" size="mini" text="棰嗗彇"></u-button>
+ </view>
+
+ </navigator>
+ </view>
+
<view :url="jumpUrl" class="btn-box">
<u-button @click="clickDone" text="瀹屾垚" type="success" plain shape="circle"></u-button>
</view>
@@ -80,15 +94,15 @@
</view>
<view class="u-flex-1">锟{$u.priceFormat(orderInfo.orderPrice/100, 2)}}</view>
</view>
-<!-- <view class="u-flex u-m-t-30 u-font-30">
+ <view class="u-flex u-m-t-30 u-font-30">
<view class="color-999 u-flex">
<view class="label">浣跨敤绉垎</view>锛�
</view>
<view class="u-flex-1">{{orderInfo.payIntegral}}绉垎<text
v-if="orderInfo.payIntegral>0">鎶垫墸{{$u.priceFormat(orderInfo.integralMoney/100, 2)}}鍏�</text>
</view>
- </view>-->
- <view class="u-flex u-m-t-30 u-font-30">
+ </view>
+ <view class="u-flex u-m-t-30 u-font-30">
<view class="color-999 u-flex">
<view class="label">浼樻儬鍒�</view>锛�
</view>
@@ -102,7 +116,7 @@
</view>
</view>
<view class="btn-box">
- <u-button @click="clickDone" text="瀹屾垚" type="success" plain shape="circle"></u-button>
+ <u-button @click="doJump" text="瀹屾垚" type="success" plain shape="circle"></u-button>
</view>
</block>
@@ -111,12 +125,17 @@
<script>
import {
+ getPayCompleteUrl,
getWxOrderInfo,
- } from 'common/api/index'
+ } from '@/common/api/index'
+ import {
+ activityInfo,
+ myBrushDetail,
+ orderRefBrushNode
+ } from '@/common/api/shuaka'
export default {
data() {
return {
- plat: this.$utils.getPlat(),
info: {
bankCardName: '',
totalDiscount: 0,
@@ -147,20 +166,33 @@
};
},
onLoad(opt) {
+ activityInfo().then(res => {
+ this.info = res
+ })
+ myBrushDetail().then(res => {
+ if (res) {
+ this.join = true
+ } else {
+ this.join = false
+ }
+ })
if (uni.getStorageSync("bankCardStyle")) {
this.bankCardStyle = uni.getStorageSync("bankCardStyle")
}
+ getPayCompleteUrl().then(res => {
+ this.jumpUrl = res
+ })
if (opt.youHuiInfo) {
this.youHuiInfo = JSON.parse(opt.youHuiInfo)
}
if (opt.orderId) {
this.orderId = opt.orderId
- /*orderRefBrushNode({
+ orderRefBrushNode({
orderId: this.orderId
}).then(res => {
this.couponList = res.coupIdsMap || []
- })*/
+ })
}
},
onReady() {
@@ -212,32 +244,9 @@
return null;
},
clickDone() {
- let browser = navigator.userAgent.toLowerCase();
- if (browser.match(/Alipay/i) == "alipay") {
- console.log("鏀粯瀹漚pp鐨勬祻瑙堝櫒");
- //杩欎釜鍙互鍏抽棴瀹夊崜绯荤粺鐨勬墜鏈�
- document.addEventListener("AlipayJSBridgeReady", function () {
- AlipayJSBridge.call("closeWindow");
- },
- false
- );
- //杩欎釜鍙互鍏抽棴ios绯荤粺鐨勬墜鏈�
- AlipayJSBridge.call('closeWebview'); //鏀粯瀹�
- } else if (browser.match(/MicroMessenger/i) == "micromessenger") {
- //杩欎釜鍙互鍏抽棴瀹夊崜绯荤粺鐨勬墜鏈�
- document.addEventListener("WeixinJSBridgeReady", function () {
- WeixinJSBridge.call("closeWindow");
- },
- false
- );
- //杩欎釜鍙互鍏抽棴ios绯荤粺鐨勬墜鏈�
- WeixinJSBridge.call("closeWindow");
- } else {
- console.log("鍏跺畠娴忚鍣�");
- window.opener = null; //濡傛灉娌℃湁杩欒鍜屼笅闈㈢殑涓�琛屽垯浼氬嚭鐜颁笂闈㈢殑绗簩涓闂銆�
- window.open(' ', '_self', ' ');
- window.close()
- }
+ // window.close()
+ WeixinJSBridge.call('closeWindow');
+
},
doJump() {
var mchData = {
@@ -295,7 +304,7 @@
.coupon {
width: 638rpx;
height: 172rpx;
- background-image: url('~@/static/pay-by-card-coupon.png');
+ background-image: url('~@/static/shuaka/pay-by-card-coupon.png');
background-size: cover;
margin: 10rpx auto 20rpx;
display: flex;
@@ -366,4 +375,4 @@
.lh-1 {
line-height: 1;
}
-</style>
+</style>
\ No newline at end of file
diff --git a/pages/pay/register.vue b/pages/pay/register.vue
new file mode 100644
index 0000000..c44068a
--- /dev/null
+++ b/pages/pay/register.vue
@@ -0,0 +1,218 @@
+<template>
+ <view class="u-p-h-50">
+ <view class="title">鎮ㄥソ锛屾杩庢敞鍐岋紒</view>
+ <u-form labelPosition="top" :model="form" :rules="rules" labelWidth="200"
+ :labelStyle="{fontSize:'34rpx',fontWeight:'bold'}" ref="uForm">
+ <u-form-item label="濮撳悕" prop="memberName" borderBottom>
+ <u-input v-model="form.memberName" border="none" placeholder="璇疯緭鍏ュ鍚�"></u-input>
+ </u-form-item>
+ <u-form-item label="韬唤璇佸彿" prop="idcard" borderBottom>
+ <u-input v-model="form.idcard" border="none" placeholder="璇疯緭鍏ヨ韩浠借瘉鍙�"></u-input>
+ </u-form-item>
+ <u-form-item label="鎵嬫満鍙�" prop="mobile" borderBottom>
+ <u-input v-model="form.mobile" border="none" placeholder="璇疯緭鍏ユ墜鏈哄彿"></u-input>
+ </u-form-item>
+ <u-form-item label="鍥惧舰楠岃瘉鐮�" prop="captchaCode" borderBottom>
+ <u-input v-model="form.captchaCode" border="none" placeholder="璇疯緭鍏ュ浘褰㈤獙璇佺爜"></u-input>
+ <image @click="getImgCode" class="img-code" slot="right" :src="imgCode.bg" mode=""></image>
+ </u-form-item>
+ <u-form-item label="鐭俊楠岃瘉鐮�" prop="verificationCode" borderBottom>
+ <u-input v-model="form.verificationCode" maxlength="6" border="none" placeholder="璇疯緭鍏ョ煭淇¢獙璇佺爜"></u-input>
+ <u-button slot="right" @tap="getCode" color="#de2d35" plain>{{tips}}</u-button>
+ </u-form-item>
+ </u-form>
+ <view class="u-text-center u-m-t-40 color-999 u-font-24">
+ <label @click="checked = !checked" class="radio">
+ <radio style="transform: scale(0.7);" color="#de2d35" :checked="checked" /><text>鎴戝凡闃呰骞跺悓鎰�</text>
+ <text style="color: #de2d35;" @click.stop="show = true">銆婇噾铻嶇敓鎬佸湀骞冲彴浼氬憳娉ㄥ唽鍗忚銆�</text>
+ </label>
+
+ </view>
+ <u-modal confirmText="闃呰骞跺悓鎰�" confirmColor="#de2d35" @confirm="show = false;checked = true" :show="show" title="閲戣瀺鐢熸�佸湀骞冲彴浼氬憳娉ㄥ唽鍗忚">
+ <scroll-view scroll-y style="height: 60vh;">
+ <user-agreement></user-agreement>
+ </scroll-view>
+ </u-modal>
+ <u-code :seconds="seconds" ref="uCode" @change="codeChange"></u-code>
+ <view class="btn-box">
+ <u-button @click="submit" text="娉ㄥ唽" type="error" color="#de2d35" shape="circle"></u-button>
+ </view>
+ </view>
+</template>
+
+<script>
+ import {
+ getVerify,
+ getH5PayCheckVerifyCode,
+ h5PayLogin
+ } from '@/common/api/index'
+ export default {
+ data() {
+ return {
+ show: false,
+ checked: true,
+ cid: '',
+ imgCode: {},
+ tips: '',
+ // refCode: null,
+ seconds: 60,
+ form: {
+ memberName: '',
+ idcard: '',
+ mobile: '',
+ captchaCode: '',
+ verificationCode: '',
+ },
+ rules: {
+ memberName: [{
+ type: 'string',
+ required: true,
+ message: '濮撳悕涓嶈兘涓虹┖',
+ trigger: ['blur']
+ }],
+ idcard: [{
+ type: 'string',
+ required: true,
+ message: '韬唤璇佸彿涓嶈兘涓虹┖',
+ trigger: ['blur']
+ }, {
+ validator: (rule, value, callback) => {
+ return uni.$u.test.idCard(value);
+ },
+ message: '韬唤璇佸彿涓嶆纭�',
+ // 瑙﹀彂鍣ㄥ彲浠ュ悓鏃剁敤blur鍜宑hange
+ trigger: ['blur'],
+ }],
+ mobile: [{
+ type: 'string',
+ required: true,
+ message: '鎵嬫満鍙蜂笉鑳戒负绌�',
+ trigger: ['blur']
+ },
+ {
+ validator: (rule, value, callback) => {
+ return uni.$u.test.mobile(value);
+ },
+ message: '鎵嬫満鍙风爜涓嶆纭�',
+ // 瑙﹀彂鍣ㄥ彲浠ュ悓鏃剁敤blur鍜宑hange
+ trigger: ['change'],
+ }
+ ],
+ captchaCode: [{
+ type: 'string',
+ required: true,
+ message: '鍥惧舰楠岃瘉鐮佷笉鑳戒负绌�',
+ trigger: ['blur', 'change']
+ }],
+ verificationCode: [{
+ type: 'string',
+ required: true,
+ message: '鐭俊楠岃瘉鐮佷笉鑳戒负绌�',
+ trigger: ['blur', 'change']
+ }],
+ },
+ };
+ },
+ onLoad(opt) {
+ this.cid = opt.cid
+ this.getImgCode()
+ },
+ methods: {
+ codeChange(text) {
+ this.tips = text;
+ },
+ getCode() {
+ if (!this.form.captchaCode) {
+ uni.showToast({
+ icon: 'none',
+ title: '璇疯緭鍏ュ浘褰㈤獙璇佺爜'
+ })
+ return
+ }
+ if (!this.form.mobile) {
+ uni.showToast({
+ icon: 'none',
+ title: '璇疯緭鍏ユ墜鏈哄彿'
+ })
+ return
+ }
+ if (this.$refs.uCode.canGetCode) {
+ // 妯℃嫙鍚戝悗绔姹傞獙璇佺爜
+ uni.showLoading({
+ title: '姝e湪鑾峰彇楠岃瘉鐮�'
+ })
+ getH5PayCheckVerifyCode({
+ mobile: this.form.mobile,
+ captchaCode: this.form.captchaCode,
+ verifyToken: this.imgCode.token
+ }).then(res => {
+ uni.hideLoading();
+ // 杩欓噷姝ゆ彁绀轰細琚玹his.start()鏂规硶涓殑鎻愮ず瑕嗙洊
+ uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+ // 閫氱煡楠岃瘉鐮佺粍浠跺唴閮ㄥ紑濮嬪�掕鏃�
+ this.$refs.uCode.start();
+ }).catch(() => {
+ // uni.hideLoading();
+ this.getImgCode()
+ })
+ } else {
+ uni.$u.toast('鍊掕鏃剁粨鏉熷悗鍐嶅彂閫�');
+ }
+ },
+ getImgCode() {
+ uni.showLoading()
+ getVerify().then(res => {
+ uni.hideLoading();
+ res.bg = 'data:image/jpeg;base64,' + res.bg
+ this.imgCode = res
+ }).catch(() => {
+ uni.hideLoading();
+ })
+ },
+ submit() {
+ if(!this.checked){
+ uni.showToast({
+ icon: 'none',
+ title: '璇峰厛闃呰骞跺悓鎰忕敤鎴峰崗璁�'
+ })
+ return
+ }
+ this.$refs.uForm.validate().then(res => {
+ uni.showLoading()
+ h5PayLogin(this.form).then(res => {
+ uni.hideLoading();
+ uni.setStorageSync('IS_NEW', false)
+ uni.redirectTo({
+ url: '/pages/pay/scanpay?cid=' + this.cid
+ })
+ }).catch(() => {
+ uni.hideLoading();
+ })
+ }).catch(errors => {
+ // uni.$u.toast('鏍¢獙澶辫触')
+ })
+ }
+ },
+ }
+</script>
+<style>
+ page {
+ background-color: #fff;
+ }
+</style>
+<style lang="scss">
+ .title {
+ font-size: 44rpx;
+ font-weight: bold;
+ padding: 50rpx 0;
+ }
+
+ .btn-box {
+ margin-top: 40rpx;
+ }
+
+ .img-code {
+ width: 140rpx;
+ height: 70rpx;
+ }
+</style>
diff --git a/pages/pay/scanRes.vue b/pages/pay/scanRes.vue
new file mode 100644
index 0000000..3e71035
--- /dev/null
+++ b/pages/pay/scanRes.vue
@@ -0,0 +1,116 @@
+<template>
+ <view>
+ <movable-area :style="'width: ' + windowWidth + 'px;height:' + windowHeight + 'px'">
+ <web-view :src="url">
+ </web-view>
+ <movable-view direction="all" x="553rpx" :y="windowHeight/2-hf" v-if="cid" @click="openPay" class="pay-btn">
+ <image class="pay-img" src="/static/pay-btn.jpeg" mode=""></image>
+ </movable-view>
+ </movable-area>
+
+ </view>
+</template>
+
+<script>
+ import {
+ ACCESSTOKEN,
+ config
+ } from '@/common/config.js';
+ import {
+ getWechatInfo,
+ getOpenId,
+ getOpenIdBase
+ } from '@/common/api/index'
+ export default {
+ data() {
+ return {
+ hf: uni.upx2px(81),
+ cid: '',
+ windowHeight: 724,
+ windowWidth: 0,
+ url: ''
+ };
+ },
+ onLoad(opt) {
+ let sysInfo = uni.getSystemInfoSync();
+ this.windowHeight = sysInfo.windowHeight;
+ this.windowWidth = sysInfo.windowWidth;
+ if (opt.cid) {
+ uni.setStorageSync('CID', opt.cid)
+ if (opt.cid == '1285474127884455937') {
+ this.url =
+ "https://fxm.xintoucloud.com/scene-user-fillin?sceneCode=DE88783ECF1D4DC2BCBF25A1A683651AFA4A9523573FF4080F2086B00E00E78A1235219708A15E8B223AAC2D243884DE"
+ } else if (opt.cid == '1586530233928945664') {
+ this.url =
+ "https://fxm.xintoucloud.com/scene-user-fillin?sceneCode=622C5D9E30E54D07BCB3BF280DBEE266F4C88598A368881C81D0D8CECA02C3DB1235219708A15E8B223AAC2D243884DE"
+ }
+ this.cid = opt.cid
+ }
+ if (opt.code) {
+ uni.showLoading()
+ getOpenId({
+ params: {
+ code: opt.code
+ }
+ }).then(res => {
+ uni.setStorageSync(ACCESSTOKEN, res.token.accessToken)
+ uni.setStorageSync('IS_NEW', res.isNew)
+ let url = '/pages/pay/scanpay?cid=' + this.cid
+ if (res.isNew) {
+ url = '/pages/pay/wxpay?cid=' + this.cid
+ }
+ uni.hideLoading()
+ uni.redirectTo({
+ url: url
+ })
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+ },
+ methods: {
+ openPay() {
+ const TOKEN = uni.getStorageSync(ACCESSTOKEN) || null;
+ if (TOKEN) {
+ const IS_NEW = uni.getStorageSync('IS_NEW') || null;
+ let url = '/pages/pay/scanpay?cid=' + this.cid
+ if (IS_NEW) {
+ url = '/pages/pay/wxpay?cid=' + this.cid
+ }
+ uni.redirectTo({
+ url: url
+ })
+ } else {
+ uni.showLoading()
+ getWechatInfo().then(res => {
+ const redirect_uri = encodeURIComponent(
+ `${config.webURL}/pages/pay/scanRes?cid=${this.cid}`)
+ window.location.href =
+ `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
+ })
+ }
+ }
+
+ }
+ }
+</script>
+
+<style lang="scss">
+ .pay-btn {
+ position: fixed;
+ z-index: 99999;
+ width: 162rpx;
+ height: 162rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: #fff;
+ border-radius: 15rpx;
+ overflow: hidden;
+ }
+
+ .pay-img {
+ width: 162rpx;
+ height: 162rpx;
+ }
+</style>
diff --git a/pages/pay/scanpay.vue b/pages/pay/scanpay.vue
new file mode 100644
index 0000000..e0bf538
--- /dev/null
+++ b/pages/pay/scanpay.vue
@@ -0,0 +1,876 @@
+<!-- 鎵爜鏀粯 -->
+<template>
+ <view class="page">
+ <u-alert type="warning" closable description="瀹夊叏鎻愰啋锛氳璋ㄦ厧鏍稿鍟嗗銆佽鍗曚俊鎭紝淇濇姢鑷繁璧勯噾瀹夊叏!"></u-alert>
+ <view class="shop u-flex u-row-between">
+ <view class="u-m-r-30">
+ <view class="u-font-28 color-666 u-m-b-10">浠樻缁�</view>
+ <view class="u-font-44 font-bold color-333">{{ shopInfo.shop_name }}</view>
+ </view>
+ <image :src="shopInfo.logo_image||'/static/imgs/store-logo.png'" class="avg-img"></image>
+ </view>
+ <view class="u-p-48 bg-fff u-flex-1 content">
+ <view class="u-font-28 color-666">閲戦</view>
+ <view class="u-p-v-20 u-flex u-border-bottom u-relative">
+ <view class="money-icon color-333">楼</view>
+ <view class="u-flex-1 u-flex u-m-l-10" style="height: 80rpx;">
+ <view v-if="money" class="money-num">{{ money }}</view>
+ <view :class="['cursor',{'cursor-act':!money&&bordShow}]"></view>
+ <view v-if="!money" class="u-font-50 color-999">璇疯緭鍏ラ噾棰�</view>
+ <view :class="['cursor',{'cursor-act':money&&bordShow}]"></view>
+ </view>
+ <view class="mask" @click="showBord"></view>
+ </view>
+ <view class="u-font-28 color-666 u-m-t-60">閫夋嫨鏀粯鏂瑰紡</view>
+ <u-radio-group v-model="payWay" placement="column">
+ <view v-if="platform == 15" class="u-border-bottom u-p-v-20 u-flex u-row-between">
+ <image src="@/static/imgs/pay-union.png" class="pay-icon"></image>
+ <view class="flex-1">
+ <view class="u-font-30 color-333">浜戦棯浠�</view>
+ <text v-if="isNew" class="tag u-m-t-10">浼氬憳浜紭鎯�</text>
+ <text v-if="!isNew&&token&&shopInfo.use_score_flag&&shopInfo.app_pay_use_score_flag" class="u-font-24 color-999 u-m-t-10">
+ 鍙敤
+ <text class="color-red">{{ integral }}</text>
+ 绉垎
+ </text>
+ </view>
+ <view v-if="token&&couponInfo&&shopInfo.user_coupon_flag&&shopInfo.app_pay_use_coupon_flag" class="tag-pain">
+ 婊{
+ parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
+ }}鍏冨噺{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}鍏�
+ </view>
+ <u-radio @change="radioChange($event,15)" :name="15" activeColor="#D41F28" :customStyle="{ marginLeft: '10rpx' }"></u-radio>
+ </view>
+ <view v-if="platform == 5" class="u-border-bottom u-p-v-20 u-flex u-row-between">
+ <image src="@/static/imgs/pay-zfb.png" class="pay-icon"></image>
+ <view class="flex-1">
+ <view class="u-font-30 color-333">鏀粯瀹�</view>
+ <text v-if="isNew" class="tag u-m-t-10">浼氬憳浜紭鎯�</text>
+ <text v-if="!isNew&&token&&shopInfo.use_score_flag&&shopInfo.app_pay_use_score_flag" class="u-font-24 color-999 u-m-t-10">
+ 鍙敤
+ <text class="color-red">{{ integral }}</text>
+ 绉垎
+ </text>
+ </view>
+ <view v-if="token&&couponInfo&&shopInfo.user_coupon_flag&&shopInfo.app_pay_use_coupon_flag" class="tag-pain">
+ 婊{
+ parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
+ }}鍏冨噺{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}鍏�
+ </view>
+ <u-radio @change="radioChange($event,5)" :name="5" activeColor="#D41F28" :customStyle="{ marginLeft: '10rpx' }"></u-radio>
+ </view>
+ <view v-if="platform == 2" class="u-border-bottom u-p-v-20 u-flex u-row-between">
+ <image src="@/static/imgs/pay-wx.png" class="pay-icon"></image>
+ <view class="flex-1">
+ <view class="u-font-30 color-333">寰俊</view>
+ <text v-if="isNew" class="tag u-m-t-10">浼氬憳浜紭鎯�</text>
+ <text v-if="!isNew&&token&&shopInfo.use_score_flag&&shopInfo.app_pay_use_score_flag" class="u-font-24 color-999 u-m-t-10">
+ 鍙敤
+ <text class="color-red">{{ integral }}</text>
+ 绉垎
+ </text>
+ </view>
+ <view v-if="token&&couponInfo&&shopInfo.user_coupon_flag&&shopInfo.app_pay_use_coupon_flag" class="tag-pain">
+ 婊{
+ parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
+ }}鍏冨噺{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}鍏�
+ </view>
+ <u-radio @change="radioChange($event,2)" :name="2" activeColor="#D41F28" :customStyle="{ marginLeft: '10rpx' }">
+ </u-radio>
+ </view>
+ <navigator v-if="shuaka&&token&&bankCard!=-1" class="shuka" url="/pages/pay/shuaKa/shuaKa">
+ <image src="/static/shuaka/shuaka.png" mode=""></image>
+ </navigator>
+ <view v-if="bankCard.id" class="u-border-bottom u-p-v-20 u-flex">
+ <view @click="bordShow=false;bankCardOpen=true" class="flex-1 u-flex">
+ <image :src="bankCardStyle.logo" class="pay-icon"></image>
+ <view>
+ <view class="u-font-30 color-333 u-flex">
+ {{ bankCard.bankName }}({{ cardType[bankCard.cardType] }})({{ bankCard.cardNo }})
+ <u-icon name="arrow-right" color="#000">
+ </u-icon>
+ </view>
+ <!-- <text v-if="isNew" class="tag u-m-t-10">浼氬憳浜紭鎯�</text> -->
+ <text v-if="!isNew&&shopInfo.use_score_flag&&shopInfo.bank_pay_use_score_flag" class="u-font-24 color-999 u-m-t-10">
+ 鍙敤
+ <text class="color-red">{{ integral }}</text>
+ 绉垎
+ </text>
+ </view>
+ </view>
+ <view v-if="!isNew&&shopInfo.user_coupon_flag&&shopInfo.bank_pay_use_coupon_flag&&couponInfo" class="tag-pain">
+ 婊{
+ parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
+ }}鍏冨噺{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}鍏�
+ </view>
+ <u-radio @change="radioChange($event,3)" :name="bankCard.id" activeColor="#D41F28" :customStyle="{ marginLeft: '10rpx' }">
+ </u-radio>
+ </view>
+ </u-radio-group>
+ <navigator v-if="bankCard==-1&&bindCard&&token&&!isNew" class="shuka" url="/pages/pay/bindCard/bindCard">
+ <image src="/static/bangka.png" mode=""></image>
+ </navigator>
+ <navigator v-if="bankCard==-1&&!isNew" url="/pages/pay/bindCard/bindCard" class="u-border-bottom u-p-v-20 u-flex u-row-between">
+ <view class="u-flex-1 u-flex ">
+ <image class="pay-icon" :src="bankCardStyle.logo" mode=""></image>
+ <view class="flex-1 u-m-l-20">
+ <view class="u-font-30 color-333">閾惰鍗�</view>
+ <view class="u-font-24 color-red">缁戝崱鍙韩鏇村浼樻儬</view>
+ </view>
+ </view>
+ <u-radio disabled activeColor="#D41F28" :customStyle="{ marginLeft: '30rpx' }">
+ </u-radio>
+ </navigator>
+ <navigator v-if="isNew" class="reg-btn" :url="'/pages/pay/register?cid='+cid">
+ <image src="/static/register-btn.png" mode=""></image>
+ </navigator>
+ </view>
+
+
+ <button class="pay-it" @click="pay">浠樻</button>
+ <!-- 閫夋嫨閾惰鍗� -->
+ <u-popup mode="bottom" :closeable="true" :show="bankCardOpen" :round="10" @close="bankCardOpen = false">
+ <view class="u-font-32 color-333 u-text-center u-p-30 u-border-bottom">閫夋嫨閾惰鏀粯</view>
+ <scroll-view scroll-y class="u-p-h-30 bankCard-list">
+ <block v-for="(item,i) in bankCardList" :key="i">
+ <view @click="chooseBankCard(item)" class="u-border-bottom u-p-v-30 u-flex">
+ <view class="flex-1 u-flex">
+ <image :src="bankCardStyle.logo" class="pay-icon"></image>
+ <view>
+ <view class="u-font-26 color-333">{{ item.bankName }}</view>
+ <view class="u-m-t-10 u-font-28 color-333">{{ cardType[item.cardType] }}({{ item.cardNo }})
+ </view>
+ </view>
+ </view>
+ <u-icon name="checkbox-mark" :color="bankCardId==item.id?'#D31F28':'#fff'" size="22"></u-icon>
+ </view>
+ </block>
+ <navigator url="/pages/pay/bindCard/bindCard" class="u-border-bottom u-p-v-30 u-flex">
+ <view class="add-icon">
+ <u-icon name="plus" bold color="#D31F28"></u-icon>
+ </view>
+ <view class="u-font-28 color-333 u-m-l-20">浣跨敤鏂板崱鏀粯</view>
+ </navigator>
+ </scroll-view>
+ </u-popup>
+ <!-- 鏁板瓧閿洏 -->
+ <u-popup :show="bordShow" :overlay="false" @close="bordShow = false">
+ <key-bord @changeMoney="changeMoney" :num.sync="money" @close="bordShow = false" @pay="pay"></key-bord>
+ </u-popup>
+ <!-- 鏀粯楠岃瘉鐮� -->
+ <u-popup :show="codeShow" closeable mode="center" @close="codeShow = false">
+ <view class="u-p-h-40 u-p-b-40">
+ <view class="u-text-center u-p-t-20 u-m-b-30 u-font-34">璇疯緭鍏ユ墜鏈洪獙璇佺爜</view>
+ <view class="u-text-center u-m-b-20 color-666">{{ shopInfo.shop_name }}</view>
+ <view class="u-flex u-row-center font-bold u-m-b-40">
+ <text class="u-font-42">锟�</text>
+ <text class="u-font-money">{{ money }}
+ </text>
+ </view>
+ <u-code-input @finish="bankPay" v-model="smscode" mode="box" :focus="true"></u-code-input>
+ </view>
+
+ </u-popup>
+ </view>
+</template>
+
+<script>
+ import {
+ config,
+ cardType,
+ ACCESSTOKEN
+ } from '@/common/config.js';
+ import {
+ headBand,
+ bankCardStyle,
+ myBankCard,
+ queryShop,
+ queryMyDiscount,
+ getScoreWorth,
+ userLogin,
+ queryScore,
+ queryMyUseSweepPayMaxCoupon,
+ getWechatConfigInfo,
+ saveWxOrder,
+ tlPay
+ } from '@/common/api/index'
+ import wx from 'weixin-js-sdk'; // 浣跨敤js-sdk
+ import {
+ activityInfo
+ } from '@/common/api/shuaka'
+ export default {
+ data() {
+ return {
+ platform: this.$utils.getPlat(),
+ cardType: cardType,
+ cid: '',
+ bordShow: false, // 鏄剧ず閿洏
+ scoreWorth: 0,
+ shopInfo: {
+ shop_name: '',
+ scan_flag: '',
+ use_score_flag: 0, //鍟嗛摵鏄惁鍙敤绉垎 0鍚� 1鏄�
+ user_coupon_flag: 0, //鍟嗛摵鏄惁鍙敤浼樻儬鍒� 0鍚� 1鏄�
+ app_pay_use_score_flag: 0, //寰俊/鏀粯瀹濇槸鍚﹀彲鐢ㄧН鍒� 0鍚� 1鏄�
+ app_pay_use_coupon_flag: 0, //寰俊/鏀粯瀹濇槸鍚﹀彲鐢ㄤ紭鎯犲埜 0鍚� 1鏄�
+ bank_pay_use_score_flag: 0, //閾惰鍗℃敮浠樻槸鍚﹀彲鐢ㄧН鍒� 0鍚� 1鏄�
+ bank_pay_use_coupon_flag: 0, //閾惰鍗℃敮浠樻槸鍚﹀彲鐢ㄤ紭鎯犲埜 0鍚� 1鏄�
+ },
+ money: '', // 閲戦
+ integral: 0, // 浣跨敤绉垎
+ couponInfo: null, // 浼樻儬鍒稿唴瀹�
+ payWay: 3, //鏀粯鏂瑰紡 5 鏀粯瀹� 2 寰俊 3閾惰鍗� 15浜戦棯浠�
+ token: null,
+ isNew: false, // 鏄惁鏂扮敤鎴凤紝鏂扮敤鎴锋煡璇笉鍒扮Н鍒嗗拰閾惰鍗�
+ codeShow: false, // 閾惰鍗℃敮浠橀獙璇佺爜杈撳叆寮圭獥
+ smscode: '', // 閾惰鍗℃敮浠橀獙璇佺爜
+ thpinfo: null,
+ bankCardStyle: {
+ color: '',
+ logo: ''
+ },
+ bankCardList: [], //閾惰鍗″垪琛�
+ bankCard: -1, // 閫変腑閾惰鍗�
+ bankCardId: null, // 閫変腑閾惰鍗�
+ bankCardOpen: false,
+ canReset: false,
+ end: 0,
+ count: 0,
+ shuaka: null, //鍒峰崱娲诲姩
+ bindCard: false, // 缁戝崱鏈夌ぜ
+ discount: {
+ memberGradeName: '',
+ shopDiscount: 10
+ },
+ aLiUserId: ''
+ };
+ },
+ onLoad(opt) {
+ this.isNew = uni.getStorageSync('IS_NEW')
+ uni.showLoading()
+ this.payWay = this.platform
+ if (opt.cid) {
+ this.cid = opt.cid
+ uni.setStorageSync('CID', opt.cid)
+ this.init()
+ }
+ if (opt.code || opt.auth_code || opt.userAuthCode) {
+ let code = opt.code
+ if (this.platform == 5) {
+ code = opt.auth_code
+ }
+ if (this.platform == 15) {
+ code = opt.userAuthCode
+ }
+ this.end++
+ userLogin({
+ platform: this.platform,
+ params: {
+ code
+ }
+ }).then(res => {
+ this.getToken(res)
+ }).catch(() => {
+ uni.hideLoading()
+ })
+
+ } else {
+ if (process.env.NODE_ENV === 'development') {
+ console.log('寮�鍙戠幆澧�');
+ } else {
+ console.log('鐢熶骇鐜');
+ const redirect_uri = encodeURIComponent(window.location.href.split('?')[0] + '?cid=' + this.cid)
+ if (this.platform == 2) {
+ window.location.href =
+ `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.wx_appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
+ } else if (this.platform == 5) {
+ window.location.href =
+ `https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${config.ali_appid}&scope=auth_base&redirect_uri=${redirect_uri}&state=STATE`
+ }
+ }
+ }
+
+ },
+ onShow() {
+ this.token = uni.getStorageSync(ACCESSTOKEN) || null
+ this.bordShow = false
+ this.bankCardOpen = false
+ this.codeShow = false
+ this.smscode = ''
+ if (this.canReset && this.token && !this.isNew) {
+ this.end = 0
+ this.count = 0
+ uni.showLoading()
+ this.getUserInfo()
+ }
+ this.canReset = true
+ },
+ methods: {
+ getToken(res) {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.token = res.token.accessToken
+ uni.setStorageSync(ACCESSTOKEN, res.token.accessToken)
+ uni.setStorageSync('IS_NEW', res.isNew)
+ this.isNew = res.isNew
+ if (!res.isNew) {
+ this.getUserInfo()
+ }
+ },
+ radioChange(e, item) {
+ this.bordShow = false
+ this.payWay = item
+ },
+ // 鏇存柊閲戦
+ changeMoney(str) {
+ this.money = str;
+ },
+ // 灞曠ず閿洏
+ showBord() {
+ this.bordShow = true;
+ },
+ init() {
+ this.end += 5
+ //鑾峰彇鍟嗛摵淇℃伅
+ queryShop({
+ params: {
+ cid: this.cid
+ }
+ }).then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ if (res.logo_image) {
+ try {
+ let arr = JSON.parse(res.logo_image)
+ res.logo_image = config.sftpURL + arr[0].path
+ } catch (e) {
+ //TODO handle the exception
+ res.logo_image = ''
+ }
+ }
+ uni.setStorageSync('SHOP_INFO', res)
+ this.shopInfo = res
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ // 鍒峰崱鏈夌ぜ
+ activityInfo().then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.shuaka = res
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ // 棣栫粦鏈夌ぜ
+ headBand().then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.bindCard = res
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ // 绉垎浠峰��
+ getScoreWorth().then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.scoreWorth = res.settingVal
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ //鑾峰彇閾惰鍗¢鏍奸厤缃�
+ bankCardStyle().then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ try {
+ let arr = JSON.parse(res.logo)
+ res.logo = config.sftpURL + arr[0].path
+ } catch (e) {
+ //TODO handle the exception
+ res.logo = ''
+ }
+ this.bankCardStyle = res
+ uni.setStorageSync('bankCardStyle', res)
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ if (this.platform == 2) {
+ this.end += 1
+ //鑾峰彇寰俊jsSdk閰嶇疆
+ const uri = encodeURIComponent(window.location)
+ getWechatConfigInfo({
+ url: uri
+ }).then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ wx.config({
+ debug: false, // 寮�鍚皟璇曟ā寮�
+ appId: res.appId, // 蹇呭~锛屽叕浼楀彿鐨勫敮涓�鏍囪瘑
+ timestamp: res.timestamp, // 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴�
+ nonceStr: res.noncestr, // 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓�
+ signature: res.signature, // 蹇呭~锛岀鍚�
+ jsApiList: ['chooseWXPay'], // 蹇呭~锛岄渶瑕佷娇鐢ㄧ殑 JS 鎺ュ彛鍒楄〃
+ openTagList: [
+ 'wx-open-launch-weapp'
+ ] // 鍙�夛紝闇�瑕佷娇鐢ㄧ殑寮�鏀炬爣绛惧垪琛紝渚嬪['wx-open-launch-app']
+ });
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+
+ },
+ // 鑾峰彇浼氬憳鐩稿叧淇℃伅
+ getUserInfo() {
+ this.end += 4
+
+ queryMyDiscount({
+ shopId: this.shopInfo.id
+ }).then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ res.shopDiscount = parseFloat(res.shopDiscount / 10)
+ this.discount = res
+ uni.setStorageSync('DISCOUNT_INFO', res)
+ }).catch(() => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ })
+ //鑾峰彇鐢ㄦ埛閾惰鍗�
+ myBankCard().then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.bankCardList = res.rows
+ if (res.rows[0]) {
+ this.bankCard = res.rows[0]
+ if (this.platform == 3) {
+ this.bankCardId = res.rows[0].id
+ }
+ } else {
+ this.bankCard = -1
+ }
+ }).catch(() => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ })
+ //鑾峰彇鐢ㄦ埛绉垎
+ queryScore().then(res => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.integral = res.totalScore
+ }).catch(() => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ })
+ //鑾峰彇鐢ㄦ埛浼樻儬鍒�
+ queryMyUseSweepPayMaxCoupon({
+ params: {
+ shopId: this.shopInfo.id
+ }
+ }).then(res => {
+
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ this.couponInfo = res
+ }).catch(() => {
+ this.count++
+ if (this.count >= this.end) {
+ uni.hideLoading()
+ }
+ })
+ },
+ // 閫夋嫨閾惰鍗�
+ chooseBankCard(item) {
+ this.payWay = 3
+ this.bankCard = item;
+ this.$nextTick(() => {
+ this.bankCardId = item.id
+ this.bankCardOpen = false
+ })
+ },
+ //璺宠浆钀ラ攢椤甸潰
+ toDiscount() {
+ if (!this.isNew) { //鏄細鍛�
+ if (this.integral > 0 || this.couponInfo) { //鏈変紭鎯犲埜鎴栫Н鍒�
+ if (this.payWay == 3 && (this.shopInfo.bank_pay_use_score_flag || this.shopInfo
+ .bank_pay_use_coupon_flag)) { //閾惰鍗℃敮浠�
+
+ uni.navigateTo({
+ url: `/pages/pay/discountpay?integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
+ })
+ return false
+ } else if ((this.shopInfo.use_score_flag && this.shopInfo.app_pay_use_score_flag) || (this
+ .shopInfo
+ .user_coupon_flag && this.shopInfo.app_pay_use_coupon_flag)) {
+ uni.navigateTo({
+ url: `/pages/pay/discountpay?integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
+ })
+ return false
+ } else if (this.discount.shopDiscount != 1) {
+ uni.navigateTo({
+ url: `/pages/pay/discountpay?integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
+ })
+ return false
+ } else {
+ return true
+ }
+ } else if (this.discount.shopDiscount != 1) {
+ uni.navigateTo({
+ url: `/pages/pay/discountpay?integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
+ })
+ return false
+ } else {
+ return true
+ }
+ } else {
+ return true
+ }
+ },
+ //纭鏀粯
+ pay() {
+ if (uni.$u.test.isEmpty(this.money)) {
+ uni.$u.toast('璇疯緭鍏ラ噾棰濓紒')
+ return
+ }
+ this.bordShow = false
+ //鍒ゆ柇鏄惁闇�瑕佽烦杞惀閿�椤甸潰
+ if (this.toDiscount()) {
+ // 閲戦 this.money
+ uni.showLoading()
+ const params = {
+ money: parseFloat((this.money * 100).toPrecision(12)),
+ shopId: this.shopInfo.id,
+ cid: this.cid,
+ payWay: this.payWay,
+ score: 0,
+ couponDetailId: ''
+ }
+ if (this.payWay == 3) {
+ params.bankCardId = this.bankCardId
+ }
+ //鐢熸垚璁㈠崟
+ saveWxOrder(params).then(res => {
+ uni.hideLoading()
+ try {
+ this.orderId = res.orderId
+ res.youHuiInfo.shopName = this.shopInfo.shop_name
+ this.youHuiInfo = res.youHuiInfo
+ if (res.toPayMethod == 1) {
+ if (this.payWay == 3) {
+ this.smscode = ''
+ this.codeShow = true
+ }
+ } else if (res.toPayMethod == 2) {
+ if (this.payWay == 2) {
+ this.wxPay(res.paymentData)
+ }
+ if (this.payWay == 5) {
+ this.aliPay(res.paymentData)
+ }
+ } else if (res.toPayMethod == 3) {
+ window.location.href = res.paymentUrl
+ }
+ } catch (e) {
+ //TODO handle the exception
+ console.error(e);
+ }
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+
+ },
+ // 寰俊鏀粯
+ wxPay(res) {
+ /*setTimeout(() => {
+ wx.chooseWXPay({
+ timestamp: res.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴�
+ nonceStr: res.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣�
+ package: res.package, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_id鍙傛暟鍊硷紝鎻愪氦鏍煎紡濡傦細prepay_id=\*\*\*锛�
+ signType: res.signType, // 寰俊鏀粯V3鐨勪紶鍏� RSA ,寰俊鏀粯V2鐨勪紶鍏ユ牸寮忎笌V2缁熶竴涓嬪崟鐨勭鍚嶆牸寮忎繚鎸佷竴鑷�
+ paySign: res.paySign, // 鏀粯绛惧悕
+ success: function (res) {
+ // 鏀粯鎴愬姛鍚庣殑鍥炶皟鍑芥暟
+ uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })
+ }
+ });
+ }, 200)*/
+
+ setTimeout(() => {
+ WeixinJSBridge.invoke(
+ 'getBrandWCPayRequest', {
+ "appId": res.appId, //鍏紬鍙稩D锛岀敱鍟嗘埛浼犲叆
+ "timeStamp": res.timeStamp, //鏃堕棿鎴筹紝鑷�1970骞翠互鏉ョ殑绉掓暟
+ "nonceStr": res.nonceStr, //闅忔満涓�
+ "package": res.package,
+ "signType": res.signType, //寰俊绛惧悕鏂瑰紡锛�
+ "paySign": res.paySign //寰俊绛惧悕
+ },
+ (res) => {
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
+ // 浣跨敤浠ヤ笂鏂瑰紡鍒ゆ柇鍓嶇杩斿洖,寰俊鍥㈤槦閮戦噸鎻愮ず锛�
+ //res.err_msg灏嗗湪鐢ㄦ埛鏀粯鎴愬姛鍚庤繑鍥瀘k锛屼絾骞朵笉淇濊瘉瀹冪粷瀵瑰彲闈犮��
+ /*uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })*/
+ }
+ });
+ }, 200)
+ },
+ //鏀粯瀹濇敮浠�
+ aliPay(res) {
+ ap.tradePay({
+ tradeNO: res.tradeNO
+ }, (res) => {
+ if (res.resultCode == 9000) {
+ /*uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })*/
+ // 鏀粯鎴愬姛
+ } else if (res.resultCode == 8000 || res.resultCode == 6001) {
+ // 姝e湪澶勭悊涓� || 鍙栨秷
+ } else {
+ // 鏀粯澶辫触
+ }
+ });
+ },
+ //閾惰鍗℃敮浠�
+ bankPay(e) {
+ uni.showLoading()
+ tlPay({
+ orderId: this.orderId,
+ payWay: 3,
+ bankCardId: this.bankCardId,
+ smscode: e,
+ }).then(res => {
+ uni.hideLoading()
+ uni.hideKeyboard()
+ this.codeShow = false
+ uni.navigateTo({
+ url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+ .stringify(this.youHuiInfo)}`
+ })
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+ }
+ };
+</script>
+
+<style scoped lang="scss">
+ .page {
+ height: calc(100vh - 0px);
+ display: flex;
+ flex-direction: column;
+ }
+
+ .shop {
+ padding: 50rpx 64rpx;
+ }
+
+ .avg-img {
+ width: 94rpx;
+ height: 94rpx;
+ border-radius: 10rpx;
+ background-color: #ffffff;
+ }
+
+ .content {
+ border-radius: 40rpx 40rpx 0 0;
+ }
+
+ .money {
+ font-size: 40rpx;
+ color: #333;
+ }
+
+ .money-icon {
+ font-size: 70rpx;
+ // font-weight: bold;
+ margin-right: 20rpx;
+ }
+
+ .money-num {
+ font-size: 96rpx;
+ // font-weight: bold;
+ }
+
+ .pay-it {
+ position: absolute;
+ width: 686rpx;
+ height: 98rpx;
+ bottom: 0;
+ border-radius: 10rpx;
+ font-size: 34rpx;
+ color: #ffffff;
+ background-color: #de2d35;
+ margin: 32rpx;
+ }
+
+ .bank-card-ad {
+ padding-top: 50rpx;
+ background-image: url(~@/static/bank-card-ad1.png);
+ background-size: 100% auto;
+ background-position: top center;
+ background-repeat: no-repeat;
+ }
+
+ .pay-icon {
+ align-self: flex-start;
+ width: 48rpx;
+ height: 48rpx;
+ margin-right: 20rpx;
+ }
+
+ .tag {
+ background-color: #F35656;
+ font-size: 20rpx;
+ color: #fff;
+ border-radius: 4rpx;
+ line-height: 1;
+ padding: 4rpx;
+ }
+
+ .tag-pain {
+ border: 1px solid #D31F28;
+ font-size: 22rpx;
+ color: #D31F28;
+ border-radius: 4rpx;
+ line-height: 1;
+ padding: 8rpx 4rpx;
+ }
+
+ .mask {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ bottom: 0;
+ z-index: 101;
+ background-color: rgba(0, 0, 0, 0);
+ }
+
+ @keyframes cursor-blinks {
+ 0% {
+ opacity: 1;
+ display: block;
+ }
+
+ 50% {
+ opacity: 0;
+ display: none;
+ }
+
+ 100% {
+ opacity: 1;
+ display: block;
+ }
+ }
+
+ .cursor {
+ border-left: 1px solid transparent;
+ height: 80rpx;
+ }
+
+ .cursor-act {
+ border-left: 1px solid #333;
+ animation: cursor-blinks 1s infinite steps(1, start);
+ }
+
+ .reg-btn {
+ display: block;
+ margin-top: 30rpx;
+ width: 654rpx;
+ height: 198rpx;
+
+ image {
+ width: 100%;
+ height: 100%;
+ }
+ }
+
+ .u-font-money {
+ font-size: 60rpx;
+ }
+
+ .bankCard-list {
+ height: 50vh;
+ width: 750rpx;
+ box-sizing: border-box;
+
+ .pay-icon {
+ align-self: center;
+ }
+ }
+
+ .add-icon {
+ width: 50rpx;
+ height: 50rpx;
+ border-radius: 25rpx;
+ background: #ffc0c38f;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .shuka {
+ width: 678rpx;
+ height: 45rpx;
+ position: relative;
+ left: -10rpx;
+
+ image {
+ width: 100%;
+ height: 100%;
+ }
+ }
+
+ .btn {
+ /* position: fixed;
+ bottom: 100rpx; */
+ margin: 0 auto;
+ margin-top: 120rpx;
+ position: relative;
+ width: 680rpx;
+ height: 100rpx;
+ }
+
+ .wx-app {
+ position: absolute;
+ width: 680rpx;
+ height: 100rpx;
+ }
+</style>
diff --git a/pages/pay/shuaKa/introduce.vue b/pages/pay/shuaKa/introduce.vue
new file mode 100644
index 0000000..4d87bcf
--- /dev/null
+++ b/pages/pay/shuaKa/introduce.vue
@@ -0,0 +1,92 @@
+<template>
+ <view>
+ <view class="title">
+ <image class="title-icon" src="/static/shuaka/title-icon1.png"></image>
+ <view class="title-text">娲诲姩绱Н瑙勫垯</view>
+ </view>
+ <view class="content">
+ <view class="u-m-t-20">
+ 1銆佸弬涓庢椂闂达細{{$u.timeFormat(info.actStartTime, 'yyyy骞磎m鏈坉d鏃�')}}鍒皗{$u.timeFormat(info.actEndTime, 'yyyy骞磎m鏈坉d鏃�')}}锛屽悕棰漿{info.numOfUser}}浜恒��
+ </view>
+ <view>2銆佺疮绉埛鍗$瑪鏁版湁鏁堟椂闂达細鐢ㄦ埛鎴愬姛鍙備笌娲诲姩鍚巤{info.dayMax}}澶╁唴銆�</view>
+ <view class="u-m-t-20">3銆佺疮绉鍒欙細鐢ㄦ埛浣跨敤娲诲姩鎸囧畾閾惰鍗¤繘琛屾敮浠橈紝鍗曠瑪鏀粯瀹為檯鏀粯閲戦澶т簬绛変簬{{info.numOfMin/100}}鍏冪殑浜ゆ槗锛屾柟鍙疮绉椿鍔ㄥ埛鍗$瑪鏁般��</view>
+ <view class="u-m-t-20">
+ 4銆佺疮绉笂闄愶細鐢ㄦ埛鍙備笌娲诲姩鍚庯紝姣忎釜鑷劧鏃ユ渶澶氱疮绉瘂{info.numOfDay}}绗旀椿鍔ㄥ埛鍗$瑪鏁帮紝瓒呰繃{{info.numOfDay}}绗斿悗锛屽綋澶╃户缁氦鏄撳皢涓嶄細璁″叆娲诲姩鍒峰崱绗旀暟銆�</view>
+ </view>
+ <view class="title">
+ <image class="title-icon" src="/static/shuaka/title-icon2.png"></image>
+ <view class="title-text">娲诲姩瑙勫垯</view>
+ </view>
+ <view class="content">{{info.actRules}}</view>
+
+ </view>
+</template>
+
+<script>
+ import {
+ activityInfo
+ } from '@/common/api/shuaka'
+ export default {
+ data() {
+ return {
+ info: {
+ bankCardName: '',
+ totalDiscount: 0,
+ dayMax: 0,
+ numOfMin: 0,
+ numOfDay: 0,
+ numOfUser: 0,
+ actRules: ''
+ },
+ };
+ },
+ onLoad() {
+ activityInfo().then(res => {
+ if (res) {
+ res.actRules = decodeURIComponent(res.actRules || '')
+ this.info = res
+ }
+ })
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ page {
+ box-sizing: border-box;
+ background-color: #ffffff;
+ padding: 0 32rpx 32rpx;
+ }
+
+ .title {
+ display: flex;
+ justify-content: center;
+ margin: 60rpx 0;
+ }
+
+ .title-icon {
+ width: 42rpx;
+ height: 42rpx;
+ margin-top: 10rpx;
+ margin-right: 10rpx;
+ }
+
+ .title-text {
+ font-size: 36rpx;
+ font-weight: 500;
+ padding-bottom: 20rpx;
+ color: #333333;
+ background-image: url('~@/static/shuaka/title-bg.png');
+ background-position: left bottom;
+ background-size: 170rpx 14rpx;
+ background-repeat: no-repeat;
+ }
+
+ .content {
+ line-height: 1.5;
+ font-size: 30rpx;
+ font-weight: 400;
+ counter-reset: #333333;
+ white-space: pre-wrap;
+ }
+</style>
diff --git a/pages/pay/shuaKa/shuaKa.vue b/pages/pay/shuaKa/shuaKa.vue
new file mode 100644
index 0000000..0e10c5a
--- /dev/null
+++ b/pages/pay/shuaKa/shuaKa.vue
@@ -0,0 +1,673 @@
+<template>
+ <view>
+ <view :class="join?'page1':'page'">
+ <image class="logo1" :src="bankCardStyle.logo"></image>
+ <view class="douyu-txt page-title">鍒�<text>{{info.bankCardName}}</text></view>
+ <view class="douyu-txt page-title">鏈�楂樺彲寰梴{info.totalDiscount/100}}鍏冪ぜ鍖�</view>
+ <view class="detils-title">鍒穥{info.bankCardName}}锛岀疮绉瑪鏁拌幏绀煎寘 <navigator class="detail"
+ url="/pages/pay/shuaKa/introduce">璇︽儏
+ </navigator>
+ </view>
+ <view v-if="join" class="step-box">
+ <view class="step">
+ <view class="step-title">鏈椿鍔ㄥ墿浣�<text>{{diffDay}}</text>澶�</view>
+ <scroll-view :scroll-into-view="`step-item-${current-1}`" class="step-item-box"
+ scroll-with-animation scroll-x>
+ <view :id="`step-item-${i}`" class="jmy-flex step-item" v-for="(item,i) in milepost" :key="i">
+ <view @click="stepClick(i)" class="jmy-text-center">
+ <image class="step-icon"
+ :src="item.lackBrushCount>0?'/static/shuaka/pay-by-card-step.png':'/static/shuaka/pay-by-card-step-act.png'">
+ </image>
+ <view :class="['step-item-title',{'step-item-title-act':current==i}]">
+ {{item.nodeName}}
+ </view>
+ </view>
+ <view v-if="item.lackBrushCount==0&&item.curt&&i<milepost.length-1"
+ class="step-line step-line-cur"></view>
+ <view v-else-if="item.lackBrushCount>0&&i<milepost.length-1"
+ class="step-line step-line-next">
+ </view>
+ <view v-else-if="item.lackBrushCount==0&&i<milepost.length-1" class="step-line"></view>
+ </view>
+ </scroll-view>
+ </view>
+ <swiper @change="bindchange" next-margin="62rpx" style="height: calc(100vh - 600rpx);" :current="current">
+ <swiper-item v-for="(post,i) in milepost" :key="i">
+ <scroll-view scroll-y="true" style="height: calc(100% - 40rpx);">
+ <view class="coupon-box">
+ <view class="jmy-flex coupon-box-title">
+ <image src="/static/shuaka/coupon-title-left.png"></image>
+ <view v-if="post.lackBrushCount==0">浣犲凡鑾峰緱浠ヤ笅浼樻儬鍒�</view>
+ <view v-else>
+ <view v-if="post.nodeNumOfMin-post.lackBrushCount">
+ 宸插埛{{post.nodeNumOfMin-post.lackBrushCount}}绗�</view>
+ <view>鍐嶅埛<text style="color: #D31F28;">{{post.lackBrushCount}}</text>绗斿彲瑙i攣浠ヤ笅浼樻儬鍒�
+ </view>
+ </view>
+
+ <image src="/static/shuaka/coupon-title-right.png"></image>
+ </view>
+ <view v-for="(item,i) in post.lackBrushCount==0?post.coupIdsMap:post.coupIds" :key="i"
+ :class="['coupon',post.lackBrushCount==0?'coupon-get':'coupon-lock' ]">
+ <view class="num">
+ <view>
+ <text class="unit">锟�</text>
+ <text class="money">{{parseFloat(item.discount/100)}}</text>
+ </view>
+ <view class="condition">
+ 婊{parseFloat((item.threshold_value||item.thresholdValue)/100)}}鍏冧娇鐢�
+ </view>
+ </view>
+ <view class="info">
+ <view class="title">{{item.name}}</view>
+ <view v-if="item.validityDay" class="validity">
+ 鏈夋晥鏈燂細棰嗗彇鍚巤{item.validityDay}}澶�</view>
+ <view v-else class="validity">
+ 鏈夋晥鏈熻嚦锛歿{$u.timeFormat(item.out_time||item.validityEndTime, 'yyyy-mm-dd hh:MM')}}
+ </view>
+ </view>
+ <image v-if="post.lackBrushCount!=0" class="lock-icon"
+ src="/static/shuaka/pay-by-card-lock.png" mode=""></image>
+ </view>
+ </view>
+ </scroll-view>
+ </swiper-item>
+ </swiper>
+
+ <!-- <view @click="checkNotice" :class="['notice',{'check':notice}]">閫氱煡鎴戝弬涓庢椿鍔ㄨ繘灞�</view> -->
+ </view>
+ <image v-else @click="joinActivity" class="btn" src="/static/shuaka/pay-by-card-btn.png"></image>
+ </view>
+ <u-popup :show="popup" @close="popup=false;getDto()" mode="center" bgColor="transparent">
+ <view class="popup">
+ <view class="popup-title">鎭枩鑾峰緱</view>
+ <view class="jmy-flex popup-sub-title">
+ <image src="/static/shuaka/coupon-title-left.png"></image>
+ <view>宸茶幏<text>{{couponIds.length}}</text>寮犱紭鎯犲埜</view>
+ <image src="/static/shuaka/coupon-title-right.png"></image>
+ </view>
+ <scroll-view class="scroll-view" scroll-y>
+ <view v-for="(item,i) in couponIds" :key="i" class="coupon1">
+ <view class="num">
+ <view>
+ <text class="unit">锟�</text>
+ <text class="money">{{parseFloat(item.discount/100)}}</text>
+ </view>
+ <view class="condition">婊{parseFloat(item.threshold_value/100)}}鍏冧娇鐢�</view>
+ </view>
+ <view class="info">
+ <view class="title">{{item.name}}</view>
+ <view v-if="item.validityDay" class="validity">
+ 鏈夋晥鏈燂細棰嗗彇鍚巤{item.validityDay}}澶�</view>
+ <view v-else class="validity">
+ 鏈夋晥鏈熻嚦锛歿{$u.timeFormat(item.out_time||item.validityEndTime, 'yyyy-mm-dd hh:MM')}}</view>
+ </view>
+ </view>
+ </scroll-view>
+ <navigator class="popup-btn jmy-flex" url="/pages/myCard/myCard">鏌ョ湅鍗″寘</navigator>
+ </view>
+ <image @click="popup=false;getDto()" class="popup-close" src="/static/shuaka/popup-close.png"></image>
+ </u-popup>
+ </view>
+</template>
+
+<script>
+ import {
+ bankCardStyle,
+ } from '@/common/api/index'
+ import {
+ activityInfo,
+ signActivity,
+ myBrushDetail
+ } from '@/common/api/shuaka'
+ export default {
+ data() {
+ return {
+ brushCount: 0,
+ bankCardStyle: {
+ color: '',
+ logo: ''
+ }, //閾惰鍗¢鏍�
+ current: 0,
+ join: false,
+ notice: true,
+ popup: false,
+ couponList: [],
+ couponIds: [],
+ info: {
+ bankCardName: '',
+ totalDiscount: 0,
+ milepost: []
+ },
+ milepost: [],
+ diffDay: 0,
+ };
+ },
+ onLoad() {
+ //鑾峰彇閾惰鍗¢鏍奸厤缃�
+ bankCardStyle().then(res => {
+ try {
+ res.logo = this.$utils.getGoodsImg(res.logo, '2')
+ } catch (e) {
+ //TODO handle the exception
+ res.logo = ''
+ }
+ this.bankCardStyle = res
+ // console.log(this.bankCardStyle);
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ /* 娲诲姩璇︽儏 */
+ activityInfo().then(res => {
+ this.info = res
+ })
+ this.getDto()
+ },
+ methods: {
+ getDto() {
+ uni.showLoading()
+ /* 鍙備笌淇℃伅 */
+ myBrushDetail().then(res => {
+ uni.hideLoading()
+ if (res) {
+ this.diffDay = this.$utils.getDiffDay(res.taskStartTime, res.taskEndTime)
+ this.join = true
+ this.brushCount = Number(res.brushCount)
+ res.milePost.map((item, i) => {
+ if (item.lackBrushCount == 0) {
+ this.current = i
+ }
+ })
+ res.milePost[this.current].curt = true
+ if (res.milePost[this.current].lackBrushCount == 0) {
+ this.couponList = res.milePost[this.current].coupIdsMap
+ } else {
+ this.couponList = res.milePost[this.current].coupIds
+ }
+
+ this.milepost = res.milePost
+ }
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ },
+ stepClick(i) {
+ const cur = this.milepost[i]
+ if (cur.lackBrushCount == 0) {
+ this.couponList = cur.coupIdsMap
+ } else {
+ this.couponList = cur.coupIds
+ }
+ this.current = i
+ },
+ bindchange({
+ detail: {
+ current
+ }
+ }) {
+ this.current = current
+ },
+ joinActivity() {
+ signActivity().then(res => {
+ if (res.isOk) {
+ if (this.couponIds) {
+ this.couponIds = res.couponIds
+ this.popup = true
+ } else {
+ this.join = true
+ uni.showToast({
+ icon: 'success',
+ title: '鍙備笌鎴愬姛'
+ })
+ }
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: res.reason
+ })
+ }
+ })
+ },
+ checkNotice() {
+ this.notice = !this.notice
+ },
+ closePopup() {
+ this.popup = !this.popup
+ },
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ @font-face {
+ font-family: "DOUYU";
+ src: url("https://zhkj.jinmingyuan.com:8443/sftpxcx/jrstq/font/DOUYU.ttf");
+ }
+
+ .jmy-flex {
+ display: flex;
+ align-items: center;
+ }
+
+ .jmy-flex-nowrap {
+ flex-wrap: nowrap;
+ }
+
+ .jmy-text-center {
+ text-align: center;
+ }
+
+
+ .douyu-txt {
+ font-family: "DOUYU";
+ }
+
+ .page {
+ min-height: 100vh;
+ background-image: url('~@/static/shuaka/pay-by-card-bg.png');
+ background-position: center top;
+ background-color: #FDEDDE;
+ background-size: 100% auto;
+ background-repeat: no-repeat;
+ }
+
+ .page1 {
+ min-height: 100vh;
+ background-image: url('~@/static/shuaka/pay-by-card-bg-top.png');
+ background-position: center top;
+ background-color: #F8F9F9;
+ background-size: 100% auto;
+ background-repeat: no-repeat;
+ }
+
+ .logo1 {
+ box-sizing: border-box;
+ padding: 10rpx;
+ width: 90rpx;
+ height: 90rpx;
+ background-color: #ffffff;
+ border-radius: 45rpx;
+ margin: 30rpx 30rpx 0;
+ }
+
+ .page-title {
+ font-size: 60rpx;
+ font-weight: 400;
+ color: #6670E7;
+ text-align: center;
+ line-height: 1.3;
+ }
+
+ .page-title text {
+ color: #FB5B4A;
+ }
+
+ .detils-title {
+ width: 590rpx;
+ height: 65rpx;
+ line-height: 65rpx;
+ margin: 20rpx auto;
+ background-image: url('~@/static/shuaka/pay-by-card-dto-ttitle-bg.png');
+ background-size: cover;
+ color: #6670E7;
+ font-size: 25rpx;
+ font-weight: 400;
+ text-align: center;
+ }
+
+ .detail {
+ display: inline-block;
+ font-size: 28rpx;
+ color: #FB5B4A;
+ margin-left: 30rpx;
+ }
+
+ .detail::after {
+ content: '';
+ display: inline-block;
+ width: 10rpx;
+ height: 10rpx;
+ border-top: 1rpx solid #FB5B4A;
+ border-right: 1rpx solid #FB5B4A;
+ transform: rotate(45deg);
+ position: relative;
+ bottom: 4rpx;
+ }
+
+ .demo {
+ display: block;
+ width: 683rpx;
+ height: 708rpx;
+ margin: auto;
+ }
+
+ .btn {
+ position: fixed;
+ bottom: 30rpx;
+ bottom: calc(24rpx + constant(safe-area-inset-bottom));
+ /* 鍏煎 iOS < 11.2 */
+ bottom: calc(24rpx + env(safe-area-inset-bottom));
+ /* 鍏煎 iOS >= 11.2 */
+ left: 0;
+ width: 703rpx;
+ height: 137rpx;
+ }
+
+ .step-box {
+ flex: 1;
+ background-color: #F8F9F9;
+ display: flex;
+ flex-direction: column;
+ }
+
+ .step {
+ background-color: #ffffff;
+ }
+
+ .step-title {
+ font-size: 28rpx;
+ color: #7B4324;
+ font-weight: 500;
+ text-align: center;
+ padding: 20rpx;
+ }
+
+ .step-title text {
+ color: #D31F28;
+ font-weight: 700;
+ }
+
+ .step-icon {
+ width: 70rpx;
+ height: 70rpx;
+ }
+
+ .step-item-title {
+ font-size: 22rpx;
+ font-weight: 400;
+ color: #7B4324;
+ }
+
+ .step-item-title-act {
+ color: #FB5B4A;
+ }
+
+ .step-line {
+ background-image: linear-gradient(to right, #FFA91E 0, #FFA91E 100%);
+ width: 117rpx;
+ height: 4rpx;
+ border-radius: 2rpx;
+ position: relative;
+ top: -20rpx;
+ }
+
+ .step-line-cur {
+ background-image: linear-gradient(to right, #FFA91E 0, #FFA91E 50%, #EFEFEF 51%, #EFEFEF 100%);
+ }
+
+ .step-line-next {
+ background-image: linear-gradient(to right, #EFEFEF 0, #EFEFEF 100%);
+ }
+
+ .step-item-box {
+ background-color: #ffffff;
+ white-space: nowrap;
+ }
+
+ .step-item {
+ display: inline-flex;
+ padding-bottom: 20rpx;
+ }
+
+ .step-item-box .step-item:first-child {
+ padding-left: 40rpx;
+ }
+
+ .step-item-box .step-item:last-child {
+ padding-right: 40rpx;
+ }
+
+ .coupon-box {
+ width: 652rpx;
+ margin: 32rpx;
+ border-radius: 10rpx;
+ border: 1rpx solid rgba(255, 177, 166, 1);
+ background: linear-gradient(180.4deg, rgba(255, 255, 255, 1) 0%, rgba(255, 253, 249, 1) 100%);
+ }
+
+ .coupon-box-title {
+ justify-content: center;
+ text-align: center;
+ margin: 20rpx;
+ font-size: 28rpx;
+ font-weight: 400;
+ color: #333;
+ }
+
+ .coupon-box-title image {
+ width: 132rpx;
+ height: 21rpx;
+ }
+
+ .coupon-box-title text {
+ font-size: 28rpx;
+ font-weight: 400;
+ color: #333;
+ margin: 0 10rpx;
+ }
+
+ .coupon {
+ width: 598rpx;
+ height: 180rpx;
+ background-size: cover;
+ margin: 20rpx auto;
+ display: flex;
+ align-items: center;
+ }
+
+ .lock-icon {
+ width: 58rpx;
+ height: 58rpx;
+ margin-left: 15rpx;
+ }
+
+ .coupon-get {
+ background-image: url('~@/static/shuaka/pay-by-card-coupon-get.png');
+ }
+
+ .coupon-lock {
+ background-image: url('~@/static/shuaka/pay-by-card-coupon-lock.png');
+ }
+
+ .num {
+ color: #D31F28;
+ width: 150rpx;
+ text-align: center;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ }
+
+ .coupon-lock .num {
+ color: #CBCBCB;
+ }
+
+ .unit {
+ font-size: 36rpx;
+ font-weight: 900;
+ }
+
+ .money {
+ line-height: 1;
+ font-size: 64rpx;
+ font-weight: 900;
+ }
+
+ .condition {
+ font-size: 20rpx;
+ font-weight: 400;
+ }
+
+ .info {
+ width: 360rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ padding: 0 10rpx;
+ }
+
+ .title {
+ font-size: 26rpx;
+ font-weight: 400;
+ color: #333;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ /* white-space:nowrap; */
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ }
+
+ .coupon-lock .title {
+ opacity: 0.33;
+ }
+
+ .validity {
+ margin-top: 15rpx;
+ font-size: 20rpx;
+ font-weight: 400;
+ color: #999;
+ }
+
+ .coupon-lock .validity {
+ opacity: 0.33;
+ }
+
+ .notice {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 24rpx;
+ line-height: 1;
+ font-weight: 400;
+ color: #333;
+ margin-bottom: 40rpx;
+ }
+
+ .notice::before {
+ box-sizing: border-box;
+ display: inline-block;
+ content: '';
+ margin-right: 10rpx;
+ width: 28rpx;
+ height: 28rpx;
+ border: 1px solid #999;
+ border-radius: 4rpx;
+ transition: all 0.3s;
+ }
+
+ .notice.check::before {
+ border: none;
+ background-image: url('~@/static/shuaka/notice-check.png');
+ background-size: cover;
+ transition: all 0.3s;
+ }
+
+
+ .popup {
+ box-sizing: border-box;
+ width: 632rpx;
+ height: 935rpx;
+ background-image: url('~@/static/shuaka/pay-by-card-modal-bg.png');
+ background-size: cover;
+ padding: 210rpx 40rpx 20rpx;
+ }
+
+ .popup-close {
+ display: block;
+ margin: 40rpx auto 0;
+ width: 64rpx;
+ height: 64rpx;
+ }
+
+ .popup-title {
+ font-size: 42rpx;
+ font-weight: 700;
+ color: #F2281F;
+ text-align: center;
+ line-height: 1;
+ margin-top: 20rpx;
+ }
+
+ .popup-sub-title {
+ justify-content: center;
+ margin: 20rpx 0 10rpx;
+ color: #B36C44;
+ font-size: 28rpx;
+ }
+
+ .popup-sub-title view {
+ margin: 0 10rpx;
+ }
+
+ .popup-sub-title text {
+ color: #D31F28;
+ }
+
+ .popup-sub-title image {
+ width: 132rpx;
+ height: 21rpx;
+ }
+
+ .popup-btn {
+ margin: 20rpx auto 0;
+ width: 478rpx;
+ height: 88rpx;
+ border-radius: 44rpx;
+ background-color: rgba(238, 68, 82, 1);
+ font-size: 36rpx;
+ font-weight: 500;
+ color: #fff;
+ justify-content: center;
+ }
+
+ .scroll-view {
+ height: 435rpx;
+ }
+
+ .coupon1 {
+ width: 508rpx;
+ height: 145rpx;
+ background-image: url('~@/static/shuaka/pay-by-card-coupon.png');
+ background-size: cover;
+ margin: 20rpx auto;
+ display: flex;
+ align-items: center;
+ }
+
+ .coupon1 .num {
+ height: 110rpx;
+ border-right: 1rpx dashed #FA969A;
+ }
+
+ .coupon1 .unit {
+ font-size: 24rpx;
+ }
+
+ .coupon1 .money {
+ font-size: 50rpx;
+ }
+
+ .coupon1 .condition {
+ font-size: 20rpx;
+ }
+
+ .coupon1 .title {
+ text-align: left;
+ font-size: 24rpx;
+ }
+
+ .coupon1 .validity {
+ font-size: 20rpx;
+ }
+</style>
diff --git a/pages/pay/wxpay.vue b/pages/pay/wxpay.vue
new file mode 100644
index 0000000..62095c4
--- /dev/null
+++ b/pages/pay/wxpay.vue
@@ -0,0 +1,292 @@
+<template>
+ <view>
+ <view class="u-relative">
+ <view class="u-p-30 u-flex">
+ <image :src="info.logo_image||'/static/imgs/store-logo.png'" class="avg-img"></image>
+ <view class="u-font-32 font-bold color-333 u-m-l-20">{{ info.shop_name }}</view>
+ </view>
+ <view class="pay-box bg-fff">
+ <view class="u-font-24 color-666">閲戦</view>
+ <view class="u-p-v-20 u-flex u-border-bottom-f5 u-relative">
+ <view class="money-icon color-333">楼</view>
+ <view class="u-flex-1 u-flex u-m-l-10" style="height: 80rpx;">
+ <view v-if="money" class="u-font-40">{{money}}</view>
+ <view v-if="!money&&bordShow" class="cursor"></view>
+ <view v-if="!money" class="u-font-32 color-999">璇疯緭鍏ラ噾棰�</view>
+ <view v-if="money&&bordShow" class="cursor"></view>
+ </view>
+ <!-- <u-input placeholder="璇疯緭鍏ラ噾棰�" v-model="money" border="none" disabled disabledColor="#FFFFFF"
+ placeholderStyle="color: #c0c4cc" fontSize="40rpx" color="#333"></u-input> -->
+ <view class="mask" @click="showBord"></view>
+ </view>
+ <view class="u-font-24 color-666 u-p-v-20">閫夋嫨鏀粯鏂瑰紡</view>
+ <view>
+ <u-radio-group v-model="payType" placement="column">
+
+ <view v-if="platform == 0 || platform == 2"
+ class="u-border-bottom-f5 u-p-v-20 u-flex u-row-between">
+ <view class="flex-1 u-flex">
+ <image src="@/static/imgs/pay-wx.png" class="pay-icon"></image>
+ <view class="u-font-30 color-333 u-m-l-10">寰俊</view>
+ </view>
+ <u-radio :name="0" activeColor="#D41F28" :customStyle="{ marginLeft: '30rpx' }"></u-radio>
+ </view>
+ <view v-if="platform == 1 || platform == 2"
+ class="u-border-bottom-f5 u-p-v-20 u-flex u-row-between">
+ <view class="flex-1 u-flex">
+ <image src="@/static/imgs/pay-zfb.png" class="pay-icon"></image>
+ <view class="u-font-30 color-333 u-m-l-10">鏀粯瀹�</view>
+ </view>
+ <u-radio :name="1" activeColor="#D41F28" :customStyle="{ marginLeft: '30rpx' }"></u-radio>
+ </view>
+ <view class="u-border-bottom-f5 u-p-v-20 u-flex u-row-between">
+ <view class="flex-1 u-flex">
+ <image src="@/static/imgs/pay-jyk.png" class="pay-icon"></image>
+ <view class="u-m-l-10 flex-1 u-flex u-row-between">
+ <view>
+ <view class="u-font-30 color-333">閲戠嚂鍗�(8646)</view>
+ <view class="u-font-24 color-999">
+ 鍙敤
+ <text class="color-red">15</text>
+ 绉垎
+ <text class="color-red">婊�40-20</text>
+ 浼樻儬鍒�
+ </view>
+ </view>
+ <u-tag text="浜�8鎶樹紭鎯�" type="error" plain size="mini"></u-tag>
+ </view>
+ </view>
+ <u-radio :name="2" activeColor="#D41F28" :customStyle="{ marginLeft: '30rpx' }"></u-radio>
+ </view>
+ </u-radio-group>
+ </view>
+ <button class="pay-it" @click="pay">纭畾鏀粯</button>
+ </view>
+
+ </view>
+
+ <navigator class="reg-btn" :url="'/pages/pay/register?cid='+cid">
+ <image src="/static/register-btn.png" mode=""></image>
+ </navigator>
+ <u-popup :show="bordShow" :overlay="false" @close="close" @open="open">
+ <key-bord @changeMoney="changeMoney" :num.sync="money" @close="close" @pay="pay"></key-bord>
+ </u-popup>
+ </view>
+</template>
+
+<script>
+ import {
+ config
+ } from '@/common/config.js';
+ import {
+ queryShop,
+ getWechatInfo,
+ getWechatConfigInfo,
+ saveWxOrder
+ } from '@/common/api/index'
+ import wx from 'weixin-js-sdk'; // 浣跨敤js-sdk
+ export default {
+ data() {
+ return {
+ platform: this.$utils.getPlat(),
+ cid: '',
+ info: {
+ shop_name: '',
+ scan_flag: '',
+ use_score_flag: '',
+ user_coupon_flag: ''
+ },
+ hasNum: false, // 鏄惁杈撳叆閲戦
+ money: '', // 閲戦
+ transStyles: {
+ position: 'fixed',
+ bottom: 0,
+ left: 0,
+ width: '100%',
+ backgroundColor: '#FFFFFF',
+ zIndex: 1001
+ },
+ payType: this.$utils.getPlat(), // 鏀粯鏂瑰紡
+ bordShow: false // 鏄剧ず閿洏
+ };
+ },
+ onLoad(opt) {
+ this.cid = opt.cid
+ uni.showLoading()
+ queryShop({
+ params: opt
+ }).then(res => {
+ if (res.logo_image) {
+ try {
+ let arr = JSON.parse(res.logo_image)
+ res.logo_image = config.sftpURL + arr[0].path
+ } catch (e) {
+ //TODO handle the exception
+ res.logo_image = ''
+ }
+ }
+ this.info = res
+ this.registerSDK()
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ },
+ methods: {
+ registerSDK() {
+ const uri = encodeURIComponent(window.location)
+ getWechatConfigInfo({
+ url: uri
+ }).then(res => {
+ uni.hideLoading()
+ wx.config({
+ debug: false, // 寮�鍚皟璇曟ā寮�,璋冪敤鐨勬墍鏈� api 鐨勮繑鍥炲�间細鍦ㄥ鎴风 alert 鍑烘潵锛岃嫢瑕佹煡鐪嬩紶鍏ョ殑鍙傛暟锛屽彲浠ュ湪 pc 绔墦寮�锛屽弬鏁颁俊鎭細閫氳繃 log 鎵撳嚭锛屼粎鍦� pc 绔椂鎵嶄細鎵撳嵃銆�
+ appId: res.appId, // 蹇呭~锛屽叕浼楀彿鐨勫敮涓�鏍囪瘑
+ timestamp: res.timestamp, // 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴�
+ nonceStr: res.nonceStr, // 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓�
+ signature: res.signature, // 蹇呭~锛岀鍚�
+ jsApiList: ['chooseWXPay'] // 蹇呭~锛岄渶瑕佷娇鐢ㄧ殑 JS 鎺ュ彛鍒楄〃
+ });
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ },
+ // 鏇存柊閲戦
+ changeMoney(str) {
+ this.money = str;
+ },
+ // 灞曠ず閿洏
+ showBord() {
+ this.bordShow = true;
+ },
+ // 鍏抽棴閿洏
+ close() {
+ this.bordShow = false;
+ },
+ pay() {
+ if (!this.money) {
+ uni.showToast({
+ icon: 'none',
+ title: '璇疯緭鍏ラ噾棰�'
+ });
+ return;
+ }
+ uni.showLoading()
+ saveWxOrder({
+ cusid: this.info.cusid,
+ c: this.info.c,
+ money: parseInt(this.money * 100)
+ }).then(res => {
+ uni.hideLoading()
+ setTimeout(() => {
+ wx.chooseWXPay({
+ timestamp: res.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴�
+ nonceStr: res.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣�
+ package: res.package, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_id鍙傛暟鍊硷紝鎻愪氦鏍煎紡濡傦細prepay_id=\*\*\*锛�
+ signType: res.signType, // 寰俊鏀粯V3鐨勪紶鍏� RSA ,寰俊鏀粯V2鐨勪紶鍏ユ牸寮忎笌V2缁熶竴涓嬪崟鐨勭鍚嶆牸寮忎繚鎸佷竴鑷�
+ paySign: res.paySign, // 鏀粯绛惧悕
+ success: function(ret) {
+ // 鏀粯鎴愬姛鍚庣殑鍥炶皟鍑芥暟
+ uni.navigateTo({
+ url: '/pages/pay/paySuccess?youHuiInfo=' + JSON
+ .stringify(res.youHuiInfo)
+ })
+ }
+ });
+ }, 200)
+
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+ }
+ };
+</script>
+
+<style scoped lang="scss">
+ .avg-img {
+ width: 80rpx;
+ height: 80rpx;
+ }
+
+ .reg-btn {
+ display: block;
+ margin: 80rpx auto 0;
+ width: 686rpx;
+ height: 198rpx;
+
+ image {
+ width: 100%;
+ height: 100%;
+ }
+ }
+
+ .pay-box {
+ padding: 40rpx 20rpx;
+ border-radius: 10rpx;
+ margin: 0 30rpx;
+ }
+
+ .money-icon {
+ font-size: 50rpx;
+ font-weight: bold;
+ margin-right: 20rpx;
+ }
+
+ .money-num {
+ font-size: 50rpx;
+ font-weight: bold;
+ }
+
+ .pay-icon {
+ width: 48rpx;
+ height: 48rpx;
+ }
+
+ .mask {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ bottom: 0;
+ z-index: 101;
+ background-color: rgba(0, 0, 0, 0);
+ }
+
+ .pay-it {
+ border-radius: 50rpx;
+ font-size: 34rpx;
+ color: #ffffff;
+ background-color: #de2d35;
+ width: 90%;
+ margin-top: 20rpx;
+ }
+
+ @keyframes cursor-blinks {
+ 0% {
+ opacity: 1;
+ display: block;
+ }
+
+ 50% {
+ opacity: 0;
+ display: none;
+ }
+
+ 100% {
+ opacity: 1;
+ display: block;
+ }
+ }
+
+ .cursor {
+ border-left: 1px solid #333;
+ margin-left: 2px;
+ height: 40rpx;
+ animation: cursor-blinks 1s infinite steps(1, start)
+ }
+
+ .cursor-act {
+ border-left-color: transparent;
+ animation: cursor-blinks 1s infinite steps(1, start);
+ }
+</style>
diff --git a/pay/index.vue b/pay/index.vue
deleted file mode 100644
index 3c72e14..0000000
--- a/pay/index.vue
+++ /dev/null
@@ -1,56 +0,0 @@
-<template>
- <view>
-
- </view>
-</template>
-
-<script>
- import {
- config
- } from 'common/config.js';
- export default {
- data() {
- return {
- opt: {},
- platform: this.$utils.getPlat()
- };
- },
- onLoad(opt) {
- this.opt = opt
- },
- onShow() {
- let redirect_uri = `${config.webURL}/pay/scanpay?cid=${this.opt.cid||''}&activityQrcodeId=${this.opt.activityQrcodeId||''}&onlineId=${this.opt.onlineId||''}`
- if(this.platform==2&&uni.getStorageSync('OPENID')){
- window.location.href = redirect_uri
- return
- }
- if(this.platform==5&&uni.getStorageSync('ALIUSERID')){
- window.location.href = redirect_uri
- return
- }
- if(this.platform==15&&uni.getStorageSync('UNIONPAYID')){
- window.location.href = redirect_uri
- return
- }
- redirect_uri = encodeURIComponent(redirect_uri)
- if (this.platform == 2) {
- window.location.href =
- `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.wx_appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=0#wechat_redirect`
- } else if (this.platform == 5) {
- window.location.href =
- `https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${config.ali_appid}&scope=auth_base&redirect_uri=${redirect_uri}&state=STATE`
- } else if (this.platform == 15) {
- window.location.href =
- `https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=${redirect_uri}`
- } else {
- uni.reLaunch({
- url: `/pay/scanpay?cid=${this.opt.cid}`
- })
- }
- },
- }
-</script>
-
-<style lang="scss">
-
-</style>
diff --git a/pay/scanpay.vue b/pay/scanpay.vue
deleted file mode 100644
index e3f3f53..0000000
--- a/pay/scanpay.vue
+++ /dev/null
@@ -1,1022 +0,0 @@
-<!-- 鎵爜鏀粯 -->
-<template>
- <view class="page">
- <u-loading-page :loading="loading"></u-loading-page>
- <block v-if="shopInfo.scanFlag==1">
- <view class="shop u-flex u-row-between">
- <view class="u-m-r-30">
- <view class="u-font-26 color-666 u-m-b-10">浠樻缁�</view>
- <view class="u-font-34 color-333">{{ shopInfo.shopName }}</view>
- </view>
- <u-image width="88rpx" height="88rpx" shape="circle" errorIcon="/static/store-logo.png" loadingIcon="/static/store-logo.png" :src="shopInfo.logoImage||'/static/store-logo.png'" bgColor="#fff"></u-image>
- </view>
- <view class="u-p-24 bg-fff u-m-32 u-br-10">
- <view class="u-flex u-row-between">
- <view class="u-font-28 color-666">閲戦</view>
- <view v-if="!onlineId" @click="buyerNote='';showRemark=true;" class="remark">娣诲姞澶囨敞</view>
- </view>
- <view class="u-p-v-20 u-flex u-col-bottom u-border-bottom u-relative money-box">
- <view class="money-icon color-333 lh-1">楼</view>
- <view class="u-flex-1 u-flex u-col-bottom u-m-l-10" style="height: 80rpx;">
- <view v-if="money" class="money-num lh-1">{{ money }}</view>
- <view :class="['cursor',{'cursor-act':!money&&bordShow}]"></view>
- <view v-if="!money" class="u-font-50 color-999 lh-1">璇疯緭鍏ラ噾棰�</view>
- <view :class="['cursor',{'cursor-act':money&&bordShow}]"></view>
- </view>
- <view class="mask" @click="showBord"></view>
- </view>
- <view v-if="payWay==2" class="u-tips-color u-p-t-24">
- <wx-open-launch-weapp id="launch-btn" appid="wx47b3b5ca64bc7d5d" path="pages/index/index">
- <script type="text/wxtag-template">
- <style>
- .txt {
- font-size: 13px;
- color: #999
- }
-
- .btn {
- font-size: 13px;
- color: #1E8BE0
- }
- </style>
- <span class="txt">寰俊鎼滅储鎴栫偣鍑绘墦寮�</span>
- <span class="btn">銆愬唨浼橀偖銆�</span>
- <span class="txt">灏忕▼搴忥紝浜洿澶氫紭鎯狅紒</span>
- </script>
- </wx-open-launch-weapp>
- </view>
- </view>
- <block v-if="useCoupon">
- <view class="bg-fff u-m-32 u-br-10">
- <view class="u-flex u-p-24 u-border-bottom">
- <!-- <u-icon name="coupon-fill" size="60rpx" color="#D31F28"></u-icon> -->
- <view class="u-font-32 u-flex-1 u-m-h-16">浼樻儬鍒�</view>
- <view @click="showCoupon" class="u-flex">
- <block v-if="couponInfo.id">
- <view v-if="couponInfo.discountType==1" class="tag-pain">
- 婊{ $utils.fenToYuan(couponInfo.thresholdValue) }}鍏冨噺{{ $utils.fenToYuan(couponInfo.discount) }}鍏冨埜
- </view>
- <view v-if="couponInfo.discountType==2" class="tag-pain">
- {{ $utils.accMul(couponInfo.discount, 10) }}鎶樺埜
- </view>
- </block>
- <view v-else class="u-font-28 lh-1 u-tips-color">璇烽�夋嫨</view>
- <u-icon class="u-m-l-10" name="arrow-right" color="#999" size="16"></u-icon>
- </view>
- </view>
- </view>
- </block>
- <block v-if="payWay==2&&shopInfo.userCouponFlag==1&&discount">
- <view class="u-m-32 u-br-10 bg-fff">
- <view class="u-p-24 u-flex u-row-between u-border-bottom">
- <view class="u-font-32 color-333">鎶垫墸閲戦</view>
- <view class="color-green">- {{ discount }}</view>
- </view>
- <view class="u-p-24 u-flex u-row-between u-br-10 bg-fff">
- <view class="u-font-32 color-333">瀹炰粯閲戦</view>
- <view class="color-red">
- <text class="u-font-26 u-m-r-6">楼</text>
- <text class="u-font-34">{{ payMoney }}</text>
- </view>
- </view>
- </view>
- </block>
- <button class="pay-it" @click="checkLocation">浠樻</button>
- <view v-if="bordShow" style="height: 470rpx"></view>
- <!-- 鏁板瓧閿洏 -->
- <u-popup zIndex="500" :show="bordShow" :overlay="false" @close="bordShow = false">
- <key-bord @changeMoney="changeMoney" :num.sync="money" @close="bordShow = false" @pay="checkLocation"></key-bord>
- </u-popup>
- <!-- 浼樻儬鍒稿脊绐� -->
- <u-popup v-if="payWay==2" mode="bottom" :closeable="true" :show="couponShow" @close="couponShow = false" :round="10">
- <view class="u-font-32 color-333 u-text-center u-p-t-30">浼樻儬鍒�</view>
- <view v-if="checkCoupon.id" class="choose-coupon">
- 宸查�夋嫨浼樻儬鍒�1寮狅紝鍙姷鎵o骏{{ discount1 }}
- </view>
- <scroll-view scroll-y class="u-p-30 coupon-list">
- <u-loadmore v-if="!couponList" status="loading"/>
- <u-empty v-else-if="couponList.length===0" mode="coupon" icon="/static/no_coupon.png" text="鏆傛棤浼樻儬鍒稿彲鐢�!"></u-empty>
- <block v-else>
- <view @click="clickCoupon(item)" class="u-m-b-24 u-flex coupon" v-for="(item, index) in couponList" :key="index">
- <view class="num-box">
- <view v-if="item.discountType==1" class="font-bold" style="color: #D31F28;">
- <text class="u-font-36">锟�</text>
- <text class="money">{{ $utils.fenToYuan(item.discount) }}</text>
- </view>
- <view v-if="item.discountType==2" class="font-bold" style="color: #D31F28;">
- <text class="money">{{ $utils.accMul(item.discount, 10) }}</text>
- <text class="u-font-36">鎶�</text>
- </view>
- <view v-if="item.orderMax" class="u-font-24 u-m-t-20">浣庝簬{{ $utils.fenToYuan(item.orderMax) }}鍏冨彲鐢�</view>
- <view v-else-if="item.thresholdValue" class="u-font-24 u-m-t-20">婊{ $utils.fenToYuan(item.thresholdValue) }}鍏冨彲鐢�</view>
- <view v-else class="u-font-24 u-m-t-20">鏃犻棬妲�</view>
- </view>
- <view class="butt"></view>
- <view class="u-p-30 u-flex-1 u-flex">
- <view class="u-flex-1">
- <view class="u-font-32 color-333 u-line-2">{{ item.name }}</view>
- <view class="u-font-22 color-999 u-m-t-20">
- 鏈夋晥鏈熻嚦锛歿{ $u.timeFormat(item.outTime, 'yyyy-mm-dd hh:MM') }}
- </view>
- </view>
- <u-icon v-if="item.id==checkCoupon.id" name="checkmark-circle-fill" color="#D31F28" size="24">
- </u-icon>
- </view>
- </view>
- </block>
- </scroll-view>
- <view @click="getCoupon" class="coupon-btn">纭畾</view>
- </u-popup>
- <!-- 澶囨敞寮圭獥 -->
- <u-modal showCancelButton :show="showRemark" title="澶囨敞" confirmColor="#D31F28" @close="showRemark = false" @cancel="showRemark = false" @confirm="showRemark = false">
- <view style="border: 1rpx solid #eee;width: 100%">
- <u--textarea v-model="buyerNote" placeholder="璇疯緭鍏ュ娉ㄥ唴瀹�" maxlength="100" none count></u--textarea>
- </view>
-
- </u-modal>
- </block>
- <view v-if="shopInfo.scanFlag==0" class="empty-box">
- <image src="/static/empty.png" class="empty"></image>
- <view class="tips">{{ tips }}</view>
- <view @click="clickDone" class="clickDone">鍏抽棴</view>
- </view>
- </view>
-</template>
-
-<script>
-import {
- config,
- ACCESSTOKEN,
- CHECK_LOCATION
-} from 'common/config.js';
-import {
- queryShopByCid,
- queryShopByOnlineId,
- queryShopByActQrId,
- userLogin,
- queryUseSweepPayCoupon,
- getWechatConfigInfo,
- closeOrder,
- saveOrder,
-} from 'common/api/index'
-
-import wx from 'weixin-js-sdk'; // 浣跨敤js-sdk
-
-export default {
- data() {
- return {
- tips: '璇ュ晢鎴锋殏鏈紑閫氭敮浠樺姛鑳�',
- payLoading: false,
- loading: false,
- remark: '',
- buyerNote: '',
- showRemark: false,
- UNIONID: null,
- payWay: this.$utils.getPlat(), //2 寰俊鍏紬鍙� 3寰俊灏忕▼搴� 5鏀粯瀹� 15浜戦棯浠�
- cid: '', //鐮佺墝id C鎵獴闈欐�佺爜鏃舵湁
- activityQrcodeId: '', //鍔ㄦ�佹敹娆剧爜 C鎵獴鍔ㄦ�佺爜鏃舵湁
- shopId: '', //鍟嗘埛id C鎵獴鍔ㄦ�佺爜鏃舵湁
- bordShow: false, // 鏄剧ず閿洏
- onlineId: '', //鍐�浼橀偖绾夸笂璁㈠崟id
- orderId: '', //
- shopInfo: {
- cusid: '',
- shopName: '',
- logoImage: '',
- checkLocation: false,
- scanFlag: -1,
- useScoreFlag: -1, //鍟嗛摵鏄惁鍙敤绉垎 0鍚� 1鏄�
- userCouponFlag: -1, //鍟嗛摵鏄惁鍙敤浼樻儬鍒� 0鍚� 1鏄�
- },
- lat: '', //绾害
- lng: '', //缁忓害
- money: '', // 閲戦
- token: null,
- isNew: false, // 鏄惁鏂扮敤鎴凤紝鏂扮敤鎴锋煡璇笉鍒扮Н鍒嗗拰閾惰鍗�
- canReset: false,
- couponShow: false, // 浼樻儬鍒稿脊绐�
- couponList: null, // 浼樻儬鍒�
- couponInfo: {
- id: '',
- discount: 0,
- thresholdValue: 0,
- discountMax: 0,
- }, // 浼樻儬鍒稿唴瀹�
- checkCoupon: {
- id: null,
- discount: 0,
- thresholdValue: 0,
- discountMax: 0,
- },
- };
- },
- computed: {
- useCoupon() {
- if(this.onlineId){
- return this.couponInfo.id!=''
- }
- return this.payWay==2&&this.shopInfo.userCouponFlag==1
- },
- discount1() {
- if(!(this.money || 0)||!this.checkCoupon.id){
- return 0
- }
- if (this.checkCoupon.discountType == 1) {
- const num = this.$utils.fenToYuan(this.checkCoupon.discount)
- return parseFloat(num);
- }
- const dis = 1 - parseFloat(this.checkCoupon.discount)
- let dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
- if(dic>this.checkCoupon.discountMax){
- dic = this.checkCoupon.discountMax
- }
- return this.$utils.fenToYuan(dic).toFixed(2);
- },
- discount() {
- if(!(this.money || 0)||!this.couponInfo.id){
- return 0
- }
- if (this.couponInfo.discountType == 1) {
- const num = this.$utils.fenToYuan(this.couponInfo.discount)
- return parseFloat(num);
- }
- const dis = 1 - parseFloat(this.couponInfo.discount)
- let dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
- if(dic>this.couponInfo.discountMax){
- dic = this.couponInfo.discountMax
- }
- return this.$utils.fenToYuan(dic).toFixed(2);
- },
- payMoney() {
- if(this.discount===0||!Number(this.money || 0)){
- return 0
- }
- const num = this.$utils.accMul(this.money,100) - this.$utils.accMul(this.discount,100);
- return this.$utils.fenToYuan(num).toFixed(2);
- }
- },
- onLoad(opt) {
- this.UNIONID = uni.getStorageSync('UNIONID') || null
- this.isNew = uni.getStorageSync('IS_NEW')
-
- if (opt.cid) {
- this.bordShow = true
- this.cid = opt.cid
- this.init()
- } else if (opt.onlineId) {
- this.onlineId = opt.onlineId
- this.init()
- } else if (opt.activityQrcodeId) {
- this.activityQrcodeId = opt.activityQrcodeId
- this.shopId = opt.shopId
- this.init()
- } else {
- this.shopInfo.scanFlag = 0
- this.loading = false
- this.tips = '璇锋壂鎻忓唨椹夸粯鐮佺墝锛�'
- }
-
- if (opt.code || opt.auth_code || opt.userAuthCode) {
- let params = {
- code: opt.code
- }
- let code = opt.code
- if (this.payWay == 2 && opt.state == 1) { //寰俊
- params.getUserInfo = 1
- }
- if (this.payWay == 5) { //鏀粯瀹�
- params.code = opt.auth_code
- }
- if (this.payWay == 15) { //浜戦棯浠�
- code = opt.userAuthCode
- }
- const cd = uni.getStorageSync('cd')
- if (code === cd) {
- return
- }
- uni.setStorageSync('cd', code)
- userLogin({
- platform: this.payWay,
- params
- }).then(res => {
- this.getToken(res)
- })
- }
-
- },
- methods: {
- /*鍏抽棴椤甸潰*/
- clickDone() {
- let browser = navigator.userAgent.toLowerCase();
- if (browser.match(/Alipay/i) == "alipay") {
- //杩欎釜鍙互鍏抽棴瀹夊崜绯荤粺鐨勬墜鏈�
- document.addEventListener("AlipayJSBridgeReady", function () {
- AlipayJSBridge.call("closeWindow");
- },
- false
- );
- //杩欎釜鍙互鍏抽棴ios绯荤粺鐨勬墜鏈�
- AlipayJSBridge.call('closeWebview'); //鏀粯瀹�
- } else if (browser.match(/MicroMessenger/i) == "micromessenger") {
- //杩欎釜鍙互鍏抽棴瀹夊崜绯荤粺鐨勬墜鏈�
- document.addEventListener("WeixinJSBridgeReady", function () {
- WeixinJSBridge.call("closeWindow");
- },
- false
- );
- //杩欎釜鍙互鍏抽棴ios绯荤粺鐨勬墜鏈�
- WeixinJSBridge.call("closeWindow");
- } else {
- window.opener = null; //濡傛灉娌℃湁杩欒鍜屼笅闈㈢殑涓�琛屽垯浼氬嚭鐜颁笂闈㈢殑绗簩涓闂銆�
- window.open(' ', '_self', ' ');
- window.close()
- }
- },
- /*鐧诲綍*/
- getToken(res) {
- this.token = res.token
- if (res.openid) {
- uni.setStorageSync('OPENID', res.openid)
- }
- if (res.unionid) {
- uni.setStorageSync('UNIONID', res.unionid)
- }
- if (res.aLiUserId) {
- uni.setStorageSync('ALIUSERID', res.aLiUserId)
- }
- if (res.cloudPayUserId) {
- uni.setStorageSync('UNIONPAYID', res.cloudPayUserId)
- }
- this.UNIONID = res.unionid
- uni.setStorageSync(ACCESSTOKEN, res.token)
- uni.setStorageSync('IS_NEW', res.isNew)
- this.isNew = res.isNew
- if (!this.onlineId&&!res.isNew && !uni.$u.test.isEmpty(this.money)) {
- this.queryUseSweepPayCoupon()
- }
- },
- /*鎺堟潈unionid*/
- toRegister() {
- if (this.payWay == 2) {
- const redirect_uri = encodeURIComponent(`${config.webURL}/pay/scanpay?cid=${this.cid || ''}&activityQrcodeId=${this.activityQrcodeId || ''}&onlineId=${this.onlineId||''}`)
- uni.clearStorageSync()
- window.location.href =
- `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.wx_appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`
- }
- },
- // 鏇存柊閲戦
- changeMoney(str) {
- this.money = str;
- this.couponInfo = {
- id: '',
- discount: 0,
- thresholdValue: 0
- } // 浼樻儬鍒稿唴瀹�
- this.checkCoupon = {
- id: null,
- discount: 0,
- thresholdValue: 0
- }
- },
- // 灞曠ず閿洏
- showBord() {
- if(this.onlineId||this.activityQrcodeId){
- this.bordShow = false;
- return
- }
- this.bordShow = true;
- },
- init() {
- this.loading = true
- let timer = setTimeout(() => {
- this.shopInfo.scanFlag = 0
- this.tips = '褰撳墠鐢ㄦ埛杩囧锛岃绋嶅悗閲嶈瘯锝瀇锝�'
- this.loading = false
- }, 2000)
- let api = queryShopByCid
- let params = {
- cid: this.cid
- }
- if (this.cid) {
- api = queryShopByCid
- params = {
- cid: this.cid
- }
- }
- if (this.activityQrcodeId) {
- api = queryShopByActQrId
- params = {
- activityQrcodeId: this.activityQrcodeId
- }
- }
- if (this.onlineId) {
- api = queryShopByOnlineId
- params = {
- onlineId: this.onlineId
- }
- }
- //鑾峰彇鍟嗛摵淇℃伅
- api({
- params
- }).then(res => {
- clearTimeout(timer)
- this.loading = false
- if (!uni.$u.test.isEmpty(res.logoImage)) {
- res.logoImage = config.baseURL + res.logoImage
- }
- this.shopInfo = res
- if(res.total){
- this.money = this.$utils.fenToYuan(res.total)
- }
- if(this.onlineId){
- this.money = this.$utils.fenToYuan(res.totalPrice)
- if(res.couponId){
- this.couponInfo = {
- id: res.couponId,
- thresholdValue: res.thresholdValue,
- discount: res.discount,
- discountType: res.discountType,
- discountMax: res.discountMax
- }
- }
- }
- }).catch((err) => {
- clearTimeout(timer)
- this.shopInfo.scanFlag = 0
- this.tips = err.description || '褰撳墠鐢ㄦ埛杩囧锛岃绋嶅悗閲嶈瘯锝瀇锝�'
- this.loading = false
- })
-
- if (this.payWay == 2) {
- const uri = encodeURIComponent(window.location)
- getWechatConfigInfo({
- url: uri
- }).then(res => {
- wx.config({
- debug: false, // 寮�鍚皟璇曟ā寮�
- appId: res.appId, // 蹇呭~锛屽叕浼楀彿鐨勫敮涓�鏍囪瘑
- timestamp: res.timestamp, // 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴�
- nonceStr: res.noncestr, // 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓�
- signature: res.signature, // 蹇呭~锛岀鍚�
- jsApiList: ['hideAllNonBaseMenuItem','getLocation'], // 蹇呭~锛岄渶瑕佷娇鐢ㄧ殑JS鎺ュ彛鍒楄〃
- openTagList: ['wx-open-launch-weapp'] //鍙�夛紝闇�瑕佷娇鐢ㄧ殑寮�鏀炬爣绛惧垪琛�
- });
- wx.ready( ()=> {
- wx.hideAllNonBaseMenuItem();
- })
- })
- }
- if(this.payWay == 5){
- ap.hideOptionButton();
- }
- },
- apGetLocation(callback){
- ap.getLocation((res)=> {
- console.log('apGetLocation',res)
- if(res.latitude){
- this.lat = parseFloat(res.latitude).toFixed(6); // 绾害锛屾诞鐐规暟锛岃寖鍥翠负90 ~ -90
- this.lng = parseFloat(res.longitude).toFixed(6); // 缁忓害锛屾诞鐐规暟锛岃寖鍥翠负180 ~ -180銆�
- if(callback) callback()
- }else{
- uni.showModal({
- title: '鎻愮ず',
- content: "鑾峰彇鍦扮悊浣嶇疆澶辫触锛屾棤娉曡繘琛屾敮浠橈紒璇锋墦寮�鎵嬫満瀹氫綅鏉冮檺骞跺悓鎰忚幏鍙栦綅缃悗閲嶈瘯!",
- confirmText: '閲嶆柊鎺堟潈',
- cancelText: '閫�鍑�',
- success: ret=>{
- if(ret.confirm){
- this.apGetLocation(callback)
- }else{
- this.clickDone()
- }
- }
- })
- }
- })
- },
- wxGetLocation(callback){
- wx.getLocation({
- type: 'gcj02', // 榛樿涓簑gs84鐨刧ps鍧愭爣锛屽鏋滆杩斿洖鐩存帴缁檕penLocation鐢ㄧ殑鐏槦鍧愭爣锛屽彲浼犲叆'gcj02'
- complete: (res)=> {
- if(res.errMsg==="getLocation:ok"){
- this.lat = parseFloat(res.latitude).toFixed(6); // 绾害锛屾诞鐐规暟锛岃寖鍥翠负90 ~ -90
- this.lng = parseFloat(res.longitude).toFixed(6); // 缁忓害锛屾诞鐐规暟锛岃寖鍥翠负180 ~ -180銆�
- if(callback) callback()
- }else{
- uni.showModal({
- title: '鎻愮ず',
- content: "鑾峰彇鍦扮悊浣嶇疆澶辫触锛屾棤娉曡繘琛屾敮浠橈紒璇锋墦寮�鎵嬫満瀹氫綅鏉冮檺骞跺悓鎰忚幏鍙栦綅缃悗閲嶈瘯!",
- confirmText: '閲嶆柊鎺堟潈',
- cancelText: '閫�鍑�',
- success: ret=>{
- if(ret.confirm){
- this.wxGetLocation(callback)
- }else{
- this.clickDone()
- }
- }
- })
- }
- }
- });
- },
- // 鑾峰彇浼氬憳鐩稿叧淇℃伅
- showCoupon() {
- if(this.onlineId){
- return
- }
- if (this.UNIONID||this.payWay==5) {
- if (uni.$u.test.isEmpty(this.money)) {
- uni.$u.toast('璇疯緭鍏ラ噾棰濓紒')
- return
- }
- this.couponList = null
- this.couponShow = true
- this.queryUseSweepPayCoupon()
- } else {
- this.toRegister()
- }
- },
- //鑾峰彇鐢ㄦ埛浼樻儬鍒�
- queryUseSweepPayCoupon() {
- //2 寰俊 5鏀粯瀹� 15浜戦棯浠�
- const applyPayWayStr = {
- 2: 1,
- 5: 2,
- 15: 3
- }
- queryUseSweepPayCoupon({
- params: {
- score: 0,
- applyPayWayStr: applyPayWayStr[this.payWay],
- cusid: this.shopInfo.id,
- money: this.$utils.accMul(this.money,100),
- }
- }).then(res => {
- this.couponList = res
- }).catch(() => {
- this.couponList = []
- })
- },
- //閫夋嫨浼樻儬鍒�
- clickCoupon(item) {
- if (this.checkCoupon.id == item.id) {
- this.checkCoupon = {
- id: '',
- discount: 0,
- thresholdValue: 0
- }
- } else {
- this.checkCoupon = item
- }
- },
- //纭浼樻儬鍒�
- getCoupon() {
- // item 涓轰紭鎯犲埜淇℃伅
- this.couponInfo = this.checkCoupon;
- this.couponShow = false;
- },
- checkLocation(){
- if(!CHECK_LOCATION){
- this.pay()
- return
- }
- if (uni.$u.test.isEmpty(this.money)) {
- uni.$u.toast('璇疯緭鍏ラ噾棰濓紒')
- return
- }
- if(!this.lat){
- if(this.payWay == 2){
- this.wxGetLocation(this.pay)
- }
- if(this.payWay == 5){
- this.apGetLocation(this.pay)
- }
- }else{
- this.pay()
- }
- },
- //纭鏀粯
- pay() {
- if (uni.$u.test.isEmpty(this.money)) {
- uni.$u.toast('璇疯緭鍏ラ噾棰濓紒')
- return
- }
- this.bordShow = false
- if (this.payLoading) return
- this.payLoading = true
- // 閲戦 this.money
- uni.showLoading({
- title: '涓嬪崟涓�',
- mask: true
- })
- let params = {
- money: this.$utils.accMul(this.money,100),
- shopId: this.shopInfo.id,
- payWay: this.payWay,
- buyerNote: this.buyerNote,
- score: 0,
- couponDetailId: this.couponInfo.id,
- lat: this.lat,
- lng: this.lng
- }
- if (this.activityQrcodeId) {
- params.activityQrcodeId = this.activityQrcodeId
- }
- if (this.cid) {
- params.cid = this.cid
- }
- if (this.onlineId) {
- params.onlineId = this.onlineId
- }
- //鐢熸垚璁㈠崟
- saveOrder(params).then(res => {
- uni.hideLoading()
- try {
- this.orderId = res.orderId
- res.youHuiInfo.shopName = this.shopInfo.shopName
- this.youHuiInfo = res.youHuiInfo
- if (this.payWay == 2) {
- this.wxPay(res.paymentData)
- }
- if (this.payWay == 5) {
- this.aliPay(res.paymentData)
- }
- if (this.payWay == 15) {
- this.aliPay(res.paymentUrl)
- }
- } catch (e) {
- this.payLoading = false
- //TODO handle the exception
- console.error(e);
- }
- }).catch(() => {
- this.payLoading = false
- uni.hideLoading()
- })
- },
- // 寰俊鏀粯
- wxPay(res) {
- setTimeout(() => {
- WeixinJSBridge.invoke(
- 'getBrandWCPayRequest', {
- "appId": res.appId, //鍏紬鍙稩D锛岀敱鍟嗘埛浼犲叆
- "timeStamp": res.timeStamp, //鏃堕棿鎴筹紝鑷�1970骞翠互鏉ョ殑绉掓暟
- "nonceStr": res.nonceStr, //闅忔満涓�
- "package": res.package,
- "signType": res.signType, //寰俊绛惧悕鏂瑰紡锛�
- "paySign": res.paySign //寰俊绛惧悕
- },
- (res) => {
- this.payLoading = false
- if (res.err_msg == "get_brand_wcpay_request:ok") {
- // 浣跨敤浠ヤ笂鏂瑰紡鍒ゆ柇鍓嶇杩斿洖,寰俊鍥㈤槦閮戦噸鎻愮ず锛�
- //res.err_msg灏嗗湪鐢ㄦ埛鏀粯鎴愬姛鍚庤繑鍥瀘k锛屼絾骞朵笉淇濊瘉瀹冪粷瀵瑰彲闈犮��
- /*uni.navigateTo({
- url: `/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON.stringify(this.youHuiInfo)}`
- })*/
- } else {
- this.closeOrder()
- }
- });
- }, 200)
- },
- //鏀粯瀹濇敮浠�
- aliPay(res) {
- ap.tradePay({
- tradeNO: res.tradeNO
- }, (res) => {
- this.payLoading = false
- if (res.resultCode == 9000) {
- uni.navigateTo({
- url: `/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
- .stringify(this.youHuiInfo)}`
- })
- // 鏀粯鎴愬姛
- } else if (res.resultCode == 8000) {
- // 姝e湪澶勭悊涓� || 鍙栨秷
- } else if (res.resultCode == 6001) {
- // 鍙栨秷
- this.closeOrder()
- } else {
- // 鏀粯澶辫触
- this.closeOrder()
- }
- });
- },
- closeOrder() {
- uni.showLoading({
- title: '鍙栨秷鏀粯涓�',
- mask: true
- })
- closeOrder({
- params: {
- id: this.orderId,
- }
- }).then(res => {
- uni.hideLoading()
- }).catch(()=>{
- uni.hideLoading()
- })
- }
- }
-};
-</script>
-
-<style scoped lang="scss">
-.page {
- height: calc(100vh - 0px);
- background-color: #EDEDED;
- border-top: 1px solid #EDEDED;
- box-sizing: border-box;
-}
-
-.shop {
- padding: 50rpx 32rpx 10px;
-}
-
-.avg-img {
- width: 88rpx;
- height: 88rpx;
- border-radius: 44rpx;
- background-color: #ffffff;
-}
-
-
-.money {
- font-size: 40rpx;
-}
-
-
-.money-icon {
- position: relative;
- bottom: 6rpx;
- font-size: 42rpx;
- color: #666;
- margin-right: 10rpx;
-}
-
-.money-num {
- font-size: 72rpx;
-}
-
-.pay-it {
- position: absolute;
- width: 686rpx;
- height: 98rpx;
- bottom: 0;
- border-radius: 10rpx;
- font-size: 34rpx;
- color: #ffffff;
- background-color: #de2d35;
- margin: 32rpx;
-}
-
-.item-icon {
- width: 38rpx;
- height: 38rpx;
-}
-
-.pay-icon {
- align-self: flex-start;
- width: 48rpx;
- height: 48rpx;
- margin-right: 20rpx;
-}
-
-.tag {
- background-color: #F35656;
- font-size: 20rpx;
- color: #fff;
- border-radius: 4rpx;
- line-height: 1;
- padding: 4rpx;
-}
-
-.tag-pain {
- border: 1px solid #D31F28;
- font-size: 22rpx;
- color: #D31F28;
- border-radius: 4rpx;
- line-height: 1;
- padding: 8rpx 4rpx;
-}
-
-.mask {
- position: absolute;
- width: 100%;
- height: 100%;
- left: 0;
- bottom: 0;
- z-index: 101;
- background-color: rgba(0, 0, 0, 0);
-}
-
-@keyframes cursor-blinks {
- 0% {
- opacity: 1;
- display: block;
- }
-
- 50% {
- opacity: 0;
- display: block;
- }
-
- 100% {
- opacity: 1;
- display: block;
- }
-}
-
-.cursor {
- width: 1px;
- height: 70rpx;
-}
-
-.cursor-act {
- width: 1px;
- background-color: #999;
- animation: cursor-blinks 1s infinite steps(1, start);
-}
-
-.reg-btn {
- display: block;
- margin-top: 30rpx;
- width: 654rpx;
- height: 198rpx;
-
- image {
- width: 100%;
- height: 100%;
- }
-}
-
-.u-font-money {
- font-size: 60rpx;
-}
-
-.bankCard-list {
- height: 50vh;
- width: 750rpx;
- box-sizing: border-box;
-
- .pay-icon {
- align-self: center;
- }
-}
-
-.add-icon {
- width: 50rpx;
- height: 50rpx;
- border-radius: 25rpx;
- background: #ffc0c38f;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.shuka {
- width: 678rpx;
- height: 45rpx;
- position: relative;
- left: -10rpx;
-
- image {
- width: 100%;
- height: 100%;
- }
-}
-
-.btn {
- margin: 120rpx auto 0;
- position: relative;
- width: 680rpx;
- height: 100rpx;
-}
-
-.wx-app {
- position: absolute;
- width: 680rpx;
- height: 100rpx;
-}
-
-.coupon {
- background-color: rgba(255, 241, 241, 0.47);
- height: 171rpx;
- border: solid 1rpx #f85d64;
- border-radius: 10rpx;
- position: relative;
- overflow: hidden;
-}
-.num-box{
- width: 200rpx;
- text-align: center;
-}
-.choose-coupon {
- margin: 32rpx 32rpx 0;
- border-radius: 10rpx;
- background: #fff1f1;
- padding: 26rpx 16rpx;
- color: #D31F28;
- font-size: 28rpx;
-}
-
-.coupon-list {
- box-sizing: border-box;
- height: calc(60vh - 44px);
-}
-
-
-.butt {
- width: 1rpx;
- height: 100%;
- position: relative;
- z-index: 9;
- border-left: 1rpx dashed #f85d64;
-}
-
-.butt:before {
- z-index: 10;
- box-sizing: border-box;
- position: absolute;
- content: "";
- width: 24rpx;
- height: 12rpx;
- border-bottom: 1rpx solid #f85d64;
- border-right: 1rpx solid #f85d64;
- border-left: 1rpx solid #f85d64;
- border-radius: 0 0 24rpx 24rpx;
- left: -12rpx;
- background-color: #ffffff;
-}
-
-.butt:after {
- box-sizing: border-box;
- position: absolute;
- content: "";
- width: 24rpx;
- height: 12rpx;
- bottom: 0;
- border-bottom: 1rpx solid #ffff;
- border-right: 1rpx solid #f85d64;
- border-left: 1rpx solid #f85d64;
- border-top: 1rpx solid #f85d64;
- border-radius: 24rpx 24rpx 0 0;
- left: -12rpx;
- background-color: #ffffff;
-}
-
-.remark {
- color: #1E8BE0
-}
-
-.lh-1 {
- line-height: 1;
-}
-
-.coupon-btn {
- margin: 0 30rpx 30rpx;
- height: 98rpx;
- border-radius: 10rpx;
- background-color: #D31F28;
- font-size: 34rpx;
- color: #fff;
- line-height: 98rpx;
- text-align: center;
-}
-
-.empty-box {
- height: calc(80vh - 64rpx);
- margin: 32rpx;
- background-color: #fff;
- border-radius: 10rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
-
- .tips {
- font-size: 28rpx;
- color: #999;
- margin: 60rpx 0;
- }
-
- .empty {
- width: 291rpx;
- height: 302rpx;
- }
-
- .clickDone {
- font-size: 34rpx;
- color: #fff;
- width: 331rpx;
- height: 88rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 61rpx;
- background: linear-gradient(0deg, #D31F28 0%, #D31F28 100%), linear-gradient(270deg, #F62B20 13.24%, #FC4E0B 111.68%), #D9D9D9;
- }
-}
-</style>
diff --git a/static/act-bg.png b/static/act-bg.png
new file mode 100644
index 0000000..941be37
--- /dev/null
+++ b/static/act-bg.png
Binary files differ
diff --git a/static/bangka.png b/static/bangka.png
new file mode 100644
index 0000000..09cf03c
--- /dev/null
+++ b/static/bangka.png
Binary files differ
diff --git a/static/bank-card-ad1.png b/static/bank-card-ad1.png
new file mode 100644
index 0000000..09cf03c
--- /dev/null
+++ b/static/bank-card-ad1.png
Binary files differ
diff --git a/static/bank-card-ad2.png b/static/bank-card-ad2.png
new file mode 100644
index 0000000..1143115
--- /dev/null
+++ b/static/bank-card-ad2.png
Binary files differ
diff --git a/static/bind-card-modal.png b/static/bind-card-modal.png
new file mode 100644
index 0000000..d39833d
--- /dev/null
+++ b/static/bind-card-modal.png
Binary files differ
diff --git a/static/bind-card-title.png b/static/bind-card-title.png
new file mode 100644
index 0000000..0c1a35c
--- /dev/null
+++ b/static/bind-card-title.png
Binary files differ
diff --git a/static/cart/icon_add.png b/static/cart/icon_add.png
new file mode 100644
index 0000000..232c922
--- /dev/null
+++ b/static/cart/icon_add.png
Binary files differ
diff --git a/static/cart/icon_addLight.png b/static/cart/icon_addLight.png
new file mode 100644
index 0000000..afd408b
--- /dev/null
+++ b/static/cart/icon_addLight.png
Binary files differ
diff --git a/static/cart/icon_less.png b/static/cart/icon_less.png
new file mode 100644
index 0000000..8f1ed73
--- /dev/null
+++ b/static/cart/icon_less.png
Binary files differ
diff --git a/static/cart/icon_lessLight.png b/static/cart/icon_lessLight.png
new file mode 100644
index 0000000..75bdd72
--- /dev/null
+++ b/static/cart/icon_lessLight.png
Binary files differ
diff --git a/static/check-type.png b/static/check-type.png
new file mode 100644
index 0000000..da0aaa7
--- /dev/null
+++ b/static/check-type.png
Binary files differ
diff --git a/static/close-icon.png b/static/close-icon.png
new file mode 100644
index 0000000..05fc551
--- /dev/null
+++ b/static/close-icon.png
Binary files differ
diff --git a/static/coupon-bg2.png b/static/coupon-bg2.png
new file mode 100644
index 0000000..a594ace
--- /dev/null
+++ b/static/coupon-bg2.png
Binary files differ
diff --git a/static/coupon-icon.png b/static/coupon-icon.png
new file mode 100644
index 0000000..448161c
--- /dev/null
+++ b/static/coupon-icon.png
Binary files differ
diff --git a/static/del-icon.png b/static/del-icon.png
deleted file mode 100644
index d5d6fe5..0000000
--- a/static/del-icon.png
+++ /dev/null
Binary files differ
diff --git a/static/empty.png b/static/empty.png
deleted file mode 100755
index 157e3e5..0000000
--- a/static/empty.png
+++ /dev/null
Binary files differ
diff --git a/static/imgs/del-icon.png b/static/imgs/del-icon.png
new file mode 100644
index 0000000..afbfc78
--- /dev/null
+++ b/static/imgs/del-icon.png
Binary files differ
diff --git a/static/imgs/pay-jyk.png b/static/imgs/pay-jyk.png
new file mode 100644
index 0000000..2f45ca1
--- /dev/null
+++ b/static/imgs/pay-jyk.png
Binary files differ
diff --git a/static/imgs/pay-union.png b/static/imgs/pay-union.png
new file mode 100644
index 0000000..e8aea1e
--- /dev/null
+++ b/static/imgs/pay-union.png
Binary files differ
diff --git a/static/imgs/pay-wx.png b/static/imgs/pay-wx.png
new file mode 100644
index 0000000..59ae69b
--- /dev/null
+++ b/static/imgs/pay-wx.png
Binary files differ
diff --git a/static/imgs/pay-zfb.png b/static/imgs/pay-zfb.png
new file mode 100644
index 0000000..1966caf
--- /dev/null
+++ b/static/imgs/pay-zfb.png
Binary files differ
diff --git a/static/imgs/store-logo.png b/static/imgs/store-logo.png
new file mode 100644
index 0000000..26e0937
--- /dev/null
+++ b/static/imgs/store-logo.png
Binary files differ
diff --git a/static/integral.png b/static/integral.png
new file mode 100644
index 0000000..01f755f
--- /dev/null
+++ b/static/integral.png
Binary files differ
diff --git a/static/no_coupon.png b/static/no_coupon.png
deleted file mode 100644
index 0037367..0000000
--- a/static/no_coupon.png
+++ /dev/null
Binary files differ
diff --git a/static/pay-btn.jpeg b/static/pay-btn.jpeg
new file mode 100644
index 0000000..d5991e9
--- /dev/null
+++ b/static/pay-btn.jpeg
Binary files differ
diff --git a/static/pay-btn.png b/static/pay-btn.png
new file mode 100644
index 0000000..0cc5c09
--- /dev/null
+++ b/static/pay-btn.png
Binary files differ
diff --git a/static/pay-by-card-coupon.png b/static/pay-by-card-coupon.png
deleted file mode 100644
index ae595dd..0000000
--- a/static/pay-by-card-coupon.png
+++ /dev/null
Binary files differ
diff --git a/static/paySuccess.png b/static/paySuccess.png
index 42bc7c6..943381c 100644
--- a/static/paySuccess.png
+++ b/static/paySuccess.png
Binary files differ
diff --git a/static/register-btn.png b/static/register-btn.png
new file mode 100644
index 0000000..d18589a
--- /dev/null
+++ b/static/register-btn.png
Binary files differ
diff --git a/static/shuaka/coupon-title-left.png b/static/shuaka/coupon-title-left.png
new file mode 100644
index 0000000..9d4d61c
--- /dev/null
+++ b/static/shuaka/coupon-title-left.png
Binary files differ
diff --git a/static/shuaka/coupon-title-right.png b/static/shuaka/coupon-title-right.png
new file mode 100644
index 0000000..9615048
--- /dev/null
+++ b/static/shuaka/coupon-title-right.png
Binary files differ
diff --git a/static/shuaka/notice-check.png b/static/shuaka/notice-check.png
new file mode 100644
index 0000000..ed383d8
--- /dev/null
+++ b/static/shuaka/notice-check.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-bg-top.png b/static/shuaka/pay-by-card-bg-top.png
new file mode 100644
index 0000000..c934d70
--- /dev/null
+++ b/static/shuaka/pay-by-card-bg-top.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-bg.png b/static/shuaka/pay-by-card-bg.png
new file mode 100644
index 0000000..ed0ee57
--- /dev/null
+++ b/static/shuaka/pay-by-card-bg.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-btn.png b/static/shuaka/pay-by-card-btn.png
new file mode 100644
index 0000000..c3d5176
--- /dev/null
+++ b/static/shuaka/pay-by-card-btn.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-coupon-get.png b/static/shuaka/pay-by-card-coupon-get.png
new file mode 100644
index 0000000..91ac90e
--- /dev/null
+++ b/static/shuaka/pay-by-card-coupon-get.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-coupon-lock.png b/static/shuaka/pay-by-card-coupon-lock.png
new file mode 100644
index 0000000..351f7cc
--- /dev/null
+++ b/static/shuaka/pay-by-card-coupon-lock.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-coupon.png b/static/shuaka/pay-by-card-coupon.png
new file mode 100644
index 0000000..f3ce1f7
--- /dev/null
+++ b/static/shuaka/pay-by-card-coupon.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-dto-ttitle-bg.png b/static/shuaka/pay-by-card-dto-ttitle-bg.png
new file mode 100644
index 0000000..a664c93
--- /dev/null
+++ b/static/shuaka/pay-by-card-dto-ttitle-bg.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-lock.png b/static/shuaka/pay-by-card-lock.png
new file mode 100644
index 0000000..8b76314
--- /dev/null
+++ b/static/shuaka/pay-by-card-lock.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-modal-bg.png b/static/shuaka/pay-by-card-modal-bg.png
new file mode 100644
index 0000000..ab16627
--- /dev/null
+++ b/static/shuaka/pay-by-card-modal-bg.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-step-act.png b/static/shuaka/pay-by-card-step-act.png
new file mode 100644
index 0000000..3eb8b06
--- /dev/null
+++ b/static/shuaka/pay-by-card-step-act.png
Binary files differ
diff --git a/static/shuaka/pay-by-card-step.png b/static/shuaka/pay-by-card-step.png
new file mode 100644
index 0000000..ed878b2
--- /dev/null
+++ b/static/shuaka/pay-by-card-step.png
Binary files differ
diff --git a/static/shuaka/popup-close.png b/static/shuaka/popup-close.png
new file mode 100644
index 0000000..a1f343d
--- /dev/null
+++ b/static/shuaka/popup-close.png
Binary files differ
diff --git a/static/shuaka/shuaka.png b/static/shuaka/shuaka.png
new file mode 100644
index 0000000..1143115
--- /dev/null
+++ b/static/shuaka/shuaka.png
Binary files differ
diff --git a/static/shuaka/title-bg.png b/static/shuaka/title-bg.png
new file mode 100644
index 0000000..1e23a49
--- /dev/null
+++ b/static/shuaka/title-bg.png
Binary files differ
diff --git a/static/shuaka/title-icon1.png b/static/shuaka/title-icon1.png
new file mode 100644
index 0000000..aef9568
--- /dev/null
+++ b/static/shuaka/title-icon1.png
Binary files differ
diff --git a/static/shuaka/title-icon2.png b/static/shuaka/title-icon2.png
new file mode 100644
index 0000000..68f03cb
--- /dev/null
+++ b/static/shuaka/title-icon2.png
Binary files differ
diff --git a/static/store-logo.png b/static/store-logo.png
deleted file mode 100755
index 908d90a..0000000
--- a/static/store-logo.png
+++ /dev/null
Binary files differ
diff --git a/static/title-left.png b/static/title-left.png
new file mode 100644
index 0000000..0adae28
--- /dev/null
+++ b/static/title-left.png
Binary files differ
diff --git a/static/title-right.png b/static/title-right.png
new file mode 100644
index 0000000..06c8ba9
--- /dev/null
+++ b/static/title-right.png
Binary files differ
diff --git a/uni_modules/uview-ui/components/u-input/u-input.vue b/uni_modules/uview-ui/components/u-input/u-input.vue
index c755390..3f0af7d 100644
--- a/uni_modules/uview-ui/components/u-input/u-input.vue
+++ b/uni_modules/uview-ui/components/u-input/u-input.vue
@@ -88,7 +88,7 @@
* @property {Boolean} password 鏄惁瀵嗙爜绫诲瀷 锛� 榛樿 false 锛�
* @property {String | Number} maxlength 鏈�澶ц緭鍏ラ暱搴︼紝璁剧疆涓� -1 鐨勬椂鍊欎笉闄愬埗鏈�澶ч暱搴� 锛� 榛樿 -1 锛�
* @property {String} placeholder 杈撳叆妗嗕负绌烘椂鐨勫崰浣嶇
- * @property {String} placeholderClass 鎸囧畾placeholder鐨勬牱寮忕被锛屾敞鎰忛〉闈㈡垨缁勪欢鐨剆tyle涓啓浜唖coped鏃讹紝闇�瑕佸湪绫诲悕鍓嶅啓/deep/ 锛� 榛樿 'input-placeholder' 锛�
+ * @property {String} placeholderClass 鎸囧畾placeholder鐨勬牱寮忕被锛屾敞鎰忛〉闈㈡垨缁勪欢鐨剆tyle涓啓浜唖coped鏃讹紝闇�瑕佸湪绫诲悕鍓嶅啓::v-deep 锛� 榛樿 'input-placeholder' 锛�
* @property {String | Object} placeholderStyle 鎸囧畾placeholder鐨勬牱寮忥紝瀛楃涓�/瀵硅薄褰㈠紡锛屽"color: red;"
* @property {Boolean} showWordLimit 鏄惁鏄剧ず杈撳叆瀛楁暟缁熻锛屽彧鍦� type ="text"鎴杢ype ="textarea"鏃舵湁鏁� 锛� 榛樿 false 锛�
* @property {String} confirmType 璁剧疆鍙充笅瑙掓寜閽殑鏂囧瓧锛屽吋瀹规�ц瑙乽ni-app鏂囨。 锛� 榛樿 'done' 锛�
@@ -318,7 +318,7 @@
@include flex(row);
margin: 0;
flex: 1;
-
+
&__field {
line-height: 26px;
text-align: left;
diff --git a/uni_modules/uview-ui/components/u-parse/u-parse.vue b/uni_modules/uview-ui/components/u-parse/u-parse.vue
index 7bc8b3d..0abdfb8 100644
--- a/uni_modules/uview-ui/components/u-parse/u-parse.vue
+++ b/uni_modules/uview-ui/components/u-parse/u-parse.vue
@@ -31,7 +31,7 @@
* @property {Boolean} showImgMenu 鏄惁鍏佽鍥剧墖琚暱鎸夋椂鏄剧ず鑿滃崟锛堥粯璁� true 锛�
* @property {Object} tagStyle 鏍囩鐨勯粯璁ゆ牱寮�
* @property {Boolean | Number} useAnchor 鏄惁浣跨敤閿氱偣閾炬帴
- *
+ *
* @event {Function} load dom 缁撴瀯鍔犺浇瀹屾瘯鏃惰Е鍙�
* @event {Function} ready 鎵�鏈夊浘鐗囧姞杞藉畬姣曟椂瑙﹀彂
* @event {Function} imgTap 鍥剧墖琚偣鍑绘椂瑙﹀彂
@@ -127,7 +127,7 @@
// #ifndef APP-PLUS-NVUE
let deep = ' '
// #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
- deep = '>>>'
+ deep = '::v-deep'
// #endif
const selector = uni.createSelectorQuery()
// #ifndef MP-ALIPAY
diff --git a/uni_modules/uview-ui/components/u-textarea/u-textarea.vue b/uni_modules/uview-ui/components/u-textarea/u-textarea.vue
index 0dac03e..c00ea50 100644
--- a/uni_modules/uview-ui/components/u-textarea/u-textarea.vue
+++ b/uni_modules/uview-ui/components/u-textarea/u-textarea.vue
@@ -48,7 +48,7 @@
*
* @property {String | Number} value 杈撳叆妗嗙殑鍐呭
* @property {String | Number} placeholder 杈撳叆妗嗕负绌烘椂鍗犱綅绗�
- * @property {String} placeholderClass 鎸囧畾placeholder鐨勬牱寮忕被锛屾敞鎰忛〉闈㈡垨缁勪欢鐨剆tyle涓啓浜唖coped鏃讹紝闇�瑕佸湪绫诲悕鍓嶅啓/deep/ 锛� 榛樿 'input-placeholder' 锛�
+ * @property {String} placeholderClass 鎸囧畾placeholder鐨勬牱寮忕被锛屾敞鎰忛〉闈㈡垨缁勪欢鐨剆tyle涓啓浜唖coped鏃讹紝闇�瑕佸湪绫诲悕鍓嶅啓::v-deep 锛� 榛樿 'input-placeholder' 锛�
* @property {String | Object} placeholderStyle 鎸囧畾placeholder鐨勬牱寮忥紝瀛楃涓�/瀵硅薄褰㈠紡锛屽"color: red;"
* @property {String | Number} height 杈撳叆妗嗛珮搴︼紙榛樿 70 锛�
* @property {String} confirmType 璁剧疆閿洏鍙充笅瑙掓寜閽殑鏂囧瓧锛屼粎寰俊灏忕▼搴忥紝App-vue鍜孒5鏈夋晥锛堥粯璁� 'done' 锛�
--
Gitblit v1.9.1