From a153e3a87f09c66282076a3f499ad50206a620f8 Mon Sep 17 00:00:00 2001 From: lsl Date: Mon, 15 May 2023 13:58:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提交完整代码 --- README.md | 6 +- app.js | 4 +- app.json | 17 +- app.wxss | 3 - miniprogram_npm/dayjs/index.js | 4 +- .../weapp-qrcode-canvas-2d/index.js | 18 + .../weapp-qrcode-canvas-2d/index.js.map | 1 + miniprogram_npm/wxmp-rsa/index.js | 52 +- node_modules/.package-lock.json | 5 + .../weapp-qrcode-canvas-2d/.editorconfig | 9 + .../weapp-qrcode-canvas-2d/.eslintignore | 3 + .../weapp-qrcode-canvas-2d/.eslintrc.js | 26 + .../weapp-qrcode-canvas-2d/.travis.yml | 23 + node_modules/weapp-qrcode-canvas-2d/LICENSE | 21 + node_modules/weapp-qrcode-canvas-2d/README.md | 171 +++ .../build/rollup.dev.config.js | 39 + .../build/rollup.prod.config.js | 49 + .../dist/weapp.qrcode.common.js | 5 + .../dist/weapp.qrcode.esm.js | 5 + .../dist/weapp.qrcode.js | 1326 +++++++++++++++++ .../dist/weapp.qrcode.min.js | 5 + .../examples/wechat-app/utils/weapp.qrcode.js | 1326 +++++++++++++++++ .../weapp-qrcode-canvas-2d/package.json | 42 + .../weapp-qrcode-canvas-2d/src/index.js | 141 ++ .../weapp-qrcode-canvas-2d/src/qrcode.js | 1242 +++++++++++++++ package-lock.json | 6 + package.json | 1 + pages/home/jl/index.js | 6 + pages/home/jl/index.wxml | 2 + pages/home/jl/index.wxss | 17 + pages/home/jl/jlai.js | 66 + pages/home/jl/jlai.json | 3 + pages/home/jl/jlai.wxml | 2 + pages/home/jl/jlai.wxss | 1 + pages/home/jl/jlai/jlai.js | 69 + pages/home/jl/jlai/jlai.json | 3 + pages/home/jl/jlai/jlai.wxml | 3 + pages/home/jl/jlai/jlai.wxss | 23 + pages/home/me/cjwt/cjwt.js | 66 + pages/home/me/cjwt/cjwt.json | 4 + pages/home/me/cjwt/cjwt.wxml | 2 + pages/home/me/cjwt/cjwt.wxss | 1 + pages/home/me/grzl/grzl.js | 171 +++ pages/home/me/grzl/grzl.json | 8 + pages/home/me/grzl/grzl.wxml | 40 + pages/home/me/grzl/grzl.wxss | 185 +++ pages/home/me/gw/gw.js | 66 + pages/home/me/gw/gw.json | 4 + pages/home/me/gw/gw.wxml | 3 + pages/home/me/gw/gw.wxss | 1 + pages/home/me/iconfont.wxss | 39 - pages/home/me/indexx.js | 95 +- pages/home/me/indexx.json | 6 +- pages/home/me/indexx.wxml | 59 +- pages/home/me/indexx.wxss | 175 ++- pages/home/me/manual/manual.js | 66 + pages/home/me/manual/manual.json | 4 + pages/home/me/manual/manual.wxml | 3 + pages/home/me/manual/manual.wxss | 1 + pages/home/me/member/member.js | 87 ++ pages/home/me/member/member.json | 5 + pages/home/me/member/member.wxml | 26 + pages/home/me/member/member.wxss | 232 +++ pages/home/me/member2/member.js | 87 ++ pages/home/me/member2/member.json | 5 + pages/home/me/member2/member.wxml | 26 + pages/home/me/member2/member.wxss | 232 +++ pages/home/me/mydevice/device.js | 140 ++ pages/home/me/mydevice/device.json | 3 + pages/home/me/mydevice/device.wxml | 32 + pages/home/me/mydevice/device.wxss | 692 +++++++++ pages/home/me/sq/sq.js | 66 + pages/home/me/sq/sq.json | 4 + pages/home/me/sq/sq.wxml | 2 + pages/home/me/sq/sq.wxss | 1 + pages/home/me/yhsyxy/yhsyxy.js | 66 + pages/home/me/yhsyxy/yhsyxy.json | 4 + pages/home/me/yhsyxy/yhsyxy.wxml | 2 + pages/home/me/yhsyxy/yhsyxy.wxss | 1 + pages/home/me/yjfk/yjfk.js | 107 ++ pages/home/me/yjfk/yjfk.json | 5 + pages/home/me/yjfk/yjfk.wxml | 19 + pages/home/me/yjfk/yjfk.wxss | 125 ++ pages/home/me/ysxy/ysxy.js | 66 + pages/home/me/ysxy/ysxy.json | 4 + pages/home/me/ysxy/ysxy.wxml | 3 + pages/home/me/ysxy/ysxy.wxss | 1 + pages/home/xx/index.js | 16 +- pages/home/xx/index.wxml | 6 +- pages/home/xy/index.js | 35 +- pages/home/xy/index.json | 3 +- pages/home/xy/index.wxml | 18 +- pages/home/xy/index.wxss | 12 +- pages/home/xyc/index.js | 164 +- pages/home/xyc/index.json | 9 +- pages/home/xyc/index.wxml | 53 +- pages/home/xyc/index.wxss | 231 ++- pages/home/xyc/tdyw/tdyw.js | 69 + pages/home/xyc/tdyw/tdyw.json | 3 + pages/home/xyc/tdyw/tdyw.wxml | 4 + pages/home/xyc/tdyw/tdyw.wxss | 23 + pages/home/xyc/wdyw/wdyw.js | 69 + pages/home/xyc/wdyw/wdyw.json | 3 + pages/home/xyc/wdyw/wdyw.wxml | 4 + pages/home/xyc/wdyw/wdyw.wxss | 23 + pages/index/index.js | 204 ++- pages/index/index.json | 4 +- pages/index/index.wxml | 3 +- pages/index/out/out.json | 1 + pages/index/out/out.wxml | 2 +- project.private.config.json | 2 +- utils/formdata/index.js | 148 ++ utils/formdata/mimeMap.js | 345 +++++ utils/request.js | 102 ++ 114 files changed, 9092 insertions(+), 251 deletions(-) create mode 100644 miniprogram_npm/weapp-qrcode-canvas-2d/index.js create mode 100644 miniprogram_npm/weapp-qrcode-canvas-2d/index.js.map create mode 100644 node_modules/weapp-qrcode-canvas-2d/.editorconfig create mode 100644 node_modules/weapp-qrcode-canvas-2d/.eslintignore create mode 100644 node_modules/weapp-qrcode-canvas-2d/.eslintrc.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/.travis.yml create mode 100644 node_modules/weapp-qrcode-canvas-2d/LICENSE create mode 100644 node_modules/weapp-qrcode-canvas-2d/README.md create mode 100644 node_modules/weapp-qrcode-canvas-2d/build/rollup.dev.config.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/build/rollup.prod.config.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.common.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.esm.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.min.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/examples/wechat-app/utils/weapp.qrcode.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/package.json create mode 100644 node_modules/weapp-qrcode-canvas-2d/src/index.js create mode 100644 node_modules/weapp-qrcode-canvas-2d/src/qrcode.js create mode 100644 pages/home/jl/jlai.js create mode 100644 pages/home/jl/jlai.json create mode 100644 pages/home/jl/jlai.wxml create mode 100644 pages/home/jl/jlai.wxss create mode 100644 pages/home/jl/jlai/jlai.js create mode 100644 pages/home/jl/jlai/jlai.json create mode 100644 pages/home/jl/jlai/jlai.wxml create mode 100644 pages/home/jl/jlai/jlai.wxss create mode 100644 pages/home/me/cjwt/cjwt.js create mode 100644 pages/home/me/cjwt/cjwt.json create mode 100644 pages/home/me/cjwt/cjwt.wxml create mode 100644 pages/home/me/cjwt/cjwt.wxss create mode 100644 pages/home/me/grzl/grzl.js create mode 100644 pages/home/me/grzl/grzl.json create mode 100644 pages/home/me/grzl/grzl.wxml create mode 100644 pages/home/me/grzl/grzl.wxss create mode 100644 pages/home/me/gw/gw.js create mode 100644 pages/home/me/gw/gw.json create mode 100644 pages/home/me/gw/gw.wxml create mode 100644 pages/home/me/gw/gw.wxss delete mode 100644 pages/home/me/iconfont.wxss create mode 100644 pages/home/me/manual/manual.js create mode 100644 pages/home/me/manual/manual.json create mode 100644 pages/home/me/manual/manual.wxml create mode 100644 pages/home/me/manual/manual.wxss create mode 100644 pages/home/me/member/member.js create mode 100644 pages/home/me/member/member.json create mode 100644 pages/home/me/member/member.wxml create mode 100644 pages/home/me/member/member.wxss create mode 100644 pages/home/me/member2/member.js create mode 100644 pages/home/me/member2/member.json create mode 100644 pages/home/me/member2/member.wxml create mode 100644 pages/home/me/member2/member.wxss create mode 100644 pages/home/me/mydevice/device.js create mode 100644 pages/home/me/mydevice/device.json create mode 100644 pages/home/me/mydevice/device.wxml create mode 100644 pages/home/me/mydevice/device.wxss create mode 100644 pages/home/me/sq/sq.js create mode 100644 pages/home/me/sq/sq.json create mode 100644 pages/home/me/sq/sq.wxml create mode 100644 pages/home/me/sq/sq.wxss create mode 100644 pages/home/me/yhsyxy/yhsyxy.js create mode 100644 pages/home/me/yhsyxy/yhsyxy.json create mode 100644 pages/home/me/yhsyxy/yhsyxy.wxml create mode 100644 pages/home/me/yhsyxy/yhsyxy.wxss create mode 100644 pages/home/me/yjfk/yjfk.js create mode 100644 pages/home/me/yjfk/yjfk.json create mode 100644 pages/home/me/yjfk/yjfk.wxml create mode 100644 pages/home/me/yjfk/yjfk.wxss create mode 100644 pages/home/me/ysxy/ysxy.js create mode 100644 pages/home/me/ysxy/ysxy.json create mode 100644 pages/home/me/ysxy/ysxy.wxml create mode 100644 pages/home/me/ysxy/ysxy.wxss create mode 100644 pages/home/xyc/tdyw/tdyw.js create mode 100644 pages/home/xyc/tdyw/tdyw.json create mode 100644 pages/home/xyc/tdyw/tdyw.wxml create mode 100644 pages/home/xyc/tdyw/tdyw.wxss create mode 100644 pages/home/xyc/wdyw/wdyw.js create mode 100644 pages/home/xyc/wdyw/wdyw.json create mode 100644 pages/home/xyc/wdyw/wdyw.wxml create mode 100644 pages/home/xyc/wdyw/wdyw.wxss create mode 100644 utils/formdata/index.js create mode 100644 utils/formdata/mimeMap.js diff --git a/README.md b/README.md index 68005b3..4426eb5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# xzjl-ui +# xzjl-ui 星座精灵小程序仓库 + +代码开发规范 +1.用户在首页(pages/index/index)通过识别NfC或者扫码进入小程序页面,成功后进入星运页面(pages/home/xy/index) + 星座精灵小程序仓库 diff --git a/app.js b/app.js index 5a432fc..e3b2430 100644 --- a/app.js +++ b/app.js @@ -17,7 +17,9 @@ App({ }, globalData: { BASE_URL:"https://api.wish.ydxxkj.top/api", - userInfo: null, + userInfo: { + xyNfc:false + }, xx:"1sd撒啊娃娃" }, xzjlReq(){ diff --git a/app.json b/app.json index 22ff90a..0a1410f 100644 --- a/app.json +++ b/app.json @@ -10,7 +10,22 @@ "pages/index/index", "pages/index/out/out", "pages/home/xx/xz/xz", - "pages/home/xx/xz/index" + "pages/home/xx/xz/index", + "pages/home/me/manual/manual", + "pages/home/me/member/member", + "pages/home/me/member2/member", + "pages/home/me/gw/gw", + "pages/home/me/ysxy/ysxy", + "pages/home/me/yhsyxy/yhsyxy", + "pages/home/me/cjwt/cjwt", + "pages/home/me/mydevice/device", + "pages/home/me/sq/sq", + "pages/home/me/yjfk/yjfk", + "pages/home/xyc/wdyw/wdyw", + "pages/home/xyc/tdyw/tdyw", + "pages/home/me/grzl/grzl", + "pages/home/jl/jlai", + "pages/home/jl/jlai/jlai" ], "window": { "backgroundTextStyle": "light", diff --git a/app.wxss b/app.wxss index b6af8d4..c7bc7f6 100644 --- a/app.wxss +++ b/app.wxss @@ -1,6 +1,3 @@ -/**app.wxss**/ -@import 'styles/icons/iconfont.wxss'; - .container { height: 100%; display: flex; diff --git a/miniprogram_npm/dayjs/index.js b/miniprogram_npm/dayjs/index.js index 8785901..91e0815 100644 --- a/miniprogram_npm/dayjs/index.js +++ b/miniprogram_npm/dayjs/index.js @@ -4,10 +4,10 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; -__DEFINE__(1683163200614, function(require, module, exports) { +__DEFINE__(1683383058314, function(require, module, exports) { !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCode.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=QRUtil.getLostPoint(this);(0==r||t>o)&&(t=o,e=r)}return e},createMovieClip:function(t,e,r){var o=t.createEmptyMovieClip(e,r);this.make();for(var n=0;n>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++){o=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=QRUtil.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++){i=!t&&1==(o>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[o][a-s]){var u=!1;i>>n&1)),QRUtil.getMask(e,o,a-s)&&(u=!u),this.modules[o][a-s]=u,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}}},QRCode.PAD0=236,QRCode.PAD1=17,QRCode.createData=function(t,e,r){for(var o=QRRSBlock.getRSBlocks(t,e),n=new QRBitBuffer,i=0;i8*s)throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*s+")");for(n.getLengthInBits()+4<=8*s&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*s||(n.put(QRCode.PAD0,8),n.getLengthInBits()>=8*s));)n.put(QRCode.PAD1,8);return QRCode.createBytes(n,o)},QRCode.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),a=new Array(e.length),s=0;s=0?g.get(c):0}}var d=0;for(h=0;h=0;)e^=QRUtil.G15<=0;)e^=QRUtil.G18<>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case QRMaskPattern.PATTERN000:return(e+r)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return r%3==0;case QRMaskPattern.PATTERN011:return(e+r)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case QRMaskPattern.PATTERN101:return e*r%2+e*r%3==0;case QRMaskPattern.PATTERN110:return(e*r%2+e*r%3)%2==0;case QRMaskPattern.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),r=0;r5&&(r+=3+i-5)}for(o=0;o=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<=1&&n<=127?e+=t.charAt(r):n>2047?(e+=String.fromCharCode(224|n>>12&15),e+=String.fromCharCode(128|n>>6&63),e+=String.fromCharCode(128|n>>0&63)):(e+=String.fromCharCode(192|n>>6&31),e+=String.fromCharCode(128|n>>0&63));return e}function drawQrcode(t,e){if(t=t||{},(t=extend(!0,{canvasId:"myQrcode",text:"爱一个人就要勇敢说出来",width:260,height:260,padding:20,typeNumber:-1,correctLevel:QRErrorCorrectLevel.H,background:"#ffffff",foreground:"#000000",image:{imageResource:"",width:80,height:80,round:!0}},t)).canvasId||t.canvas){if(t.paddingColor||(t.paddingColor=t.background),e){var r=new QRCode(t.typeNumber,t.correctLevel);return r.addData(utf16to8(t.text)),r.make(),new Promise(function(t,e){t(r)})}return new Promise(function(e,r){return e(function(){var e=new QRCode(t.typeNumber,t.correctLevel);e.addData(utf16to8(t.text)),e.make();const r=wx.getSystemInfoSync().pixelRatio;var o=t.canvas;const n=o.getContext("2d");o.width=t.width*r,o.height=t.width*r;const i=o.width;n.fillStyle=t.paddingColor,n.fillRect(0,0,i+2*t.padding,i+2*t.padding);for(var a=(i-2*t.padding)/e.getModuleCount(),s=(i-2*t.padding)/e.getModuleCount(),u=0;u>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},module.exports=drawQrcode; + +}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); }) +return __REQUIRE__(1683383058315); +})() +//miniprogram-npm-outsideDeps=[] +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/miniprogram_npm/weapp-qrcode-canvas-2d/index.js.map b/miniprogram_npm/weapp-qrcode-canvas-2d/index.js.map new file mode 100644 index 0000000..7a3151a --- /dev/null +++ b/miniprogram_npm/weapp-qrcode-canvas-2d/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["weapp.qrcode.common.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["/**\n * weapp.qrcode.js v1.1.1 (undefined)\n */\n\nvar hasOwn=Object.prototype.hasOwnProperty,toStr=Object.prototype.toString,defineProperty=Object.defineProperty,gOPD=Object.getOwnPropertyDescriptor,isArray=function(t){return\"function\"==typeof Array.isArray?Array.isArray(t):\"[object Array]\"===toStr.call(t)},isPlainObject=function(t){if(!t||\"[object Object]\"!==toStr.call(t))return!1;var e,r=hasOwn.call(t,\"constructor\"),o=t.constructor&&t.constructor.prototype&&hasOwn.call(t.constructor.prototype,\"isPrototypeOf\");if(t.constructor&&!r&&!o)return!1;for(e in t);return void 0===e||hasOwn.call(t,e)},setProperty=function(t,e){defineProperty&&\"__proto__\"===e.name?defineProperty(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},getProperty=function(t,e){if(\"__proto__\"===e){if(!hasOwn.call(t,e))return;if(gOPD)return gOPD(t,e).value}return t[e]},extend=function t(){var e,r,o,n,i,a,s=arguments[0],u=1,l=arguments.length,h=!1;for(\"boolean\"==typeof s&&(h=s,s=arguments[1]||{},u=2),(null==s||\"object\"!=typeof s&&\"function\"!=typeof s)&&(s={});u=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCode.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=QRUtil.getLostPoint(this);(0==r||t>o)&&(t=o,e=r)}return e},createMovieClip:function(t,e,r){var o=t.createEmptyMovieClip(e,r);this.make();for(var n=0;n>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++){o=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=QRUtil.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++){i=!t&&1==(o>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[o][a-s]){var u=!1;i>>n&1)),QRUtil.getMask(e,o,a-s)&&(u=!u),this.modules[o][a-s]=u,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}}},QRCode.PAD0=236,QRCode.PAD1=17,QRCode.createData=function(t,e,r){for(var o=QRRSBlock.getRSBlocks(t,e),n=new QRBitBuffer,i=0;i8*s)throw new Error(\"code length overflow. (\"+n.getLengthInBits()+\">\"+8*s+\")\");for(n.getLengthInBits()+4<=8*s&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*s||(n.put(QRCode.PAD0,8),n.getLengthInBits()>=8*s));)n.put(QRCode.PAD1,8);return QRCode.createBytes(n,o)},QRCode.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),a=new Array(e.length),s=0;s=0?g.get(c):0}}var d=0;for(h=0;h=0;)e^=QRUtil.G15<=0;)e^=QRUtil.G18<>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case QRMaskPattern.PATTERN000:return(e+r)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return r%3==0;case QRMaskPattern.PATTERN011:return(e+r)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case QRMaskPattern.PATTERN101:return e*r%2+e*r%3==0;case QRMaskPattern.PATTERN110:return(e*r%2+e*r%3)%2==0;case QRMaskPattern.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error(\"bad maskPattern:\"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),r=0;r5&&(r+=3+i-5)}for(o=0;o=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<=1&&n<=127?e+=t.charAt(r):n>2047?(e+=String.fromCharCode(224|n>>12&15),e+=String.fromCharCode(128|n>>6&63),e+=String.fromCharCode(128|n>>0&63)):(e+=String.fromCharCode(192|n>>6&31),e+=String.fromCharCode(128|n>>0&63));return e}function drawQrcode(t,e){if(t=t||{},(t=extend(!0,{canvasId:\"myQrcode\",text:\"爱一个人就要勇敢说出来\",width:260,height:260,padding:20,typeNumber:-1,correctLevel:QRErrorCorrectLevel.H,background:\"#ffffff\",foreground:\"#000000\",image:{imageResource:\"\",width:80,height:80,round:!0}},t)).canvasId||t.canvas){if(t.paddingColor||(t.paddingColor=t.background),e){var r=new QRCode(t.typeNumber,t.correctLevel);return r.addData(utf16to8(t.text)),r.make(),new Promise(function(t,e){t(r)})}return new Promise(function(e,r){return e(function(){var e=new QRCode(t.typeNumber,t.correctLevel);e.addData(utf16to8(t.text)),e.make();const r=wx.getSystemInfoSync().pixelRatio;var o=t.canvas;const n=o.getContext(\"2d\");o.width=t.width*r,o.height=t.width*r;const i=o.width;n.fillStyle=t.paddingColor,n.fillRect(0,0,i+2*t.padding,i+2*t.padding);for(var a=(i-2*t.padding)/e.getModuleCount(),s=(i-2*t.padding)/e.getModuleCount(),u=0;u>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},module.exports=drawQrcode;\n"]} \ No newline at end of file diff --git a/miniprogram_npm/wxmp-rsa/index.js b/miniprogram_npm/wxmp-rsa/index.js index 011adf2..ef46bdf 100644 --- a/miniprogram_npm/wxmp-rsa/index.js +++ b/miniprogram_npm/wxmp-rsa/index.js @@ -4,13 +4,13 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; -__DEFINE__(1683163200615, function(require, module, exports) { +__DEFINE__(1683383058316, function(require, module, exports) { var __TEMP__ = require('./JSEncrypt');var JSEncrypt = __TEMP__['JSEncrypt']; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'JSEncrypt', { enumerable: true, configurable: true, get: function() { return JSEncrypt; } }); if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });exports.default = JSEncrypt; -}, function(modId) {var map = {"./JSEncrypt":1683163200616}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200616, function(require, module, exports) { +}, function(modId) {var map = {"./JSEncrypt":1683383058317}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058317, function(require, module, exports) { var __TEMP__ = require('./lib/jsbn/base64');var b64tohex = __TEMP__['b64tohex'];var hex2b64 = __TEMP__['hex2b64']; var __TEMP__ = require('./JSEncryptRSAKey');var JSEncryptRSAKey = __TEMP__['JSEncryptRSAKey']; var __TEMP__ = require('./version.json');var version = __REQUIRE_DEFAULT__(__TEMP__); @@ -217,8 +217,8 @@ var JSEncrypt = /** @class */ (function () { }()); if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'JSEncrypt', { enumerable: true, configurable: true, get: function() { return JSEncrypt; } }); -}, function(modId) { var map = {"./lib/jsbn/base64":1683163200617,"./JSEncryptRSAKey":1683163200619,"./version.json":1683163200630}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200617, function(require, module, exports) { +}, function(modId) { var map = {"./lib/jsbn/base64":1683383058318,"./JSEncryptRSAKey":1683383058320,"./version.json":1683383058331}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058318, function(require, module, exports) { var __TEMP__ = require('./util');var int2char = __TEMP__['int2char']; var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var b64pad = "="; @@ -296,8 +296,8 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t return a; };exports.b64toBA = b64toBA -}, function(modId) { var map = {"./util":1683163200618}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200618, function(require, module, exports) { +}, function(modId) { var map = {"./util":1683383058319}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058319, function(require, module, exports) { var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });function int2char(n) { return BI_RM.charAt(n); @@ -358,7 +358,7 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t //#endregion BIT_OPERATIONS }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200619, function(require, module, exports) { +__DEFINE__(1683383058320, function(require, module, exports) { var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || @@ -675,8 +675,8 @@ var JSEncryptRSAKey = /** @class */ (function (_super) { }(RSAKey)); if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'JSEncryptRSAKey', { enumerable: true, configurable: true, get: function() { return JSEncryptRSAKey; } }); -}, function(modId) { var map = {"./lib/jsbn/base64":1683163200617,"./lib/asn1js/hex":1683163200620,"./lib/asn1js/base64":1683163200621,"./lib/asn1js/asn1":1683163200622,"./lib/jsbn/rsa":1683163200624,"./lib/jsbn/jsbn":1683163200625,"./lib/jsrsasign/asn1-1.0":1683163200628}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200620, function(require, module, exports) { +}, function(modId) { var map = {"./lib/jsbn/base64":1683383058318,"./lib/asn1js/hex":1683383058321,"./lib/asn1js/base64":1683383058322,"./lib/asn1js/asn1":1683383058323,"./lib/jsbn/rsa":1683383058325,"./lib/jsbn/jsbn":1683383058326,"./lib/jsrsasign/asn1-1.0":1683383058329}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058321, function(require, module, exports) { // Hex JavaScript decoder // Copyright (c) 2008-2013 Lapo Luchini // Permission to use, copy, modify, and/or distribute this software for any @@ -743,7 +743,7 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t }; }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200621, function(require, module, exports) { +__DEFINE__(1683383058322, function(require, module, exports) { // Base64 JavaScript decoder // Copyright (c) 2008-2013 Lapo Luchini // Permission to use, copy, modify, and/or distribute this software for any @@ -834,7 +834,7 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t }; }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200622, function(require, module, exports) { +__DEFINE__(1683383058323, function(require, module, exports) { // ASN.1 JavaScript decoder // Copyright (c) 2008-2014 Lapo Luchini // Permission to use, copy, modify, and/or distribute this software for any @@ -1401,8 +1401,8 @@ var ASN1Tag = /** @class */ (function () { }()); if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'ASN1Tag', { enumerable: true, configurable: true, get: function() { return ASN1Tag; } }); -}, function(modId) { var map = {"./int10":1683163200623}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200623, function(require, module, exports) { +}, function(modId) { var map = {"./int10":1683383058324}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058324, function(require, module, exports) { // Big integer base-10 printing library // Copyright (c) 2014 Lapo Luchini // Permission to use, copy, modify, and/or distribute this software for any @@ -1492,7 +1492,7 @@ var Int10 = /** @class */ (function () { if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'Int10', { enumerable: true, configurable: true, get: function() { return Int10; } }); }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200624, function(require, module, exports) { +__DEFINE__(1683383058325, function(require, module, exports) { // Depends on jsbn.js and rng.js // Version 1.1: support utf-8 encoding in pkcs1pad2 // convert a (hex) string to a bignum object @@ -1965,8 +1965,8 @@ function removeDigestHeader(str) { // public // RSAKey.prototype.encrypt_b64 = RSAEncryptB64; -}, function(modId) { var map = {"./jsbn":1683163200625,"./rng":1683163200626}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200625, function(require, module, exports) { +}, function(modId) { var map = {"./jsbn":1683383058326,"./rng":1683383058327}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058326, function(require, module, exports) { // Copyright (c) 2005 Tom Wu // All Rights Reserved. // See "LICENSE" for details. @@ -3722,8 +3722,8 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t BigInteger.ZERO = nbv(0); BigInteger.ONE = nbv(1); -}, function(modId) { var map = {"./util":1683163200618}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200626, function(require, module, exports) { +}, function(modId) { var map = {"./util":1683383058319}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058327, function(require, module, exports) { // Random number generator - requires a PRNG backend, e.g. prng4.js var __TEMP__ = require('./prng4');var prng_newstate = __TEMP__['prng_newstate'];var rng_psize = __TEMP__['rng_psize']; var rng_state; @@ -3781,8 +3781,8 @@ var SecureRandom = /** @class */ (function () { }()); if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'SecureRandom', { enumerable: true, configurable: true, get: function() { return SecureRandom; } }); -}, function(modId) { var map = {"./prng4":1683163200627}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200627, function(require, module, exports) { +}, function(modId) { var map = {"./prng4":1683383058328}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058328, function(require, module, exports) { // prng4.js - uses Arcfour as a PRNG var Arcfour = /** @class */ (function () { function Arcfour() { @@ -3831,7 +3831,7 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });var rng_psize = exports.rng_psize = 256; }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200628, function(require, module, exports) { +__DEFINE__(1683383058329, function(require, module, exports) { /* asn1-1.0.13.js (c) 2013-2017 Kenji Urushima | kjur.github.com/jsrsasign/license */ /* @@ -5426,8 +5426,8 @@ KJUR.asn1.DERTaggedObject = function (params) { }; YAHOO.lang.extend(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object); -}, function(modId) { var map = {"../jsbn/jsbn":1683163200625,"./yahoo":1683163200629}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200629, function(require, module, exports) { +}, function(modId) { var map = {"../jsbn/jsbn":1683383058326,"./yahoo":1683383058330}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1683383058330, function(require, module, exports) { /*! Copyright (c) 2011, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: @@ -5499,13 +5499,13 @@ YAHOO.lang = { }; }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1683163200630, function(require, module, exports) { +__DEFINE__(1683383058331, function(require, module, exports) { module.exports = { "version": "3.2.1" } }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -return __REQUIRE__(1683163200615); +return __REQUIRE__(1683383058316); })() //miniprogram-npm-outsideDeps=[] //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index a295faa..809ec4c 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -17,6 +17,11 @@ "dayjs": "^1.10.7" } }, + "node_modules/weapp-qrcode-canvas-2d": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/weapp-qrcode-canvas-2d/-/weapp-qrcode-canvas-2d-1.1.2.tgz", + "integrity": "sha512-HQef+xpZiiWDcq8aLZdXnVdNljoYsEWiEKiBYnAnfgqXTeYfC8ApzoB9pMI5mnPFbhtu5xCi8oId1g/86uUl8Q==" + }, "node_modules/wxmp-rsa": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wxmp-rsa/-/wxmp-rsa-2.1.0.tgz", diff --git a/node_modules/weapp-qrcode-canvas-2d/.editorconfig b/node_modules/weapp-qrcode-canvas-2d/.editorconfig new file mode 100644 index 0000000..9d08a1a --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/node_modules/weapp-qrcode-canvas-2d/.eslintignore b/node_modules/weapp-qrcode-canvas-2d/.eslintignore new file mode 100644 index 0000000..a86a5dc --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/.eslintignore @@ -0,0 +1,3 @@ +build/*.js +src/qrcode.js +src/index.js diff --git a/node_modules/weapp-qrcode-canvas-2d/.eslintrc.js b/node_modules/weapp-qrcode-canvas-2d/.eslintrc.js new file mode 100644 index 0000000..6913aee --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/.eslintrc.js @@ -0,0 +1,26 @@ +module.exports = { + root: true, + parser: 'babel-eslint', + parserOptions: { + sourceType: 'module' + }, + env: { + browser: true, + }, + // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style + extends: 'standard', + "globals": { + __VERSION__: false, + ENV: false, + wx: false + }, + // add your custom rules here + 'rules': { + // allow paren-less arrow functions + 'arrow-parens': 0, + // allow async-await + 'generator-star-spacing': 0, + // allow debugger during development + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 + } +} diff --git a/node_modules/weapp-qrcode-canvas-2d/.travis.yml b/node_modules/weapp-qrcode-canvas-2d/.travis.yml new file mode 100644 index 0000000..e358a83 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/.travis.yml @@ -0,0 +1,23 @@ +language: node_js +sudo: required +node_js: + - 10.0.0 +cache: + directories: + - node_modules +before_install: + - export TZ='Asia/Shanghai' +install: + - npm install +script: + - npm run publish + +after_script: + - git init + - git config user.name "${USER_NAME}" + - git config user.email "${USER_EMAIL}" + - git add . + - git commit -m "publish" + - git push -f https://${access_token}@github.com/DoctorWei/weapp.qrcode-canvas-2d HEAD:master + +branch: master \ No newline at end of file diff --git a/node_modules/weapp-qrcode-canvas-2d/LICENSE b/node_modules/weapp-qrcode-canvas-2d/LICENSE new file mode 100644 index 0000000..984eeed --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 DoctorWei + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/weapp-qrcode-canvas-2d/README.md b/node_modules/weapp-qrcode-canvas-2d/README.md new file mode 100644 index 0000000..b9f1e7b --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/README.md @@ -0,0 +1,171 @@ +# weapp-qrcode-canvas-2d + + [weapp-qrcode-canvas-2d](https://github.com/DoctorWei/weapp-qrcode-canvas-2d) 是使用新版canvas-2d接口在微信小程序中生成二维码(外部二维码)的js包。canvas 2d 接口支持同层渲染且性能更佳,建议切换使用,可大幅提升速度。 + +# 仓库地址 +- [weapp-qrcode-canvas-2d【码云gitee】](https://gitee.com/WeiDoctor/weapp-qrcode-canvas-2d) +- [weapp-qrcode-canvas-2d【github】](https://github.com/DoctorWei/weapp-qrcode-canvas-2d) + + + +# 测试环境 +- 微信小程序基础库版本:2.10.4 +- 开发者工具版本:Stable 1.03.2101150 + +# Usage + +先在 wxml 文件中,创建绘制的 `canvas`,并定义好 `width`, `height`, `id` , `type` ,其中type的值必须为`2d` + +```html + +``` + +## 安装方法1:直接引入 js 文件 +直接引入 js 文件,使用 `drawQrcode()` 绘制二维码 + +```js +// 将 dist 目录下,weapp.qrcode.esm.js 复制到项目中。路径根据实际引用的页面路径自行改变 + +import drawQrcode from '../../utils/weapp.qrcode.esm.js' +``` + +## 安装方法2:npm安装 + +``` +npm install weapp-qrcode-canvas-2d --save +``` +// 然后需要在小程序开发者工具中:构建npm + +```js +import drawQrcode from 'weapp-qrcode-canvas-2d' +``` + +## 安装完成后调用 + +### 例子1:没有使用叠加图片 +```js +const query = wx.createSelectorQuery() +query.select('#myQrcode') + .fields({ + node: true, + size: true + }) + .exec((res) => { + var canvas = res[0].node + + // 调用方法drawQrcode生成二维码 + drawQrcode({ + canvas: canvas, + canvasId: 'myQrcode', + width: 260, + padding: 30, + background: '#ffffff', + foreground: '#000000', + text: '大王顶真帅', + }) + + // 获取临时路径(得到之后,想干嘛就干嘛了) + wx.canvasToTempFilePath({ + canvasId: 'myQrcode', + canvas: canvas, + x: 0, + y: 0, + width: 260, + height: 260, + destWidth: 260, + destHeight: 260, + success(res) { + console.log('二维码临时路径:', res.tempFilePath) + }, + fail(res) { + console.error(res) + } + }) + }) +``` + +### 例子2:使用叠加图片(在二维码中加logo) +```js +const query = wx.createSelectorQuery() + +query.select('#myQrcode') + .fields({ + node: true, + size: true + }) + .exec(async (res) => { + var canvas = res[0].node + + var img = canvas.createImage(); + img.src = "/image/logo.png" + + img.onload = function () { + // img.onload完成后才能调用 drawQrcode方法 + + var options = { + canvas: canvas, + canvasId: 'myQrcode', + width: 260, + padding: 30, + paddingColor: '#fff', + background: '#fff', + foreground: '#000000', + text: 'https://gitee.com/w386888618/weapp-qrcode-canvas-2d', + image: { + imageResource: img, + width: 80, // 建议不要设置过大,以免影响扫码 + height: 80 // 建议不要设置过大,以免影响扫码 + round: true // Logo图片是否为圆形 + } + } + + drawQrcode(options) + + // 获取临时路径(得到之后,想干嘛就干嘛了) + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: 260, + height: 260, + destWidth: 600, + destHeight: 600, + canvasId: 'myQrcode', + canvas: canvas, + success(res) { + console.log('二维码临时路径为:', res.tempFilePath) + }, + fail(res) { + console.error(res) + } + }) + + }; + }) +``` + + +# API +## drawQrcode([options]) +### options + +Type: Object + +| 参数 | 必须 | 说明 | 示例| +| ------ | ------ | ------ | ------ | +| canvas | 必须 | 画布标识,传入 canvas 组件实例 | | +| canvasId | 非 | 绘制的`canvasId` | `'myQrcode'` | +| text | 必须 | 二维码内容 | 'https://github.com/DoctorWei/weapp-qrcode-canvas-2d' | +| width | 非 | 二维码宽度,与`canvas`的`width`保持一致 | 260 | +| padding | 非 | 空白内边距 | 20 | +| paddingColor | 非 | 内边距颜色 | 默认与background一致 | +| background | 非 | 二维码背景颜色,默认值白色 | `'#ffffff'` | +| foreground | 非 | 二维码前景色,默认值黑色 | `'#000000'` | +| typeNumber | 非| 二维码的计算模式,默认值-1 | 8 | +| correctLevel | 非| 二维码纠错级别,默认值为高级,取值:`{ L: 1, M: 0, Q: 3, H: 2 }` | 1 | +| image | 非 | 在 canvas 上绘制图片,层级高于二维码,v1.1.1+版本支持。具体使用见:例子2 | `{imageResource: '', width:80, height: 80, round: true}` | +# TIPS + +weapp-qrcode-canvas-2d 参考以下源码 + +- 参考 [weapp-qrcode](https://github.com/yingye/weapp-qrcode) +- 参考 [jquery-qrcode](https://github.com/jeromeetienne/jquery-qrcode) \ No newline at end of file diff --git a/node_modules/weapp-qrcode-canvas-2d/build/rollup.dev.config.js b/node_modules/weapp-qrcode-canvas-2d/build/rollup.dev.config.js new file mode 100644 index 0000000..a8ef569 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/build/rollup.dev.config.js @@ -0,0 +1,39 @@ +var babel = require('rollup-plugin-babel') +var resolve = require('rollup-plugin-node-resolve') +var commonjs = require('rollup-plugin-commonjs') +var eslint = require('rollup-plugin-eslint') +var license = require('rollup-plugin-license') + +var path = require('path') + +var pkg = require('../package.json') + +module.exports = { + input: path.resolve(__dirname, '../src/index.js'), + output: [ + { + file: path.resolve(__dirname, '../dist/weapp.qrcode.js'), + format: 'umd' + }, + { + file: path.resolve(__dirname, '../examples/wechat-app/utils/weapp.qrcode.js'), + format: 'umd' + } + ], + moduleName: 'drawQrcode', + plugins: [ + eslint(), + resolve({ + jsnext: true, + main: true, + browser: true + }), + commonjs(), + babel({ + exclude: 'node_modules/**' + }), + license({ + banner: 'weapp.qrcode.js v' + pkg.version + ' (' + pkg.homepage + ')' + }) + ] +} \ No newline at end of file diff --git a/node_modules/weapp-qrcode-canvas-2d/build/rollup.prod.config.js b/node_modules/weapp-qrcode-canvas-2d/build/rollup.prod.config.js new file mode 100644 index 0000000..c00e826 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/build/rollup.prod.config.js @@ -0,0 +1,49 @@ +var babel = require('rollup-plugin-babel') +var babel = require('rollup-plugin-babel') +var resolve = require('rollup-plugin-node-resolve') +var commonjs = require('rollup-plugin-commonjs') +var eslint = require('rollup-plugin-eslint') +var license = require('rollup-plugin-license') +var uglify = require('rollup-plugin-uglify') + +var path = require('path') +var pkg = require('../package.json') + +module.exports = { + input: path.resolve(__dirname, '../src/index.js'), + output: [ + { + file: path.resolve(__dirname, '../dist/weapp.qrcode.min.js'), + format: 'umd' + }, + { + file: path.resolve(__dirname, '../dist/weapp.qrcode.common.js'), + format: 'cjs' + }, + { + file: path.resolve(__dirname, '../dist/weapp.qrcode.esm.js'), + format: 'es' + } + ], + moduleName: 'drawQrcode', + plugins: [ + eslint(), + resolve({ + jsnext: true, + main: true, + browser: true + }), + commonjs(), + babel({ + exclude: 'node_modules/**' + }), + uglify({ + compress: { + // 'drop_console': true + } + }), + license({ + banner: 'weapp.qrcode.js v' + pkg.version + ' (' + pkg.homepage + ')' + }) + ] +} \ No newline at end of file diff --git a/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.common.js b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.common.js new file mode 100644 index 0000000..80b98d4 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.common.js @@ -0,0 +1,5 @@ +/** + * weapp.qrcode.js v1.1.1 (undefined) + */ + +"use strict";var hasOwn=Object.prototype.hasOwnProperty,toStr=Object.prototype.toString,defineProperty=Object.defineProperty,gOPD=Object.getOwnPropertyDescriptor,isArray=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===toStr.call(t)},isPlainObject=function(t){if(!t||"[object Object]"!==toStr.call(t))return!1;var e,r=hasOwn.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&hasOwn.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!o)return!1;for(e in t);return void 0===e||hasOwn.call(t,e)},setProperty=function(t,e){defineProperty&&"__proto__"===e.name?defineProperty(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},getProperty=function(t,e){if("__proto__"===e){if(!hasOwn.call(t,e))return;if(gOPD)return gOPD(t,e).value}return t[e]},extend=function t(){var e,r,o,n,i,a,s=arguments[0],u=1,l=arguments.length,h=!1;for("boolean"==typeof s&&(h=s,s=arguments[1]||{},u=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});u=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCode.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=QRUtil.getLostPoint(this);(0==r||t>o)&&(t=o,e=r)}return e},createMovieClip:function(t,e,r){var o=t.createEmptyMovieClip(e,r);this.make();for(var n=0;n>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++){o=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=QRUtil.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++){i=!t&&1==(o>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[o][a-s]){var u=!1;i>>n&1)),QRUtil.getMask(e,o,a-s)&&(u=!u),this.modules[o][a-s]=u,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}}},QRCode.PAD0=236,QRCode.PAD1=17,QRCode.createData=function(t,e,r){for(var o=QRRSBlock.getRSBlocks(t,e),n=new QRBitBuffer,i=0;i8*s)throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*s+")");for(n.getLengthInBits()+4<=8*s&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*s||(n.put(QRCode.PAD0,8),n.getLengthInBits()>=8*s));)n.put(QRCode.PAD1,8);return QRCode.createBytes(n,o)},QRCode.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),a=new Array(e.length),s=0;s=0?g.get(c):0}}var d=0;for(h=0;h=0;)e^=QRUtil.G15<=0;)e^=QRUtil.G18<>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case QRMaskPattern.PATTERN000:return(e+r)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return r%3==0;case QRMaskPattern.PATTERN011:return(e+r)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case QRMaskPattern.PATTERN101:return e*r%2+e*r%3==0;case QRMaskPattern.PATTERN110:return(e*r%2+e*r%3)%2==0;case QRMaskPattern.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),r=0;r5&&(r+=3+i-5)}for(o=0;o=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<=1&&n<=127?e+=t.charAt(r):n>2047?(e+=String.fromCharCode(224|n>>12&15),e+=String.fromCharCode(128|n>>6&63),e+=String.fromCharCode(128|n>>0&63)):(e+=String.fromCharCode(192|n>>6&31),e+=String.fromCharCode(128|n>>0&63));return e}function drawQrcode(t,e){if(t=t||{},(t=extend(!0,{canvasId:"myQrcode",text:"爱一个人就要勇敢说出来",width:260,height:260,padding:20,typeNumber:-1,correctLevel:QRErrorCorrectLevel.H,background:"#ffffff",foreground:"#000000",image:{imageResource:"",width:80,height:80,round:!0}},t)).canvasId||t.canvas){if(t.paddingColor||(t.paddingColor=t.background),e){var r=new QRCode(t.typeNumber,t.correctLevel);return r.addData(utf16to8(t.text)),r.make(),new Promise(function(t,e){t(r)})}return new Promise(function(e,r){return e(function(){var e=new QRCode(t.typeNumber,t.correctLevel);e.addData(utf16to8(t.text)),e.make();const r=wx.getSystemInfoSync().pixelRatio;var o=t.canvas;const n=o.getContext("2d");o.width=t.width*r,o.height=t.width*r;const i=o.width;n.fillStyle=t.paddingColor,n.fillRect(0,0,i+2*t.padding,i+2*t.padding);for(var a=(i-2*t.padding)/e.getModuleCount(),s=(i-2*t.padding)/e.getModuleCount(),u=0;u>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},module.exports=drawQrcode; diff --git a/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.esm.js b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.esm.js new file mode 100644 index 0000000..46c52be --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.esm.js @@ -0,0 +1,5 @@ +/** + * weapp.qrcode.js v1.1.1 (undefined) + */ + +var hasOwn=Object.prototype.hasOwnProperty,toStr=Object.prototype.toString,defineProperty=Object.defineProperty,gOPD=Object.getOwnPropertyDescriptor,isArray=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===toStr.call(t)},isPlainObject=function(t){if(!t||"[object Object]"!==toStr.call(t))return!1;var e,r=hasOwn.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&hasOwn.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!o)return!1;for(e in t);return void 0===e||hasOwn.call(t,e)},setProperty=function(t,e){defineProperty&&"__proto__"===e.name?defineProperty(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},getProperty=function(t,e){if("__proto__"===e){if(!hasOwn.call(t,e))return;if(gOPD)return gOPD(t,e).value}return t[e]},extend=function t(){var e,r,o,n,i,a,s=arguments[0],u=1,l=arguments.length,h=!1;for("boolean"==typeof s&&(h=s,s=arguments[1]||{},u=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});u=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCode.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=QRUtil.getLostPoint(this);(0==r||t>o)&&(t=o,e=r)}return e},createMovieClip:function(t,e,r){var o=t.createEmptyMovieClip(e,r);this.make();for(var n=0;n>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++){o=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=QRUtil.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++){i=!t&&1==(o>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[o][a-s]){var u=!1;i>>n&1)),QRUtil.getMask(e,o,a-s)&&(u=!u),this.modules[o][a-s]=u,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}}},QRCode.PAD0=236,QRCode.PAD1=17,QRCode.createData=function(t,e,r){for(var o=QRRSBlock.getRSBlocks(t,e),n=new QRBitBuffer,i=0;i8*s)throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*s+")");for(n.getLengthInBits()+4<=8*s&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*s||(n.put(QRCode.PAD0,8),n.getLengthInBits()>=8*s));)n.put(QRCode.PAD1,8);return QRCode.createBytes(n,o)},QRCode.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),a=new Array(e.length),s=0;s=0?g.get(c):0}}var d=0;for(h=0;h=0;)e^=QRUtil.G15<=0;)e^=QRUtil.G18<>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case QRMaskPattern.PATTERN000:return(e+r)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return r%3==0;case QRMaskPattern.PATTERN011:return(e+r)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case QRMaskPattern.PATTERN101:return e*r%2+e*r%3==0;case QRMaskPattern.PATTERN110:return(e*r%2+e*r%3)%2==0;case QRMaskPattern.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),r=0;r5&&(r+=3+i-5)}for(o=0;o=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<=1&&n<=127?e+=t.charAt(r):n>2047?(e+=String.fromCharCode(224|n>>12&15),e+=String.fromCharCode(128|n>>6&63),e+=String.fromCharCode(128|n>>0&63)):(e+=String.fromCharCode(192|n>>6&31),e+=String.fromCharCode(128|n>>0&63));return e}function drawQrcode(t,e){if(t=t||{},(t=extend(!0,{canvasId:"myQrcode",text:"爱一个人就要勇敢说出来",width:260,height:260,padding:20,typeNumber:-1,correctLevel:QRErrorCorrectLevel.H,background:"#ffffff",foreground:"#000000",image:{imageResource:"",width:80,height:80,round:!0}},t)).canvasId||t.canvas){if(t.paddingColor||(t.paddingColor=t.background),e){var r=new QRCode(t.typeNumber,t.correctLevel);return r.addData(utf16to8(t.text)),r.make(),new Promise(function(t,e){t(r)})}return new Promise(function(e,r){return e(function(){var e=new QRCode(t.typeNumber,t.correctLevel);e.addData(utf16to8(t.text)),e.make();const r=wx.getSystemInfoSync().pixelRatio;var o=t.canvas;const n=o.getContext("2d");o.width=t.width*r,o.height=t.width*r;const i=o.width;n.fillStyle=t.paddingColor,n.fillRect(0,0,i+2*t.padding,i+2*t.padding);for(var a=(i-2*t.padding)/e.getModuleCount(),s=(i-2*t.padding)/e.getModuleCount(),u=0;u>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};export default drawQrcode; diff --git a/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.js b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.js new file mode 100644 index 0000000..19ee962 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.js @@ -0,0 +1,1326 @@ +/** + * weapp.qrcode.js v1.1.1 (undefined) + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.drawQrcode = factory()); +}(this, (function () { 'use strict'; + +var hasOwn = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var defineProperty = Object.defineProperty; +var gOPD = Object.getOwnPropertyDescriptor; + +var isArray = function isArray(arr) { + if (typeof Array.isArray === 'function') { + return Array.isArray(arr); + } + + return toStr.call(arr) === '[object Array]'; +}; + +var isPlainObject = function isPlainObject(obj) { + if (!obj || toStr.call(obj) !== '[object Object]') { + return false; + } + + var hasOwnConstructor = hasOwn.call(obj, 'constructor'); + var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); + // Not own constructor property must be Object + if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) { /**/ } + + return typeof key === 'undefined' || hasOwn.call(obj, key); +}; + +// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target +var setProperty = function setProperty(target, options) { + if (defineProperty && options.name === '__proto__') { + defineProperty(target, options.name, { + enumerable: true, + configurable: true, + value: options.newValue, + writable: true + }); + } else { + target[options.name] = options.newValue; + } +}; + +// Return undefined instead of __proto__ if '__proto__' is not an own property +var getProperty = function getProperty(obj, name) { + if (name === '__proto__') { + if (!hasOwn.call(obj, name)) { + return void 0; + } else if (gOPD) { + // In early versions of node, obj['__proto__'] is buggy when obj has + // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. + return gOPD(obj, name).value; + } + } + + return obj[name]; +}; + +var extend = function extend() { + var options, name, src, copy, copyIsArray, clone; + var target = arguments[0]; + var i = 1; + var length = arguments.length; + var deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { + target = {}; + } + + for (; i < length; ++i) { + options = arguments[i]; + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = getProperty(target, name); + copy = getProperty(options, name); + + // Prevent never-ending loop + if (target !== copy) { + // Recurse if we're merging plain objects or arrays + if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + } else { + clone = src && isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); + + // Don't bring in undefined values + } else if (typeof copy !== 'undefined') { + setProperty(target, { name: name, newValue: copy }); + } + } + } + } + } + + // Return the modified object + return target; +}; + +//--------------------------------------------------------------------- +// QRCode for JavaScript +// +// Copyright (c) 2009 Kazuhiko Arase +// +// URL: http://www.d-project.com/ +// +// Licensed under the MIT license: +// http://www.opensource.org/licenses/mit-license.php +// +// The word "QR Code" is registered trademark of +// DENSO WAVE INCORPORATED +// http://www.denso-wave.com/qrcode/faqpatent-e.html +// +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// QR8bitByte +//--------------------------------------------------------------------- + +function QR8bitByte(data) { + this.mode = QRMode.MODE_8BIT_BYTE; + this.data = data; +} + +QR8bitByte.prototype = { + + getLength: function (buffer) { + return this.data.length; + }, + + write: function (buffer) { + for (var i = 0; i < this.data.length; i++) { + // not JIS ... + buffer.put(this.data.charCodeAt(i), 8); + } + } +}; + +//--------------------------------------------------------------------- +// QRCode +//--------------------------------------------------------------------- + +function QRCode(typeNumber, errorCorrectLevel) { + this.typeNumber = typeNumber; + this.errorCorrectLevel = errorCorrectLevel; + this.modules = null; + this.moduleCount = 0; + this.dataCache = null; + this.dataList = new Array(); +} + +QRCode.prototype = { + + addData: function (data) { + var newData = new QR8bitByte(data); + this.dataList.push(newData); + this.dataCache = null; + }, + + isDark: function (row, col) { + if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) { + throw new Error(row + "," + col); + } + return this.modules[row][col]; + }, + + getModuleCount: function () { + return this.moduleCount; + }, + + make: function () { + // Calculate automatically typeNumber if provided is < 1 + if (this.typeNumber < 1) { + var typeNumber = 1; + for (typeNumber = 1; typeNumber < 40; typeNumber++) { + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel); + + var buffer = new QRBitBuffer(); + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + for (var i = 0; i < this.dataList.length; i++) { + var data = this.dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber)); + data.write(buffer); + } + if (buffer.getLengthInBits() <= totalDataCount * 8) break; + } + this.typeNumber = typeNumber; + } + this.makeImpl(false, this.getBestMaskPattern()); + }, + + makeImpl: function (test, maskPattern) { + + this.moduleCount = this.typeNumber * 4 + 17; + this.modules = new Array(this.moduleCount); + + for (var row = 0; row < this.moduleCount; row++) { + + this.modules[row] = new Array(this.moduleCount); + + for (var col = 0; col < this.moduleCount; col++) { + this.modules[row][col] = null; //(col + row) % 3; + } + } + + this.setupPositionProbePattern(0, 0); + this.setupPositionProbePattern(this.moduleCount - 7, 0); + this.setupPositionProbePattern(0, this.moduleCount - 7); + this.setupPositionAdjustPattern(); + this.setupTimingPattern(); + this.setupTypeInfo(test, maskPattern); + + if (this.typeNumber >= 7) { + this.setupTypeNumber(test); + } + + if (this.dataCache == null) { + this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); + } + + this.mapData(this.dataCache, maskPattern); + }, + + setupPositionProbePattern: function (row, col) { + + for (var r = -1; r <= 7; r++) { + + if (row + r <= -1 || this.moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c++) { + + if (col + c <= -1 || this.moduleCount <= col + c) continue; + + if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + + getBestMaskPattern: function () { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i++) { + + this.makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }, + + createMovieClip: function (target_mc, instance_name, depth) { + + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); + var cs = 1; + + this.make(); + + for (var row = 0; row < this.modules.length; row++) { + + var y = row * cs; + + for (var col = 0; col < this.modules[row].length; col++) { + + var x = col * cs; + var dark = this.modules[row][col]; + + if (dark) { + qr_mc.beginFill(0, 100); + qr_mc.moveTo(x, y); + qr_mc.lineTo(x + cs, y); + qr_mc.lineTo(x + cs, y + cs); + qr_mc.lineTo(x, y + cs); + qr_mc.endFill(); + } + } + } + + return qr_mc; + }, + + setupTimingPattern: function () { + + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = r % 2 == 0; + } + + for (var c = 8; c < this.moduleCount - 8; c++) { + if (this.modules[6][c] != null) { + continue; + } + this.modules[6][c] = c % 2 == 0; + } + }, + + setupPositionAdjustPattern: function () { + + var pos = QRUtil.getPatternPosition(this.typeNumber); + + for (var i = 0; i < pos.length; i++) { + + for (var j = 0; j < pos.length; j++) { + + var row = pos[i]; + var col = pos[j]; + + if (this.modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r++) { + + for (var c = -2; c <= 2; c++) { + + if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + + setupTypeNumber: function (test) { + + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + + for (var i = 0; i < 18; i++) { + var mod = !test && (bits >> i & 1) == 1; + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i++) { + var mod = !test && (bits >> i & 1) == 1; + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + + setupTypeInfo: function (test, maskPattern) { + + var data = this.errorCorrectLevel << 3 | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i++) { + + var mod = !test && (bits >> i & 1) == 1; + + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i++) { + + var mod = !test && (bits >> i & 1) == 1; + + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + + // fixed module + this.modules[this.moduleCount - 8][8] = !test; + }, + + mapData: function (data, maskPattern) { + + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col--; + + while (true) { + + for (var c = 0; c < 2; c++) { + + if (this.modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = (data[byteIndex] >>> bitIndex & 1) == 1; + } + + var mask = QRUtil.getMask(maskPattern, row, col - c); + + if (mask) { + dark = !dark; + } + + this.modules[row][col - c] = dark; + bitIndex--; + + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + } + +}; + +QRCode.PAD0 = 0xEC; +QRCode.PAD1 = 0x11; + +QRCode.createData = function (typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = new QRBitBuffer(); + + for (var i = 0; i < dataList.length; i++) { + var data = dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber)); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")"); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD1, 8); + } + + return QRCode.createBytes(buffer, rsBlocks); +}; + +QRCode.createBytes = function (buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r++) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0; + } + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + + return data; +}; + +//--------------------------------------------------------------------- +// QRMode +//--------------------------------------------------------------------- + +var QRMode = { + MODE_NUMBER: 1 << 0, + MODE_ALPHA_NUM: 1 << 1, + MODE_8BIT_BYTE: 1 << 2, + MODE_KANJI: 1 << 3 +}; + +//--------------------------------------------------------------------- +// QRErrorCorrectLevel +//--------------------------------------------------------------------- + +var QRErrorCorrectLevel = { + L: 1, + M: 0, + Q: 3, + H: 2 +}; + +//--------------------------------------------------------------------- +// QRMaskPattern +//--------------------------------------------------------------------- + +var QRMaskPattern = { + PATTERN000: 0, + PATTERN001: 1, + PATTERN010: 2, + PATTERN011: 3, + PATTERN100: 4, + PATTERN101: 5, + PATTERN110: 6, + PATTERN111: 7 +}; + +//--------------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------------- + +var QRUtil = { + + PATTERN_POSITION_TABLE: [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], + + G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0, + G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0, + G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1, + + getBCHTypeInfo: function (data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15); + } + return (data << 10 | d) ^ QRUtil.G15_MASK; + }, + + getBCHTypeNumber: function (data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18); + } + return data << 12 | d; + }, + + getBCHDigit: function (data) { + + var digit = 0; + + while (data != 0) { + digit++; + data >>>= 1; + } + + return digit; + }, + + getPatternPosition: function (typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + + getMask: function (maskPattern, i, j) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000: + return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001: + return i % 2 == 0; + case QRMaskPattern.PATTERN010: + return j % 3 == 0; + case QRMaskPattern.PATTERN011: + return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100: + return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0; + case QRMaskPattern.PATTERN101: + return i * j % 2 + i * j % 3 == 0; + case QRMaskPattern.PATTERN110: + return (i * j % 2 + i * j % 3) % 2 == 0; + case QRMaskPattern.PATTERN111: + return (i * j % 3 + (i + j) % 2) % 2 == 0; + + default: + throw new Error("bad maskPattern:" + maskPattern); + } + }, + + getErrorCorrectPolynomial: function (errorCorrectLength) { + + var a = new QRPolynomial([1], 0); + + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0)); + } + + return a; + }, + + getLengthInBits: function (mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch (mode) { + case QRMode.MODE_NUMBER: + return 10; + case QRMode.MODE_ALPHA_NUM: + return 9; + case QRMode.MODE_8BIT_BYTE: + return 8; + case QRMode.MODE_KANJI: + return 8; + default: + throw new Error("mode:" + mode); + } + } else if (type < 27) { + + // 10 - 26 + + switch (mode) { + case QRMode.MODE_NUMBER: + return 12; + case QRMode.MODE_ALPHA_NUM: + return 11; + case QRMode.MODE_8BIT_BYTE: + return 16; + case QRMode.MODE_KANJI: + return 10; + default: + throw new Error("mode:" + mode); + } + } else if (type < 41) { + + // 27 - 40 + + switch (mode) { + case QRMode.MODE_NUMBER: + return 14; + case QRMode.MODE_ALPHA_NUM: + return 13; + case QRMode.MODE_8BIT_BYTE: + return 16; + case QRMode.MODE_KANJI: + return 12; + default: + throw new Error("mode:" + mode); + } + } else { + throw new Error("type:" + type); + } + }, + + getLostPoint: function (qrCode) { + + var moduleCount = qrCode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row++) { + + for (var col = 0; col < moduleCount; col++) { + + var sameCount = 0; + var dark = qrCode.isDark(row, col); + + for (var r = -1; r <= 1; r++) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c++) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrCode.isDark(row + r, col + c)) { + sameCount++; + } + } + } + + if (sameCount > 5) { + lostPoint += 3 + sameCount - 5; + } + } + } + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row++) { + for (var col = 0; col < moduleCount - 1; col++) { + var count = 0; + if (qrCode.isDark(row, col)) count++; + if (qrCode.isDark(row + 1, col)) count++; + if (qrCode.isDark(row, col + 1)) count++; + if (qrCode.isDark(row + 1, col + 1)) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row++) { + for (var col = 0; col < moduleCount - 6; col++) { + if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount - 6; row++) { + if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount; row++) { + if (qrCode.isDark(row, col)) { + darkCount++; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + } + +}; + +//--------------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------------- + +var QRMath = { + + glog: function (n) { + + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + + return QRMath.LOG_TABLE[n]; + }, + + gexp: function (n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return QRMath.EXP_TABLE[n]; + }, + + EXP_TABLE: new Array(256), + + LOG_TABLE: new Array(256) + +}; + +for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; +} +for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8]; +} +for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i; +} + +//--------------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------------- + +function QRPolynomial(num, shift) { + + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + + var offset = 0; + + while (offset < num.length && num[offset] == 0) { + offset++; + } + + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } +} + +QRPolynomial.prototype = { + + get: function (index) { + return this.num[index]; + }, + + getLength: function () { + return this.num.length; + }, + + multiply: function (e) { + + var num = new Array(this.getLength() + e.getLength() - 1); + + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j))); + } + } + + return new QRPolynomial(num, 0); + }, + + mod: function (e) { + + if (this.getLength() - e.getLength() < 0) { + return this; + } + + var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0)); + + var num = new Array(this.getLength()); + + for (var i = 0; i < this.getLength(); i++) { + num[i] = this.get(i); + } + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio); + } + + // recursive call + return new QRPolynomial(num, 0).mod(e); + } +}; + +//--------------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------------- + +function QRRSBlock(totalCount, dataCount) { + this.totalCount = totalCount; + this.dataCount = dataCount; +} + +QRRSBlock.RS_BLOCK_TABLE = [ + +// L +// M +// Q +// H + +// 1 +[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], + +// 2 +[1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], + +// 3 +[1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], + +// 4 +[1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], + +// 5 +[1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], + +// 6 +[2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], + +// 7 +[2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], + +// 8 +[2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], + +// 9 +[2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], + +// 10 +[2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], + +// 11 +[4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], + +// 12 +[2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], + +// 13 +[4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], + +// 14 +[3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], + +// 15 +[5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12], + +// 16 +[5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], + +// 17 +[1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], + +// 18 +[5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], + +// 19 +[3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], + +// 20 +[3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], + +// 21 +[4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], + +// 22 +[2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], + +// 23 +[4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], + +// 24 +[6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], + +// 25 +[8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], + +// 26 +[10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], + +// 27 +[8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], + +// 28 +[3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], + +// 29 +[7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], + +// 30 +[5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], + +// 31 +[13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], + +// 32 +[17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], + +// 33 +[17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], + +// 34 +[13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], + +// 35 +[12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], + +// 36 +[6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], + +// 37 +[17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], + +// 38 +[4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], + +// 39 +[20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], + +// 40 +[19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]]; + +QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) { + + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); + + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i++) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j++) { + list.push(new QRRSBlock(totalCount, dataCount)); + } + } + + return list; +}; + +QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) { + + switch (errorCorrectLevel) { + case QRErrorCorrectLevel.L: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default: + return undefined; + } +}; + +//--------------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------------- + +function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; +} + +QRBitBuffer.prototype = { + + get: function (index) { + var bufIndex = Math.floor(index / 8); + return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1; + }, + + put: function (num, length) { + for (var i = 0; i < length; i++) { + this.putBit((num >>> length - i - 1 & 1) == 1); + } + }, + + getLengthInBits: function () { + return this.length; + }, + + putBit: function (bit) { + + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + + if (bit) { + this.buffer[bufIndex] |= 0x80 >>> this.length % 8; + } + + this.length++; + } +}; + +// support Chinese +function utf16to8(str) { + var out, i, len, c; + out = ''; + len = str.length; + for (i = 0; i < len; i++) { + c = str.charCodeAt(i); + if (c >= 0x0001 && c <= 0x007F) { + out += str.charAt(i); + } else if (c > 0x07FF) { + out += String.fromCharCode(0xE0 | c >> 12 & 0x0F); + out += String.fromCharCode(0x80 | c >> 6 & 0x3F); + out += String.fromCharCode(0x80 | c >> 0 & 0x3F); + } else { + out += String.fromCharCode(0xC0 | c >> 6 & 0x1F); + out += String.fromCharCode(0x80 | c >> 0 & 0x3F); + } + } + return out; +} + +function drawQrcode(options, debug) { + options = options || {}; + options = extend(true, { + canvasId: 'myQrcode', + // canvas: canvas, + text: '爱一个人就要勇敢说出来', + width: 260, + height: 260, + padding: 20, + // paddingColor: '#ffffff', // 默认与background一致 + typeNumber: -1, + correctLevel: QRErrorCorrectLevel.H, + background: '#ffffff', + foreground: '#000000', + image: { + imageResource: '', + width: 80, + height: 80, + round: true + } + }, options); + + if (!options.canvasId && !options.canvas) { + console.warn('please set canvasId or canvas!'); + return; + } + + if (!options.paddingColor) options.paddingColor = options.background; + + if (debug) { + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(utf16to8(options.text)); + qrcode.make(); + + return new Promise(function (resolve, reject) { + resolve(qrcode); + }); + } else { + + return new Promise(function (resolve, reject) { + return resolve(createCanvas()); + }); + } + + function createCanvas() { + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(utf16to8(options.text)); + qrcode.make(); + + const dpr = wx.getSystemInfoSync().pixelRatio; + var canvas = options.canvas; + const ctx = canvas.getContext('2d'); + canvas.width = options.width * dpr; + canvas.height = options.width * dpr; + const width = canvas.width; + + // 背景色 + ctx.fillStyle = options.paddingColor; + ctx.fillRect(0, 0, width + options.padding * 2, width + options.padding * 2); + + var tileW = (width - options.padding * 2) / qrcode.getModuleCount(); + var tileH = (width - options.padding * 2) / qrcode.getModuleCount(); + + // 开始画二维码 + for (var row = 0; row < qrcode.getModuleCount(); row++) { + for (var col = 0; col < qrcode.getModuleCount(); col++) { + ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background; + var w = Math.ceil((col + 1) * tileW) - Math.floor(col * tileW); + var h = Math.ceil((row + 1) * tileW) - Math.floor(row * tileW); + ctx.fillRect(Math.round(col * tileW) + options.padding, Math.round(row * tileH) + options.padding, w, h); + } + } + + if (options.image.imageResource) { + const imgW = options.image.width * dpr; + const imgH = options.image.height * dpr; + const dx = (width - imgW) / 2; + const dy = (width - imgH) / 2; + if (options.image.round) { + // Logo边框 + const imgW2 = options.image.width * dpr + 30; + const dx2 = (width - imgW2) / 2; + const r2 = imgW2 / 2; + const cx2 = dx2 + r2; + ctx.beginPath(); + ctx.arc(cx2, cx2, r2, 0, 2 * Math.PI); + ctx.fillStyle = '#ffffff'; + ctx.fill(); + ctx.restore(); + + // 画Logo + const r = imgW / 2; + const cx = dx + r; + const cy = dy + r; + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, 2 * Math.PI); + ctx.clip(); + + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgW); + ctx.restore(); + } else { + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgH); + ctx.restore(); + } + } + + return ctx; + } +} + +return drawQrcode; + +}))); diff --git a/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.min.js b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.min.js new file mode 100644 index 0000000..d20a129 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/dist/weapp.qrcode.min.js @@ -0,0 +1,5 @@ +/** + * weapp.qrcode.js v1.1.1 (undefined) + */ + +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.drawQrcode=e()}(this,function(){"use strict";var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===e.call(t)},i=function(r){if(!r||"[object Object]"!==e.call(r))return!1;var o,n=t.call(r,"constructor"),i=r.constructor&&r.constructor.prototype&&t.call(r.constructor.prototype,"isPrototypeOf");if(r.constructor&&!n&&!i)return!1;for(o in r);return void 0===o||t.call(r,o)},a=function(t,e){r&&"__proto__"===e.name?r(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},u=function(e,r){if("__proto__"===r){if(!t.call(e,r))return;if(o)return o(e,r).value}return e[r]},s=function t(){var e,r,o,s,h,l,f=arguments[0],g=1,c=arguments.length,d=!1;for("boolean"==typeof f&&(d=f,f=arguments[1]||{},g=2),(null==f||"object"!=typeof f&&"function"!=typeof f)&&(f={});g=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=l.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=B.getLostPoint(this);(0==r||t>o)&&(t=o,e=r)}return e},createMovieClip:function(t,e,r){var o=t.createEmptyMovieClip(e,r);this.make();for(var n=0;n>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++){o=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=B.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++){i=!t&&1==(o>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var u=0;u<2;u++)if(null==this.modules[o][a-u]){var s=!1;i>>n&1)),B.getMask(e,o,a-u)&&(s=!s),this.modules[o][a-u]=s,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}}},l.PAD0=236,l.PAD1=17,l.createData=function(t,e,r){for(var o=_.getRSBlocks(t,e),n=new D,i=0;i8*u)throw new Error("code length overflow. ("+n.getLengthInBits()+">"+8*u+")");for(n.getLengthInBits()+4<=8*u&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*u||(n.put(l.PAD0,8),n.getLengthInBits()>=8*u));)n.put(l.PAD1,8);return l.createBytes(n,o)},l.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),a=new Array(e.length),u=0;u=0?g.get(c):0}}var d=0;for(l=0;l=0;)e^=B.G15<=0;)e^=B.G18<>>=1;return e},getPatternPosition:function(t){return B.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case d:return e%2==0;case m:return r%3==0;case p:return(e+r)%3==0;case v:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case C:return e*r%2+e*r%3==0;case w:return(e*r%2+e*r%3)%2==0;case L:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new A([1],0),r=0;r5&&(r+=3+i-5)}for(o=0;o=256;)t-=255;return y.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},E=0;E<8;E++)y.EXP_TABLE[E]=1<=1&&n<=127?e+=t.charAt(r):n>2047?(e+=String.fromCharCode(224|n>>12&15),e+=String.fromCharCode(128|n>>6&63),e+=String.fromCharCode(128|n>>0&63)):(e+=String.fromCharCode(192|n>>6&31),e+=String.fromCharCode(128|n>>0&63));return e}return A.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;r>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},function(t,e){if(t=t||{},(t=s(!0,{canvasId:"myQrcode",text:"爱一个人就要勇敢说出来",width:260,height:260,padding:20,typeNumber:-1,correctLevel:g.H,background:"#ffffff",foreground:"#000000",image:{imageResource:"",width:80,height:80,round:!0}},t)).canvasId||t.canvas){if(t.paddingColor||(t.paddingColor=t.background),e){var r=new l(t.typeNumber,t.correctLevel);return r.addData(P(t.text)),r.make(),new Promise(function(t,e){t(r)})}return new Promise(function(e,r){return e(function(){var e=new l(t.typeNumber,t.correctLevel);e.addData(P(t.text)),e.make();const r=wx.getSystemInfoSync().pixelRatio;var o=t.canvas;const n=o.getContext("2d");o.width=t.width*r,o.height=t.width*r;const i=o.width;n.fillStyle=t.paddingColor,n.fillRect(0,0,i+2*t.padding,i+2*t.padding);for(var a=(i-2*t.padding)/e.getModuleCount(),u=(i-2*t.padding)/e.getModuleCount(),s=0;s= 7) { + this.setupTypeNumber(test); + } + + if (this.dataCache == null) { + this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); + } + + this.mapData(this.dataCache, maskPattern); + }, + + setupPositionProbePattern: function (row, col) { + + for (var r = -1; r <= 7; r++) { + + if (row + r <= -1 || this.moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c++) { + + if (col + c <= -1 || this.moduleCount <= col + c) continue; + + if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + + getBestMaskPattern: function () { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i++) { + + this.makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }, + + createMovieClip: function (target_mc, instance_name, depth) { + + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); + var cs = 1; + + this.make(); + + for (var row = 0; row < this.modules.length; row++) { + + var y = row * cs; + + for (var col = 0; col < this.modules[row].length; col++) { + + var x = col * cs; + var dark = this.modules[row][col]; + + if (dark) { + qr_mc.beginFill(0, 100); + qr_mc.moveTo(x, y); + qr_mc.lineTo(x + cs, y); + qr_mc.lineTo(x + cs, y + cs); + qr_mc.lineTo(x, y + cs); + qr_mc.endFill(); + } + } + } + + return qr_mc; + }, + + setupTimingPattern: function () { + + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = r % 2 == 0; + } + + for (var c = 8; c < this.moduleCount - 8; c++) { + if (this.modules[6][c] != null) { + continue; + } + this.modules[6][c] = c % 2 == 0; + } + }, + + setupPositionAdjustPattern: function () { + + var pos = QRUtil.getPatternPosition(this.typeNumber); + + for (var i = 0; i < pos.length; i++) { + + for (var j = 0; j < pos.length; j++) { + + var row = pos[i]; + var col = pos[j]; + + if (this.modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r++) { + + for (var c = -2; c <= 2; c++) { + + if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + + setupTypeNumber: function (test) { + + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + + for (var i = 0; i < 18; i++) { + var mod = !test && (bits >> i & 1) == 1; + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i++) { + var mod = !test && (bits >> i & 1) == 1; + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + + setupTypeInfo: function (test, maskPattern) { + + var data = this.errorCorrectLevel << 3 | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i++) { + + var mod = !test && (bits >> i & 1) == 1; + + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i++) { + + var mod = !test && (bits >> i & 1) == 1; + + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + + // fixed module + this.modules[this.moduleCount - 8][8] = !test; + }, + + mapData: function (data, maskPattern) { + + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col--; + + while (true) { + + for (var c = 0; c < 2; c++) { + + if (this.modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = (data[byteIndex] >>> bitIndex & 1) == 1; + } + + var mask = QRUtil.getMask(maskPattern, row, col - c); + + if (mask) { + dark = !dark; + } + + this.modules[row][col - c] = dark; + bitIndex--; + + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + } + +}; + +QRCode.PAD0 = 0xEC; +QRCode.PAD1 = 0x11; + +QRCode.createData = function (typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = new QRBitBuffer(); + + for (var i = 0; i < dataList.length; i++) { + var data = dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber)); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")"); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD1, 8); + } + + return QRCode.createBytes(buffer, rsBlocks); +}; + +QRCode.createBytes = function (buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r++) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0; + } + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + + return data; +}; + +//--------------------------------------------------------------------- +// QRMode +//--------------------------------------------------------------------- + +var QRMode = { + MODE_NUMBER: 1 << 0, + MODE_ALPHA_NUM: 1 << 1, + MODE_8BIT_BYTE: 1 << 2, + MODE_KANJI: 1 << 3 +}; + +//--------------------------------------------------------------------- +// QRErrorCorrectLevel +//--------------------------------------------------------------------- + +var QRErrorCorrectLevel = { + L: 1, + M: 0, + Q: 3, + H: 2 +}; + +//--------------------------------------------------------------------- +// QRMaskPattern +//--------------------------------------------------------------------- + +var QRMaskPattern = { + PATTERN000: 0, + PATTERN001: 1, + PATTERN010: 2, + PATTERN011: 3, + PATTERN100: 4, + PATTERN101: 5, + PATTERN110: 6, + PATTERN111: 7 +}; + +//--------------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------------- + +var QRUtil = { + + PATTERN_POSITION_TABLE: [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], + + G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0, + G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0, + G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1, + + getBCHTypeInfo: function (data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15); + } + return (data << 10 | d) ^ QRUtil.G15_MASK; + }, + + getBCHTypeNumber: function (data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18); + } + return data << 12 | d; + }, + + getBCHDigit: function (data) { + + var digit = 0; + + while (data != 0) { + digit++; + data >>>= 1; + } + + return digit; + }, + + getPatternPosition: function (typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + + getMask: function (maskPattern, i, j) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000: + return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001: + return i % 2 == 0; + case QRMaskPattern.PATTERN010: + return j % 3 == 0; + case QRMaskPattern.PATTERN011: + return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100: + return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0; + case QRMaskPattern.PATTERN101: + return i * j % 2 + i * j % 3 == 0; + case QRMaskPattern.PATTERN110: + return (i * j % 2 + i * j % 3) % 2 == 0; + case QRMaskPattern.PATTERN111: + return (i * j % 3 + (i + j) % 2) % 2 == 0; + + default: + throw new Error("bad maskPattern:" + maskPattern); + } + }, + + getErrorCorrectPolynomial: function (errorCorrectLength) { + + var a = new QRPolynomial([1], 0); + + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0)); + } + + return a; + }, + + getLengthInBits: function (mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch (mode) { + case QRMode.MODE_NUMBER: + return 10; + case QRMode.MODE_ALPHA_NUM: + return 9; + case QRMode.MODE_8BIT_BYTE: + return 8; + case QRMode.MODE_KANJI: + return 8; + default: + throw new Error("mode:" + mode); + } + } else if (type < 27) { + + // 10 - 26 + + switch (mode) { + case QRMode.MODE_NUMBER: + return 12; + case QRMode.MODE_ALPHA_NUM: + return 11; + case QRMode.MODE_8BIT_BYTE: + return 16; + case QRMode.MODE_KANJI: + return 10; + default: + throw new Error("mode:" + mode); + } + } else if (type < 41) { + + // 27 - 40 + + switch (mode) { + case QRMode.MODE_NUMBER: + return 14; + case QRMode.MODE_ALPHA_NUM: + return 13; + case QRMode.MODE_8BIT_BYTE: + return 16; + case QRMode.MODE_KANJI: + return 12; + default: + throw new Error("mode:" + mode); + } + } else { + throw new Error("type:" + type); + } + }, + + getLostPoint: function (qrCode) { + + var moduleCount = qrCode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row++) { + + for (var col = 0; col < moduleCount; col++) { + + var sameCount = 0; + var dark = qrCode.isDark(row, col); + + for (var r = -1; r <= 1; r++) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c++) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrCode.isDark(row + r, col + c)) { + sameCount++; + } + } + } + + if (sameCount > 5) { + lostPoint += 3 + sameCount - 5; + } + } + } + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row++) { + for (var col = 0; col < moduleCount - 1; col++) { + var count = 0; + if (qrCode.isDark(row, col)) count++; + if (qrCode.isDark(row + 1, col)) count++; + if (qrCode.isDark(row, col + 1)) count++; + if (qrCode.isDark(row + 1, col + 1)) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row++) { + for (var col = 0; col < moduleCount - 6; col++) { + if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount - 6; row++) { + if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount; row++) { + if (qrCode.isDark(row, col)) { + darkCount++; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + } + +}; + +//--------------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------------- + +var QRMath = { + + glog: function (n) { + + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + + return QRMath.LOG_TABLE[n]; + }, + + gexp: function (n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return QRMath.EXP_TABLE[n]; + }, + + EXP_TABLE: new Array(256), + + LOG_TABLE: new Array(256) + +}; + +for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; +} +for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8]; +} +for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i; +} + +//--------------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------------- + +function QRPolynomial(num, shift) { + + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + + var offset = 0; + + while (offset < num.length && num[offset] == 0) { + offset++; + } + + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } +} + +QRPolynomial.prototype = { + + get: function (index) { + return this.num[index]; + }, + + getLength: function () { + return this.num.length; + }, + + multiply: function (e) { + + var num = new Array(this.getLength() + e.getLength() - 1); + + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j))); + } + } + + return new QRPolynomial(num, 0); + }, + + mod: function (e) { + + if (this.getLength() - e.getLength() < 0) { + return this; + } + + var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0)); + + var num = new Array(this.getLength()); + + for (var i = 0; i < this.getLength(); i++) { + num[i] = this.get(i); + } + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio); + } + + // recursive call + return new QRPolynomial(num, 0).mod(e); + } +}; + +//--------------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------------- + +function QRRSBlock(totalCount, dataCount) { + this.totalCount = totalCount; + this.dataCount = dataCount; +} + +QRRSBlock.RS_BLOCK_TABLE = [ + +// L +// M +// Q +// H + +// 1 +[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], + +// 2 +[1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], + +// 3 +[1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], + +// 4 +[1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], + +// 5 +[1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], + +// 6 +[2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], + +// 7 +[2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], + +// 8 +[2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], + +// 9 +[2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], + +// 10 +[2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], + +// 11 +[4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], + +// 12 +[2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], + +// 13 +[4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], + +// 14 +[3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], + +// 15 +[5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12], + +// 16 +[5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], + +// 17 +[1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], + +// 18 +[5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], + +// 19 +[3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], + +// 20 +[3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], + +// 21 +[4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], + +// 22 +[2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], + +// 23 +[4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], + +// 24 +[6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], + +// 25 +[8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], + +// 26 +[10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], + +// 27 +[8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], + +// 28 +[3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], + +// 29 +[7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], + +// 30 +[5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], + +// 31 +[13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], + +// 32 +[17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], + +// 33 +[17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], + +// 34 +[13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], + +// 35 +[12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], + +// 36 +[6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], + +// 37 +[17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], + +// 38 +[4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], + +// 39 +[20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], + +// 40 +[19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]]; + +QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) { + + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); + + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i++) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j++) { + list.push(new QRRSBlock(totalCount, dataCount)); + } + } + + return list; +}; + +QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) { + + switch (errorCorrectLevel) { + case QRErrorCorrectLevel.L: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default: + return undefined; + } +}; + +//--------------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------------- + +function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; +} + +QRBitBuffer.prototype = { + + get: function (index) { + var bufIndex = Math.floor(index / 8); + return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1; + }, + + put: function (num, length) { + for (var i = 0; i < length; i++) { + this.putBit((num >>> length - i - 1 & 1) == 1); + } + }, + + getLengthInBits: function () { + return this.length; + }, + + putBit: function (bit) { + + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + + if (bit) { + this.buffer[bufIndex] |= 0x80 >>> this.length % 8; + } + + this.length++; + } +}; + +// support Chinese +function utf16to8(str) { + var out, i, len, c; + out = ''; + len = str.length; + for (i = 0; i < len; i++) { + c = str.charCodeAt(i); + if (c >= 0x0001 && c <= 0x007F) { + out += str.charAt(i); + } else if (c > 0x07FF) { + out += String.fromCharCode(0xE0 | c >> 12 & 0x0F); + out += String.fromCharCode(0x80 | c >> 6 & 0x3F); + out += String.fromCharCode(0x80 | c >> 0 & 0x3F); + } else { + out += String.fromCharCode(0xC0 | c >> 6 & 0x1F); + out += String.fromCharCode(0x80 | c >> 0 & 0x3F); + } + } + return out; +} + +function drawQrcode(options, debug) { + options = options || {}; + options = extend(true, { + canvasId: 'myQrcode', + // canvas: canvas, + text: '爱一个人就要勇敢说出来', + width: 260, + height: 260, + padding: 20, + // paddingColor: '#ffffff', // 默认与background一致 + typeNumber: -1, + correctLevel: QRErrorCorrectLevel.H, + background: '#ffffff', + foreground: '#000000', + image: { + imageResource: '', + width: 80, + height: 80, + round: true + } + }, options); + + if (!options.canvasId && !options.canvas) { + console.warn('please set canvasId or canvas!'); + return; + } + + if (!options.paddingColor) options.paddingColor = options.background; + + if (debug) { + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(utf16to8(options.text)); + qrcode.make(); + + return new Promise(function (resolve, reject) { + resolve(qrcode); + }); + } else { + + return new Promise(function (resolve, reject) { + return resolve(createCanvas()); + }); + } + + function createCanvas() { + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel); + qrcode.addData(utf16to8(options.text)); + qrcode.make(); + + const dpr = wx.getSystemInfoSync().pixelRatio; + var canvas = options.canvas; + const ctx = canvas.getContext('2d'); + canvas.width = options.width * dpr; + canvas.height = options.width * dpr; + const width = canvas.width; + + // 背景色 + ctx.fillStyle = options.paddingColor; + ctx.fillRect(0, 0, width + options.padding * 2, width + options.padding * 2); + + var tileW = (width - options.padding * 2) / qrcode.getModuleCount(); + var tileH = (width - options.padding * 2) / qrcode.getModuleCount(); + + // 开始画二维码 + for (var row = 0; row < qrcode.getModuleCount(); row++) { + for (var col = 0; col < qrcode.getModuleCount(); col++) { + ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background; + var w = Math.ceil((col + 1) * tileW) - Math.floor(col * tileW); + var h = Math.ceil((row + 1) * tileW) - Math.floor(row * tileW); + ctx.fillRect(Math.round(col * tileW) + options.padding, Math.round(row * tileH) + options.padding, w, h); + } + } + + if (options.image.imageResource) { + const imgW = options.image.width * dpr; + const imgH = options.image.height * dpr; + const dx = (width - imgW) / 2; + const dy = (width - imgH) / 2; + if (options.image.round) { + // Logo边框 + const imgW2 = options.image.width * dpr + 30; + const dx2 = (width - imgW2) / 2; + const r2 = imgW2 / 2; + const cx2 = dx2 + r2; + ctx.beginPath(); + ctx.arc(cx2, cx2, r2, 0, 2 * Math.PI); + ctx.fillStyle = '#ffffff'; + ctx.fill(); + ctx.restore(); + + // 画Logo + const r = imgW / 2; + const cx = dx + r; + const cy = dy + r; + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, 2 * Math.PI); + ctx.clip(); + + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgW); + ctx.restore(); + } else { + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgH); + ctx.restore(); + } + } + + return ctx; + } +} + +return drawQrcode; + +}))); diff --git a/node_modules/weapp-qrcode-canvas-2d/package.json b/node_modules/weapp-qrcode-canvas-2d/package.json new file mode 100644 index 0000000..9e8260f --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/package.json @@ -0,0 +1,42 @@ +{ + "name": "weapp-qrcode-canvas-2d", + "version": "1.1.2", + "bundleDependencies": false, + "deprecated": false, + "description": "generate qrcode in wx", + "devDependencies": { + "babel-core": "^6.26.0", + "babel-eslint": "^8.2.1", + "eslint": "^4.16.0", + "eslint-config-standard": "^11.0.0-beta.0", + "eslint-plugin-import": "^2.8.0", + "eslint-plugin-node": "^5.2.1", + "eslint-plugin-promise": "^3.6.0", + "eslint-plugin-standard": "^3.0.1", + "rollup": "^0.55.1", + "rollup-plugin-babel": "^3.0.3", + "rollup-plugin-commonjs": "^8.3.0", + "rollup-plugin-eslint": "^4.0.0", + "rollup-plugin-license": "^0.6.0", + "rollup-plugin-node-resolve": "^3.0.2", + "rollup-plugin-replace": "^2.0.0", + "rollup-plugin-uglify": "^3.0.0" + }, + "keywords": [ + "wechat", + "weapp", + "qrcode", + "canvas", + "canvas 2d", + "canvas-2d" + ], + "license": "MIT", + "main": "dist/weapp.qrcode.common.js", + "module": "dist/weapp.qrcode.esm.js", + "scripts": { + "build": "rollup --config build/rollup.prod.config.js", + "dev": "rollup --config build/rollup.dev.config.js -w", + "publish": "rollup --config build/rollup.dev.config.js & npm run build", + "test": "echo \"Error: no test specified\" && exit 1" + } +} \ No newline at end of file diff --git a/node_modules/weapp-qrcode-canvas-2d/src/index.js b/node_modules/weapp-qrcode-canvas-2d/src/index.js new file mode 100644 index 0000000..95d864d --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/src/index.js @@ -0,0 +1,141 @@ +import extend from 'extend' +import { + QRCode, + QRErrorCorrectLevel +} from './qrcode' + +// support Chinese +function utf16to8(str) { + var out, i, len, c + out = '' + len = str.length + for (i = 0; i < len; i++) { + c = str.charCodeAt(i) + if ((c >= 0x0001) && (c <= 0x007F)) { + out += str.charAt(i) + } else if (c > 0x07FF) { + out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)) + out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)) + out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)) + } else { + out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)) + out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)) + } + } + return out +} + +function drawQrcode(options, debug) { + options = options || {} + options = extend(true, { + canvasId: 'myQrcode', + // canvas: canvas, + text: '爱一个人就要勇敢说出来', + width: 260, + height: 260, + padding: 20, + // paddingColor: '#ffffff', // 默认与background一致 + typeNumber: -1, + correctLevel: QRErrorCorrectLevel.H, + background: '#ffffff', + foreground: '#000000', + image: { + imageResource: '', + width: 80, + height: 80, + round: true + } + }, options) + + if (!options.canvasId && !options.canvas) { + console.warn('please set canvasId or canvas!') + return + } + + if (!options.paddingColor) options.paddingColor = options.background + + if (debug) { + var qrcode = new QRCode(options.typeNumber, options.correctLevel) + qrcode.addData(utf16to8(options.text)) + qrcode.make() + + return new Promise(function (resolve, reject) { + resolve(qrcode); + }) + + } else { + + return new Promise(function (resolve, reject) { + return resolve(createCanvas()); + }) + + } + + function createCanvas() { + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel) + qrcode.addData(utf16to8(options.text)) + qrcode.make() + + const dpr = wx.getSystemInfoSync().pixelRatio + var canvas = options.canvas + const ctx = canvas.getContext('2d') + canvas.width = options.width * dpr + canvas.height = options.width * dpr + const width = canvas.width + + // 背景色 + ctx.fillStyle = options.paddingColor + ctx.fillRect(0, 0, width + options.padding * 2, width + options.padding * 2); + + var tileW = (width - options.padding * 2) / qrcode.getModuleCount() + var tileH = (width - options.padding * 2) / qrcode.getModuleCount() + + // 开始画二维码 + for (var row = 0; row < qrcode.getModuleCount(); row++) { + for (var col = 0; col < qrcode.getModuleCount(); col++) { + ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background + var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW)) + var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW)) + ctx.fillRect(Math.round(col * tileW) + options.padding, Math.round(row * tileH) + options.padding, w, h); + } + } + + if (options.image.imageResource) { + const imgW = options.image.width * dpr + const imgH = options.image.height * dpr + const dx = (width - imgW) / 2 + const dy = (width - imgH) / 2 + if (options.image.round) { + // Logo边框 + const imgW2 = options.image.width * dpr + 30 + const dx2 = (width - imgW2) / 2 + const r2 = imgW2 / 2 + const cx2 = dx2 + r2; + ctx.beginPath(); + ctx.arc(cx2, cx2, r2, 0, 2 * Math.PI); + ctx.fillStyle = '#ffffff' + ctx.fill(); + ctx.restore(); + + // 画Logo + const r = imgW / 2 + const cx = dx + r; + const cy = dy + r; + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, 2 * Math.PI); + ctx.clip(); + + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgW); + ctx.restore(); + } else { + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgH) + ctx.restore(); + } + } + + return ctx + } +} + +export default drawQrcode diff --git a/node_modules/weapp-qrcode-canvas-2d/src/qrcode.js b/node_modules/weapp-qrcode-canvas-2d/src/qrcode.js new file mode 100644 index 0000000..3289c78 --- /dev/null +++ b/node_modules/weapp-qrcode-canvas-2d/src/qrcode.js @@ -0,0 +1,1242 @@ +//--------------------------------------------------------------------- +// QRCode for JavaScript +// +// Copyright (c) 2009 Kazuhiko Arase +// +// URL: http://www.d-project.com/ +// +// Licensed under the MIT license: +// http://www.opensource.org/licenses/mit-license.php +// +// The word "QR Code" is registered trademark of +// DENSO WAVE INCORPORATED +// http://www.denso-wave.com/qrcode/faqpatent-e.html +// +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// QR8bitByte +//--------------------------------------------------------------------- + +function QR8bitByte(data) { + this.mode = QRMode.MODE_8BIT_BYTE; + this.data = data; +} + +QR8bitByte.prototype = { + + getLength : function(buffer) { + return this.data.length; + }, + + write : function(buffer) { + for (var i = 0; i < this.data.length; i++) { + // not JIS ... + buffer.put(this.data.charCodeAt(i), 8); + } + } +}; + +//--------------------------------------------------------------------- +// QRCode +//--------------------------------------------------------------------- + +function QRCode(typeNumber, errorCorrectLevel) { + this.typeNumber = typeNumber; + this.errorCorrectLevel = errorCorrectLevel; + this.modules = null; + this.moduleCount = 0; + this.dataCache = null; + this.dataList = new Array(); +} + +QRCode.prototype = { + + addData : function(data) { + var newData = new QR8bitByte(data); + this.dataList.push(newData); + this.dataCache = null; + }, + + isDark : function(row, col) { + if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) { + throw new Error(row + "," + col); + } + return this.modules[row][col]; + }, + + getModuleCount : function() { + return this.moduleCount; + }, + + make : function() { + // Calculate automatically typeNumber if provided is < 1 + if (this.typeNumber < 1 ){ + var typeNumber = 1; + for (typeNumber = 1; typeNumber < 40; typeNumber++) { + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel); + + var buffer = new QRBitBuffer(); + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + for (var i = 0; i < this.dataList.length; i++) { + var data = this.dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) ); + data.write(buffer); + } + if (buffer.getLengthInBits() <= totalDataCount * 8) + break; + } + this.typeNumber = typeNumber; + } + this.makeImpl(false, this.getBestMaskPattern() ); + }, + + makeImpl : function(test, maskPattern) { + + this.moduleCount = this.typeNumber * 4 + 17; + this.modules = new Array(this.moduleCount); + + for (var row = 0; row < this.moduleCount; row++) { + + this.modules[row] = new Array(this.moduleCount); + + for (var col = 0; col < this.moduleCount; col++) { + this.modules[row][col] = null;//(col + row) % 3; + } + } + + this.setupPositionProbePattern(0, 0); + this.setupPositionProbePattern(this.moduleCount - 7, 0); + this.setupPositionProbePattern(0, this.moduleCount - 7); + this.setupPositionAdjustPattern(); + this.setupTimingPattern(); + this.setupTypeInfo(test, maskPattern); + + if (this.typeNumber >= 7) { + this.setupTypeNumber(test); + } + + if (this.dataCache == null) { + this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); + } + + this.mapData(this.dataCache, maskPattern); + }, + + setupPositionProbePattern : function(row, col) { + + for (var r = -1; r <= 7; r++) { + + if (row + r <= -1 || this.moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c++) { + + if (col + c <= -1 || this.moduleCount <= col + c) continue; + + if ( (0 <= r && r <= 6 && (c == 0 || c == 6) ) + || (0 <= c && c <= 6 && (r == 0 || r == 6) ) + || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + + getBestMaskPattern : function() { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i++) { + + this.makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }, + + createMovieClip : function(target_mc, instance_name, depth) { + + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); + var cs = 1; + + this.make(); + + for (var row = 0; row < this.modules.length; row++) { + + var y = row * cs; + + for (var col = 0; col < this.modules[row].length; col++) { + + var x = col * cs; + var dark = this.modules[row][col]; + + if (dark) { + qr_mc.beginFill(0, 100); + qr_mc.moveTo(x, y); + qr_mc.lineTo(x + cs, y); + qr_mc.lineTo(x + cs, y + cs); + qr_mc.lineTo(x, y + cs); + qr_mc.endFill(); + } + } + } + + return qr_mc; + }, + + setupTimingPattern : function() { + + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = (r % 2 == 0); + } + + for (var c = 8; c < this.moduleCount - 8; c++) { + if (this.modules[6][c] != null) { + continue; + } + this.modules[6][c] = (c % 2 == 0); + } + }, + + setupPositionAdjustPattern : function() { + + var pos = QRUtil.getPatternPosition(this.typeNumber); + + for (var i = 0; i < pos.length; i++) { + + for (var j = 0; j < pos.length; j++) { + + var row = pos[i]; + var col = pos[j]; + + if (this.modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r++) { + + for (var c = -2; c <= 2; c++) { + + if (r == -2 || r == 2 || c == -2 || c == 2 + || (r == 0 && c == 0) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + + setupTypeNumber : function(test) { + + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + + setupTypeInfo : function(test, maskPattern) { + + var data = (this.errorCorrectLevel << 3) | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + + // fixed module + this.modules[this.moduleCount - 8][8] = (!test); + + }, + + mapData : function(data, maskPattern) { + + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col--; + + while (true) { + + for (var c = 0; c < 2; c++) { + + if (this.modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1); + } + + var mask = QRUtil.getMask(maskPattern, row, col - c); + + if (mask) { + dark = !dark; + } + + this.modules[row][col - c] = dark; + bitIndex--; + + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + + } + +}; + +QRCode.PAD0 = 0xEC; +QRCode.PAD1 = 0x11; + +QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = new QRBitBuffer(); + + for (var i = 0; i < dataList.length; i++) { + var data = dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) ); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error("code length overflow. (" + + buffer.getLengthInBits() + + ">" + + totalDataCount * 8 + + ")"); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD1, 8); + } + + return QRCode.createBytes(buffer, rsBlocks); +} + +QRCode.createBytes = function(buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r++) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0; + } + + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + + return data; + +} + +//--------------------------------------------------------------------- +// QRMode +//--------------------------------------------------------------------- + +var QRMode = { + MODE_NUMBER : 1 << 0, + MODE_ALPHA_NUM : 1 << 1, + MODE_8BIT_BYTE : 1 << 2, + MODE_KANJI : 1 << 3 +}; + +//--------------------------------------------------------------------- +// QRErrorCorrectLevel +//--------------------------------------------------------------------- + +var QRErrorCorrectLevel = { + L : 1, + M : 0, + Q : 3, + H : 2 +}; + +//--------------------------------------------------------------------- +// QRMaskPattern +//--------------------------------------------------------------------- + +var QRMaskPattern = { + PATTERN000 : 0, + PATTERN001 : 1, + PATTERN010 : 2, + PATTERN011 : 3, + PATTERN100 : 4, + PATTERN101 : 5, + PATTERN110 : 6, + PATTERN111 : 7 +}; + +//--------------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------------- + +var QRUtil = { + + PATTERN_POSITION_TABLE : [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ], + + G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0), + G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0), + G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1), + + getBCHTypeInfo : function(data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) ); + } + return ( (data << 10) | d) ^ QRUtil.G15_MASK; + }, + + getBCHTypeNumber : function(data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) ); + } + return (data << 12) | d; + }, + + getBCHDigit : function(data) { + + var digit = 0; + + while (data != 0) { + digit++; + data >>>= 1; + } + + return digit; + }, + + getPatternPosition : function(typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + + getMask : function(maskPattern, i, j) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001 : return i % 2 == 0; + case QRMaskPattern.PATTERN010 : return j % 3 == 0; + case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; + case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0; + case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; + case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; + + default : + throw new Error("bad maskPattern:" + maskPattern); + } + }, + + getErrorCorrectPolynomial : function(errorCorrectLength) { + + var a = new QRPolynomial([1], 0); + + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) ); + } + + return a; + }, + + getLengthInBits : function(mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch(mode) { + case QRMode.MODE_NUMBER : return 10; + case QRMode.MODE_ALPHA_NUM : return 9; + case QRMode.MODE_8BIT_BYTE : return 8; + case QRMode.MODE_KANJI : return 8; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 27) { + + // 10 - 26 + + switch(mode) { + case QRMode.MODE_NUMBER : return 12; + case QRMode.MODE_ALPHA_NUM : return 11; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 10; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 41) { + + // 27 - 40 + + switch(mode) { + case QRMode.MODE_NUMBER : return 14; + case QRMode.MODE_ALPHA_NUM : return 13; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 12; + default : + throw new Error("mode:" + mode); + } + + } else { + throw new Error("type:" + type); + } + }, + + getLostPoint : function(qrCode) { + + var moduleCount = qrCode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row++) { + + for (var col = 0; col < moduleCount; col++) { + + var sameCount = 0; + var dark = qrCode.isDark(row, col); + + for (var r = -1; r <= 1; r++) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c++) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrCode.isDark(row + r, col + c) ) { + sameCount++; + } + } + } + + if (sameCount > 5) { + lostPoint += (3 + sameCount - 5); + } + } + } + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row++) { + for (var col = 0; col < moduleCount - 1; col++) { + var count = 0; + if (qrCode.isDark(row, col ) ) count++; + if (qrCode.isDark(row + 1, col ) ) count++; + if (qrCode.isDark(row, col + 1) ) count++; + if (qrCode.isDark(row + 1, col + 1) ) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row++) { + for (var col = 0; col < moduleCount - 6; col++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row, col + 1) + && qrCode.isDark(row, col + 2) + && qrCode.isDark(row, col + 3) + && qrCode.isDark(row, col + 4) + && !qrCode.isDark(row, col + 5) + && qrCode.isDark(row, col + 6) ) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount - 6; row++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row + 1, col) + && qrCode.isDark(row + 2, col) + && qrCode.isDark(row + 3, col) + && qrCode.isDark(row + 4, col) + && !qrCode.isDark(row + 5, col) + && qrCode.isDark(row + 6, col) ) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount; row++) { + if (qrCode.isDark(row, col) ) { + darkCount++; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + } + +}; + + +//--------------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------------- + +var QRMath = { + + glog : function(n) { + + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + + return QRMath.LOG_TABLE[n]; + }, + + gexp : function(n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return QRMath.EXP_TABLE[n]; + }, + + EXP_TABLE : new Array(256), + + LOG_TABLE : new Array(256) + +}; + +for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; +} +for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] + ^ QRMath.EXP_TABLE[i - 5] + ^ QRMath.EXP_TABLE[i - 6] + ^ QRMath.EXP_TABLE[i - 8]; +} +for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i; +} + +//--------------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------------- + +function QRPolynomial(num, shift) { + + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + + var offset = 0; + + while (offset < num.length && num[offset] == 0) { + offset++; + } + + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } +} + +QRPolynomial.prototype = { + + get : function(index) { + return this.num[index]; + }, + + getLength : function() { + return this.num.length; + }, + + multiply : function(e) { + + var num = new Array(this.getLength() + e.getLength() - 1); + + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) ); + } + } + + return new QRPolynomial(num, 0); + }, + + mod : function(e) { + + if (this.getLength() - e.getLength() < 0) { + return this; + } + + var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) ); + + var num = new Array(this.getLength() ); + + for (var i = 0; i < this.getLength(); i++) { + num[i] = this.get(i); + } + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio); + } + + // recursive call + return new QRPolynomial(num, 0).mod(e); + } +}; + +//--------------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------------- + +function QRRSBlock(totalCount, dataCount) { + this.totalCount = totalCount; + this.dataCount = dataCount; +} + +QRRSBlock.RS_BLOCK_TABLE = [ + + // L + // M + // Q + // H + + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16], + + // 11 + [4, 101, 81], + [1, 80, 50, 4, 81, 51], + [4, 50, 22, 4, 51, 23], + [3, 36, 12, 8, 37, 13], + + // 12 + [2, 116, 92, 2, 117, 93], + [6, 58, 36, 2, 59, 37], + [4, 46, 20, 6, 47, 21], + [7, 42, 14, 4, 43, 15], + + // 13 + [4, 133, 107], + [8, 59, 37, 1, 60, 38], + [8, 44, 20, 4, 45, 21], + [12, 33, 11, 4, 34, 12], + + // 14 + [3, 145, 115, 1, 146, 116], + [4, 64, 40, 5, 65, 41], + [11, 36, 16, 5, 37, 17], + [11, 36, 12, 5, 37, 13], + + // 15 + [5, 109, 87, 1, 110, 88], + [5, 65, 41, 5, 66, 42], + [5, 54, 24, 7, 55, 25], + [11, 36, 12], + + // 16 + [5, 122, 98, 1, 123, 99], + [7, 73, 45, 3, 74, 46], + [15, 43, 19, 2, 44, 20], + [3, 45, 15, 13, 46, 16], + + // 17 + [1, 135, 107, 5, 136, 108], + [10, 74, 46, 1, 75, 47], + [1, 50, 22, 15, 51, 23], + [2, 42, 14, 17, 43, 15], + + // 18 + [5, 150, 120, 1, 151, 121], + [9, 69, 43, 4, 70, 44], + [17, 50, 22, 1, 51, 23], + [2, 42, 14, 19, 43, 15], + + // 19 + [3, 141, 113, 4, 142, 114], + [3, 70, 44, 11, 71, 45], + [17, 47, 21, 4, 48, 22], + [9, 39, 13, 16, 40, 14], + + // 20 + [3, 135, 107, 5, 136, 108], + [3, 67, 41, 13, 68, 42], + [15, 54, 24, 5, 55, 25], + [15, 43, 15, 10, 44, 16], + + // 21 + [4, 144, 116, 4, 145, 117], + [17, 68, 42], + [17, 50, 22, 6, 51, 23], + [19, 46, 16, 6, 47, 17], + + // 22 + [2, 139, 111, 7, 140, 112], + [17, 74, 46], + [7, 54, 24, 16, 55, 25], + [34, 37, 13], + + // 23 + [4, 151, 121, 5, 152, 122], + [4, 75, 47, 14, 76, 48], + [11, 54, 24, 14, 55, 25], + [16, 45, 15, 14, 46, 16], + + // 24 + [6, 147, 117, 4, 148, 118], + [6, 73, 45, 14, 74, 46], + [11, 54, 24, 16, 55, 25], + [30, 46, 16, 2, 47, 17], + + // 25 + [8, 132, 106, 4, 133, 107], + [8, 75, 47, 13, 76, 48], + [7, 54, 24, 22, 55, 25], + [22, 45, 15, 13, 46, 16], + + // 26 + [10, 142, 114, 2, 143, 115], + [19, 74, 46, 4, 75, 47], + [28, 50, 22, 6, 51, 23], + [33, 46, 16, 4, 47, 17], + + // 27 + [8, 152, 122, 4, 153, 123], + [22, 73, 45, 3, 74, 46], + [8, 53, 23, 26, 54, 24], + [12, 45, 15, 28, 46, 16], + + // 28 + [3, 147, 117, 10, 148, 118], + [3, 73, 45, 23, 74, 46], + [4, 54, 24, 31, 55, 25], + [11, 45, 15, 31, 46, 16], + + // 29 + [7, 146, 116, 7, 147, 117], + [21, 73, 45, 7, 74, 46], + [1, 53, 23, 37, 54, 24], + [19, 45, 15, 26, 46, 16], + + // 30 + [5, 145, 115, 10, 146, 116], + [19, 75, 47, 10, 76, 48], + [15, 54, 24, 25, 55, 25], + [23, 45, 15, 25, 46, 16], + + // 31 + [13, 145, 115, 3, 146, 116], + [2, 74, 46, 29, 75, 47], + [42, 54, 24, 1, 55, 25], + [23, 45, 15, 28, 46, 16], + + // 32 + [17, 145, 115], + [10, 74, 46, 23, 75, 47], + [10, 54, 24, 35, 55, 25], + [19, 45, 15, 35, 46, 16], + + // 33 + [17, 145, 115, 1, 146, 116], + [14, 74, 46, 21, 75, 47], + [29, 54, 24, 19, 55, 25], + [11, 45, 15, 46, 46, 16], + + // 34 + [13, 145, 115, 6, 146, 116], + [14, 74, 46, 23, 75, 47], + [44, 54, 24, 7, 55, 25], + [59, 46, 16, 1, 47, 17], + + // 35 + [12, 151, 121, 7, 152, 122], + [12, 75, 47, 26, 76, 48], + [39, 54, 24, 14, 55, 25], + [22, 45, 15, 41, 46, 16], + + // 36 + [6, 151, 121, 14, 152, 122], + [6, 75, 47, 34, 76, 48], + [46, 54, 24, 10, 55, 25], + [2, 45, 15, 64, 46, 16], + + // 37 + [17, 152, 122, 4, 153, 123], + [29, 74, 46, 14, 75, 47], + [49, 54, 24, 10, 55, 25], + [24, 45, 15, 46, 46, 16], + + // 38 + [4, 152, 122, 18, 153, 123], + [13, 74, 46, 32, 75, 47], + [48, 54, 24, 14, 55, 25], + [42, 45, 15, 32, 46, 16], + + // 39 + [20, 147, 117, 4, 148, 118], + [40, 75, 47, 7, 76, 48], + [43, 54, 24, 22, 55, 25], + [10, 45, 15, 67, 46, 16], + + // 40 + [19, 148, 118, 6, 149, 119], + [18, 75, 47, 31, 76, 48], + [34, 54, 24, 34, 55, 25], + [20, 45, 15, 61, 46, 16] +]; + +QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) { + + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); + + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i++) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j++) { + list.push(new QRRSBlock(totalCount, dataCount) ); + } + } + + return list; +} + +QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) { + + switch(errorCorrectLevel) { + case QRErrorCorrectLevel.L : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default : + return undefined; + } +} + +//--------------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------------- + +function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; +} + +QRBitBuffer.prototype = { + + get : function(index) { + var bufIndex = Math.floor(index / 8); + return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1; + }, + + put : function(num, length) { + for (var i = 0; i < length; i++) { + this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1); + } + }, + + getLengthInBits : function() { + return this.length; + }, + + putBit : function(bit) { + + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + + if (bit) { + this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) ); + } + + this.length++; + } +}; + +export { + QRCode, + QRErrorCorrectLevel +} diff --git a/package-lock.json b/package-lock.json index c7eabd3..0892a72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "tdesign-miniprogram": "^1.1.1", + "weapp-qrcode-canvas-2d": "^1.1.2", "wxmp-rsa": "^2.1.0" } }, @@ -26,6 +27,11 @@ "dayjs": "^1.10.7" } }, + "node_modules/weapp-qrcode-canvas-2d": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/weapp-qrcode-canvas-2d/-/weapp-qrcode-canvas-2d-1.1.2.tgz", + "integrity": "sha512-HQef+xpZiiWDcq8aLZdXnVdNljoYsEWiEKiBYnAnfgqXTeYfC8ApzoB9pMI5mnPFbhtu5xCi8oId1g/86uUl8Q==" + }, "node_modules/wxmp-rsa": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wxmp-rsa/-/wxmp-rsa-2.1.0.tgz", diff --git a/package.json b/package.json index 8ef49bd..1f23865 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "tdesign-miniprogram": "^1.1.1", + "weapp-qrcode-canvas-2d": "^1.1.2", "wxmp-rsa": "^2.1.0" } } diff --git a/pages/home/jl/index.js b/pages/home/jl/index.js index f0b0184..7c90418 100644 --- a/pages/home/jl/index.js +++ b/pages/home/jl/index.js @@ -5,6 +5,12 @@ Page({ * 页面的初始数据 */ data: { + + }, + go2Jlai(){ + wx.navigateTo({ + url: '/pages/home/jl/jlai/jlai' + }) }, diff --git a/pages/home/jl/index.wxml b/pages/home/jl/index.wxml index 323d027..15873e9 100644 --- a/pages/home/jl/index.wxml +++ b/pages/home/jl/index.wxml @@ -122,5 +122,7 @@ +
精灵 AI
+ diff --git a/pages/home/jl/index.wxss b/pages/home/jl/index.wxss index 696f883..9a0b0e7 100644 --- a/pages/home/jl/index.wxss +++ b/pages/home/jl/index.wxss @@ -605,3 +605,20 @@ margin-top: 708.33rpx; } +.jltxt{ + position: absolute; + left: 300px; + top: 504px; + width: 75px; + height: 35px; + line-height: 70rpx; + border-radius: 10px 0px 0px 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + color: rgba(255, 255, 255, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-medium; +} diff --git a/pages/home/jl/jlai.js b/pages/home/jl/jlai.js new file mode 100644 index 0000000..4191762 --- /dev/null +++ b/pages/home/jl/jlai.js @@ -0,0 +1,66 @@ +// pages/home/jl/jlai.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/jl/jlai.json b/pages/home/jl/jlai.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/pages/home/jl/jlai.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/jl/jlai.wxml b/pages/home/jl/jlai.wxml new file mode 100644 index 0000000..aca141f --- /dev/null +++ b/pages/home/jl/jlai.wxml @@ -0,0 +1,2 @@ + +pages/home/jl/jlai.wxml diff --git a/pages/home/jl/jlai.wxss b/pages/home/jl/jlai.wxss new file mode 100644 index 0000000..8bbcc35 --- /dev/null +++ b/pages/home/jl/jlai.wxss @@ -0,0 +1 @@ +/* pages/home/jl/jlai.wxss */ \ No newline at end of file diff --git a/pages/home/jl/jlai/jlai.js b/pages/home/jl/jlai/jlai.js new file mode 100644 index 0000000..38452b0 --- /dev/null +++ b/pages/home/jl/jlai/jlai.js @@ -0,0 +1,69 @@ +// pages/home/jl/jlai/jlai.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/jl/jlai/jlai.json b/pages/home/jl/jlai/jlai.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/pages/home/jl/jlai/jlai.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/jl/jlai/jlai.wxml b/pages/home/jl/jlai/jlai.wxml new file mode 100644 index 0000000..ebf8e82 --- /dev/null +++ b/pages/home/jl/jlai/jlai.wxml @@ -0,0 +1,3 @@ + + +星座精灵AI diff --git a/pages/home/jl/jlai/jlai.wxss b/pages/home/jl/jlai/jlai.wxss new file mode 100644 index 0000000..2238215 --- /dev/null +++ b/pages/home/jl/jlai/jlai.wxss @@ -0,0 +1,23 @@ +/* pages/home/jl/jlai/jlai.wxss */ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} \ No newline at end of file diff --git a/pages/home/me/cjwt/cjwt.js b/pages/home/me/cjwt/cjwt.js new file mode 100644 index 0000000..212b3f6 --- /dev/null +++ b/pages/home/me/cjwt/cjwt.js @@ -0,0 +1,66 @@ +// pages/home/me/cjwt/cjwt.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/cjwt/cjwt.json b/pages/home/me/cjwt/cjwt.json new file mode 100644 index 0000000..ad53302 --- /dev/null +++ b/pages/home/me/cjwt/cjwt.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "常见问题", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/cjwt/cjwt.wxml b/pages/home/me/cjwt/cjwt.wxml new file mode 100644 index 0000000..b077891 --- /dev/null +++ b/pages/home/me/cjwt/cjwt.wxml @@ -0,0 +1,2 @@ + + diff --git a/pages/home/me/cjwt/cjwt.wxss b/pages/home/me/cjwt/cjwt.wxss new file mode 100644 index 0000000..07729b0 --- /dev/null +++ b/pages/home/me/cjwt/cjwt.wxss @@ -0,0 +1 @@ +/* pages/home/me/cjwt/cjwt.wxss */ diff --git a/pages/home/me/grzl/grzl.js b/pages/home/me/grzl/grzl.js new file mode 100644 index 0000000..0676b8a --- /dev/null +++ b/pages/home/me/grzl/grzl.js @@ -0,0 +1,171 @@ +// pages/home/me/grzl/grzl.js +const app = getApp();//新建页面时 默认引入 +const req = app.xzjlReq();//初始化一个的request() 实例 +Page({ + + /** + * 页面的初始数据 + */ + data: { + avatars:[ + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx1.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx2.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx3.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx4.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx5.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx6.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx1.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx2.png', + 'https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tx3.png', + ], + + sexs:[{label:'男生',value:'male'},{label:'女生',value:'female'}], + sexVisible:false, + note:'', + cVisible:false, + userInfo:{} + }, + changeAvatar(e){ + req.patchRequest('/api/user/curt',{avatar:e.target.dataset.img}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + wx.showToast({ + title:'修改成功', + icon: 'none', + duration: 1000 + }) + } + }).catch((err)=>{ + console.log(err); + }) + }, + onColumnChange(e) {/**修改性别 */ + req.patchRequest('/api/user/curt',{spriteType:e.detail.value[0]}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + wx.showToast({ + title:'修改成功', + icon: 'none', + duration: 1000 + }) + } + }).catch((err)=>{ + console.log(err); + }) + }, + handleCalendar(){ + this.setData({cVisible:true}) + console.log('11111') + }, + changeDate(e) {/**修改日期 */ + const { value } = e.detail; + const format = (val) => { + const date = new Date(val); + return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`; + }; + + this.setData({ + note: format(value), + }); + req.patchRequest('/api/user/curt',{date:format(value)}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + wx.showToast({ + title:'修改成功', + icon: 'none', + duration: 1000 + }) + } + }).catch((err)=>{ + console.log(err); + }) + }, + changeSex(){ + this.setData({sexVisible:true}) + console.log('修改性别') + }, + doChangeName1(e){ + console.log(e) + console.log(e.detail.value) + req.patchRequest('/api/user/curt',{nick:e.detail.value}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + wx.showToast({ + title:'修改成功', + icon: 'none', + duration: 1000 + }) + } + }).catch((err)=>{ + console.log(err); + }) + }, + getUserInfo(){ + req.getRequest('/api/user/curt',{}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + } + console.log(this.userInfo); + }).catch((err)=>{ + console.log(err); + }) + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.getUserInfo() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/grzl/grzl.json b/pages/home/me/grzl/grzl.json new file mode 100644 index 0000000..b68ae56 --- /dev/null +++ b/pages/home/me/grzl/grzl.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "t-input": "tdesign-miniprogram/input/input", + "t-calendar": "tdesign-miniprogram/calendar/calendar", + "t-picker": "tdesign-miniprogram/picker/picker", + "t-picker-item": "tdesign-miniprogram/picker-item/picker-item" + } +} \ No newline at end of file diff --git a/pages/home/me/grzl/grzl.wxml b/pages/home/me/grzl/grzl.wxml new file mode 100644 index 0000000..31696d0 --- /dev/null +++ b/pages/home/me/grzl/grzl.wxml @@ -0,0 +1,40 @@ + + + +修改资料 + + + + + +
+ +
+ + +性别 +星座 +生日 +精灵头像 +{{userInfo.spriteType=='male'?'男生':'女生'}} +{{userInfo.horoscope.name}} +{{userInfo.horoscope.date}} + + + + + + + + + \ No newline at end of file diff --git a/pages/home/me/grzl/grzl.wxss b/pages/home/me/grzl/grzl.wxss new file mode 100644 index 0000000..61297f5 --- /dev/null +++ b/pages/home/me/grzl/grzl.wxss @@ -0,0 +1,185 @@ +/* pages/home/me/grzl/grzl.wxss */ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.yhtx{ + position: absolute; + left: 74px; + top: 109px; + width: 140rpx; + height: 140rpx; + border-radius: 74rpx; + border: 3px solid rgba(161, 134, 81, 1); +} + +.avatar1{ + position: absolute; + left: 77px; + top: 112px; + width: 140rpx; + height: 140rpx; + border-radius: 74rpx; +} + +.cameralogo{ + position: absolute; + left: 128px; + top: 162px; + width: 13px; + height: 13px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/camera.png); +} +.nickname{ + z-index: 999; + position: absolute; + left: 176px; +top: 131px; +width: 126px; +height: 27px; +color: rgba(108, 108, 108, 1); +font-size: 18px; +text-align: left; +font-family: SourceHanSansSC-medium; +} + +.xzwz{ + position: absolute; + left: 32px; +top: 436px; +width: 32px; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.srwz{ + position: absolute; + left: 32px; +top: 380px; +width: 32px; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.xbwz{ + position: absolute; + left: 32px; +top: 324px; +width: 32px; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.ssxz{ + position: absolute; + left: 291px; + top: 436px; + width: 52px; + height: 24px; + color: rgba(154, 154, 154, 1); + font-size: 16px; + text-align: right; + font-family: SourceHanSansSC-regular; +} + +.rlt{ + position: absolute; + left: 260px; + top: 380px; + width: 83px; + height: 24px; + color: rgba(154, 154, 154, 1); + font-size: 16px; + text-align: right; + font-family: SourceHanSansSC-regular; +} + +.srtxt{ + position: absolute; + left: 500rpx; + top: 380px; + width: 200rpx; + height: 24px; + color: rgba(154, 154, 154, 1); + font-size: 16px; + text-align: right; + font-family: SourceHanSansSC-regular; +} + +.xbtxt{ + position: absolute; + left: 311px; + top: 324px; + width: 32px; + height: 24px; + color: rgba(154, 154, 154, 1); + font-size: 16px; + text-align: right; + font-family: SourceHanSansSC-regular; +} +.jltxtxt{ + position: absolute; + left: 25px; +top: 200px; +width: 56px; +height: 21px; +color: rgba(154, 154, 154, 1); +font-size: 14px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.txcheck{ + position: absolute; + left: 0px; + top: 221px; + width: 422px; + height: 82px; + text-align: center; + overflow: auto; + display: flex; +} + +.itemxx{ + margin-left: 21px; + margin-top: 32rpx; + width: 50px; + height: 50px; + display: flex; +} + +.iii{ + width: 50px; + height: 50px; + border-radius: 50rpx; +} \ No newline at end of file diff --git a/pages/home/me/gw/gw.js b/pages/home/me/gw/gw.js new file mode 100644 index 0000000..b0bb91b --- /dev/null +++ b/pages/home/me/gw/gw.js @@ -0,0 +1,66 @@ +// pages/home/me/gw/gw.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/gw/gw.json b/pages/home/me/gw/gw.json new file mode 100644 index 0000000..1739ead --- /dev/null +++ b/pages/home/me/gw/gw.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "了解星座精灵", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/gw/gw.wxml b/pages/home/me/gw/gw.wxml new file mode 100644 index 0000000..efd4b69 --- /dev/null +++ b/pages/home/me/gw/gw.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/home/me/gw/gw.wxss b/pages/home/me/gw/gw.wxss new file mode 100644 index 0000000..394b55d --- /dev/null +++ b/pages/home/me/gw/gw.wxss @@ -0,0 +1 @@ +/* pages/home/me/gw/gw.wxss */ \ No newline at end of file diff --git a/pages/home/me/iconfont.wxss b/pages/home/me/iconfont.wxss deleted file mode 100644 index 437f9ea..0000000 --- a/pages/home/me/iconfont.wxss +++ /dev/null @@ -1,39 +0,0 @@ -@font-face { - font-family: "iconfont"; - src: url('iconfont.eot?t=8a9a2e45cddd46c8252416b9bb21c7e4'); /* IE9 */ - src: url('iconfont.eot?t=8a9a2e45cddd46c8252416b9bb21c7e4#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('iconfont.woff?t=8a9a2e45cddd46c8252416b9bb21c7e4') format('woff2'), - url('iconfont.woff?t=8a9a2e45cddd46c8252416b9bb21c7e4') format('woff'), /* chrome、firefox */ - url('iconfont.ttf?t=8a9a2e45cddd46c8252416b9bb21c7e4') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ - url('iconfont.svg?t=8a9a2e45cddd46c8252416b9bb21c7e4#iconfont') format('svg'); /* iOS 4.1- */ - } - - .iconfont { - font-family: "iconfont" !important; - font-size: 16px; - font-style: normal; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - } - - .icon-xzlogout:before { - content: "\e008"; - } - .icon-xzversion:before { - content: "\e009"; - } - .icon-xzysxy:before { - content: "\e00a"; - } - .icon-xzyhxy:before { - content: "\e00b"; - } - .icon-xzcjwt:before { - content: "\e00c"; - } - .icon-xzphone:before { - content: "\e00d"; - } - .icon-xzjl:before { - content: "\e00e"; - } \ No newline at end of file diff --git a/pages/home/me/indexx.js b/pages/home/me/indexx.js index e4bf7cc..dc9169d 100644 --- a/pages/home/me/indexx.js +++ b/pages/home/me/indexx.js @@ -9,8 +9,93 @@ Page({ * 页面的初始数据 */ data: { - showConfirm: false + bdsjhVisible:false, + avatar:"", + userInfo:{ + avatar:"", + nick:"", + isChatVip:false,//是否会员 + phone:'', + hasPhone:false + } + + }, + doBdsjh(){ + console.log('绑定手机号') + this.setData({bdsjhVisible:true}) + }, + doCancelSjh(){ + this.setData({bdsjhVisible:false}) + }, + doEXecSjh(){ + this.setData({bdsjhVisible:false}) + }, + go2Grzl(){ + wx.navigateTo({ + url: '/pages/home/me/grzl/grzl' + }) + }, + go2Member(){/**跳转到会员购买页面 */ + wx.navigateTo({ + url: '/pages/home/me/member/member' + }) + }, + go2Member2(){/**跳转到会员续费页面 */ + wx.navigateTo({ + url: '/pages/home/me/member2/member' + }) + }, + go2Gw(){/**跳转到会员购买页面 */ + wx.navigateTo({ + url: '/pages/home/me/gw/gw' + }) + }, + go2Ysxy(){/**跳转到会员购买页面 */ + wx.navigateTo({ + url: '/pages/home/me/ysxy/ysxy' + }) + }, + go2Yhsyxy(){/**跳转到会员购买页面 */ + wx.navigateTo({ + url: '/pages/home/me/yhsyxy/yhsyxy' + }) + }, + go2Cjwt(){/**跳转到会员购买页面 */ + wx.navigateTo({ + url: '/pages/home/me/cjwt/cjwt' + }) + }, + go2Device(){ + wx.navigateTo({ + url: '/pages/home/me/mydevice/device' + }) + }, + go2Sq(){ + wx.navigateTo({ + url: '/pages/home/me/sq/sq' + }) + }, + go2Yjfk(){ + wx.navigateTo({ + url: '/pages/home/me/yjfk/yjfk' + }) + }, + + go2Manual(){ + wx.navigateTo({ + url: '/pages/home/me/manual/manual' + }) + }, + getUserInfo(){ + req.getRequest('/api/user/curt',{}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + } + console.log(this.userInfo); + }).catch((err)=>{ + console.log(err); + }) }, ReqData(){ req.getRequest('/getList',{id: 1024}).then((res)=>{ @@ -24,21 +109,21 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - this.ReqData() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { - + this.getUserInfo() }, /** * 生命周期函数--监听页面显示 */ onShow() { - + this.getUserInfo() + }, /** @@ -87,8 +172,6 @@ Page({ } , ljXzjl(){ - - console.log(app.globalData.xx) }, logout() { const dialogConfig = { diff --git a/pages/home/me/indexx.json b/pages/home/me/indexx.json index fd94b68..56f07a5 100644 --- a/pages/home/me/indexx.json +++ b/pages/home/me/indexx.json @@ -3,6 +3,10 @@ "t-cell": "tdesign-miniprogram/cell/cell", "t-icon": "tdesign-miniprogram/icon/icon", "t-toast": "tdesign-miniprogram/toast/toast", - "t-dialog": "tdesign-miniprogram/dialog/dialog" + "t-dialog": "tdesign-miniprogram/dialog/dialog", + "t-avatar": "tdesign-miniprogram/avatar/avatar", + "t-avatar-group": "tdesign-miniprogram/avatar-group/avatar-group", + "t-popup": "tdesign-miniprogram/popup/popup", + "t-input": "tdesign-miniprogram/input/input" } } \ No newline at end of file diff --git a/pages/home/me/indexx.wxml b/pages/home/me/indexx.wxml index 40ed9f5..0d2c935 100644 --- a/pages/home/me/indexx.wxml +++ b/pages/home/me/indexx.wxml @@ -1,53 +1,55 @@ + - - -此处昵称七个字 - - 还有21天到期 + + +{{userInfo.nick}} + + + 还有21天到期 - 说明书 + 说明书 加入社群 我的设备 - + - + - + - - + + 了解星座精灵 - + 绑定手机号 - 18650351666 + {{userInfo.phone}} - + 常见问题 - + 意见反馈 - + 用户使用协议 - + 隐私协议 - + 小程序版本 V1.0 @@ -56,7 +58,28 @@ 退出登录 + + + + + 绑定手机号码 + 如设备丢失,可凭手机号码找回账号 + 手机号码 + 验证码 + + + + + + + + + 重新获取 + 取消 + 完成 + + diff --git a/pages/home/me/indexx.wxss b/pages/home/me/indexx.wxss index 5b84257..192e79e 100644 --- a/pages/home/me/indexx.wxss +++ b/pages/home/me/indexx.wxss @@ -20,9 +20,6 @@ height: 140rpx; display: flex; flex-direction: column; - background-repeat: no-repeat; - background-size:100% 100%; - background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/txk.png); color:#9A9A9A; text-align: center; font-size: 27rpx; @@ -36,9 +33,6 @@ height: 72rpx; display: flex; flex-direction: column; - background-repeat: no-repeat; - background-size:100% 100%; - background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/txkx.png); color:#9A9A9A; text-align: center; font-size: 27rpx; @@ -67,6 +61,16 @@ background-size:100% 100%; background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/hy.png); } +.unhybs{ + position: absolute; + left: 562rpx; + top: 208rpx; + width: 100rpx; + height: 100rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/unhy.png); +} .hydqr{ position: absolute; @@ -199,6 +203,7 @@ margin-top: 720rpx; width:730rpx; margin-left: 10rpx; + overflow-x:hidden; } .mycelltext{ @@ -206,4 +211,162 @@ color: rgba(108, 108, 108, 1); font-size: 32rpx; font-family: SourceHanSansSC-regular; +} + +.meempty{ + width:750rpx; + height:60rpx; +} + +.avatar{ + margin-left: 67rpx!important; + margin-top: 211rpx!important; + position: absolute!important; + width: 140rpx!important; + height: 140rpx!important; + display: flex!important; + flex-direction: column!important; +} + +.bdsjh{ + width:660rpx; + height:786rpx; + border-radius: 30rpx; +} +.bdsjhm1{ + position: absolute; + left: 64rpx; + top: 96rpx; + width: 108px; + height: 26px; + color: rgba(51, 51, 51, 1); + font-size: 18px; + text-align: left; + font-family: SourceHanSansSC-medium; +} + +.bdsjhm2{ + position: absolute; + left: 64rpx; + top: 156rpx; + width: 224px; + height: 21px; + color: rgba(154, 154, 154, 1); + font-size: 14px; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.qxSjh{ + position: absolute; + left: 64rpx; +top: 620rpx; +width: 105px; +height: 35px; +line-height: 70rpx; +border-radius: 10px; +background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); +text-align: center; +box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); +border: 3px solid rgba(255, 255, 255, 1); +color: rgba(255, 255, 255, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-medium; +} + +.wcSjh{ + position: absolute; + left: 386rpx; + top: 620rpx; + width: 105px; + height: 35px; + line-height: 70rpx; + border-radius: 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + color: rgba(255, 255, 255, 1); + font-size: 14px; + text-align: center; + font-family: SourceHanSansSC-medium; +} + +.sjhm1{ + position: absolute; + left: 64rpx; +top: 284rpx; +width: 48px; +height: 18px; +color: rgba(102, 102, 102, 1); +font-size: 12px; +text-align: left; +font-family: SourceHanSansSC-medium; +} + +.yzm1{ + position: absolute; + left: 64rpx; +top: 422rpx; +width: 36px; +height: 18px; +color: rgba(102, 102, 102, 1); +font-size: 12px; +text-align: left; +font-family: SourceHanSansSC-medium; +} +.t-input{ + padding: 0!important; + margin: 0!important; + padding-bottom: 10rpx!important; +} +.input-example{ + padding-bottom: 10rpx!important; +} +.sjhminput1{ + padding: 0!important; + position: absolute; + left:64rpx; + top:330rpx; + --td-input-border-color: rgba(75, 75, 75, 1); + --td-input-border-color: rgba(255, 255, 255, 1); + --td-input-default-text-color: rgba(248, 99, 42, 1); +} + +.sjhbkx{ + position: absolute; + left: 64rpx; + top: 384rpx; + width: 266px; + border: 1rpx solid rgba(248, 99, 42, 1); +} + +.yzmbkx{ + position: absolute; + left: 64rpx; + top: 532rpx; + width: 266px; + border: 1rpx solid rgba(237, 238, 242, 1); +} + +.sjhminput2{ + padding: 0!important; + position: absolute; + left:64rpx; + top:480rpx; + --td-input-border-color: rgba(75, 75, 75, 1); + --td-input-border-color: rgba(255, 255, 255, 1); +} + +.cxhq{ + position: absolute; + left: 500rpx; +top: 478rpx; +width: 48px; +height: 17px; +color: rgba(248, 99, 42, 1); +font-size: 12px; +text-align: left; +font-family: PingFangSC-regular; } \ No newline at end of file diff --git a/pages/home/me/manual/manual.js b/pages/home/me/manual/manual.js new file mode 100644 index 0000000..996dbaa --- /dev/null +++ b/pages/home/me/manual/manual.js @@ -0,0 +1,66 @@ +// pages/home/me/manual/manual.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/manual/manual.json b/pages/home/me/manual/manual.json new file mode 100644 index 0000000..e10cf95 --- /dev/null +++ b/pages/home/me/manual/manual.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "说明书", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/manual/manual.wxml b/pages/home/me/manual/manual.wxml new file mode 100644 index 0000000..0fa45ac --- /dev/null +++ b/pages/home/me/manual/manual.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/home/me/manual/manual.wxss b/pages/home/me/manual/manual.wxss new file mode 100644 index 0000000..3c813e6 --- /dev/null +++ b/pages/home/me/manual/manual.wxss @@ -0,0 +1 @@ +/* pages/home/me/manual/manual.wxss */ \ No newline at end of file diff --git a/pages/home/me/member/member.js b/pages/home/me/member/member.js new file mode 100644 index 0000000..27f9791 --- /dev/null +++ b/pages/home/me/member/member.js @@ -0,0 +1,87 @@ +// pages/home/me/member/member.js +import Toast from 'tdesign-miniprogram/toast/index'; +Page({ + + /** + * 页面的初始数据 + */ + data: { + yhy:true + + }, + doKtHy(){/**开通会员操作 */ + console.log('开通会员') + }, + go2Week(){ + this.setData({yhy:false}) + }, + go2Month(){ + this.setData({yhy:true}) + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + tQuest(){ + Toast({ + context: this, + selector: '#t-toast', + message: '星座精灵AI的付费会员服务基于OpenAI的GPT-3.5 Turbo模型,为您提供高智能情感咨询服务,以及星座、星骰和塔罗牌等娱乐服务。利用人工智能技术和高质量的自然语言响应,星座精灵AI可以更好的帮助您深入探索内心世界。', + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/member/member.json b/pages/home/me/member/member.json new file mode 100644 index 0000000..38b2cd4 --- /dev/null +++ b/pages/home/me/member/member.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "t-toast": "tdesign-miniprogram/toast/toast" + } +} \ No newline at end of file diff --git a/pages/home/me/member/member.wxml b/pages/home/me/member/member.wxml new file mode 100644 index 0000000..8e9be5f --- /dev/null +++ b/pages/home/me/member/member.wxml @@ -0,0 +1,26 @@ + + +VIP会员 + + + + + + + +开通会员 +VIP会员权益 + + 1、星座精灵AI服务无限次畅聊 + 2、不定期商品及新品折扣优惠 + 3、 其他权益陆续增加中...... + +周会员 +月会员 +即刻解锁无限次星座精灵AI无限畅聊! + +¥29 / 周 +¥69 / 月 + +¥29 / 周 +¥69 / 月 diff --git a/pages/home/me/member/member.wxss b/pages/home/me/member/member.wxss new file mode 100644 index 0000000..eac28f3 --- /dev/null +++ b/pages/home/me/member/member.wxss @@ -0,0 +1,232 @@ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.hybt{ + position: absolute; + left: 30rpx; + top: 1326rpx; + width: 690rpx; + height: 230rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/hybt.png); +} + +.sftp{ + position: absolute; + left: 15px; + top: 82px; + width: 345px; + height: 115px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/sftp.png); +} + +.hgpng{ + position: absolute; + left: 109px; +top: 124px; +width: 157px; +height: 174px; +background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/hgpng.png); +} + +.question{ + position: absolute; + left: 236px; + top: 124px; + width: 30px; + height: 30px; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/qqest.png); +} +.hybtn{ + position: absolute; + left: 118px; + top: 645px; + width: 140px; + height: 40px; + line-height: 80rpx; + border-radius: 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + color: rgba(255, 255, 255, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-medium; +} + +.viphyqy{ + position: absolute; +top: 502px; +width: 750rpx; +height: 20px; +color: rgba(108, 108, 108, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-regular; +} + +.introd{ + left:180rpx; + position: absolute; +top: 538px; +width: 750rpx; +height: 75px; +line-height: 50rpx; +color: rgba(108, 108, 108, 1); +font-size: 14px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.zhytxt{ + position: absolute; + left: 82px; +top: 442px; +width: 42px; +height: 21px; +color: rgba(154, 154, 154, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-regular; +} + +.yhytxt{ + position: absolute; + left: 506rpx; +top: 442px; +width: 42px; +height: 21px; +color: rgba(154, 154, 154, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-regular; +} + +.hydqr{ + position: absolute; + top: 314px; + width: 750rpx; + height: 20px; + color: rgba(248, 99, 42, 1); + font-size: 14px; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.week1{ + position: absolute; + left: 32px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(255, 255, 255, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 2px solid rgba(248, 99, 42, 1); +} + +.month1{ + position: absolute; + left: 203px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(248, 99, 42, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 1px solid rgba(248, 99, 42, 1); +} + +.text1{ + margin-left: 2px; + top: 384px; + width: 60px; + height: 41px; + font-size: 28px; + font-family: SourceHanSansSC-regular; +} + +.text2{ + left: 130px; + top: 401px; + width: 16px; + height: 17px; + font-size: 16px; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.tcolor1{ + color: rgba(79, 79, 79, 1); +} + +.tcolor2{ + color: rgba(255, 255, 255, 1); +} + +.week2{ + position: absolute; + left: 32px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(248, 99, 42, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 1px solid rgba(248, 99, 42, 1); +} + +.month2{ + + position: absolute; + left: 203px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(255, 255, 255, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 2px solid rgba(248, 99, 42, 1); +} \ No newline at end of file diff --git a/pages/home/me/member2/member.js b/pages/home/me/member2/member.js new file mode 100644 index 0000000..27f9791 --- /dev/null +++ b/pages/home/me/member2/member.js @@ -0,0 +1,87 @@ +// pages/home/me/member/member.js +import Toast from 'tdesign-miniprogram/toast/index'; +Page({ + + /** + * 页面的初始数据 + */ + data: { + yhy:true + + }, + doKtHy(){/**开通会员操作 */ + console.log('开通会员') + }, + go2Week(){ + this.setData({yhy:false}) + }, + go2Month(){ + this.setData({yhy:true}) + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + tQuest(){ + Toast({ + context: this, + selector: '#t-toast', + message: '星座精灵AI的付费会员服务基于OpenAI的GPT-3.5 Turbo模型,为您提供高智能情感咨询服务,以及星座、星骰和塔罗牌等娱乐服务。利用人工智能技术和高质量的自然语言响应,星座精灵AI可以更好的帮助您深入探索内心世界。', + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/member2/member.json b/pages/home/me/member2/member.json new file mode 100644 index 0000000..38b2cd4 --- /dev/null +++ b/pages/home/me/member2/member.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "t-toast": "tdesign-miniprogram/toast/toast" + } +} \ No newline at end of file diff --git a/pages/home/me/member2/member.wxml b/pages/home/me/member2/member.wxml new file mode 100644 index 0000000..df83028 --- /dev/null +++ b/pages/home/me/member2/member.wxml @@ -0,0 +1,26 @@ + + +VIP会员 + + + + + + + +开通会员 +VIP会员权益 + + 1、星座精灵AI服务无限次畅聊 + 2、不定期商品及新品折扣优惠 + 3、 其他权益陆续增加中...... + +周会员 +月会员 +您的会员将于 2023年5月20日到期 + +¥29 / 周 +¥69 / 月 + +¥29 / 周 +¥69 / 月 diff --git a/pages/home/me/member2/member.wxss b/pages/home/me/member2/member.wxss new file mode 100644 index 0000000..eac28f3 --- /dev/null +++ b/pages/home/me/member2/member.wxss @@ -0,0 +1,232 @@ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.hybt{ + position: absolute; + left: 30rpx; + top: 1326rpx; + width: 690rpx; + height: 230rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/hybt.png); +} + +.sftp{ + position: absolute; + left: 15px; + top: 82px; + width: 345px; + height: 115px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/sftp.png); +} + +.hgpng{ + position: absolute; + left: 109px; +top: 124px; +width: 157px; +height: 174px; +background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/hgpng.png); +} + +.question{ + position: absolute; + left: 236px; + top: 124px; + width: 30px; + height: 30px; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/qqest.png); +} +.hybtn{ + position: absolute; + left: 118px; + top: 645px; + width: 140px; + height: 40px; + line-height: 80rpx; + border-radius: 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + color: rgba(255, 255, 255, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-medium; +} + +.viphyqy{ + position: absolute; +top: 502px; +width: 750rpx; +height: 20px; +color: rgba(108, 108, 108, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-regular; +} + +.introd{ + left:180rpx; + position: absolute; +top: 538px; +width: 750rpx; +height: 75px; +line-height: 50rpx; +color: rgba(108, 108, 108, 1); +font-size: 14px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.zhytxt{ + position: absolute; + left: 82px; +top: 442px; +width: 42px; +height: 21px; +color: rgba(154, 154, 154, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-regular; +} + +.yhytxt{ + position: absolute; + left: 506rpx; +top: 442px; +width: 42px; +height: 21px; +color: rgba(154, 154, 154, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-regular; +} + +.hydqr{ + position: absolute; + top: 314px; + width: 750rpx; + height: 20px; + color: rgba(248, 99, 42, 1); + font-size: 14px; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.week1{ + position: absolute; + left: 32px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(255, 255, 255, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 2px solid rgba(248, 99, 42, 1); +} + +.month1{ + position: absolute; + left: 203px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(248, 99, 42, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 1px solid rgba(248, 99, 42, 1); +} + +.text1{ + margin-left: 2px; + top: 384px; + width: 60px; + height: 41px; + font-size: 28px; + font-family: SourceHanSansSC-regular; +} + +.text2{ + left: 130px; + top: 401px; + width: 16px; + height: 17px; + font-size: 16px; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.tcolor1{ + color: rgba(79, 79, 79, 1); +} + +.tcolor2{ + color: rgba(255, 255, 255, 1); +} + +.week2{ + position: absolute; + left: 32px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(248, 99, 42, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 1px solid rgba(248, 99, 42, 1); +} + +.month2{ + + position: absolute; + left: 203px; + top: 374px; + width: 140px; + height: 60px; + line-height: 60px; + border-radius: 15px; + background-color: rgba(255, 255, 255, 1); + color: rgba(16, 16, 16, 1); + font-size: 14px; + text-align: center; + font-family: Arial; + border: 2px solid rgba(248, 99, 42, 1); +} \ No newline at end of file diff --git a/pages/home/me/mydevice/device.js b/pages/home/me/mydevice/device.js new file mode 100644 index 0000000..50aad0b --- /dev/null +++ b/pages/home/me/mydevice/device.js @@ -0,0 +1,140 @@ +// pages/home/me/mydevice/device.js +const app = getApp();//新建页面时 默认引入 +const req = app.xzjlReq();//初始化一个的request() 实例 + +// 引入二维码 +import drawQrcode from 'weapp-qrcode-canvas-2d' +Page({ + + /** + * 页面的初始数据 + */ + data: { + devs:[] + + }, + doCopy(e){/**赋值设备唯一识别码 */ + let key = e.target.dataset.copy + wx.setClipboardData({ //设置系统剪贴板的内容 + data: key, + success(res) { + wx.getClipboardData({ // 获取系统剪贴板的内容 + success(res) { + wx.showToast({ + title: '复制成功', + }) + } + }) + } + }) + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + doDevQuery(){ + req.getRequest('/api/user/curt/equipments',{}).then((res)=>{ + if(res.data.code==200){ + // 循环查询 + this.setData({devs:res.data.data}) + } + }).catch((err)=>{ + console.log(err); + }) + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.doDevQuery() + const query = wx.createSelectorQuery() + query.select('#myQrcode') + .fields({ + node: true, + size: true + }) + .exec((res) => { + var canvas = res[0].node + + // 调用方法drawQrcode生成二维码 + drawQrcode({ + canvas: canvas, + canvasId: 'myQrcode', + width: 260, + padding: 30, + background: '#ffffff', + foreground: '#000000', + text: '大王顶真帅', + }) + + // 获取临时路径(得到之后,想干嘛就干嘛了) + wx.canvasToTempFilePath({ + canvasId: 'myQrcode', + canvas: canvas, + x: 0, + y: 0, + width: 260, + height: 260, + destWidth: 260, + destHeight: 260, + success(res) { + console.log('二维码临时路径:', res.tempFilePath) + }, + fail(res) { + console.error(res) + } + }) + }) + + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/mydevice/device.json b/pages/home/me/mydevice/device.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/pages/home/me/mydevice/device.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/mydevice/device.wxml b/pages/home/me/mydevice/device.wxml new file mode 100644 index 0000000..580d78b --- /dev/null +++ b/pages/home/me/mydevice/device.wxml @@ -0,0 +1,32 @@ + +我的设备 + + + + + + + + {{item.constellation}}-晶石手环 + 设备唯一识别码 + 识别码是设备唯一ID,绝对不能告诉别人哦! + 设备二维码 + + 可代替设备用于登录,可在设备丢失时临时登录使用 + 请不要将二维码告知他人,否则有账号丢失风险 + + {{item.mac}} + + + + + + + + + + + + + + diff --git a/pages/home/me/mydevice/device.wxss b/pages/home/me/mydevice/device.wxss new file mode 100644 index 0000000..ded92f5 --- /dev/null +++ b/pages/home/me/mydevice/device.wxss @@ -0,0 +1,692 @@ +/* pages/home/me/mydevice/device.wxss */ +.reback11{ + position: absolute; + margin-left: 20rpx; + top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} + + + + + + + + + + + + + + + + + + + + + + + + + + +.call{ + margin-top:0rpx; + padding: 0; + width:750rpx; + height:1624rpx; + overflow: hidden; +} + +.call1{ + margin-top:-50rpx; + padding: 0!important; + width:750rpx; + height:1624rpx; + overflow: hidden; +} + +.dcrightql{ + position:absolute; + width:116.67rpx; + height:116.67rpx; + margin-left: 520rpx; + margin-top:1232rpx; + border-radius: 58.335rpx; +} +.dcrightql1{ + position:absolute; +} + +.dcrbs{ + position:absolute; + width:62.67rpx; + height:72rpx; + margin-top:29.30rpx; + margin-left: 32.33rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/rbs.png); +} + +.lovepic{ + position: absolute; + width:290rpx; + height:50.67rpx; + margin-top:1264.67rpx; + margin-left:235.33rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/pulse.png); +} + +.dchxtxtql{ + position:absolute; + width:200rpx; + height:16rpx; + margin-top:1320.67rpx; + margin-left: 275.33rpx; + text-align: center; + color: #9a9a9a; + font-size: 27rpx; +} + + +.txl{ + position:absolute; + width:72rpx; + height:72rpx; + margin-top:142.67rpx; + margin-left:218rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/tx.png); +} + +.txr{ + position:absolute; + width:72rpx; + height:72rpx; + margin-top:142.67rpx; + margin-left:400.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/tx.png); +} + +.txtextl{ + position:absolute; + width:772rpx; + height:72rpx; + line-height:72rpx; + color: #9a9a9a; + margin-top:142.67rpx; + margin-left:36rpx; + font-size: 27rpx; +} +.jiuchan{ + position: absolute; + width:47.33rpx; + height:26rpx; + margin-top: 169.33rpx; + margin-left: 322.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/jiuchan.png); + +} + +.txtextr{ + position:absolute; + width:772rpx; + height:72rpx; + line-height:72rpx; + color: #9a9a9a; + margin-top:142.67rpx; + margin-left:493.33rpx; + font-size: 27rpx; +} + +.bkg3{ + position: absolute; + width:47.33rpx; + height:26rpx; + margin-top: 169.33rpx; + margin-left: 322.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bkg3.png); +} + +.xxt{ + position: absolute; + width:326.67rpx; + height:771.33rpx; + margin-top: 326.67rpx; + margin-left: 212rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/szn.png); +} + +.yan1{ + position: absolute; + width:114rpx; + height:116.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 837.33rpx; + margin-left:118.67rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} +.yan2{ + position: absolute; + width:114rpx; + height:116.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 837.33rpx; + margin-left:318rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} +.yan3{ + position: absolute; + width:114rpx; + height:116.67rpx; + margin-top: 837.33rpx; + margin-left:517.33rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} + +.bkg1{ + position: absolute; + width:684.67rpx; + height:988rpx; + margin-top: 169.33rpx; + margin-left:46rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bkg1.png); +} + +.bkg3{ + position: absolute; + width:660rpx; + height:952rpx; + margin-top: 205.33rpx; + margin-left:42rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bkg3.png); +} + +.yan11{ + position: absolute; + width:46.67rpx; + height:46.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 33.33rpx; + margin-left:34.33rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/paw.png); +} + +.yan12{ + position: absolute; + width:46.67rpx; + height:46.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 33.33rpx; + margin-left:34.33rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/male.png); +} + +.yan13{ + position: absolute; + width:46.67rpx; + height:46.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 33.33rpx; + margin-left:34.33rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/female.png); +} + +.xxtl{ + position: absolute; + width:326.67rpx; + height:771.33rpx; + margin-top: 326.67rpx; + margin-left: 88rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/szn.png); +} + +.xxtr{ + position: absolute; + width:323.33rpx; + height:787.33rpx; + margin-top: 308.67rpx; + margin-left: 355.33rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/xxtr.png); +} + +.yanql1{ + position: absolute; + width:114rpx; + height:116.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 492rpx; + margin-left:86.67rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} + +.yanql2{ + position: absolute; + width:114rpx; + height:116.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 663.33rpx; + margin-left:38.67rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} + +.yanql4{ + position: absolute; + width:114rpx; + height:116.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 492rpx; + margin-left:550.67rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} + +.yanql5{ + position: absolute; + width:114rpx; + height:116.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + margin-top: 663.33rpx; + margin-left:598rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); +} + +.xxtq{ + position: absolute; + width:326.67rpx; + height:771.33rpx; + margin-top: 326.67rpx; + margin-left: 212rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/xxtr.png); +} + +.k1{ + position: absolute; + width:116rpx; + height:116rpx; + line-height:116rpx; + text-align: center; + margin-top: 1232.67rpx; + margin-left: 114.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/circle.png); + +} + +.k2{ + position: absolute; + width:116rpx; + height:116rpx; + margin-top: 1232.67rpx; + margin-left: 318rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png); + +} + +.k3{ + position: absolute; + width:116rpx; + height:116rpx; + line-height:116rpx; + text-align: center; + margin-top: 1232.67rpx; + margin-left: 520.67rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/circle.png); + +} + +.k11{ + position: absolute; + width:46rpx; + height:46rpx; + margin-top: 34rpx; + margin-left: 36rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yst.png); + +} + +.ktext1{ + position: absolute; + width:116rpx; + height:116rpx; + margin-top: 1366rpx; + margin-left: 114.67rpx; + text-align: center; + color: #9a9a9a; + font-size: 27rpx; +} + +.ktext2{ + position: absolute; + width:116rpx; + height:116rpx; + margin-top: 1366rpx; + margin-left: 318rpx; + text-align: center; + color: #9a9a9a; + font-size: 27rpx; +} + +.ktext3{ + position: absolute; + width:116rpx; + height:116rpx; + margin-top: 1366rpx; + margin-left: 520.67rpx; + text-align: center; + color: #9a9a9a; + font-size: 27rpx; +} + +.ttpopup{ + width: 659.33rpx; + height:804rpx; + background:rgba(255, 255, 255, 0.9); + border-radius: 36rpx; +} + +.ztys{ + position: absolute; + width: 542.67rpx; + height: 290rpx; + display: flex; + flex-direction: column; + background-repeat: no-repeat; + background-size:100% 100%; + left: 0; + right: 0; + margin: 84rpx auto; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xzt/ztys.png); +} + +.jkzs{ + position: absolute; + width: 111.33rpx; + height: 26.67rpx; + display: flex; + flex-direction: column; + background-repeat: no-repeat; + background-size:100% 100%; + margin-left:97.33rpx; + margin-top: 589.33rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/jkzs.png); +} + +.aqzs{ + position: absolute; + width: 111.33rpx; + height: 26.67rpx; + display: flex; + flex-direction: column; + background-repeat: no-repeat; + background-size:100% 100%; + margin-left:97.33rpx; + margin-top: 653.33rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/aqzs.png); +} + +.cyzs{ + position: absolute; + width: 111.33rpx; + height: 26.67rpx; + display: flex; + flex-direction: column; + background-repeat: no-repeat; + background-size:100% 100%; + margin-left:97.33rpx; + margin-top: 717.33rpx; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/cyzs.png); +} + +.rjkzs{ + position: absolute; + width: 311.33rpx; + height: 26.67rpx; + line-height: 26.67rpx; + display: flex; + flex-direction: column; + margin-left:279.33rpx; + margin-top: 580.33rpx; +} + +.raqzs{ + position: absolute; + width: 111.33rpx; + height: 26.67rpx; + line-height:26.67rpx; + display: flex; + flex-direction: column; + background-repeat: no-repeat; + background-size:100% 100%; + margin-left:279.33rpx; + margin-top: 644.33rpx; +} + +.rcyzs{ + position: absolute; + width: 111.33rpx; + height: 26.67rpx; + line-height:26.67rpx; + display: flex; + flex-direction: column; + background-repeat: no-repeat; + background-size:100% 100%; + margin-left:279.33rpx; + margin-top: 708.33rpx; +} + + +.shtp{ + position: absolute; + left: 121px; + top: 120px; + width: 134px; + height: 134px; + border-radius: 134rpx; + line-height: 17px; + opacity: 0.5; + background-color: rgba(239, 239, 239, 1); + color: rgba(16, 16, 16, 1); + font-size: 12px; + text-align: center; + font-family: Arial; +} + +.shimg{ + position: absolute; + left: 131px; + top: 131px; + width: 113px; + height: 113px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/shimg.png); +} + +.shmz{ + position: absolute; + top: 270px; + width: 750rpx; + height: 24px; + color: rgba(248, 99, 42, 1); + font-size: 16px; + text-align: center; + font-family: SourceHanSansSC-medium; +} + +.sbwysbm{ + position: absolute; + top: 349px; + width: 750rpx; + height: 24px; + color: rgba(108, 108, 108, 1); + font-size: 16px; + text-align: center; + font-family: SourceHanSansSC-medium; +} + +.intr1{ + position: absolute; + top: 728px; + width: 750rpx; + height: 18px; + color: rgba(154, 154, 154, 1); + font-size: 12px; + text-align: center; + font-family: SourceHanSansSC-regular; +} + + +.intr2{ + position: absolute; + top: 746px; + width: 750rpx; + height: 18px; + color: rgba(154, 154, 154, 1); + font-size: 12px; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.sbmm{ + position: absolute; +top: 449px; +width: 750rpx; +height: 18px; +color: rgba(154, 154, 154, 1); +font-size: 12px; +text-align: center; +font-family: SourceHanSansSC-regular; +} +.sbewmt{ + position: absolute; +top: 522px; +width: 750rpx; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: center; +font-family: SourceHanSansSC-medium; +} + +.sbewm{ + position: absolute; + left: 113px; + top: 562px; + width: 150px; + height: 150px; +} +.sbsbmk{ + position: absolute; + left: 44px; + top: 389px; + width: 288px; + height: 44px; + line-height: 20px; + border-radius: 15px; + background-color: rgba(239, 239, 239, 0.5); + text-align: center; + border: 1px solid rgba(187, 187, 187, 1); +} + +.sbsbmkt{ + position: absolute; + left: 76px; + top: 389px; + width: 185px; + height: 44px; + line-height: 44px; + color: rgba(108, 108, 108, 1); + font-size: 16px; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.fz{ + position: absolute; + left: 296px; + top: 401px; + width: 20px; + height: 20px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/copy.png); +} + +.tbl{ + position: absolute; + left: 0px; + top: 150px; + width: 75px; + height: 75px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tbl.png); +} + +.tbr{ + position: absolute; + left: 301px; + top: 150px; + width: 75px; + height: 75px; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/tbr.png); +} \ No newline at end of file diff --git a/pages/home/me/sq/sq.js b/pages/home/me/sq/sq.js new file mode 100644 index 0000000..994786a --- /dev/null +++ b/pages/home/me/sq/sq.js @@ -0,0 +1,66 @@ +// pages/home/me/sq/sq.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/sq/sq.json b/pages/home/me/sq/sq.json new file mode 100644 index 0000000..15edd67 --- /dev/null +++ b/pages/home/me/sq/sq.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "加入社群", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/sq/sq.wxml b/pages/home/me/sq/sq.wxml new file mode 100644 index 0000000..f458aa9 --- /dev/null +++ b/pages/home/me/sq/sq.wxml @@ -0,0 +1,2 @@ + + diff --git a/pages/home/me/sq/sq.wxss b/pages/home/me/sq/sq.wxss new file mode 100644 index 0000000..8c27dde --- /dev/null +++ b/pages/home/me/sq/sq.wxss @@ -0,0 +1 @@ +/* pages/home/me/sq/sq.wxss */ \ No newline at end of file diff --git a/pages/home/me/yhsyxy/yhsyxy.js b/pages/home/me/yhsyxy/yhsyxy.js new file mode 100644 index 0000000..ed1eb27 --- /dev/null +++ b/pages/home/me/yhsyxy/yhsyxy.js @@ -0,0 +1,66 @@ +// pages/home/me/yhsyxy/yhsyxy.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/yhsyxy/yhsyxy.json b/pages/home/me/yhsyxy/yhsyxy.json new file mode 100644 index 0000000..cfc3323 --- /dev/null +++ b/pages/home/me/yhsyxy/yhsyxy.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "用户使用协议", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/yhsyxy/yhsyxy.wxml b/pages/home/me/yhsyxy/yhsyxy.wxml new file mode 100644 index 0000000..06ff9d2 --- /dev/null +++ b/pages/home/me/yhsyxy/yhsyxy.wxml @@ -0,0 +1,2 @@ + + diff --git a/pages/home/me/yhsyxy/yhsyxy.wxss b/pages/home/me/yhsyxy/yhsyxy.wxss new file mode 100644 index 0000000..f243eac --- /dev/null +++ b/pages/home/me/yhsyxy/yhsyxy.wxss @@ -0,0 +1 @@ +/* pages/home/me/yhsyxy/yhsyxy.wxss */ \ No newline at end of file diff --git a/pages/home/me/yjfk/yjfk.js b/pages/home/me/yjfk/yjfk.js new file mode 100644 index 0000000..4063133 --- /dev/null +++ b/pages/home/me/yjfk/yjfk.js @@ -0,0 +1,107 @@ +// pages/home/me/yjfk/yjfk.js +const app = getApp();//新建页面时 默认引入 +const req = app.xzjlReq();//初始化一个的request() 实例 +Page({ + + /** + * 页面的初始数据 + */ + data: { + ctt:'', + yj:{ + contactWay: "", + content: "" + } + + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + doExecYjfk(e){ + let form = e.detail.value + req.postRequest('/api/v1/opinion',form).then((res)=>{ + console.log(res) + if(res.data.code==200){ + console.log('反馈成功') + wx.showToast({ + title:'反馈提交成功', + icon: 'none', + duration: 1000 + }) + + }else{ + wx.showToast({ + title:'反馈提交失败', + icon: 'none', + duration: 1000 + }) + } + console.log(this.userInfo); + }).catch((err)=>{ + console.log(err); + }) + wx.switchTab({ + url: '/pages/home/me/indexx', + }) + /** + * wx.switchTab({ + url: '/pages/home/me/indexx', + }) */ + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/yjfk/yjfk.json b/pages/home/me/yjfk/yjfk.json new file mode 100644 index 0000000..92e4a2b --- /dev/null +++ b/pages/home/me/yjfk/yjfk.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "t-textarea": "tdesign-miniprogram/textarea/textarea" + } +} \ No newline at end of file diff --git a/pages/home/me/yjfk/yjfk.wxml b/pages/home/me/yjfk/yjfk.wxml new file mode 100644 index 0000000..eefb207 --- /dev/null +++ b/pages/home/me/yjfk/yjfk.wxml @@ -0,0 +1,19 @@ + + + +意见反馈 +我们非常重视您的意见 +如果有任何建议也欢迎向我们提出 +建议描述 +联系方式 + +
+ + + + + + + +
+ diff --git a/pages/home/me/yjfk/yjfk.wxss b/pages/home/me/yjfk/yjfk.wxss new file mode 100644 index 0000000..f5fbf26 --- /dev/null +++ b/pages/home/me/yjfk/yjfk.wxss @@ -0,0 +1,125 @@ +/* pages/home/me/yjfk/yjfk.wxss */ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} + +.hybt{ + position: absolute; + left: 30rpx; + top: 1326rpx; + width: 690rpx; + height: 230rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/hybt.png); +} +.fkt1{ + position: absolute; + left: 46rpx; + top: 240rpx; + width: 552rpx; + height: 106rpx; + color: rgba(248, 99, 42, 1); + font-size: 32rpx; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.fkt2{ + position: absolute; + left: 46rpx; + top: 290rpx; + width: 552rpx; + height: 106rpx; + color: rgba(248, 99, 42, 1); + font-size: 32rpx; + text-align: left; + font-family: SourceHanSansSC-regular; +} +.jyms{ + position: absolute; + left: 46rpx; + top: 418rpx; + width: 196rpx; + height: 52rpx; + color: rgba(108, 108, 108, 1); + font-size: 36rpx; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.submit{ + z-index: 9999; + position: absolute; + left: 236rpx; + top: 1290rpx; + width: 280rpx; + height: 80rpx; + line-height: 80rpx; + border-radius: 20rpx; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 4rpx 12rpx 0px rgba(0, 0, 0, 0.4); + border: 6rpx solid rgba(255, 255, 255, 1); + color: rgba(255, 255, 255, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-medium; +} +.lxfs{ + position: absolute; + left: 46rpx; + top: 980rpx; + width: 196rpx; + height: 52rpx; + color: rgba(108, 108, 108, 1); + font-size: 36rpx; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.jymsk{ + position: absolute; + left: 23px; + top: 251px; + width: 330px; + height: 207px; + line-height: 20px; + border-radius: 15px; + background-color: rgba(239, 239, 239, 1); + text-align: center; +} +.t-textarea { + background-color: transparent!important; +} + +.lxfsk{ + position: absolute; + left: 23px; + top: 532px; + width: 330px; + height: 56px; + line-height: 20px; + border-radius: 15px; + background-color: rgba(239, 239, 239, 1); + text-align: center; +} \ No newline at end of file diff --git a/pages/home/me/ysxy/ysxy.js b/pages/home/me/ysxy/ysxy.js new file mode 100644 index 0000000..f4e8e62 --- /dev/null +++ b/pages/home/me/ysxy/ysxy.js @@ -0,0 +1,66 @@ +// pages/home/me/ysxy/ysxy.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/me/ysxy/ysxy.json b/pages/home/me/ysxy/ysxy.json new file mode 100644 index 0000000..68a6bce --- /dev/null +++ b/pages/home/me/ysxy/ysxy.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "隐私协议", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/me/ysxy/ysxy.wxml b/pages/home/me/ysxy/ysxy.wxml new file mode 100644 index 0000000..5c76ea3 --- /dev/null +++ b/pages/home/me/ysxy/ysxy.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/home/me/ysxy/ysxy.wxss b/pages/home/me/ysxy/ysxy.wxss new file mode 100644 index 0000000..b0c1385 --- /dev/null +++ b/pages/home/me/ysxy/ysxy.wxss @@ -0,0 +1 @@ +/* pages/home/me/ysxy/ysxy.wxss */ \ No newline at end of file diff --git a/pages/home/xx/index.js b/pages/home/xx/index.js index a1cf8c9..4e1f9f8 100644 --- a/pages/home/xx/index.js +++ b/pages/home/xx/index.js @@ -1,10 +1,24 @@ // pages/home/xx/index.js +const app = getApp();//新建页面时 默认引入 +const req = app.xzjlReq();//初始化一个的request() 实例 Page({ /** * 页面的初始数据 */ data: { + hasLover:false,// 是否单身 + + }, + doQueryInit(){ + req.getRequest('/api/user/curt',{}).then((res)=>{ + if(res.data.code==200){ + this.setData({hasLover:res.data.data.hasLover}) + console.log(res.data.data.hasLover) + } + }).catch((err)=>{ + console.log(err); + }) }, @@ -12,7 +26,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - + this.doQueryInit() }, /** diff --git a/pages/home/xx/index.wxml b/pages/home/xx/index.wxml index a4e1324..63376d0 100644 --- a/pages/home/xx/index.wxml +++ b/pages/home/xx/index.wxml @@ -1,8 +1,12 @@ - + + + +111 + diff --git a/pages/home/xy/index.js b/pages/home/xy/index.js index 364f9be..224db90 100644 --- a/pages/home/xy/index.js +++ b/pages/home/xy/index.js @@ -1,31 +1,60 @@ // pages/home/xy/index.js +const app = getApp();//新建页面时 默认引入 +const req = app.xzjlReq();//初始化一个的request() 实例 Page({ /** * 页面的初始数据 */ data: { + xzInfo:{}, + userInfo:{}, + xyNfc:true, + xyInfo:{ + + } + }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - + this.initXy() + this.getXzTp() + }, + /**获取星座图片对应关系 */ + getXzTp(){ + req.getRequest('/api/dict/value/horoscope-resource',{}).then((res)=>{ + if(res.data.code==200){ + this.setData({xzInfo:res.data.data}) + } + }).catch((err)=>{ + console.log(err); + }) + }, + initXy(){ + req.getRequest('/api/user/curt',{}).then((res)=>{ + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + } + }).catch((err)=>{ + console.log(err); + }) + this.setData({xyInfo:wx.getStorageSync('nfc')}) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { - }, /** * 生命周期函数--监听页面显示 */ onShow() { - + this.initXy() }, /** diff --git a/pages/home/xy/index.json b/pages/home/xy/index.json index 3623e08..a54c319 100644 --- a/pages/home/xy/index.json +++ b/pages/home/xy/index.json @@ -1,6 +1,7 @@ { "usingComponents": { "t-popup": "tdesign-miniprogram/popup/popup", - "t-rate": "tdesign-miniprogram/rate/rate" + "t-rate": "tdesign-miniprogram/rate/rate", + "t-image": "tdesign-miniprogram/image/image" } } \ No newline at end of file diff --git a/pages/home/xy/index.wxml b/pages/home/xy/index.wxml index aa25b7b..429d20e 100644 --- a/pages/home/xy/index.wxml +++ b/pages/home/xy/index.wxml @@ -7,19 +7,21 @@ -7 - - +{{userInfo.horoscope.number}} + +{{userInfo.horoscope.color}} 幸运数字 -白羊座 +{{userInfo.horoscope.name}} 幸运颜色 -能量 +10% -银币 +0.1枚 +能量 +{{userInfo.pendantEnergy}}% +银币 +{{userInfo.silverCoin}}枚 + + - - + {{userInfo.horoscope.summary}} + diff --git a/pages/home/xy/index.wxss b/pages/home/xy/index.wxss index d39685c..bc18183 100644 --- a/pages/home/xy/index.wxss +++ b/pages/home/xy/index.wxss @@ -145,10 +145,14 @@ position: absolute; width: 116rpx; height: 116rpx; + line-height: 116rpx; + text-align: center; display: flex; flex-direction: column; background-repeat: no-repeat; background-size:100% 100%; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; margin-top:1232rpx; margin-left:520rpx; background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/xyszy.png); @@ -212,14 +216,16 @@ position: absolute; width: 542.67rpx; height: 290rpx; + line-height:56rpx; display: flex; flex-direction: column; - background-repeat: no-repeat; - background-size:100% 100%; left: 0; right: 0; margin: 84rpx auto; - background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xzt/ztys.png); + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: left; + font-family: SourceHanSansSC-regular; } .jkzs{ diff --git a/pages/home/xyc/index.js b/pages/home/xyc/index.js index 51f4ee8..25f9003 100644 --- a/pages/home/xyc/index.js +++ b/pages/home/xyc/index.js @@ -1,17 +1,177 @@ // pages/home/xyc/index.js +import FormData from './../../../utils/formdata/index' +import Toast from 'tdesign-miniprogram/toast/index'; +const app = getApp();//新建页面时 默认引入 +const req = app.xzjlReq();//初始化一个的request() 实例 Page({ /** * 页面的初始数据 */ data: { + fileList: ['https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png'],//图片list + form:{ + content:"", + deadline:'', + link:'', + img:'111' + }, + + cvisible: false, + note: '', + xyForm:{ + + }, + visible:false,//弹窗 + single:true, + xzInfo:{}, + userInfo:{}, + xyNfc:true, + xyInfo:{ + + } }, + handleAdd(e){/**添加图片 */ + const { fileList } = this.data; + const { files } = e.detail; + + // 方法1:选择完所有图片之后,统一上传,因此选择完就直接展示 + this.setData({ + fileList: [...fileList, ...files], // 此时设置了 fileList 之后才会展示选择的图片 + }); + files.forEach(file => this.uploadFile(file)) + }, + handleRemove(e){/**删除图片 */ + const { index } = e.detail; + const { fileList } = this.data; + + fileList.splice(index, 1); + this.setData({ + fileList, + }); + }, + uploadFile(file) {/**执行 */ + const FormData = require('./../../../utils/formdata/index.js') + let fd = new FormData() + fd.append('type','graphic') + console.log(file) + fd.appendFile(file.name,file.url) + console.log('文件上传') + req.postRequest('/api/resource',fd.getData()).then((res)=>{ + console.log(res) + if(res.data.code==200){ + console.log('res') + } + console.log(this.userInfo); + }).catch((err)=>{ + console.log(err); + }) + console.log('许愿成功!') + }, + go2MyYw(){ + wx.navigateTo({ + url: '/pages/home/xyc/wdyw/wdyw' + }) + + }, + go2TaYw(){ + wx.navigateTo({ + url: '/pages/home/xyc/tdyw/tdyw' + }) + + }, + doXzTime(){ + this.setData({ cvisible: true }); + console.log('执行选择时间') + }, + handleConfirm(e) { + const { value } = e.detail; + const format = (val) => { + const date = new Date(val); + return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`; + }; + + this.setData({ + note: format(value) + }); + }, + onClose({ detail }) { + console.log(detail.trigger); + }, + showMultiText() { + Toast({ + context: this, + selector: '#t-toast', + message: '投枚银币许个愿吧\n守护精灵将会祝福你的愿望!', + dataduration:10 + }); + }, + doXyPop(){/**弹出许愿弹窗 */ + console.log('执行力。。。。。') + this.setData({visible:true}) + + }, + onVisibleChange(e) { + this.setData({ + visible: e.detail.visible, + }); + }, + doCancelXy(){/**取消许愿 */ + this.setData({ + visible: false, + }); + + }, + doFinishXy(e){/**许愿 */ + console.log('开始执行xxxx') + console.log(e.target) + console.log(e.target.dataset.fs) + this.setData({ + visible: false, + }); + let param = e.target.dataset.fs + console.log(e.target.dataset) + console.log(e.target.dataset.note) + param.deadline = e.target.dataset.note + console.log(this.note) + //api/user/curt/wish + req.postRequest('/api/user/curt/wish',param).then((res)=>{ + console.log(res) + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + if(res.data.data&&res.data.data.loverId&&res.data.data.loverId!=null){ + this.setData({single:false}) + } + } + console.log(this.userInfo); + }).catch((err)=>{ + console.log(err); + }) + console.log('许愿成功!') + + }, + initXy(){ + req.getRequest('/api/user/curt',{}).then((res)=>{ + console.log(res) + if(res.data.code==200){ + this.setData({userInfo:res.data.data}) + if(res.data.data&&res.data.data.loverId&&res.data.data.loverId!=null){ + this.setData({single:false}) + } + } + console.log(this.userInfo); + }).catch((err)=>{ + console.log(err); + }) + this.setData({xyInfo:wx.getStorageSync('nfc')}) + }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { + this.initXy() }, @@ -19,6 +179,7 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onReady() { + this.initXy() }, @@ -26,13 +187,14 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - + console.log('隐藏了') }, /** * 生命周期函数--监听页面隐藏 */ onHide() { + console.log('隐藏了') }, diff --git a/pages/home/xyc/index.json b/pages/home/xyc/index.json index 3928faa..1ee391f 100644 --- a/pages/home/xyc/index.json +++ b/pages/home/xyc/index.json @@ -1,3 +1,10 @@ { - "usingComponents": {} + "usingComponents": { + "t-toast": "tdesign-miniprogram/toast/toast", + "t-popup": "tdesign-miniprogram/popup/popup", + "t-input": "tdesign-miniprogram/input/input", + "t-textarea": "tdesign-miniprogram/textarea/textarea", + "t-calendar": "tdesign-miniprogram/calendar/calendar", + "t-upload": "tdesign-miniprogram/upload/upload" + } } \ No newline at end of file diff --git a/pages/home/xyc/index.wxml b/pages/home/xyc/index.wxml index 28fc4ef..749c954 100644 --- a/pages/home/xyc/index.wxml +++ b/pages/home/xyc/index.wxml @@ -1,7 +1,46 @@ -银币0.3枚 -我的愿望 - - - - - \ No newline at end of file + + +银币{{userInfo.silverCoin}}枚 +我的愿望 + + +银币{{userInfo.silverCoin}}枚 +Ta的愿望 +我的愿望 + + + + + + + + + + + 许愿内容 + 期望时间 + 许愿链接 + 许愿图片 + + + + + + + + + + + + 取消 + 完成 + + + + \ No newline at end of file diff --git a/pages/home/xyc/index.wxss b/pages/home/xyc/index.wxss index d2e1c9e..bc0d1a2 100644 --- a/pages/home/xyc/index.wxss +++ b/pages/home/xyc/index.wxss @@ -63,6 +63,55 @@ font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; font-size: 30rpx; } + +.qlxybtn2{ + position: absolute; + margin-left: 30rpx; + margin-top: 193rpx; + width: 200rpx; + height: 67.495rpx; + border-radius: 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + line-height: 67.495rpx; + color: aliceblue; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + font-size: 30rpx; +} +.qlxybtn21{ + position: absolute; + margin-left: 270rpx; + margin-top: 193rpx; + width: 200rpx; + height: 67.495rpx; + border-radius: 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + line-height: 67.495rpx; + color: aliceblue; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + font-size: 30rpx; +} +.qlxybtn22{ + position: absolute; + margin-left: 510rpx; + margin-top: 193rpx; + width: 200rpx; + height: 67.495rpx; + border-radius: 10px; + background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); + text-align: center; + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); + border: 3px solid rgba(255, 255, 255, 1); + line-height: 67.495rpx; + color: aliceblue; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + font-size: 30rpx; +} .btn21{ margin-left:10rpx; text-align: left; @@ -139,4 +188,184 @@ color:#9A9A9A; text-align: center; font-size: 27rpx; -} \ No newline at end of file +} + +.txypop{ + margin-top: 50rpx; + width: 710rpx; + height:1300rpx; + border-radius: 30rpx!important; +} + +.ttop1{ + margin-left: 30rpx; + width: 650rpx; + height:1240rpx; + margin-top:30rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xyc/xy11.png); +} + +.xynr{ + position: absolute; + left: 92rpx; + top: 230rpx; + width: 72px; + height: 24px; + color: rgba(108, 108, 108, 1); + font-size: 16px; + text-align: left; + font-family: SourceHanSansSC-regular; +} + +.qwsj{ + position: absolute; + left: 92rpx; +top: 468rpx; +width: 72px; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.xylj{ + position: absolute; + left: 92rpx; +top: 588rpx; +width: 72px; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.xytp{ + position: absolute; + left: 92rpx; +top: 692rpx; +width: 72px; +height: 24px; +color: rgba(108, 108, 108, 1); +font-size: 16px; +text-align: left; +font-family: SourceHanSansSC-regular; +} + +.qx{ + position: absolute; + left: 92rpx; +top: 994rpx; +width: 105px; +height: 35px; +line-height: 35px; +border-radius: 10px; +background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); +text-align: center; +box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); +border: 3px solid rgba(255, 255, 255, 1); +color: rgba(255, 255, 255, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-medium; +} + +.wc{ + position: absolute; + left: 414rpx; +top: 994rpx; +width: 105px; +height: 35px; +line-height: 35px; +border-radius: 10px; +background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%); +text-align: center; +box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4); +border: 3px solid rgba(255, 255, 255, 1); +color: rgba(255, 255, 255, 1); +font-size: 14px; +text-align: center; +font-family: SourceHanSansSC-medium; +} + +.xynrf{ + position: absolute; + left: 250rpx; +top: 230rpx; +width: 196px; +height: 90px; +line-height: 20px; +border-radius: 10px; +color: rgba(136, 136, 136, 1); +font-size: 14px; +text-align: left; +font-family: Microsoft Yahei; +border: 1px solid rgba(187, 187, 187, 1); +} + +.xyljt{ + padding: 15rpx!important; + position: absolute; + left: 250rpx; + top: 572rpx; + width: 196px!important; + height: 80rpx!important; + line-height: 80rpx!important; + border-radius: 10px; + color: rgba(136, 136, 136, 1); + font-size: 14px; + text-align: left; + font-family: Microsoft Yahei; + border: 1px solid rgba(187, 187, 187, 1); +} + +.qwsjt{ + padding: 15rpx!important; + position: absolute; + left: 250rpx; + top: 448rpx; + width: 196px!important; + height: 80rpx!important; + line-height: 80rpx!important; + border-radius: 10px; + color: rgba(136, 136, 136, 1); + font-size: 14px; + text-align: left; + font-family: Microsoft Yahei; + border: 1px solid rgba(187, 187, 187, 1); + +} + +.xltb{ + position: absolute; + left:596rpx; + top:480rpx; + width:26rpx; + height:26rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xyc/xltb.png); + +} + +.xytpt{ + position: absolute; + width:600rpx; + height:600rpx; + margin-top:700rpx; + margin-left: 210rpx!important; +} +.t-grid { + background-color: transparent!important; +} + +.ppop{ + position: absolute; + width: 600rpx; + height: 700rpx; + margin-top: 370rpx; + margin-left: 75rpx; +} diff --git a/pages/home/xyc/tdyw/tdyw.js b/pages/home/xyc/tdyw/tdyw.js new file mode 100644 index 0000000..e3fbdc8 --- /dev/null +++ b/pages/home/xyc/tdyw/tdyw.js @@ -0,0 +1,69 @@ +// pages/home/xyc/tdyw/tdyw.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/xyc/tdyw/tdyw.json b/pages/home/xyc/tdyw/tdyw.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/pages/home/xyc/tdyw/tdyw.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/xyc/tdyw/tdyw.wxml b/pages/home/xyc/tdyw/tdyw.wxml new file mode 100644 index 0000000..329944f --- /dev/null +++ b/pages/home/xyc/tdyw/tdyw.wxml @@ -0,0 +1,4 @@ + + + +Ta的愿望 diff --git a/pages/home/xyc/tdyw/tdyw.wxss b/pages/home/xyc/tdyw/tdyw.wxss new file mode 100644 index 0000000..26db95b --- /dev/null +++ b/pages/home/xyc/tdyw/tdyw.wxss @@ -0,0 +1,23 @@ +/* pages/home/xyc/tdyw/tdyw.wxss */ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} \ No newline at end of file diff --git a/pages/home/xyc/wdyw/wdyw.js b/pages/home/xyc/wdyw/wdyw.js new file mode 100644 index 0000000..0a61e35 --- /dev/null +++ b/pages/home/xyc/wdyw/wdyw.js @@ -0,0 +1,69 @@ +// pages/home/xyc/wdyw/wdyw.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + go2Reback(){ + wx.navigateBack({ changed: true }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/home/xyc/wdyw/wdyw.json b/pages/home/xyc/wdyw/wdyw.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/pages/home/xyc/wdyw/wdyw.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home/xyc/wdyw/wdyw.wxml b/pages/home/xyc/wdyw/wdyw.wxml new file mode 100644 index 0000000..12f0e68 --- /dev/null +++ b/pages/home/xyc/wdyw/wdyw.wxml @@ -0,0 +1,4 @@ + + + +我的愿望 diff --git a/pages/home/xyc/wdyw/wdyw.wxss b/pages/home/xyc/wdyw/wdyw.wxss new file mode 100644 index 0000000..2a57683 --- /dev/null +++ b/pages/home/xyc/wdyw/wdyw.wxss @@ -0,0 +1,23 @@ +/* pages/home/xyc/wdyw/wdyw.wxss */ +.reback{ + position: absolute; + margin-left: 20rpx; + margin-top:108rpx; + width:48rpx; + height:48rpx; + background-repeat: no-repeat; + background-size:100% 100%; + background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png); +} + +.title{ + position: absolute; + left: 278rpx; + top: 108rpx; + width: 196rpx; + height: 48rpx; + color: rgba(108, 108, 108, 1); + font-size: 32rpx; + text-align: center; + font-family: SourceHanSansSC-regular; +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 4e0d575..76cc2e3 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,25 +1,26 @@ -// pages/index/index.js +// 导入TDesign弹窗 +import Toast from 'tdesign-miniprogram/toast/index'; const app = getApp();//新建页面时 默认引入 const req = app.simpleReq();//初始化一个的request() 实例 -// 导入包 +// 导入RSA加密包 import WxmpRsa from 'wxmp-rsa' Page({ - - /** - * 页面的初始数据 - */ data: { }, - + // 此处为周期事件 /** * 生命周期函数--监听页面加载 */ onLoad(options) { - + if(options&&options.sn&&options.sn!=null&&options.sn!=''){ + console.log('有数据'+options.sn) + login('nfc',options.sn) + }else{ + console.log('无数据') + } }, - /** * 生命周期函数--监听页面初次渲染完成 */ @@ -33,52 +34,27 @@ Page({ onShow() { }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - }, - toUrl(){ - wx.switchTab({ - url: '/pages/home/xy/index' - }) - }, + /*---------------------------------------------*/ + //以下为自定义事件 + /**跳转到获取晶石页面 */ go2Get(){ wx.navigateTo({ url: '/pages/index/out/out' - }) - + }) }, + /** + * 登录失败提示 + */ + loginErrorToast(mode) { + Toast({ + context: this, + selector: '#t-toast', + message: mode=='scan'?'扫码登录失败\n 二维码有误':'精灵链接失败\n 请再试一次', + theme: 'error', + direction: 'column', + }); + }, + /**扫码事件 */ scanCodeEvent(){ var that = this; var DEV_CODE = "" @@ -86,73 +62,69 @@ Page({ wx.scanCode({ onlyFromCamera: true,// 只允许从相机扫码 success(res){ - console.log("扫码成功:"+JSON.stringify(res)) - DEV_CODE = res.result - var PUBLIC_KEY = "" - req.getRequest('/api/dict/value/login-public-key',{}).then((res)=>{ - if(res.data.code==200){//扫码登录成功 - PUBLIC_KEY = res.data.data - console.log(PUBLIC_KEY) - // 实例化rsa - const rsa = new WxmpRsa() - // 设置公钥 - rsa.setPublicKey(PUBLIC_KEY) - // 加密 - const mac = rsa.encryptLong(DEV_CODE) - console.log('加密后的结果:', mac) - // 此处执行登录获取token操作 - req.postRequest('/api/user/login',{'mac':mac}).then((res)=>{ - wx.setStorageSync('token', res.data.data) - console.log('token是:'+res.data.data) - wx.showToast({ - title:'扫描登录成功', - icon: 'none', - duration: 1000 - }) - wx.switchTab({ - url: '/pages/home/xy/index' - }) - } - - ) - }else{ - wx.showToast({ - title:'扫码失败,请确认您的二维码是否正确!', - icon: 'none', - duration: 1000 - }) - } - console.log(res); - }).catch((err)=>{ - console.log(err); - }) + that.login('scan',res.result) }, }) + }, + + /** + * 登录事件, + * mode为模式参数,scan为扫码,nfc为nfc模式 + * code为用户码参数,用户码为空则代表为扫码登录 + */ + login(mode,code){ + console.log('进入登录了!!!') + var DEV_CODE = code + var PUBLIC_KEY = "" + req.getRequest('/api/dict/value/login-public-key',{}).then((res)=>{ + if(res.data.code==200){//获取公钥成功 + PUBLIC_KEY = res.data.data + // 实例化rsa + const rsa = new WxmpRsa() + // 设置公钥 + rsa.setPublicKey(PUBLIC_KEY) + // 加密 + const mac = rsa.encryptLong(DEV_CODE) + // 此处执行登录获取token操作 + req.postRequest('/api/user/login',{'mac':mac}).then((res)=>{ + if(res.data.code==200){ + wx.setStorageSync('token', res.data.data) + // 设置当前设备码 + wx.setStorageSync('code', DEV_CODE) + // 设置为初次识别NFC + wx.setStorageSync('nfc', false) + wx.showToast({ + title:mode=='scan'?'扫码登录成功':'NFC识别成功', + icon: 'none', + duration: 1000 + }) + wx.switchTab({ + url: '/pages/home/xy/index' + }) + }else if(res.data.code==500){ + this.loginErrorToast(mode) + }else{ + this.loginErrorToast(mode) + } + + } + + ) + }else{ + wx.showToast({ + title:'扫码失败,请确认您的二维码是否正确!', + icon: 'none', + duration: 1000 + }) + } + }).catch((err)=>{ + console.log(err); + }) + + }, + + + - //调用RSA加密 - /*wx.scanCode({ - onlyFromCamera: true,// 只允许从相机扫码 - success(res){ - console.log("扫码成功:"+JSON.stringify(res)) - // 扫码成功后 在此处理接下来的逻辑 - that.setData({ - scanCode: res.result//扫描得到的结果 - }) - //that.query();//扫描成功后调用查询方法 - }, - fail (err) { - // console.log(err) - wx.showToast({ - title:'扫描失败', - icon: 'none', - duration: 1000 - }) - // 扫码成功后 在此处理接下来的逻辑 - that.setData({ - scanCode: '',c:0,cc:0,ccc:0,t:0 - }) - } - })*/ - } }) \ No newline at end of file diff --git a/pages/index/index.json b/pages/index/index.json index 3928faa..38b2cd4 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -1,3 +1,5 @@ { - "usingComponents": {} + "usingComponents": { + "t-toast": "tdesign-miniprogram/toast/toast" + } } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 7278ef7..232db70 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -3,11 +3,12 @@ - + 获取晶石 + diff --git a/pages/index/out/out.json b/pages/index/out/out.json index 3928faa..8ce60a8 100644 --- a/pages/index/out/out.json +++ b/pages/index/out/out.json @@ -1,3 +1,4 @@ { + "navigationBarTitleText": "购买晶石", "usingComponents": {} } \ No newline at end of file diff --git a/pages/index/out/out.wxml b/pages/index/out/out.wxml index 5ac033d..af8dee3 100644 --- a/pages/index/out/out.wxml +++ b/pages/index/out/out.wxml @@ -1,2 +1,2 @@ - + diff --git a/project.private.config.json b/project.private.config.json index 992eece..d1772d4 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -3,6 +3,6 @@ "projectname": "xzjl-ui", "setting": { "compileHotReLoad": true, - "urlCheck": true + "urlCheck": false } } \ No newline at end of file diff --git a/utils/formdata/index.js b/utils/formdata/index.js new file mode 100644 index 0000000..1a4b462 --- /dev/null +++ b/utils/formdata/index.js @@ -0,0 +1,148 @@ +const mimeMap = require('./mimeMap.js') + +function FormData(){ + let fileManager = wx.getFileSystemManager(); + let data = {}; + let files = []; + + this.append = (name, value)=>{ + data[name] = value; + return true; + } + + this.appendFile = (name, path, fileName)=>{ + let buffer = fileManager.readFileSync(path); + if(Object.prototype.toString.call(buffer).indexOf("ArrayBuffer") < 0){ + return false; + } + + if(!fileName){ + fileName = getFileNameFromPath(path); + } + + files.push({ + name: name, + buffer: buffer, + fileName: fileName + }); + return true; + } + + this.getData = ()=>convert(data, files) +} + +function getFileNameFromPath(path){ + let idx=path.lastIndexOf("/"); + return path.substr(idx+1); +} + +function convert(data, files){ + let boundaryKey = 'wxmpFormBoundary' + randString(); // 数据分割符,一般是随机的字符串 + let boundary = '--' + boundaryKey; + let endBoundary = boundary + '--'; + + let postArray = []; + //拼接参数 + if(data && Object.prototype.toString.call(data) == "[object Object]"){ + for(let key in data){ + postArray = postArray.concat(formDataArray(boundary, key, data[key])); + } + } + //拼接文件 + if(files && Object.prototype.toString.call(files) == "[object Array]"){ + for(let i in files){ + let file = files[i]; + postArray = postArray.concat(formDataArray(boundary, file.name, file.buffer, file.fileName)); + } + } + //结尾 + let endBoundaryArray = []; + endBoundaryArray.push(...endBoundary.toUtf8Bytes()); + postArray = postArray.concat(endBoundaryArray); + return { + contentType: 'multipart/form-data; boundary=' + boundaryKey, + buffer: new Uint8Array(postArray).buffer + } +} + +function randString() { + var result = ''; + var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + for (var i = 17; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]; + return result; +} + +function formDataArray(boundary, name, value, fileName){ + let dataString = ''; + let isFile = !!fileName; + + dataString += boundary + '\r\n'; + dataString += 'Content-Disposition: form-data; name="' + name + '"'; + if (isFile){ + dataString += '; filename="' + fileName + '"' + '\r\n'; + dataString += 'Content-Type: ' + getFileMime(fileName) + '\r\n\r\n'; + } + else{ + dataString += '\r\n\r\n'; + dataString += value; + } + + var dataArray = []; + dataArray.push(...dataString.toUtf8Bytes()); + + if (isFile) { + let fileArray = new Uint8Array(value); + dataArray = dataArray.concat(Array.prototype.slice.call(fileArray)); + } + dataArray.push(..."\r".toUtf8Bytes()); + dataArray.push(..."\n".toUtf8Bytes()); + + return dataArray; +} + +function getFileMime(fileName){ + let idx = fileName.lastIndexOf("."); + let mime = mimeMap[fileName.substr(idx)]; + return mime?mime:"application/octet-stream" +} + +String.prototype.toUtf8Bytes = function(){ + var str = this; + var bytes = []; + for (var i = 0; i < str.length; i++) { + bytes.push(...str.utf8CodeAt(i)); + if (str.codePointAt(i) > 0xffff) { + i++; + } + } + return bytes; +} + +String.prototype.utf8CodeAt = function(i) { + var str = this; + var out = [], p = 0; + var c = str.charCodeAt(i); + if (c < 128) { + out[p++] = c; + } else if (c < 2048) { + out[p++] = (c >> 6) | 192; + out[p++] = (c & 63) | 128; + } else if ( + ((c & 0xFC00) == 0xD800) && (i + 1) < str.length && + ((str.charCodeAt(i + 1) & 0xFC00) == 0xDC00)) { + // Surrogate Pair + c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF); + out[p++] = (c >> 18) | 240; + out[p++] = ((c >> 12) & 63) | 128; + out[p++] = ((c >> 6) & 63) | 128; + out[p++] = (c & 63) | 128; + } else { + out[p++] = (c >> 12) | 224; + out[p++] = ((c >> 6) & 63) | 128; + out[p++] = (c & 63) | 128; + } + return out; +}; + + +module.exports = FormData; \ No newline at end of file diff --git a/utils/formdata/mimeMap.js b/utils/formdata/mimeMap.js new file mode 100644 index 0000000..57c55f1 --- /dev/null +++ b/utils/formdata/mimeMap.js @@ -0,0 +1,345 @@ +module.exports = { + "0.001": "application/x-001", + "0.323": "text/h323", + "0.907": "drawing/907", + ".acp": "audio/x-mei-aac", + ".aif": "audio/aiff", + ".aiff": "audio/aiff", + ".asa": "text/asa", + ".asp": "text/asp", + ".au": "audio/basic", + ".awf": "application/vnd.adobe.workflow", + ".bmp": "application/x-bmp", + ".c4t": "application/x-c4t", + ".cal": "application/x-cals", + ".cdf": "application/x-netcdf", + ".cel": "application/x-cel", + ".cg4": "application/x-g4", + ".cit": "application/x-cit", + ".cml": "text/xml", + ".cmx": "application/x-cmx", + ".crl": "application/pkix-crl", + ".csi": "application/x-csi", + ".cut": "application/x-cut", + ".dbm": "application/x-dbm", + ".dcd": "text/xml", + ".der": "application/x-x509-ca-cert", + ".dib": "application/x-dib", + ".doc": "application/msword", + ".drw": "application/x-drw", + ".dwf": "Model/vnd.dwf", + ".dwg": "application/x-dwg", + ".dxf": "application/x-dxf", + ".emf": "application/x-emf", + ".ent": "text/xml", + ".eps": "application/x-ps", + ".etd": "application/x-ebx", + ".fax": "image/fax", + ".fif": "application/fractals", + ".frm": "application/x-frm", + ".gbr": "application/x-gbr", + ".gif": "image/gif", + ".gp4": "application/x-gp4", + ".hmr": "application/x-hmr", + ".hpl": "application/x-hpl", + ".hrf": "application/x-hrf", + ".htc": "text/x-component", + ".html": "text/html", + ".htx": "text/html", + ".ico": "image/x-icon", + ".iff": "application/x-iff", + ".igs": "application/x-igs", + ".img": "application/x-img", + ".isp": "application/x-internet-signup", + ".java": "java/*", + ".jpe": "image/jpeg", + ".jpeg": "image/jpeg", + ".jpg": "application/x-jpg", + ".jsp": "text/html", + ".lar": "application/x-laplayer-reg", + ".lavs": "audio/x-liquid-secure", + ".lmsff": "audio/x-la-lms", + ".ltr": "application/x-ltr", + ".m2v": "video/x-mpeg", + ".m4e": "video/mpeg4", + ".man": "application/x-troff-man", + ".mdb": "application/msaccess", + ".mfp": "application/x-shockwave-flash", + ".mhtml": "message/rfc822", + ".mid": "audio/mid", + ".mil": "application/x-mil", + ".mnd": "audio/x-musicnet-download", + ".mocha": "application/x-javascript", + ".mp1": "audio/mp1", + ".mp2v": "video/mpeg", + ".mp4": "video/mpeg4", + ".mpd": "application/vnd.ms-project", + ".mpeg": "video/mpg", + ".mpga": "audio/rn-mpeg", + ".mps": "video/x-mpeg", + ".mpv": "video/mpg", + ".mpw": "application/vnd.ms-project", + ".mtx": "text/xml", + ".net": "image/pnetvue", + ".nws": "message/rfc822", + ".out": "application/x-out", + ".p12": "application/x-pkcs12", + ".p7c": "application/pkcs7-mime", + ".p7r": "application/x-pkcs7-certreqresp", + ".pc5": "application/x-pc5", + ".pcl": "application/x-pcl", + ".pdf": "application/pdf", + ".pdx": "application/vnd.adobe.pdx", + ".pgl": "application/x-pgl", + ".pko": "application/vnd.ms-pki.pko", + ".plg": "text/html", + ".plt": "application/x-plt", + ".png": "application/x-png", + ".ppa": "application/vnd.ms-powerpoint", + ".pps": "application/vnd.ms-powerpoint", + ".ppt": "application/x-ppt", + ".prf": "application/pics-rules", + ".prt": "application/x-prt", + ".ps": "application/postscript", + ".pwz": "application/vnd.ms-powerpoint", + ".ra": "audio/vnd.rn-realaudio", + ".ras": "application/x-ras", + ".rdf": "text/xml", + ".red": "application/x-red", + ".rjs": "application/vnd.rn-realsystem-rjs", + ".rlc": "application/x-rlc", + ".rm": "application/vnd.rn-realmedia", + ".rmi": "audio/mid", + ".rmm": "audio/x-pn-realaudio", + ".rms": "application/vnd.rn-realmedia-secure", + ".rmx": "application/vnd.rn-realsystem-rmx", + ".rp": "image/vnd.rn-realpix", + ".rsml": "application/vnd.rn-rsml", + ".rtf": "application/msword", + ".rv": "video/vnd.rn-realvideo", + ".sat": "application/x-sat", + ".sdw": "application/x-sdw", + ".slb": "application/x-slb", + ".slk": "drawing/x-slk", + ".smil": "application/smil", + ".snd": "audio/basic", + ".sor": "text/plain", + ".spl": "application/futuresplash", + ".ssm": "application/streamingmedia", + ".stl": "application/vnd.ms-pki.stl", + ".sty": "application/x-sty", + ".swf": "application/x-shockwave-flash", + ".tg4": "application/x-tg4", + ".tif": "image/tiff", + ".tiff": "image/tiff", + ".top": "drawing/x-top", + ".tsd": "text/xml", + ".uin": "application/x-icq", + ".vcf": "text/x-vcard", + ".vdx": "application/vnd.visio", + ".vpg": "application/x-vpeg005", + ".vsd": "application/x-vsd", + ".vst": "application/vnd.visio", + ".vsw": "application/vnd.visio", + ".vtx": "application/vnd.visio", + ".wav": "audio/wav", + ".wb1": "application/x-wb1", + ".wb3": "application/x-wb3", + ".wiz": "application/msword", + ".wk4": "application/x-wk4", + ".wks": "application/x-wks", + ".wma": "audio/x-ms-wma", + ".wmf": "application/x-wmf", + ".wmv": "video/x-ms-wmv", + ".wmz": "application/x-ms-wmz", + ".wpd": "application/x-wpd", + ".wpl": "application/vnd.ms-wpl", + ".wr1": "application/x-wr1", + ".wrk": "application/x-wrk", + ".ws2": "application/x-ws", + ".wsdl": "text/xml", + ".xdp": "application/vnd.adobe.xdp", + ".xfd": "application/vnd.adobe.xfd", + ".xhtml": "text/html", + ".xls": "application/x-xls", + ".xml": "text/xml", + ".xq": "text/xml", + ".xquery": "text/xml", + ".xsl": "text/xml", + ".xwd": "application/x-xwd", + ".sis": "application/vnd.symbian.install", + ".x_t": "application/x-x_t", + ".apk": "application/vnd.android.package-archive", + "0.301": "application/x-301", + "0.906": "application/x-906", + ".a11": "application/x-a11", + ".ai": "application/postscript", + ".aifc": "audio/aiff", + ".anv": "application/x-anv", + ".asf": "video/x-ms-asf", + ".asx": "video/x-ms-asf", + ".avi": "video/avi", + ".biz": "text/xml", + ".bot": "application/x-bot", + ".c90": "application/x-c90", + ".cat": "application/vnd.ms-pki.seccat", + ".cdr": "application/x-cdr", + ".cer": "application/x-x509-ca-cert", + ".cgm": "application/x-cgm", + ".class": "java/*", + ".cmp": "application/x-cmp", + ".cot": "application/x-cot", + ".crt": "application/x-x509-ca-cert", + ".css": "text/css", + ".dbf": "application/x-dbf", + ".dbx": "application/x-dbx", + ".dcx": "application/x-dcx", + ".dgn": "application/x-dgn", + ".dll": "application/x-msdownload", + ".dot": "application/msword", + ".dtd": "text/xml", + ".dwf": "application/x-dwf", + ".dxb": "application/x-dxb", + ".edn": "application/vnd.adobe.edn", + ".eml": "message/rfc822", + ".epi": "application/x-epi", + ".eps": "application/postscript", + ".exe": "application/x-msdownload", + ".fdf": "application/vnd.fdf", + ".fo": "text/xml", + ".g4": "application/x-g4", + ".tif": "image/tiff", + ".gl2": "application/x-gl2", + ".hgl": "application/x-hgl", + ".hpg": "application/x-hpgl", + ".hqx": "application/mac-binhex40", + ".hta": "application/hta", + ".htm": "text/html", + ".htt": "text/webviewhtml", + ".icb": "application/x-icb", + ".ico": "application/x-ico", + ".ig4": "application/x-g4", + ".iii": "application/x-iphone", + ".ins": "application/x-internet-signup", + ".IVF": "video/x-ivf", + ".jfif": "image/jpeg", + ".jpe": "application/x-jpe", + ".jpg": "image/jpeg", + ".js": "application/x-javascript", + ".la1": "audio/x-liquid-file", + ".latex": "application/x-latex", + ".lbm": "application/x-lbm", + ".ls": "application/x-javascript", + ".m1v": "video/x-mpeg", + ".m3u": "audio/mpegurl", + ".mac": "application/x-mac", + ".math": "text/xml", + ".mdb": "application/x-mdb", + ".mht": "message/rfc822", + ".mi": "application/x-mi", + ".midi": "audio/mid", + ".mml": "text/xml", + ".mns": "audio/x-musicnet-stream", + ".movie": "video/x-sgi-movie", + ".mp2": "audio/mp2", + ".mp3": "audio/mp3", + ".mpa": "video/x-mpg", + ".mpe": "video/x-mpeg", + ".mpg": "video/mpg", + ".mpp": "application/vnd.ms-project", + ".mpt": "application/vnd.ms-project", + ".mpv2": "video/mpeg", + ".mpx": "application/vnd.ms-project", + ".mxp": "application/x-mmxp", + ".nrf": "application/x-nrf", + ".odc": "text/x-ms-odc", + ".p10": "application/pkcs10", + ".p7b": "application/x-pkcs7-certificates", + ".p7m": "application/pkcs7-mime", + ".p7s": "application/pkcs7-signature", + ".pci": "application/x-pci", + ".pcx": "application/x-pcx", + ".pdf": "application/pdf", + ".pfx": "application/x-pkcs12", + ".pic": "application/x-pic", + ".pl": "application/x-perl", + ".pls": "audio/scpls", + ".png": "image/png", + ".pot": "application/vnd.ms-powerpoint", + ".ppm": "application/x-ppm", + ".ppt": "application/vnd.ms-powerpoint", + ".pr": "application/x-pr", + ".prn": "application/x-prn", + ".ps": "application/x-ps", + ".ptn": "application/x-ptn", + ".r3t": "text/vnd.rn-realtext3d", + ".ram": "audio/x-pn-realaudio", + ".rat": "application/rat-file", + ".rec": "application/vnd.rn-recording", + ".rgb": "application/x-rgb", + ".rjt": "application/vnd.rn-realsystem-rjt", + ".rle": "application/x-rle", + ".rmf": "application/vnd.adobe.rmf", + ".rmj": "application/vnd.rn-realsystem-rmj", + ".rmp": "application/vnd.rn-rn_music_package", + ".rmvb": "application/vnd.rn-realmedia-vbr", + ".rnx": "application/vnd.rn-realplayer", + ".rpm": "audio/x-pn-realaudio-plugin", + ".rt": "text/vnd.rn-realtext", + ".rtf": "application/x-rtf", + ".sam": "application/x-sam", + ".sdp": "application/sdp", + ".sit": "application/x-stuffit", + ".sld": "application/x-sld", + ".smi": "application/smil", + ".smk": "application/x-smk", + ".sol": "text/plain", + ".spc": "application/x-pkcs7-certificates", + ".spp": "text/xml", + ".sst": "application/vnd.ms-pki.certstore", + ".stm": "text/html", + ".svg": "text/xml", + ".tdf": "application/x-tdf", + ".tga": "application/x-tga", + ".tif": "application/x-tif", + ".tld": "text/xml", + ".torrent": "application/x-bittorrent", + ".txt": "text/plain", + ".uls": "text/iuls", + ".vda": "application/x-vda", + ".vml": "text/xml", + ".vsd": "application/vnd.visio", + ".vss": "application/vnd.visio", + ".vst": "application/x-vst", + ".vsx": "application/vnd.visio", + ".vxml": "text/xml", + ".wax": "audio/x-ms-wax", + ".wb2": "application/x-wb2", + ".wbmp": "image/vnd.wap.wbmp", + ".wk3": "application/x-wk3", + ".wkq": "application/x-wkq", + ".wm": "video/x-ms-wm", + ".wmd": "application/x-ms-wmd", + ".wml": "text/vnd.wap.wml", + ".wmx": "video/x-ms-wmx", + ".wp6": "application/x-wp6", + ".wpg": "application/x-wpg", + ".wq1": "application/x-wq1", + ".wri": "application/x-wri", + ".ws": "application/x-ws", + ".wsc": "text/scriptlet", + ".wvx": "video/x-ms-wvx", + ".xdr": "text/xml", + ".xfdf": "application/vnd.adobe.xfdf", + ".xls": "application/vnd.ms-excel", + ".xlw": "application/x-xlw", + ".xpl": "audio/scpls", + ".xql": "text/xml", + ".xsd": "text/xml", + ".xslt": "text/xml", + ".x_b": "application/x-x_b", + ".sisx": "application/vnd.symbian.install", + ".ipa": "application/vnd.iphone", + ".xap": "application/x-silverlight-app", + ".zip": "application/x-zip-compressed", + } \ No newline at end of file diff --git a/utils/request.js b/utils/request.js index 06535fb..91e981e 100644 --- a/utils/request.js +++ b/utils/request.js @@ -4,6 +4,13 @@ class request { this._token = wx.getStorageSync('token'); this._header = {'Authorization': this._token} } + + /** + * 文件上传封装请求 + */ + uploadRequest(url, data, header = this._header) { + return this.uploadAll(url, data, header) + } /** * GET类型的网络请求 @@ -31,6 +38,76 @@ class request { */ postRequest(url, data, header = this._header) { return this.requestAll(url, data, header, 'POST') + } + + /** + * POST类型的网络请求 + */ + patchRequest(url, data, header = this._header) { + return this.requestAll(url, data, header, 'PATCH') + } + + + uploadAll(url, data, header){ + console.log('到这个位置了。。。。。') + console.log(data) + return new Promise((resolve, reject) => { + console.log('输出以下。。。。。') + console.log(data.file) + wx.uploadFile({ + method:'POST', + url: this._baseUrl + url, + name:'', + filePath:'', + header: {'Authorization': wx.getStorageSync('token')}, + formData: { + type:data.type, + file:data.file + }, + success: (res => { + if(res.data.code==401){ + wx.setStorageSync('token', null) + wx.showToast({ + title:'Token无效或过期,请重新登录!', + icon: 'none', + duration: 1000 + }) + wx.navigateTo({ + url: '/pages/index/index' + }) + resolve(res) + + } + + if (res.statusCode === 200) { + //200: 服务端业务处理正常结束 + if(res.data.code==500){ + wx.showToast({ + title:'Token无效或过期,请重新登录!', + icon: 'none', + duration: 1000 + }) + wx.navigateTo({ + url: '/pages/index/index' + }) + + } + resolve(res) + } else { + //其它错误,提示用户错误信息 + reject(res) + } + }), + fail: (res => { + reject(res) + }) + }) + }) + + + + + } /** @@ -44,8 +121,33 @@ class request { header: {'Authorization': wx.getStorageSync('token')}, method: method, success: (res => { + if(res.data.code==401){ + wx.setStorageSync('token', null) + wx.showToast({ + title:'Token无效或过期,请重新登录!', + icon: 'none', + duration: 1000 + }) + wx.navigateTo({ + url: '/pages/index/index' + }) + resolve(res) + + } + if (res.statusCode === 200) { //200: 服务端业务处理正常结束 + if(res.data.code==500){ + wx.showToast({ + title:'Token无效或过期,请重新登录!', + icon: 'none', + duration: 1000 + }) + wx.navigateTo({ + url: '/pages/index/index' + }) + + } resolve(res) } else { //其它错误,提示用户错误信息