diff --git a/App.vue b/App.vue index 99f6e28..b2746c6 100644 --- a/App.vue +++ b/App.vue @@ -1,5 +1,17 @@ + + diff --git a/components/wyb-popup/iconfont.css b/components/wyb-popup/iconfont.css new file mode 100644 index 0000000..5890a5d --- /dev/null +++ b/components/wyb-popup/iconfont.css @@ -0,0 +1,16 @@ +@font-face {font-family: "iconfont"; + src: url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAKUAAsAAAAABlAAAAJJAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcApcdgE2AiQDCAsGAAQgBYRtBy8bmwXIrjBu4UkbIjvjLimCmu1EP9KHAd4jgmi/3+zde18toRbpnkUTzRKRUkgQE6RA9xL+tMuG6RYp8bFsgmbcecAB9mDhH67tDS3pQsIsmSbPL7chM1RKsFr5mNDBoUDPJItlaZG8fvhi/tciWcbRfJ7L6U2gA1l9oBz3orEmTRpAvTigAPfCKLISSiNtGLvAJdwn0DCHgMfN/kgLK1jLAvE0p7YWzoUVCparCZWavYV4U6qllxTNa/j5+JeKMEmZWQ1njw1PK39hF+TnFG59QoSADpfI2AEUxFVt+oQpGIc10pYlYF+1wRfTfZfYq12wv86qboEZqLgnpau61VyC21L06V8d9cuJmT795hWPJp8ayHj0wrZNx+/+1Nzdf8MBtu9H2p+tgB5tn/W1PEZvgeD5Xf/if61ZgE9foa3Qz0ttd57gtyh79hS62nKmQlXWDiczp2tqaGAK+we+sZbxPeRDzXiEt2o2RVazQhbsDkpNu6io2UPDNn24aagxRVHHlgkQehaSjg9kPYcs2IvSxENFL0w03ASd2bQW82is0d6iB+YE2ZWCOO5tNKodIN0xe51Vh/wE15t5DGQsUcy1UOB6jg19T1NjSyCsJQcFHkPGJJS1XKC7jaXtVpV4nNS9KGYl16KOrCHbFvIA4wRkLkkg/uitaOn9A4jaYWzrlq6a/ARa25hPDiRG9CBbBtGr616e6faolGGLAMGaxAEFZiGGkUCpn7WAXFsxaURSKeH2oNDXEFvfxL/uGDRY1hT2lKy8Y3KDmgYA') format('woff2') +} + +.iconfont { + font-family: "iconfont" !important; + font-size: 30px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-close:before { + content: "\e622"; +} + diff --git a/components/wyb-popup/wyb-popup.vue b/components/wyb-popup/wyb-popup.vue new file mode 100644 index 0000000..f93c12a --- /dev/null +++ b/components/wyb-popup/wyb-popup.vue @@ -0,0 +1,420 @@ + + + + + diff --git a/manifest.json b/manifest.json index bc64e7f..6140c54 100644 --- a/manifest.json +++ b/manifest.json @@ -68,5 +68,15 @@ "uniStatistics" : { "enable" : false }, - "vueVersion" : "2" + "vueVersion" : "2", + "h5" : { + "router" : { + "mode" : "hash", + "base" : "/scanPay" + }, + "title" : "支付", + "devServer" : { + "https" : false + } + } } diff --git a/node_modules/jweixin-module/README.md b/node_modules/jweixin-module/README.md new file mode 100644 index 0000000..7c91d7b --- /dev/null +++ b/node_modules/jweixin-module/README.md @@ -0,0 +1,30 @@ +# jweixin-module + +微信JS-SDK + +## 安装 + +### NPM + +```shell +npm install jweixin-module --save +``` + +### UMD + +```http +https://unpkg.com/jweixin-module/out/index.js +``` + +## 使用 + +```js +var jweixin = require('jweixin-module') +jweixin.ready(function(){ + // TODO +}); +``` + +## 完整API + +>[微信JS-SDK说明文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115) diff --git a/node_modules/jweixin-module/lib/index.js b/node_modules/jweixin-module/lib/index.js new file mode 100644 index 0000000..1b5014b --- /dev/null +++ b/node_modules/jweixin-module/lib/index.js @@ -0,0 +1 @@ +!function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(window,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` + + - `jsonp: (url: string, param?: IJsonpParam, timeout?: number) => Promise` + +## API + +### IJsonpParam + +IJsonpParam is the type of param for jsonp function. + +```ts +/** + * JSONP parameter declaration. + */ +interface IJsonpParam { + /** + * Callback query name. + * This param is used to define the query name of the callback function. + * + * @example + * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice" + * jsonp('/some-url', { + * callbackQuery: 'myCallback', + * callbackName: 'jsonp_func', + * myCustomUrlParam: 'veryNice' + * }) + * + * @default callback + */ + callbackQuery?: string + + /** + * Callback function name. + * This param is used to define the jsonp function name. + * + * @example + * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice" + * jsonp('/some-url', { + * callbackQuery: 'myCallback', + * callbackName: 'jsonp_func', + * myCustomUrlParam: 'veryNice' + * }) + * + * @default jsonp_ + randomStr() + */ + callbackName?: string + + /** + * Custom data. + */ + [key: string]: any +} +``` + +## Example + +```ts +import Vue from 'vue' +import { VueJsonp } from 'vue-jsonp' + +Vue.use(VueJsonp) + +const vm = new Vue() +const { code, data, message } = await vm.$jsonp<{ + code: number, + message: string, + data: { + id: number, + nickname: string + } +}>('/my-awesome-url', { + name: 'MyName', age: 20 +}) + +assert(code === 0) +assert(message === 'ok') +assert(data.id === 1) +assert(data.nickname === 'John Smith') +``` + +```ts +import { jsonp } from 'vue-jsonp' + +const result = await jsonp('/my-awesome-url') +assert(result === 'such a jsonp') +``` + +## License + +MIT diff --git a/node_modules/vue-jsonp/dist/index.d.ts b/node_modules/vue-jsonp/dist/index.d.ts new file mode 100644 index 0000000..ec621c7 --- /dev/null +++ b/node_modules/vue-jsonp/dist/index.d.ts @@ -0,0 +1,73 @@ +/** + * Vue Jsonp. + * # Carry Your World # + * + * @author: LancerComet + * @license: MIT + */ +import { PluginObject } from 'vue/types/plugin'; +declare module 'vue/types/vue' { + interface Vue { + $jsonp: typeof jsonp; + } +} +/** + * Vue JSONP. + */ +declare const VueJsonp: PluginObject; +/** + * JSONP function. + * + * @param { string } url Target URL address. + * @param { IJsonpParam } param Querying params object. + * @param { number } timeout Timeout setting (ms). + * + * @example + * jsonp('/url', { + * callbackQuery: '' + * callbackName: '', + * name: 'LancerComet', + * age: 26 + * }, 1000) + */ +declare function jsonp(url: string, param?: IJsonpParam, timeout?: number): Promise; +export { VueJsonp, jsonp }; +/** + * JSONP parameter declaration. + */ +interface IJsonpParam { + /** + * Callback query name. + * This param is used to define the query name of the callback function. + * + * @example + * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice" + * jsonp('/some-url', { + * callbackQuery: 'myCallback', + * callbackName: 'jsonp_func', + * myCustomUrlParam: 'veryNice' + * }) + * + * @default callback + */ + callbackQuery?: string; + /** + * Callback function name. + * This param is used to define the jsonp function name. + * + * @example + * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice" + * jsonp('/some-url', { + * callbackQuery: 'myCallback', + * callbackName: 'jsonp_func', + * myCustomUrlParam: 'veryNice' + * }) + * + * @default jsonp_ + randomStr() + */ + callbackName?: string; + /** + * Custom data. + */ + [key: string]: any; +} diff --git a/node_modules/vue-jsonp/dist/index.esm.js b/node_modules/vue-jsonp/dist/index.esm.js new file mode 100644 index 0000000..893bec4 --- /dev/null +++ b/node_modules/vue-jsonp/dist/index.esm.js @@ -0,0 +1,8 @@ +function e(t,n){t=t.replace(/=/g,"");var o=[];switch(n.constructor){case String:case Number:case Boolean:o.push(encodeURIComponent(t)+"="+encodeURIComponent(n));break;case Array:n.forEach((function(n){o=o.concat(e(t+"[]=",n))}));break;case Object:Object.keys(n).forEach((function(r){var a=n[r];o=o.concat(e(t+"["+r+"]",a))}))}return o}function t(e){var n=[];return e.forEach((function(e){"string"==typeof e?n.push(e):n=n.concat(t(e))})),n} +/** + * Vue Jsonp. + * # Carry Your World # + * + * @author: LancerComet + * @license: MIT + */var n={install:function(e){e.prototype.$jsonp=o}};function o(n,o,r){if(void 0===o&&(o={}),"string"!=typeof n)throw new Error('[Vue-jsonp] Type of param "url" is not string.');if("object"!=typeof o||!o)throw new Error("[Vue-jsonp] Invalid params, should be an object.");return r="number"==typeof r?r:5e3,new Promise((function(a,c){var u="string"==typeof o.callbackQuery?o.callbackQuery:"callback",i="string"==typeof o.callbackName?o.callbackName:"jsonp_"+(Math.floor(1e5*Math.random())*Date.now()).toString(16);o[u]=i,delete o.callbackQuery,delete o.callbackName;var s=[];Object.keys(o).forEach((function(t){s=s.concat(e(t,o[t]))}));var l=t(s).join("&"),f=function(){p(),clearTimeout(m),c({status:400,statusText:"Bad Request"})},p=function(){b.removeEventListener("error",f)},d=function(){document.body.removeChild(b),delete window[i]},m=null;r>-1&&(m=setTimeout((function(){p(),d(),c({statusText:"Request Timeout",status:408})}),r)),window[i]=function(e){clearTimeout(m),p(),d(),a(e)};var b=document.createElement("script");b.addEventListener("error",f),b.src=n+(/\?/.test(n)?"&":"?")+l,document.body.appendChild(b)}))}export{n as VueJsonp,o as jsonp}; diff --git a/node_modules/vue-jsonp/dist/index.js b/node_modules/vue-jsonp/dist/index.js new file mode 100644 index 0000000..c5e0aee --- /dev/null +++ b/node_modules/vue-jsonp/dist/index.js @@ -0,0 +1,8 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueJsonp={})}(this,(function(e){"use strict";function t(e,o){e=e.replace(/=/g,"");var n=[];switch(o.constructor){case String:case Number:case Boolean:n.push(encodeURIComponent(e)+"="+encodeURIComponent(o));break;case Array:o.forEach((function(o){n=n.concat(t(e+"[]=",o))}));break;case Object:Object.keys(o).forEach((function(r){var c=o[r];n=n.concat(t(e+"["+r+"]",c))}))}return n}function o(e){var t=[];return e.forEach((function(e){"string"==typeof e?t.push(e):t=t.concat(o(e))})),t} +/** + * Vue Jsonp. + * # Carry Your World # + * + * @author: LancerComet + * @license: MIT + */var n={install:function(e){e.prototype.$jsonp=r}};function r(e,n,r){if(void 0===n&&(n={}),"string"!=typeof e)throw new Error('[Vue-jsonp] Type of param "url" is not string.');if("object"!=typeof n||!n)throw new Error("[Vue-jsonp] Invalid params, should be an object.");return r="number"==typeof r?r:5e3,new Promise((function(c,a){var i="string"==typeof n.callbackQuery?n.callbackQuery:"callback",s="string"==typeof n.callbackName?n.callbackName:"jsonp_"+(Math.floor(1e5*Math.random())*Date.now()).toString(16);n[i]=s,delete n.callbackQuery,delete n.callbackName;var u=[];Object.keys(n).forEach((function(e){u=u.concat(t(e,n[e]))}));var f=o(u).join("&"),l=function(){p(),clearTimeout(b),a({status:400,statusText:"Bad Request"})},p=function(){m.removeEventListener("error",l)},d=function(){document.body.removeChild(m),delete window[s]},b=null;r>-1&&(b=setTimeout((function(){p(),d(),a({statusText:"Request Timeout",status:408})}),r)),window[s]=function(e){clearTimeout(b),p(),d(),c(e)};var m=document.createElement("script");m.addEventListener("error",l),m.src=e+(/\?/.test(e)?"&":"?")+f,document.body.appendChild(m)}))}e.VueJsonp=n,e.jsonp=r,Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/node_modules/vue-jsonp/dist/utils/index.d.ts b/node_modules/vue-jsonp/dist/utils/index.d.ts new file mode 100644 index 0000000..6b2f521 --- /dev/null +++ b/node_modules/vue-jsonp/dist/utils/index.d.ts @@ -0,0 +1,20 @@ +/** + * Generate random string. + * + * @return { string } + */ +declare function randomStr(): string; +/** + * Format params into querying string. + * + * @return {string[]} + */ +declare function formatParams(queryKey: string, value: any): string[]; +/** + * Flat querys. + * + * @param {string[] | (string[])[]} array + * @returns + */ +declare function flatten(array: string[] | (string[])[]): string[]; +export { formatParams, flatten, randomStr }; diff --git a/node_modules/vue-jsonp/package.json b/node_modules/vue-jsonp/package.json new file mode 100644 index 0000000..c3ceeaf --- /dev/null +++ b/node_modules/vue-jsonp/package.json @@ -0,0 +1,80 @@ +{ + "_from": "vue-jsonp", + "_id": "vue-jsonp@2.0.0", + "_inBundle": false, + "_integrity": "sha512-Mzd9GNeuKP5hHFDWZNMWOsCuMILSkA6jo2l4A02wheFz3qqBzH7aSEFTey1BRCZCLizlaf1EqJ5YUtF392KspA==", + "_location": "/vue-jsonp", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "vue-jsonp", + "name": "vue-jsonp", + "escapedName": "vue-jsonp", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/vue-jsonp/-/vue-jsonp-2.0.0.tgz", + "_shasum": "3bfac56bb72941a2511c11e1a123b876f03427f7", + "_spec": "vue-jsonp", + "_where": "C:\\Users\\Administrator\\Documents\\high-mini", + "author": { + "name": "LancerComet", + "email": "chw644@hotmail.com" + }, + "bugs": { + "url": "https://github.com/LancerComet/vue-jsonp/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "A tiny library for handling JSONP request.", + "devDependencies": { + "@types/expect-puppeteer": "^4.4.3", + "@types/jest": "^26.0.14", + "@types/jest-environment-puppeteer": "^4.4.0", + "@types/puppeteer": "^3.0.2", + "jest": "^26.4.2", + "jest-puppeteer": "^4.4.0", + "puppeteer": "^5.3.1", + "rollup": "^2.28.2", + "rollup-plugin-cleanup": "^3.2.1", + "rollup-plugin-delete": "^2.0.0", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-typescript2": "^0.27.3", + "ts-jest": "^26.4.1", + "tslint": "^6.1.3", + "typescript": "^4.0.3", + "vue": "^2.6.12" + }, + "files": [ + "dist/", + "index.d.ts", + "README.md" + ], + "homepage": "https://github.com/LancerComet/vue-jsonp#readme", + "keywords": [ + "Vue", + "JSONP" + ], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist/index.esm.js", + "name": "vue-jsonp", + "repository": { + "type": "git", + "url": "git+https://github.com/LancerComet/vue-jsonp.git" + }, + "scripts": { + "build": "rollup -c", + "prepublish": "npm run test", + "pretest": "npm run build", + "preversion": "npm run test", + "test": "jest" + }, + "version": "2.0.0" +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bfec92c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,16 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "jweixin-module": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz", + "integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w==" + }, + "vue-jsonp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/vue-jsonp/-/vue-jsonp-2.0.0.tgz", + "integrity": "sha512-Mzd9GNeuKP5hHFDWZNMWOsCuMILSkA6jo2l4A02wheFz3qqBzH7aSEFTey1BRCZCLizlaf1EqJ5YUtF392KspA==" + } + } +} diff --git a/pages.json b/pages.json index bf32f65..0eaad5f 100644 --- a/pages.json +++ b/pages.json @@ -3,7 +3,13 @@ { "path": "pages/index/index", "style": { - "navigationBarTitleText": "uni-app" + "navigationBarTextStyle": "white", + "navigationBarTitleText": "首页", + "onReachBottomDistance": 50, + "app-plus": { + "titleNView": false, //禁用原生导航栏 + "softinputNavBar": "none" + } } } ], diff --git a/pages/index/index.vue b/pages/index/index.vue index 67fbf3a..5aff822 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,140 +1,464 @@ - - - - - diff --git a/static/index1.png b/static/index1.png new file mode 100644 index 0000000..5e17c16 Binary files /dev/null and b/static/index1.png differ diff --git a/static/index2.png b/static/index2.png new file mode 100644 index 0000000..120a1a8 Binary files /dev/null and b/static/index2.png differ diff --git a/static/jt.png b/static/jt.png new file mode 100644 index 0000000..e82b724 Binary files /dev/null and b/static/jt.png differ diff --git a/static/noorder.png b/static/noorder.png new file mode 100644 index 0000000..dd772b3 Binary files /dev/null and b/static/noorder.png differ diff --git a/uni.scss b/uni.scss index a9a742d..802eedf 100644 --- a/uni.scss +++ b/uni.scss @@ -38,39 +38,708 @@ $uni-border-color:#c8c7cc; /* 尺寸变量 */ -/* 文字尺寸 */ -$uni-font-size-sm:12px; -$uni-font-size-base:14px; -$uni-font-size-lg:16; - -/* 图片尺寸 */ -$uni-img-size-sm:20px; -$uni-img-size-base:26px; -$uni-img-size-lg:40px; - -/* Border Radius */ -$uni-border-radius-sm: 2px; -$uni-border-radius-base: 3px; -$uni-border-radius-lg: 6px; -$uni-border-radius-circle: 50%; - -/* 水平间距 */ -$uni-spacing-row-sm: 5px; -$uni-spacing-row-base: 10px; -$uni-spacing-row-lg: 15px; - -/* 垂直间距 */ -$uni-spacing-col-sm: 4px; -$uni-spacing-col-base: 8px; -$uni-spacing-col-lg: 12px; - -/* 透明度 */ -$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 - -/* 文章场景相关 */ -$uni-color-title: #2C405A; // 文章标题颜色 -$uni-font-size-title:20px; -$uni-color-subtitle: #555555; // 二级标题颜色 -$uni-font-size-subtitle:26px; -$uni-color-paragraph: #3F536E; // 文章段落颜色 -$uni-font-size-paragraph:15px; +/* 文字尺寸 */ +$uni-font-size-sm:24upx; +$uni-font-size-base:28upx; +$uni-font-size-lg:32upx; + +/* 图片尺寸 */ +$uni-img-size-sm:40upx; +$uni-img-size-base:52upx; +$uni-img-size-lg:80upx; + +/* Border Radius */ +$uni-border-radius-sm: 4upx; +$uni-border-radius-base: 6upx; +$uni-border-radius-lg: 12upx; +$uni-border-radius-circle: 50%; + +/* 水平间距 */ +$uni-spacing-row-sm: 10px; +$uni-spacing-row-base: 20upx; +$uni-spacing-row-lg: 30upx; + +/* 垂直间距 */ +$uni-spacing-col-sm: 8upx; +$uni-spacing-col-base: 16upx; +$uni-spacing-col-lg: 24upx; + +/* 透明度 */ +$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 + +/* 文章场景相关 */ +$uni-color-title: #2C405A; // 文章标题颜色 +$uni-font-size-title:40upx; +$uni-color-subtitle: #555555; // 二级标题颜色 +$uni-font-size-subtitle:36upx; +$uni-color-paragraph: #3F536E; // 文章段落颜色 +$uni-font-size-paragraph:30upx; + +/* 字体大小 */ +.font11 { + font-size: 11px; +} +.font12 { + font-size: 12px; +} + +.font13 { + font-size: 13px; +} + +.fontlet{ + letter-spacing: 2px; +} + +.font14 { + font-size: 14px; +} + +.font15 { + font-size: 15px; +} + +.font16 { + font-size: 16px; +} + +.font18 { + font-size: 18px; +} + +.font20 { + font-size: 20px; +} + +.font24 { + font-size: 24px; +} + +.font28 { + font-size: 28px; +} + +.font40 { + font-size: 40px; +} + +.font48 { + font-size: 48px; +} + + +// 字体加粗 +.fontwig6{ + font-weight: bold; +} +/* 字体间距 */ +.fontspec { + letter-spacing: 1px; +} + +.fontspec10 { + letter-spacing: 10px; +} + + +/* 字体行间距 */ +.linehet { + line-height: 20px; +} + +/* 字体位置 */ +.fotlt { + text-align: left; +} + +.fotrt { + text-align: right; +} + +.fotct { + text-align: center; +} + +.margle { + margin-left: 6px; +} + +.margle20 { + margin-left: 20px; +} + +.marglerig{ + margin-right: 5px; +} +.marRight20{ + margin-right: 20px; +} + + +.verc { + vertical-align: middle; +} + +.versub { + vertical-align: sub; +} + +.text1 { + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + text-overflow: ellipsis; +} + + +.text2 { + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + text-overflow: ellipsis; +} + +/* 字体颜色 */ +.fcor333 { + color: #333333; +} + +.fcorfff { + color: #ffffff; +} + +.fcor666 { + color: #666666; +} + +.fcor999 { + color: #b2b2b2; +} + +.fcor089 { + color: #089bf5; +} + +.fcoreb5 { + color: #eb5823; +} + +.fcorred{ + color: red; +} + +.fcor41c{ + color: #41cda2; +} + +/* 背景颜色 */ +.backcor9 { + background-color: #f6f6f6; +} + +//渐变 +.backcorlr{ + background: linear-gradient(to right, #fe1a1a, #ff722e); +} + +.backcor9 { + background-color: #f6f6f6; +} + +.backcor008{ + background-color: #0083f5; +} + + +.backcor89 { + background-color: #089bf5; +} + +.backcorfff { + background-color: white; +} + +.backshare { + background: rgba(0, 0, 0, 0); +} + +/* 页面布局 */ +.width90 { + width: 90%; + margin-left: 5%; +} + +.width96 { + width: 96%; + margin-left: 2%; +} + +.width94 { + width: 94%; + margin-left: 3%; +} +.width92 { + width: 92%; + margin-left: 4%; +} + + +.width80 { + width: 80%; + margin-left: 10%; +} + + +.width80p { + width: 80%; +} + + +.width70 { + width: 70%; +} + +.width85 { + width: 85%; +} + + +.width50 { + width: 50%; +} + +.width40 { + width: 40%; +} + +.width60 { + width: 60% +} + +.width60w { + width: 60%; + margin-left: 20%; +} + +.width40w { + width: 40%; + margin-left: 30%; +} + +.width20w { + width: 20%; + margin-left: 40%; +} + +.width35 { + width: 35%; +} + +.width30 { + width: 30%; +} + +.width20 { + width: 20%; +} + +.width25 { + width: 25%; +} + +.width15 { + width: 15%; +} +.width8 { + width: 8%; +} + + +.width95 { + width: 95%; +} + +.width100 { + width: 100%; +} + +.bor-botm1 { + border-bottom: 1px solid #f4f4f4; +} + +/* 高40px */ +.height40p { + height: 40px; +} +.height45 { + height: 45px; +} + +.height22{ + height: 22px; +} + +.height100 { + height: 100%; +} + + +.height10 { + height: 10px; +} + + +.height60 { + height: 60px; +} + + +.height70 { + height: 70px; +} + +.height80 { + height: 80px; +} + + + +.height90 { + height: 90px; +} + + +.height100p { + height: 100px; +} + +.height110 { + height: 110px; +} + +.height120{ + height: 120px; +} + +.height130{ + height: 130px; +} + +.height150{ + height: 150px; +} + +.height180{ + height: 180px; +} + +.height220{ + height: 220px; +} + +.height30 { + height: 30px; + line-height: 30px; +} + +.height40 { + height: 40px; + line-height: 40px; +} + +.height45l { + height: 45px; + line-height: 45px; +} + +.heightl60 { + height: 60px; + line-height: 60px; +} + + +.height20 { + height: 20px; + line-height: 20px; +} +.height25 { + height: 25px; +} + +.height20 { + height: 20px; + line-height: 20px; +} + + +.height50 { + height: 50px; + line-height: 50px; +} + +/* 向上下外间距 */ + +.margle10{ + margin-left: 10px; +} +.mart90 { + margin-top: 90px; +} + +.mart80{ + margin-top: 80px; +} + +.mart70{ + margin-top: 70px; +} +.mart60{ + margin-top: 60px; +} + +.mart50 { + margin-top: 50px; +} + +.mart40 { + margin-top: 40px; +} + +.mart30 { + margin-top: 30px; +} + +.mart15 { + margin-top: 15px; +} + +.mart20 { + margin-top: 20px; +} + +.mart10 { + margin-top: 10px; +} + +.mart5 { + margin-top: 5px; +} + +.mart1 { + margin-top: 1px; +} + +.marb65 { + margin-bottom: 65px; +} + +.marb50 { + margin-bottom: 50px; +} + +.marb40 { + margin-bottom: 40px; +} + +.marb30 { + margin-bottom: 30px; +} + +.marb20 { + margin-bottom: 20px; +} + +.marb10 { + margin-bottom: 10px; +} + +.marb5 { + margin-bottom: 5px; +} + + +/* 向上下内间距 */ +.paddtop5 { + padding-top: 5px; +} +.paddtop10 { + padding-top: 10px; +} +.paading10{ + padding : 10px; +} + +.paddtop13 { + padding-top: 13px; +} + +.paddtop15 { + padding-top: 15px; +} +.paddtop20 { + padding-top: 20px; +} + +.paddtop25 { + padding-top: 25px; +} + +.paddtop40 { + padding-top: 40px; +} + +.paddleft5 { + padding-left: 5px; +} + +.paddleft10 { + padding-left: 10px; +} + +.padleft15 { + padding-left: 15px; +} + +.paddtright5 { + padding-right: 5px; +} + + +.paddtright10 { + padding-right: 10px; +} + +.paddtright15 { + padding-right: 15px; +} + +.paddbotm10 { + padding-bottom: 10px; +} + +/* 左悬浮 */ +.flleft { + float: left; +} + +/* 右悬浮 */ +.flright { + float: right; +} + +/** + * 圆角 + */ +.border-r{ + border-radius: 5px; +} + +/* button样式 */ +.btnw70 { + width: 70%; + color: white; + margin-top: 40px; + background-color: #089bf5; + border-radius: 6px; +} + +.btnw50 { + width: 50%; + margin-left: 25%; + height: 45px; + line-height: 45px; + color: white; + text-align: center; + margin-top: 40px; + background-color: #0083f5; + border-radius: 6px; +} + +/* 下滑线 */ +.line1 { + height: 1px; + background-color: #f1f1f1; +} + +.linec6 { + height: 1px; + background-color: #f1f1f1; +} + +.line10 { + height: 10px; + background-color: #f4f4f4; +} + +.line1089 { + height: 10px; + background-color: #089bf5; +} + +/* 展示样式 */ +.displ { + display: inline-block; +} + +.aliitem{ + align-items: center; + display: flex; +} + +.alijun{ + justify-content: flex-end; + display: flex; +} + +.font12{ + font-size: 12px; +} + + +.aliitem{ + align-items: center; + display: flex; +} + +.alijun{ + justify-content: flex-end; + display: flex; +} + +.alijusstart{ + justify-content: flex-start; + align-items: center; + display: flex; +} + +.alijusend{ + justify-content: flex-end; + align-items: center; + display: flex; +} + +.alicntend{ + justify-content: end; + align-items: center; + display: flex; +} + +.alijus{ + justify-content: center; + align-items: center; + display: flex; +} + +.iconw{ + width: 15px; +} + +.iconw25{ + width: 25px; +} + +.iconw40{ + width: 40px; +} \ No newline at end of file diff --git a/uni_modules/uni-pay/README.md b/uni_modules/uni-pay/README.md new file mode 100644 index 0000000..9e3f723 --- /dev/null +++ b/uni_modules/uni-pay/README.md @@ -0,0 +1,43 @@ +## 简介 + +`uni-pay`为`uniCloud`开发者提供了简单、易用、统一的支付能力封装。让开发者无需研究支付宝、微信等支付平台的后端开发、无需为它们编写不同代码,拿来即用,屏蔽差异。 + +`uni-app`前端已经封装的全端支付 api `uni.requestPayment`,现在服务端也封装好了`uni-pay for uniCloud`,从此开发者可以极快的完成前后一体的支付业务。 + +目前已封装 App 端(微信支付和支付宝支付)、微信小程序、支付宝小程序的支付能力。 + +`uni-pay`是开源 sdk,可放心使用。本插件还包含示例工程,配置自己在微信和支付宝申请的相关配置后即可运行。 + +对于`uni-pay`还未封装的支付能力,欢迎大家在开源项目上提交pr,共同完善这个开源项目。 + +详细Api请参考:[uni-pay](https://uniapp.dcloud.io/uniCloud/unipay) + +## 示例项目使用说明 + +1. 首先在`cloudfunctions/common/uni-config-center/uni-pay/config.js`内填写各个平台所需的配置。 + +**示例项目已集成[uni-id](https://ext.dcloud.net.cn/plugin?id=2116),需在`cloudfunctions/common/uni-config-center/uni-id/config.json`内填写支付宝小程序、微信小程序登录相关信息** + +如需开通对应平台的支付能力请参考以下文档 + +- [支付宝小程序开通支付](https://opendocs.alipay.com/mini/introduce/pay) +- [App接入支付宝支付](https://opendocs.alipay.com/open/204/105297/) +- [接入微信支付](https://pay.weixin.qq.com/index.php/apply/applyment_home/guide_normal#none) + +**注意** + +- 商户认证不支持个人类型的账号。 +- 微信的App支付、小程序支付、H5支付是不同的体系。微信小程序支付在 微信商户平台 申请支付时,选择公众号支付; + +2. 在`cloudfunctions`目录右键选择服务空间 +3. 上传公用模块,公用模块用法请参考:[云函数公用模块](https://uniapp.dcloud.io/uniCloud/cf-common) +4. 上传所有云函数 +5. 在`cloudfunctions/db_init.json`上右键初始化数据库 +6. 在项目内的`manifest.json`内配置App端支付参数或者微信小程序appid,[manifest.json里配置App支付相关参数](https://uniapp.dcloud.io/api/plugins/payment?id=manifestjson%e9%87%8c%e9%85%8d%e7%bd%ae%e7%9b%b8%e5%85%b3%e5%8f%82%e6%95%b0) +7. 如果是运行到App端请使用云打包制作自定义基座来测试,其他平台直接运行即可 + +## 支付流程说明 + +下面的流程图很好的展示了示例项目的支付流程 + +![](https://img.cdn.aliyun.dcloud.net.cn/uni-app/uniCloud/uni-pay-flow-chart.jpg) \ No newline at end of file diff --git a/uni_modules/uni-pay/changelog.md b/uni_modules/uni-pay/changelog.md new file mode 100644 index 0000000..9e5140d --- /dev/null +++ b/uni_modules/uni-pay/changelog.md @@ -0,0 +1,37 @@ +## 1.0.28(2022-01-10) +- 支付宝下单接口返回详细错误信息 +- 优化发行包体积 +## 1.0.27(2021-11-02) +- 新增 苹果应用内购买凭证校验接口 [详情](https://uniapp.dcloud.io/uniCloud/unipay?id=verifyreceipt) +## 1.0.26(2021-11-01) +- 新增 苹果内购凭证校验接口 +## 1.0.25(2021-10-18) +- 修复微信子商户id参数错误的Bug +## 1.0.24(2021-09-23) +- 新增 微信外部浏览器支付(H5支付) +## 1.0.23(2021-09-22) +- 修复微信支付部分值被转化为NaN导致无法直接入库的错误 +## 1.0.22(2021-08-26) +- 修复 支付宝用户未支付状态下查询订单状态(orderQuery)报错的Bug +## 1.0.21(2021-08-19) +- 修复1.0.18版本引出的微信退款通知验签失败的bug +## 1.0.20(2021-08-04) +- 修复1.0.19版本引出的微信支付签名错误问题 +## 1.0.19(2021-08-03) +- 修复timeStamp大小写导致的微信公众号支付失败 +## 1.0.18(2021-07-16) +- 通知类型不匹配时返回校验未通过 +## 1.0.17(2021-07-16) +- 新增 支付宝退款通知回调 [详情](https://uniapp.dcloud.io/uniCloud/unipay?id=verify-refund-notify) +- 新增 判断通知类型接口 [详情](https://uniapp.dcloud.io/uniCloud/unipay?id=check-notify-type) +## 1.0.16(2021-07-14) +- 修复APP微信支付报签名错误的Bug +## 1.0.15(2021-07-13) +- 修复1.0.14版本引出的微信支付使用pfx时报错的Bug +## 1.0.14(2021-07-12) +- 支持使用微信子商户号,[详情](https://uniapp.dcloud.net.cn/uniCloud/unipay?id=init),感谢[studytime](https://gitee.com/studytime) +- 修复支付宝支付传入encode后的passbackParams参数导致验签无法通过的Bug +## 1.0.13(2021-03-25) +- 修复 微信退款通知解析报错的Bug +## 1.0.12(2021-02-03) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-pay/package.json b/uni_modules/uni-pay/package.json new file mode 100644 index 0000000..19c2278 --- /dev/null +++ b/uni_modules/uni-pay/package.json @@ -0,0 +1,83 @@ +{ + "id": "uni-pay", + "displayName": "uni-pay", + "version": "1.0.28", + "description": "更简单的支付接口调用方式、拉齐不同支付平台", + "keywords": [ + "unipay", + "uni-pay", + "微信支付", + "支付宝" +], + "repository": "https://gitee.com/dcloud/uniPay.git", + "engines": { + "HBuilderX": "^3.1.0" + }, + "dcloudext": { + "category": [ + "uniCloud", + "云函数模板" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "u", + "app-nvue": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-pay/uniCloud/cloudfunctions/common/uni-pay/LICENSE.md b/uni_modules/uni-pay/uniCloud/cloudfunctions/common/uni-pay/LICENSE.md new file mode 100644 index 0000000..29f81d8 --- /dev/null +++ b/uni_modules/uni-pay/uniCloud/cloudfunctions/common/uni-pay/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/uni_modules/uni-pay/uniCloud/cloudfunctions/common/uni-pay/index.js b/uni_modules/uni-pay/uniCloud/cloudfunctions/common/uni-pay/index.js new file mode 100644 index 0000000..d4631bc --- /dev/null +++ b/uni_modules/uni-pay/uniCloud/cloudfunctions/common/uni-pay/index.js @@ -0,0 +1,8 @@ +!function(e,t){for(var r in t)e[r]=t[r]}(exports,function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=12)}([function(e,t){e.exports=require("crypto")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={FormData:!0,UniCloudError:!0};Object.defineProperty(t,"FormData",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(t,"UniCloudError",{enumerable:!0,get:function(){return s.default}});var i=u(r(15)),s=u(r(16)),a=r(17);Object.keys(a).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}}))}));var o=r(2);function u(e){return e&&e.__esModule?e:{default:e}}Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasOwn=s,t.isPlainObject=a,t.isFn=function(e){return"function"==typeof e},t.deepClone=function(e){return JSON.parse(JSON.stringify(e))},t.getExtension=function(e){return o[e]},t.snake2camel=l,t.camel2snake=f,t.snake2camelJson=function(e){return h(e,"snake2camel")},t.camel2snakeJson=function(e){return h(e,"camel2snake")},t.getOffsetDate=function(e){return new Date(Date.now()+6e4*((new Date).getTimezoneOffset()+60*(e||0)))},t.getDateStr=p,t.getTimeStr=d,t.getFullTimeStr=function(e){return p(e=e||new Date)+" "+d(e)},t.log=function(){0},t.accMul=function(e,t){if(isNaN(e)||isNaN(t))return NaN;const{value:r,power:n}=y(e),{value:i,power:s}=y(t);return r*i/Math.pow(10,n+s)},t.mime2ext=void 0;const n=Object.prototype.toString,i=Object.prototype.hasOwnProperty;function s(e,t){return i.call(e,t)}function a(e){return"[object Object]"===n.call(e)}const o={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/svg+xml":"svg","image/bmp":"bmp","image/webp":"webp"};t.mime2ext=o;const u=/_(\w)/g,c=/[A-Z]/g;function l(e){return e.replace(u,(e,t)=>t?t.toUpperCase():"")}function f(e){return e.replace(c,e=>"_"+e.toLowerCase())}function h(e,t){let r,n;switch(t){case"snake2camel":n=l,r=u;break;case"camel2snake":n=f,r=c}for(const i in e)if(s(e,i)&&r.test(i)){const r=n(i);e[r]=e[i],delete e[i],a(e[r])?e[r]=h(e[r],t):Array.isArray(e[r])&&(e[r]=e[r].map(e=>h(e,t)))}return e}function p(e,t="-"){e=e||new Date;const r=[];return r.push(e.getFullYear()),r.push(("00"+(e.getMonth()+1)).substr(-2)),r.push(("00"+e.getDate()).substr(-2)),r.join(t)}function d(e,t=":"){e=e||new Date;const r=[];return r.push(("00"+e.getHours()).substr(-2)),r.push(("00"+e.getMinutes()).substr(-2)),r.push(("00"+e.getSeconds()).substr(-2)),r.join(t)}function y(e){const t=e.toString().split("."),r=t[1]?t[1].length:0;return{value:Number(t.join("")),power:r}}},function(e,t){e.exports=require("util")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(39);t.bytesFromIP=function(e){switch(n.isIP(e)){case 4:return Buffer.from(e.split(".").map(e=>parseInt(e,10)));case 6:const t=e.split(":"),r=Buffer.alloc(16);let n=0;""===t[t.length-1]&&(t[t.length-1]="0");for(let e=0;es&&(s=n,i=r)):(r=-1,n=0),t.push(o.toString(16))}if(s>0){let e="";const r=t.slice(i+s);t.length=i,0===t.length&&(e+=":"),0===r.length&&(e+=":"),t.push(e,...r)}return t.join(":");default:return""}};const i=Object.create(null),s=/^[0-9.]+$/;function a(e,t){i[e]=t,i[t]=e}t.getOID=function(e){return s.test(e)&&""!==i[e]?e:null==i[e]?"":i[e]},t.getOIDName=function(e){return s.test(e)||""===i[e]?null==i[e]?e:i[e]:e},a("1.2.840.113549.1.1.1","rsaEncryption"),a("1.2.840.113549.1.1.4","md5WithRsaEncryption"),a("1.2.840.113549.1.1.5","sha1WithRsaEncryption"),a("1.2.840.113549.1.1.8","mgf1"),a("1.2.840.113549.1.1.10","RSASSA-PSS"),a("1.2.840.113549.1.1.11","sha256WithRsaEncryption"),a("1.2.840.113549.1.1.12","sha384WithRsaEncryption"),a("1.2.840.113549.1.1.13","sha512WithRsaEncryption"),a("1.2.840.10045.2.1","ecEncryption"),a("1.2.840.10045.4.1","ecdsaWithSha1"),a("1.2.840.10045.4.3.2","ecdsaWithSha256"),a("1.2.840.10045.4.3.3","ecdsaWithSha384"),a("1.2.840.10045.4.3.4","ecdsaWithSha512"),a("1.2.840.10040.4.3","dsaWithSha1"),a("2.16.840.1.101.3.4.3.2","dsaWithSha256"),a("1.3.14.3.2.7","desCBC"),a("1.3.14.3.2.26","sha1"),a("2.16.840.1.101.3.4.2.1","sha256"),a("2.16.840.1.101.3.4.2.2","sha384"),a("2.16.840.1.101.3.4.2.3","sha512"),a("1.2.840.113549.2.5","md5"),a("1.3.101.110","X25519"),a("1.3.101.111","X448"),a("1.3.101.112","Ed25519"),a("1.3.101.113","Ed448"),a("1.2.840.113549.1.7.1","data"),a("1.2.840.113549.1.7.2","signedData"),a("1.2.840.113549.1.7.3","envelopedData"),a("1.2.840.113549.1.7.4","signedAndEnvelopedData"),a("1.2.840.113549.1.7.5","digestedData"),a("1.2.840.113549.1.7.6","encryptedData"),a("1.2.840.113549.1.9.1","emailAddress"),a("1.2.840.113549.1.9.2","unstructuredName"),a("1.2.840.113549.1.9.3","contentType"),a("1.2.840.113549.1.9.4","messageDigest"),a("1.2.840.113549.1.9.5","signingTime"),a("1.2.840.113549.1.9.6","counterSignature"),a("1.2.840.113549.1.9.7","challengePassword"),a("1.2.840.113549.1.9.8","unstructuredAddress"),a("1.2.840.113549.1.9.14","extensionRequest"),a("1.2.840.113549.1.9.20","friendlyName"),a("1.2.840.113549.1.9.21","localKeyId"),a("1.2.840.113549.1.9.22.1","x509Certificate"),a("1.2.840.113549.1.12.10.1.1","keyBag"),a("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),a("1.2.840.113549.1.12.10.1.3","certBag"),a("1.2.840.113549.1.12.10.1.4","crlBag"),a("1.2.840.113549.1.12.10.1.5","secretBag"),a("1.2.840.113549.1.12.10.1.6","safeContentsBag"),a("1.2.840.113549.1.5.13","pkcs5PBES2"),a("1.2.840.113549.1.5.12","pkcs5PBKDF2"),a("1.2.840.113549.2.7","hmacWithSha1"),a("1.2.840.113549.2.9","hmacWithSha256"),a("1.2.840.113549.2.10","hmacWithSha384"),a("1.2.840.113549.2.11","hmacWithSha512"),a("1.2.840.113549.3.7","3desCBC"),a("2.16.840.1.101.3.4.1.2","aesCBC128"),a("2.16.840.1.101.3.4.1.42","aesCBC256"),a("2.5.4.3","commonName"),a("2.5.4.5","serialName"),a("2.5.4.6","countryName"),a("2.5.4.7","localityName"),a("2.5.4.8","stateOrProvinceName"),a("2.5.4.10","organizationName"),a("2.5.4.11","organizationalUnitName"),a("2.5.4.15","businessCategory"),a("2.16.840.1.113730.1.1","nsCertType"),a("2.5.29.2","keyAttributes"),a("2.5.29.4","keyUsageRestriction"),a("2.5.29.6","subtreesConstraint"),a("2.5.29.9","subjectDirectoryAttributes"),a("2.5.29.14","subjectKeyIdentifier"),a("2.5.29.15","keyUsage"),a("2.5.29.16","privateKeyUsagePeriod"),a("2.5.29.17","subjectAltName"),a("2.5.29.18","issuerAltName"),a("2.5.29.19","basicConstraints"),a("2.5.29.20","cRLNumber"),a("2.5.29.21","cRLReason"),a("2.5.29.22","expirationDate"),a("2.5.29.23","instructionCode"),a("2.5.29.24","invalidityDate"),a("2.5.29.27","deltaCRLIndicator"),a("2.5.29.28","issuingDistributionPoint"),a("2.5.29.29","certificateIssuer"),a("2.5.29.30","nameConstraints"),a("2.5.29.31","cRLDistributionPoints"),a("2.5.29.32","certificatePolicies"),a("2.5.29.33","policyMappings"),a("2.5.29.35","authorityKeyIdentifier"),a("2.5.29.36","policyConstraints"),a("2.5.29.37","extKeyUsage"),a("2.5.29.46","freshestCRL"),a("2.5.29.54","inhibitAnyPolicy"),a("1.3.6.1.4.1.311.60.2.1.2","jurisdictionST"),a("1.3.6.1.4.1.311.60.2.1.3","jurisdictionC"),a("1.3.6.1.4.1.11129.2.4.2","timestampList"),a("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),a("1.3.6.1.5.5.7.3.1","serverAuth"),a("1.3.6.1.5.5.7.3.2","clientAuth"),a("1.3.6.1.5.5.7.3.3","codeSigning"),a("1.3.6.1.5.5.7.3.4","emailProtection"),a("1.3.6.1.5.5.7.3.8","timeStamping"),a("1.3.6.1.5.5.7.48.1","authorityInfoAccessOcsp"),a("1.3.6.1.5.5.7.48.2","authorityInfoAccessIssuers")},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";const n=e=>!("object"!=typeof e||null===e||e instanceof RegExp||e instanceof Error||e instanceof Date);e.exports=function e(t,r,i,s){if(i=Object.assign({deep:!1,target:{}},i),(s=s||new WeakMap).has(t))return s.get(t);s.set(t,i.target);const a=i.target;delete i.target;for(const o of Object.keys(t)){const u=t[o],c=r(o,u,t);let l=c[1];i.deep&&n(l)&&(l=Array.isArray(l)?l.map(t=>n(t)?e(t,r,i,s):t):e(l,r,i,s)),a[c[0]]=l}return a}},function(e,t,r){"use strict";var n=r(6),i=r(31);e.exports=function(e,t){return t=Object.assign({deep:!0},t),n(e,(function(e,t){return[i(e),t]}),t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),i=r(34),s=r(35),a=r(7),o={RSA:"RSA-SHA1",RSA2:"RSA-SHA256"};t.ALIPAY_ALGORITHM_MAPPING=o,t.sign=function(e,t={},r){const u=t.bizContent||null;delete t.bizContent;let c=Object.assign({method:e,appId:r.appId,charset:r.charset,version:r.version,signType:r.signType,timestamp:i().format("YYYY-MM-DD HH:mm:ss")},t);r.appCertSn&&r.alipayRootCertSn&&(c=Object.assign({appCertSn:r.appCertSn,alipayRootCertSn:r.alipayRootCertSn},c)),u&&(c.bizContent=JSON.stringify(a(u)));const l=a(c),f=Object.keys(l).sort().map(e=>{let t=l[e];return"[object String]"!==Array.prototype.toString.call(t)&&(t=JSON.stringify(t)),`${e}=${s.encode(t,r.charset)}`}).join("&"),h=n.createSign(o[r.signType]).update(f,"utf8").sign(r.privateKey,"base64");return Object.assign(l,{sign:h})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(3),i=r(0),s=r(40),a=r(10),o=r(4);t.publicKeyValidator={name:"PublicKeyInfo",class:a.Class.UNIVERSAL,tag:a.Tag.SEQUENCE,capture:"publicKeyInfo",value:[{name:"PublicKeyInfo.AlgorithmIdentifier",class:a.Class.UNIVERSAL,tag:a.Tag.SEQUENCE,value:[{name:"PublicKeyAlgorithmIdentifier.algorithm",class:a.Class.UNIVERSAL,tag:a.Tag.OID,capture:"publicKeyOID"}]},{name:"PublicKeyInfo.PublicKey",class:a.Class.UNIVERSAL,tag:a.Tag.BITSTRING,capture:"publicKey"}]},t.privateKeyValidator={name:"PrivateKeyInfo",class:a.Class.UNIVERSAL,tag:a.Tag.SEQUENCE,capture:"privateKeyInfo",value:[{name:"PrivateKeyInfo.Version",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.AlgorithmIdentifier",class:a.Class.UNIVERSAL,tag:a.Tag.SEQUENCE,value:[{name:"PrivateKeyAlgorithmIdentifier.algorithm",class:a.Class.UNIVERSAL,tag:a.Tag.OID,capture:"privateKeyOID"}]},{name:"PrivateKeyInfo.PrivateKey",class:a.Class.UNIVERSAL,tag:a.Tag.OCTETSTRING,capture:"privateKey"}]};const u={name:"RSAPublicKey",class:a.Class.UNIVERSAL,tag:a.Tag.SEQUENCE,value:[{name:"RSAPublicKey.modulus",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"publicKeyExponent"}]},c={name:"RSAPrivateKey",class:a.Class.UNIVERSAL,tag:a.Tag.SEQUENCE,value:[{name:"RSAPrivateKey.version",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",class:a.Class.UNIVERSAL,tag:a.Tag.INTEGER,capture:"privateKeyCoefficient"}]},l=[o.getOID("X25519"),o.getOID("X448"),o.getOID("Ed25519"),o.getOID("Ed448")];class f{constructor(e){const r={},n=e.validate(t.publicKeyValidator,r);if(null!=n)throw new Error("Cannot read X.509 public key: "+n.message);this.oid=a.ASN1.parseOID(r.publicKeyOID.bytes),this.algo=o.getOIDName(this.oid),this._pkcs8=e,this._keyRaw=a.ASN1.parseBitString(r.publicKey.bytes).buf,this._finalKey=this._keyRaw,this._finalPEM=""}static fromPEM(e){const t=a.PEM.parse(e)[0];if(t.procType.includes("ENCRYPTED"))throw new Error("Could not convert public key from PEM, PEM is encrypted.");const r=a.ASN1.fromDER(t.body,!0);switch(t.type){case"PUBLIC KEY":return new f(r);case"RSA PUBLIC KEY":const e=a.ASN1.Seq([a.ASN1.Seq([a.ASN1.OID(o.getOID("rsaEncryption")),a.ASN1.Null()]),a.ASN1.BitString(r.DER)]);return new f(e);default:throw new Error("Could not convert public key from PEM, recommend PKCS#8 PEM")}}static addVerifier(e,t){if(""===(e=o.getOID(e)))throw new Error("Invalid object identifier: "+e);if(null!=f._verifiers[e])throw new Error(`Verifier ${e} exists`);f._verifiers[e]=t}get keyRaw(){return this._finalKey}verify(e,t,r){const n=f._verifiers[this.oid];if(null!=n){const s=i.createHash(r).update(e).digest();return n.call(this,s,t)}const s=i.createVerify(r);return s.update(e),s.verify(this.toPEM(),t)}getFingerprint(e,t="PublicKey"){let r;switch(t){case"PublicKeyInfo":r=this._pkcs8.DER;break;case"PublicKey":r=this._keyRaw;break;default:throw new Error(`Unknown fingerprint type "${t}".`)}const n=i.createHash(e);return n.update(r),n.digest()}toASN1(){return this._pkcs8}toDER(){return this._pkcs8.DER}toPEM(){return""===this._finalPEM&&(this._finalPEM=new a.PEM("PUBLIC KEY",this._pkcs8.DER).toString()),this._finalPEM}toJSON(){return{oid:this.oid,algo:this.algo,publicKey:this._keyRaw}}[n.inspect.custom](e,t){return`<${this.constructor.name} ${n.inspect(this.toJSON(),t)}>`}}f._verifiers=Object.create(null),t.PublicKey=f;class h{constructor(e){const r=Object.create(null),n=e.validate(t.privateKeyValidator,r);if(null!=n)throw new Error("Cannot read X.509 private key: "+n.message);if(this.version=a.ASN1.parseIntegerNum(r.privateKeyVersion.bytes)+1,this.oid=a.ASN1.parseOID(r.privateKeyOID.bytes),this.algo=o.getOIDName(this.oid),this._pkcs8=e,this._keyRaw=r.privateKey.bytes,this._publicKeyRaw=null,this._finalKey=this._keyRaw,this._finalPEM="",l.includes(this.oid))if(this._finalKey=this._keyRaw=a.ASN1.parseDER(this._keyRaw,a.Class.UNIVERSAL,a.Tag.OCTETSTRING).bytes,"1.3.101.112"===this.oid){const e=s.sign.keyPair.fromSeed(this._keyRaw);this._publicKeyRaw=Buffer.from(e.publicKey),this._finalKey=Buffer.from(e.secretKey)}else if(2===this.version)for(const t of e.mustCompound())t.class===a.Class.CONTEXT_SPECIFIC&&1===t.tag&&(this._publicKeyRaw=a.ASN1.parseBitString(t.bytes).buf,this._finalKey=Buffer.concat([this._keyRaw,this._publicKeyRaw]))}static fromPEM(e){const t=a.PEM.parse(e)[0];if(t.procType.includes("ENCRYPTED"))throw new Error("Could not convert private key from PEM, PEM is encrypted.");let r=a.ASN1.fromDER(t.body,!0);switch(t.type){case"PRIVATE KEY":return new h(r);case"RSA PRIVATE KEY":return r=a.ASN1.Seq([r.value[0],a.ASN1.Seq([a.ASN1.OID(o.getOID("rsaEncryption")),a.ASN1.Null()]),new a.ASN1(a.Class.UNIVERSAL,a.Tag.OCTETSTRING,r.DER)]),new h(r);default:throw new Error("Could not convert private key from PEM, recommend PKCS#8 PEM")}}static addSigner(e,t){if(""===(e=o.getOID(e)))throw new Error("Invalid object identifier: "+e);if(null!=h._signers[e])throw new Error(`Signer ${e} exists`);h._signers[e]=t}get keyRaw(){return this._finalKey}get publicKeyRaw(){return this._publicKeyRaw}sign(e,t){const r=h._signers[this.oid];if(null!=r){const n=i.createHash(t).update(e).digest();return r.call(this,n)}const n=i.createSign(t);return n.update(e),n.sign(this.toPEM())}toASN1(){return this._pkcs8}toDER(){return this._pkcs8.DER}toPEM(){return""===this._finalPEM&&(this._finalPEM=new a.PEM("PRIVATE KEY",this._pkcs8.DER).toString()),this._finalPEM}toJSON(){return{version:this.version,oid:this.oid,algo:this.algo,privateKey:this._keyRaw,publicKey:this._publicKeyRaw}}[n.inspect.custom](e,t){return`<${this.constructor.name} ${n.inspect(this.toJSON(),t)}>`}}h._signers=Object.create(null),t.PrivateKey=h;class p extends f{static fromPublicKey(e){return new p(e.toASN1())}constructor(e){if(super(e),o.getOID(this.oid)!==o.getOID("rsaEncryption"))throw new Error("Invalid RSA public key, unknown OID: "+this.oid);const t=Object.create(null);this._pkcs1=a.ASN1.fromDER(this._keyRaw,!0);const r=this._pkcs1.validate(u,t);if(null!=r)throw new Error("Cannot read RSA public key: "+r.message);this.modulus=a.ASN1.parseIntegerStr(t.publicKeyModulus.bytes),this.exponent=a.ASN1.parseIntegerNum(t.publicKeyExponent.bytes)}toASN1(){return this._pkcs1}toDER(){return this._keyRaw}toPEM(){return""===this._finalPEM&&(this._finalPEM=new a.PEM("RSA PUBLIC KEY",this._keyRaw).toString()),this._finalPEM}toPublicKeyPEM(){return new a.PEM("PUBLIC KEY",this._pkcs8.DER).toString()}toJSON(){return{oid:this.oid,algo:this.algo,modulus:y(this.modulus),exponent:this.exponent}}[n.inspect.custom](e,t){return`<${this.constructor.name} ${n.inspect(this.toJSON(),t)}>`}}t.RSAPublicKey=p;class d extends h{static fromPrivateKey(e){return new d(e.toASN1())}constructor(e){if(super(e),o.getOID(this.oid)!==o.getOID("rsaEncryption"))throw new Error("Invalid RSA private key, unknown OID: "+this.oid);const t=Object.create(null);this._pkcs1=a.ASN1.fromDER(this._keyRaw,!0);const r=this._pkcs1.validate(c,t);if(null!=r)throw new Error("Cannot read RSA private key: "+r.message);this.publicExponent=a.ASN1.parseIntegerNum(t.privateKeyPublicExponent.bytes),this.privateExponent=a.ASN1.parseIntegerStr(t.privateKeyPrivateExponent.bytes),this.modulus=a.ASN1.parseIntegerStr(t.privateKeyModulus.bytes),this.prime1=a.ASN1.parseIntegerStr(t.privateKeyPrime1.bytes),this.prime2=a.ASN1.parseIntegerStr(t.privateKeyPrime2.bytes),this.exponent1=a.ASN1.parseIntegerStr(t.privateKeyExponent1.bytes),this.exponent2=a.ASN1.parseIntegerStr(t.privateKeyExponent2.bytes),this.coefficient=a.ASN1.parseIntegerStr(t.privateKeyCoefficient.bytes)}toASN1(){return this._pkcs1}toDER(){return this._keyRaw}toPEM(){return""===this._finalPEM&&(this._finalPEM=new a.PEM("RSA PRIVATE KEY",this._keyRaw).toString()),this._finalPEM}toPrivateKeyPEM(){return new a.PEM("PRIVATE KEY",this._pkcs8.DER).toString()}toJSON(){return{version:this.version,oid:this.oid,algo:this.algo,publicExponent:this.publicExponent,privateExponent:y(this.privateExponent),modulus:y(this.modulus),prime1:y(this.prime1),prime2:y(this.prime2),exponent1:y(this.exponent1),exponent2:y(this.exponent2),coefficient:y(this.coefficient)}}[n.inspect.custom](e,t){return`<${this.constructor.name} ${n.inspect(this.toJSON(),t)}>`}}function y(e){return e.length%8!=0&&e.startsWith("00")?e.slice(2):e}t.RSAPrivateKey=d,f.addVerifier(o.getOID("Ed25519"),(function(e,t){return s.sign.detached.verify(e,t,this.keyRaw)})),h.addSigner(o.getOID("Ed25519"),(function(e){const t=this.keyRaw;if(64!==t.length)throw new Error("Invalid signing key.");return Buffer.from(s.sign.detached(e,t))}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(11);t.BufferVisitor=n.BufferVisitor;var i=r(41);t.PEM=i.PEM;var s=r(42);t.ASN1=s.ASN1,t.Class=s.Class,t.Tag=s.Tag,t.BitString=s.BitString},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BufferVisitor=class{constructor(e,t=0,r=0){this.start=t,this.end=r>t?r:t,this.buf=e}get length(){return this.buf.length}reset(e=0,t=0){return this.start=e,t>=this.start?this.end=t:this.endthis.buf.length){const e=new Error(t);throw e.available=this.buf.length,e.requested=r,e}return this.walk(0),this}mustWalk(e,t){return this.mustHas(e,t),this.walk(e),this}}},function(e,t,r){"use strict";var n=o(r(13)),i=o(r(19)),s=o(r(46)),a=r(1);function o(e){return e&&e.__esModule?e:{default:e}}e.exports={initWeixin:(e={})=>(e.clientType=e.clientType||__ctx__.PLATFORM,(0,a.createApi)(n.default,e)),initAlipay:(e={})=>(e.clientType=e.clientType||__ctx__.PLATFORM,(0,a.createApi)(i.default,e)),initAppleIapPayment:(e={})=>(e.clientType=e.clientType||__ctx__.PLATFORM,(0,a.createApi)(s.default,e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=a(r(14)),i=a(r(18)),s=r(1);function a(e){return e&&e.__esModule?e:{default:e}}t.default=class{constructor(e={}){if(!e.appId)throw new Error("appId required");if(!e.mchId)throw new Error("mchId required");if(!e.key)throw new Error("key required");e.signType=e.signType||"MD5",this.options=Object.assign({},e),this._protocols=i.default,this.baseUrl="https://api.mch.weixin.qq.com",this.paths={unifiedOrder:"/pay/unifiedorder",orderQuery:"/pay/orderquery",closeOrder:"/pay/closeorder",refund:"/secapi/pay/refund",refundQuery:"/pay/refundquery",downloadBill:"/pay/downloadbill",downloadFundflow:"/pay/downloadfundflow",getsignkey:"/pay/getsignkey"}}_getSign(e,t){const r=n.default.getSignStr(e)+"&key="+this.options.key;switch(t){case"MD5":return n.default.md5(r).toUpperCase();case"HMAC-SHA256":return n.default.sha256(r,this.options.key).toUpperCase();default:throw new Error("signType Error")}}_normalizeResult(e,t){return e.returnMsg=e.returnMsg||("SUCCESS"===e.returnCode?"ok":"fail"),e.errMsg=`payment.${t} ${e.returnMsg.toLowerCase()}`,e}_parse(e,t,r){const i=n.default.parseXML(e);if("FAIL"===i.return_code)throw new Error(""+i.return_msg);if("getSandboxKey"!==t){if(i.appid!==this.options.appId)throw new Error("appId不匹配");if(i.mch_id!==this.options.mchId)throw new Error("mchId不匹配");if(i.sign!==this._getSign(i,r))throw new Error("返回结果签名错误");i.app_id=i.appid,delete i.appid}if("FAIL"===i.result_code)throw new Error(`${i.err_code} ${i.err_code_des}`);return this._normalizeResult((0,s.snake2camelJson)(i),t)}_parseBill(e,t){const r={};if(n.default.isXML(e)){const t=n.default.parseXML(e);if("FAIL"===t.return_code)throw new Error(""+t.return_msg);if("FAIL"===t.result_code)throw new Error(`${t.err_code} ${t.err_code_des}`)}else r.returnCode="SUCCESS",r.content=e;return this._normalizeResult(r,t)}_getPublicParams(){const{appId:e,mchId:t,subAppId:r,subMchId:i}=this.options;return r?{appid:e,mchId:t,nonceStr:n.default.getNonceStr(),subAppid:r,subMchId:i}:{appid:e,mchId:t,nonceStr:n.default.getNonceStr()}}async _requestWxpay(e,t,r=!1){if(r&&!this.options.pfx)throw new Error("此接口需要微信支付证书(请传入pfx字段)");"getSandboxKey"!==t&&await this._initSandbox();const i=e.signType||this.options.signType;(e=(0,s.camel2snakeJson)(e)).sign=this._getSign(e,i);const a={method:"POST",dataType:"text",data:n.default.buildXML(e),timeout:this.options.timeout};r&&(a.pfx=this.options.pfx,a.passphrase=this.options.mchId);const{status:o,data:u}=await uniCloud.httpclient.request(this.options.sandbox?`${this.baseUrl}/sandboxnew${this.paths[t]}`:`${this.baseUrl}${this.paths[t]}`,a);if(200!==o)throw new Error("request fail");return-1!==["downloadBill","downloadFundflow"].indexOf(t)?this._parseBill(u,t):this._parse(u,t,i)}async getSandboxKey(){const e={mchId:this.options.mchId,nonceStr:n.default.getNonceStr()};return await this._requestWxpay(e,"getSandboxKey")}async _initSandbox(){this.options.sandbox&&!this.options.sandboxKey&&(this.options.key=this.options.sandboxKey=await this.getSandboxKey().sandbox_signkey)}async unifiedOrder(e){let t;if(e.tradeType)t=e.tradeType;else switch(this.options.clientType){case"app-plus":t="APP";break;case"mp-weixin":default:t="JSAPI"}const r=this._getPublicParams();r.subAppid&&(e.sub_openid=e.openid),("JSAPI"!==t||r.subAppid)&&delete e.openid;const n={...e,...r,spbillCreateIp:e.spbillCreateIp||"127.0.0.1",tradeType:t};return await this._requestWxpay(n,"unifiedOrder")}_getPayParamsByPrepayId(e,t){let r;switch(this.options.clientType){case"app-plus":r={appid:this.options.subAppId?this.options.subAppId:this.options.appId,noncestr:n.default.getNonceStr(),package:"Sign=WXPay",partnerid:this.options.mchId,prepayid:e,timestamp:""+(Date.now()/1e3|0)},r.sign=this._getSign(r,t);break;case"mp-weixin":default:{const i=""+(Date.now()/1e3|0);r={appId:this.options.subAppId?this.options.subAppId:this.options.appId,nonceStr:n.default.getNonceStr(),package:"prepay_id="+e,timeStamp:i},r.signType=t,r.paySign=this._getSign(r,t),r.timestamp=i;break}}return r}async getOrderInfo(e){let t;if(e.tradeType)t=e.tradeType;else switch(this.options.clientType){case"app-plus":t="APP";break;case"mp-weixin":default:t="JSAPI"}"JSAPI"!==t&&delete e.openid,e.tradeType=t;const r=await this.unifiedOrder(e);if("NATIVE"===t||"MWEB"===t)return r;if(!r.prepayId)throw new Error(r.errMsg||"获取prepayId失败");return this._getPayParamsByPrepayId(r.prepayId,e.signType||this.options.signType)}async orderQuery(e){const t={...e,...this._getPublicParams()};return await this._requestWxpay(t,"orderQuery")}async closeOrder(e){const t={...e,...this._getPublicParams()};return await this._requestWxpay(t,"closeOrder")}async refund(e){const t={...e,...this._getPublicParams()};return await this._requestWxpay(t,"refund",!0)}async refundQuery(e){const t={...e,...this._getPublicParams()};return await this._requestWxpay(t,"refundQuery")}async downloadBill(e){const t={...e,...this._getPublicParams(),billType:e.billType||"ALL"};return await this._requestWxpay(t,"downloadBill")}async downloadFundflow(e){const t={...e,...this._getPublicParams(),signType:e.signType||"HMAC-SHA256",accountType:e.accountType||"Basic"};return await this._requestWxpay(t,"downloadFundflow",!0)}_getNotifyData(e){let t=e.body;return e.isBase64Encoded&&(t=Buffer.from(t,"base64").toString("utf-8")),n.default.parseXML(t)}_verifyNotify(e,t){const r=this._getNotifyData(e);if("FAIL"===r.return_code)throw new Error(`${r.return_code} ${r.return_msg}`);if(r.appid!==this.options.appId)throw new Error("appId不匹配");if(r.mch_id!==this.options.mchId)throw new Error("mchId不匹配");if(t&&r.sign!==this._getSign(r,this.options.signType))throw new Error("通知验签未通过");const n=(0,s.snake2camelJson)(r);return n.appId=n.appid,delete n.appid,n}verifyPaymentNotify(e){return"payment"===this.checkNotifyType(e)&&this._verifyNotify(e,!0)}verifyRefundNotify(e){if("refund"!==this.checkNotifyType(e))return!1;const t=this._verifyNotify(e,!1),r=(0,s.snake2camelJson)(n.default.parseXML(n.default.decryptData(t.reqInfo,n.default.md5(this.options.key))));return Object.assign(t,r),delete t.reqInfo,t}checkNotifyType(e){const t=this._getNotifyData(e);return"total_fee"in t?"payment":"req_info"in t?"refund":"payment"}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=(n=r(0))&&n.__esModule?n:{default:n},s=r(1);var a={decryptData:function(e,t,r=""){const n=i.default.createDecipheriv("aes-256-ecb",t,r);n.setAutoPadding(!0);let s=n.update(e,"base64","utf8");return s+=n.final("utf8"),s},md5:function(e,t="utf8"){return i.default.createHash("md5").update(e,t).digest("hex")},sha256:function(e,t,r="utf8"){return i.default.createHmac("sha256",t).update(e,r).digest("hex")},getSignStr:function(e){return Object.keys(e).filter(t=>"sign"!==t&&void 0!==e[t]&&""!==e[t]).sort().map(t=>t+"="+((0,s.isPlainObject)(e[t])?JSON.stringify(e[t]):e[t])).join("&")},getNonceStr:function(e=16){let t="";for(;t.length${Object.keys(e).map(t=>(0,s.isPlainObject)(e[t])?`<${t}>`:`<${t}>`).join("")}`},parseXML:function(e){const t=/<(?:xml|root).*?>([\s|\S]*)<\/(?:xml|root)>/.exec(e)[1],r={},n=/<(.*?)>(?:){0,1}<\/.*?>/g;let i=null;for(;i=n.exec(t);)r[i[1]]=i[2];return r},isXML:function(e){return/^(<\?xml.*\?>)?(\r?\n)*(.|\r?\n)*<\/xml>$/i.test(e.trim())}};t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=class{constructor(){this._boundary="------FormDataBaseBoundary"+Math.random().toString(36).substring(2),this.dataList=[]}_addData(e){const t=this.dataList[this.dataList.length-1];"string"==typeof e&&"string"==typeof t?this.dataList[this.dataList.length-1]=t+"\r\n"+e:this.dataList.push(e)}append(e,t,r){this._addData("--"+this._boundary);let n=`Content-Disposition: form-data; name="${e}"`;switch(Buffer.isBuffer(t)){case!0:if(!r.filename||!r.contentType)throw new Error("filename and contentType required");n+=`; filename="${r.filename}"`,this._addData(n),this._addData("Content-Type: "+r.contentType),this._addData(""),this._addData(t);break;default:this._addData(""),this._addData(t)}}getHeaders(e){const t={"Content-Type":"multipart/form-data; boundary="+this._boundary};return Object.assign(t,e)}getBuffer(){let e=Buffer.alloc(0);return this.dataList.forEach(t=>{e=Buffer.isBuffer(t)?Buffer.concat([e,t]):Buffer.concat([e,Buffer.from(""+t)]),e=Buffer.concat([e,Buffer.from("\r\n")])}),e=Buffer.concat([e,Buffer.from("--"+this._boundary+"--")]),e}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class n extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{message:{get(){return`errCode: ${e.code||""} | errMsg: `+this.errMsg},set(e){this.errMsg=e}}})}}t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createApi=function(e,t){const r=new e(t);return new Proxy(r,{get:function(e,t){if("function"==typeof e[t]&&0!==t.indexOf("_")&&e._protocols&&e._protocols[t]){const r=e._protocols[t];return async function(n){n=i(n,r.args);let s=await e[t](n);return s=i(s,r.returnValue),s}}return e[t]}})};var n=r(2);function i(e={},t){if(!t||!e)return e;const r=["_pre","_purify","_post"];t._pre&&(e=t._pre(e));let i={shouldDelete:new Set([])};if(t._purify){const e=t._purify;for(const t in e)e[t]=new Set(e[t]);i=Object.assign(i,e)}if((0,n.isPlainObject)(t))for(const s in t){const a=t[s];(0,n.isFn)(a)&&-1===r.indexOf(s)?e[s]=a(e):"string"==typeof a&&-1===r.indexOf(s)&&(e[s]=e[a],i.shouldDelete.add(a))}else(0,n.isFn)(t)&&(e=t(e));if(i.shouldDelete)for(const t of i.shouldDelete)delete e[t];return t._post&&(e=t._post(e)),e}},function(e,t,r){"use strict";function n(e,t){t.forEach(t=>{void 0!==e[t]&&(e[t]=Number(e[t]))})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i={unifiedOrder:{args:{_purify:{shouldDelete:["subject"]}}},getOrderInfo:{args:{_purify:{shouldDelete:["subject"]}}},orderQuery:{returnValue:function(e){n(e,["cashFee","totalFee","couponCount"]),e.couponList=[];const t=e.couponCount||0;for(let r=0;r-1){const n=encodeURIComponent(t[e]);r=`${r}${r.includes("?")?"&":"?"}${e}=${n}`,delete t[e]}return{execParams:t,url:r}}async getOrderInfo(e){let t;if(e.tradeType)t=e.tradeType,delete e.tradeType;else switch(this.options.clientType){case"app-plus":t="APP";break;case"mp-alipay":default:t="JSAPI"}switch(t){case"APP":{delete e.buyerId;const t={};e.notifyUrl&&(t.notifyUrl=e.notifyUrl,delete e.notifyUrl),t.bizContent=e;const r=this._getSign("alipay.trade.app.pay",t),{url:n,execParams:i}=this.formatUrl("",r);return(n+"&biz_content="+encodeURIComponent(i.biz_content)).substr(1)}case"JSAPI":{const t=await this.unifiedOrder(e);if(!t.tradeNo)throw new Error("获取支付宝交易号失败,详细信息为:"+JSON.stringify(t));return t.tradeNo}case"NATIVE":return await this._request("alipay.trade.precreate",Object.assign({sellerId:this.options.mchId},e));default:throw new Error("不支持的支付类型,支付宝支付下单仅支持App、支付宝小程序、网站二维码支付")}}async orderQuery(e){return await this._request("alipay.trade.query",e)}async cancelOrder(e){return await this._request("alipay.trade.cancel",e)}async closeOrder(e){return await this._request("alipay.trade.close",e)}async refund(e){return await this._request("alipay.trade.refund",e)}async refundQuery(e){return await this._request("alipay.trade.fastpay.refund.query",e)}notifyRSACheck(e,t,r){const n=Object.keys(e).sort().filter(e=>e).map(t=>{let r=e[t];return"[object String]"!==Array.prototype.toString.call(r)&&(r=JSON.stringify(r)),`${t}=${r}`}).join("&");return i.default.createVerify(l[r]).update(n,"utf8").verify(this.config.alipayPublicKey,t,"base64")}_getNotifyData(e){if(!e.headers)throw new Error("通知格式不正确");let t;for(const r in e.headers)"content-type"===r.toLowerCase()&&(t=e.headers[r]);if(!1!==e.isBase64Encoded&&-1===t.indexOf("application/x-www-form-urlencoded"))throw new Error("通知格式不正确");return s.default.parse(e.body)}_verifyNotify(e){const t=this._getNotifyData(e);return!!this.checkNotifySign(t)&&(0,n.snake2camelJson)(t)}verifyPaymentNotify(e){return"payment"===this.checkNotifyType(e)&&this._verifyNotify(e)}verifyRefundNotify(e){return"refund"===this.checkNotifyType(e)&&this._verifyNotify(e)}checkNotifyType(e){return"refund_fee"in this._getNotifyData(e)?"refund":"payment"}}t.default=f,e.exports=t.default},function(e,t){e.exports=require("querystring")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5),i=r(22),s=r(0),a=r(23),o=r(24),u=r(25),c=r(27),l=r(28),f=r(7),h=r(8),p=r(36),d=r(44);t.default=class{constructor(e){if(!e.appId)throw Error("config.appId is required");if(!e.privateKey)throw Error("config.privateKey is required");const t="PKCS8"===e.keyType?"PRIVATE KEY":"RSA PRIVATE KEY";e.privateKey=this.formatKey(e.privateKey,t),e.appCertPath||e.appCertContent?(e.appCertSn=i.empty(e.appCertContent)?p.getSNFromPath(e.appCertPath,!1):p.getSN(e.appCertContent,!1),e.alipayCertSn=i.empty(e.alipayPublicCertContent)?p.getSNFromPath(e.alipayPublicCertPath,!1):p.getSN(e.alipayPublicCertContent,!1),e.alipayRootCertSn=i.empty(e.alipayRootCertContent)?p.getSNFromPath(e.alipayRootCertPath,!0):p.getSN(e.alipayRootCertContent,!0),e.alipayPublicKey=i.empty(e.alipayPublicCertContent)?p.loadPublicKeyFromPath(e.alipayPublicCertPath):p.loadPublicKey(e.alipayPublicCertContent),e.alipayPublicKey=this.formatKey(e.alipayPublicKey,"PUBLIC KEY")):e.alipayPublicKey&&(e.alipayPublicKey=this.formatKey(e.alipayPublicKey,"PUBLIC KEY")),this.config=Object.assign({urllib:a,gateway:"https://openapi.alipay.com/gateway.do",timeout:5e3,camelcase:!0,signType:"RSA2",charset:"utf-8",version:"1.0"},l(e,{deep:!0})),this.sdkVersion="alipay-sdk-nodejs-"+d.version}formatKey(e,t){const r=e.split("\n").map(e=>e.trim());return r[0].includes(t)&&r.shift(),r[r.length-1].includes(t)&&r.pop(),`-----BEGIN ${t}-----\n${r.join("")}\n-----END ${t}-----`}formatUrl(e,t){let r=e;const n=["app_id","method","format","charset","sign_type","sign","timestamp","version","notify_url","return_url","auth_token","app_auth_token","appCertSn","alipayRootCertSn"];for(const e in t)if(n.indexOf(e)>-1){const n=encodeURIComponent(t[e]);r=`${r}${r.includes("?")?"&":"?"}${e}=${n}`,delete t[e]}return{execParams:t,url:r}}multipartExec(e,t={}){const r=this.config;let s={},a={};const p=t.log&&i.fn(t.log.info)?t.log.info:null,d=t.log&&i.fn(t.log.error)?t.log.error:null;t.formData.getFields().forEach(e=>{s[e.name]=e.value,a[e.name]=e.value}),s=l(s,{deep:!0}),a=f(a),t.formData.getFiles().forEach(e=>{const t=c(e.fieldName);a[t]=u.isValid(e.path)?o(e.path):n.createReadStream(e.path)});const y=h.sign(e,s,r),{url:g}=this.formatUrl(r.gateway,y);return p&&p("[AlipaySdk]start exec url: %s, method: %s, params: %s",g,e,JSON.stringify(s)),new Promise((n,i)=>{o.post({url:g,formData:a,json:!1,timeout:r.timeout,headers:{"user-agent":this.sdkVersion}},(s,{},a)=>{s&&(s.message="[AlipaySdk]exec error",d&&d(s),i(s)),p&&p("[AlipaySdk]exec response: %s",a);const o=JSON.parse(a),u=e.replace(/\./g,"_")+"_response",c=o[u];if(c){!t.validateSign||this.checkResponseSign(a,u)?n(r.camelcase?l(c,{deep:!0}):c):i({serverResult:a,errorMessage:"[AlipaySdk]验签失败"})}i({serverResult:a,errorMessage:"[AlipaySdk]HTTP 请求错误"})})})}pageExec(e,t={}){let r={alipaySdk:this.sdkVersion};const n=this.config,s=t.log&&i.fn(t.log.info)?t.log.info:null;t.formData.getFields().forEach(e=>{r[e.name]=e.value}),r=l(r,{deep:!0});const a=h.sign(e,r,n),{url:o,execParams:u}=this.formatUrl(n.gateway,a);return s&&s("[AlipaySdk]start exec url: %s, method: %s, params: %s",o,e,JSON.stringify(r)),"get"===t.formData.getMethod()?new Promise(e=>{const t=Object.keys(u).map(e=>`${e}=${encodeURIComponent(u[e])}`);e(`${o}&${t.join("&")}`)}):new Promise(e=>{const t="alipaySDKSubmit"+Date.now();e(`\n
\n ${Object.keys(u).map(e=>``).join("")}\n
\n