Compare commits

..

No commits in common. 'main' and 'zw-test' have entirely different histories.

BIN
.DS_Store vendored

Binary file not shown.

@ -1,8 +1,4 @@
# xzjl-ui 星座精灵小程序仓库
代码开发规范
1.用户在首页(pages/index/index)通过识别NfC或者扫码进入小程序页面成功后进入星运页面(pages/home/xy/index)
# xzjl-ui
星座精灵小程序仓库

@ -1,6 +1,4 @@
// app.js
import request from './utils/request.js'
import simpleReq from './utils/login.js'
App({
onLaunch() {
// 展示本地存储能力
@ -16,16 +14,6 @@ App({
})
},
globalData: {
BASE_URL:"https://api.wish.ydxxkj.top/api",
userInfo: {
xyNfc:false
},
xx:"1sd撒啊娃娃"
},
xzjlReq(){
return new request()
}
,simpleReq(){
return new simpleReq()
userInfo: null
}
})

@ -9,32 +9,8 @@
"pages/home/jl/index",
"pages/index/index",
"pages/index/out/out",
"pages/xz/index",
"pages/home/xx/xz/xz",
"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/me/jcjb/jcjb",
"pages/home/xyc/wdyw/wdyw",
"pages/home/xyc/tdyw/tdyw",
"pages/home/me/grzl/grzl",
"pages/home/jl/jlai",
"pages/home/jl/jlai/jlai",
"pages/home/xx/hy/index",
"pages/home/xx/hy/hx/hx",
"pages/home/xx/hy/yx/yx",
"pages/home/xx/hy/zt/zt",
"pages/home/xx/lindex/lindex",
"pages/home/xx/lindex/xz/xz",
"pages/home/xx/lindex/lxz/lxz"
"pages/home/xx/xz/index"
],
"window": {
"backgroundTextStyle": "light",

@ -1,3 +1,6 @@
/**app.wxss**/
@import 'styles/icons/iconfont.wxss';
.container {
height: 100%;
display: flex;
@ -7,15 +10,3 @@
padding: 200rpx 0;
box-sizing: border-box;
}
::-webkit-scrollbar {
display: none;
width: 0;
height: 0;
color: transparent;
}
page {
width: 100%;
height: 100%;
}

@ -1,40 +0,0 @@
Component({
relations: {
'./popover': {
type: 'parent'
}
},
/**
* 组件的属性列表
*/
properties: {
// 是否有底线
hasline: {
type: Boolean,
value: false
}
},
/**
* 组件的初始数据
*/
data: {
// 每项的高度
height: 40
},
/**
* 组件的方法列表
*/
methods: {
onClick: function() {
let { index } = this.properties;
let eventDetail = {
index: index
};
let eventOption = {};
this.triggerEvent('tap', eventDetail, eventOption);
}
}
})

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

@ -1,3 +0,0 @@
<view class='popover-item {{hasline ? "underline" : ""}}' hover-class='popover-item-hover' catchtap='onClick' style='height:{{height}}px;line-height:{{height}}px;'>
<slot/>
</view>

@ -1,14 +0,0 @@
.popover-item {
width: 100%;
font-size: 14px;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.popover-item-hover {
background-color: #EEE;
}
.underline{
border-bottom:1px #EEE solid;
}

@ -1,99 +0,0 @@
const { windowWidth, windowHeight } = wx.getSystemInfoSync();
// 三角形箭头的高度
const trangleHeight = 12;
Component({
relations: {
'./popover-item': {
type: 'child'
}
},
data: {
// 当前显隐状态
visible: false,
// popover 宽
pw: 100,
// popover 高
ph: 120,
// popover 距左距离
px: 0,
// popover 距上距离
py: 0,
// 垂直方向 top/bottom
vertical: '',
// 水平方向 left/center/right
align: ''
},
methods: {
onDisplay: function(e) {
let self = this;
if (self.last && self.last === e.id) {
self.setData({
visible: !self.data.visible
});
} else {
wx.createSelectorQuery().selectViewport().scrollOffset(view => {
let { pw, ph, px, py, vertical, align } = self.data;
let pOverW = (pw - e.width) / 2;
let offsetL = e.left,
offsetR = windowWidth - e.right,
offsetB = windowHeight - e.bottom;
if (offsetL >= pOverW && offsetR >= pOverW) {
align = 'center';
px = e.left - pOverW;
} else if (offsetL > pOverW && offsetR < pOverW) {
align = 'left';
px = windowWidth - (offsetR + pw);
// 如果向右贴边了,设置一点距离
if ((windowWidth - pw) == px) px -= 5;
} else if (offsetL < pOverW && offsetR > pOverW) {
align = 'right';
px = e.left;
// 如果向左贴边了,设置一点距离
if (px == 0) px += 5;
}
if (offsetB >= (ph + trangleHeight)) {
vertical = 'bottom';
py = view.scrollTop + e.bottom + trangleHeight;
} else {
vertical = 'top';
py = view.scrollTop + e.top - ph - trangleHeight;
}
self.setData({
visible: true,
px: px,
py: py,
ph: self.getItemsHeight(),
vertical: vertical,
align: align
});
}).exec();
}
// 记录上一次点击的元素
self.last = e.id;
},
onHide: function() {
this.setData({
visible: false
});
},
// 获取所有子元素
getItems: function() {
return this.getRelationNodes('./popover-item');
},
// 获取所有子元素的总高度
getItemsHeight() {
return this.getItems().map(item => item.data.height).reduce((a, b) => a + b, 0);
}
}
})

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

@ -1,6 +0,0 @@
<view
wx:if='{{visible}}'
class='popover-view {{vertical}} {{align}}'
style='width:{{pw}}px;height:{{ph}}px;left:{{px}}px;top:{{py}}px;'>
<slot />
</view>

@ -1,40 +0,0 @@
.popover-view {
position: absolute;
background-color: white;
box-shadow: 0 0 2px 2px #ddd;
border-radius: 6rpx;
}
/* 实现三角形 */
.popover-view::before {
position: absolute;
display: inline-block;
width: 0;
height: 0px;
content: '';
border-style: solid;
border-width: 6px;
border-color: #fff #fff transparent transparent;
box-shadow: 2px -2px 2px #ddd;
}
/* 上 */
.popover-view.top::before {
bottom: -6px;
transform: rotate(135deg);
}
/* 下 */
.popover-view.bottom::before {
top: -6px;
transform: rotate(-45deg);
}
/* 左 */
.popover-view.left::before {
right: 20px;
}
/* 中 */
.popover-view.center::before {
left: 47px;
}
/* 右 */
.popover-view.right::before {
left: 20px;
}

BIN
icons/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

15
node_modules/.package-lock.json generated vendored

@ -16,21 +16,6 @@
"dependencies": {
"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/wxml2canvas": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/wxml2canvas/-/wxml2canvas-1.0.1.tgz",
"integrity": "sha512-AdWvxgTjJtW/m6Cki1cwGO0HOERKU8O9V3RcCz8UyqJbrPF7e8Nv27/epYiIs64HlbPTKWTLl7ECjQi6UVducA=="
},
"node_modules/wxmp-rsa": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/wxmp-rsa/-/wxmp-rsa-2.1.0.tgz",
"integrity": "sha512-VbWMJ+vf8t7G93sjkqjCn5yGy/Si3M8uD6OFebqjJWJ1R0WCyle7X6SNia7WWG6Qe1F2/OWxhbcSGA6ebUBwIA=="
}
}
}

@ -1,9 +0,0 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

@ -1,3 +0,0 @@
build/*.js
src/qrcode.js
src/index.js

@ -1,26 +0,0 @@
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
}
}

@ -1,23 +0,0 @@
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

@ -1,21 +0,0 @@
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.

@ -1,171 +0,0 @@
# 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)
<!-- ![weapp-qrcode-canvas-2d](https://wx4.sinaimg.cn/mw690/77d4598fly1gn4nqmgayzj205k05kgli.jpg) -->
# 测试环境
- 微信小程序基础库版本2.10.4
- 开发者工具版本Stable 1.03.2101150
# Usage
先在 wxml 文件中,创建绘制的 `canvas`,并定义好 `width`, `height`, `id` , `type` 其中type的值必须为`2d`
```html
<canvas type="2d" style="width: 260px; height: 260px;" id="myQrcode"></canvas>
```
## 安装方法1直接引入 js 文件
直接引入 js 文件,使用 `drawQrcode()` 绘制二维码
```js
// 将 dist 目录下weapp.qrcode.esm.js 复制到项目中。路径根据实际引用的页面路径自行改变
import drawQrcode from '../../utils/weapp.qrcode.esm.js'
```
## 安装方法2npm安装
```
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)

@ -1,39 +0,0 @@
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 + ')'
})
]
}

@ -1,49 +0,0 @@
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 + ')'
})
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -1,42 +0,0 @@
{
"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"
}
}

@ -1,141 +0,0 @@
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

File diff suppressed because it is too large Load Diff

330
node_modules/wxml2canvas/README.md generated vendored

@ -1,330 +0,0 @@
## v1.3.0
优化图片清晰度控制。
`new Wxml2Canvas`时增加`destZoom`属性默认3(建议取值范围2-5),取消`destWidth``destHeight`属性的作用。destZoom值越大图片越大建议不传使用小程序默认值。
## v1.2.0
支持base64图片的转换和绘制基于sdk1.9.9+,将图片存储到本地再绘制。
使用时src或background-image传入base64编码的值然后声明`data-base64="1"`。下图绿框部分为base64图片
![base64图片](https://mmocgame.qpic.cn/wechatgame/duc2TvpEgSSC0vZndxlmTVUYjVzXDV2G25rkpWlH63BOWc5iaUHI39GBcsd4pjjiaJ/0)
## v1.1.0
支持图片的缩放和裁剪,使用时声明如:`data-mode="aspectFill"`mode的13种模式完全支持。效果如下
![图片裁剪和缩放](https://mmocgame.qpic.cn/wechatgame/duc2TvpEgSQCtBianicxcWObMNDWVImPRKIAHSGu9TwQkCslPUZXMmyuwibdzcKtsUl/0)
注意目前开发者工具图片裁剪显示有bug以真机效果为准。
# Wml2Canvas 介绍
## 特性
> * 配置数据绘制基础图形、文字
> * wxml元素转换成canvas元素
## 示例
直接在小程序开发工具里运行项目可看到两种使用方式。真机预览时建议填入有权限的appid然后打开调试否则无法看到网络图片。
## 使用方式
安装:
```
npm install wxml2canvas
```
wxml:
```html
<view class="share__canvas share__canvas1">
<view class="share__canvas1-text draw_canvas"
data-type="text" data-text="这是一段无边距文字">
这是一段无边距文字
</view>
</view>
<canvas canvas-id="canvas1" class="share__canvas"></canvas>
```
js:
```javascript
import Wxml2Canvas from 'wxml2canvas'; // 根据具体路径修改node_modules会被忽略
Page({
drawImage1 () {
let self = this;
this.drawImage1 = new Wxml2Canvas({
width: 340, // 宽, 以iphone6为基准传具体数值其他机型自动适配
height: 210, // 高
element: 'canvas1',
background: '#f0f0f0',
progress (percent) {
},
finish(url) {
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas1 .draw_canvas', // draw_canvas指定待绘制的元素
limit: '.share__canvas1', // 限定绘制元素的范围,取指定元素与它的相对位置
x: 0,
y: 0
}]
}
this.drawImage1.draw(data);
},
})
```
## 属性
### 初始化属性
`new Wxml2Canvas(options)` 时传入的`options`属性如下:
| 属性名 | 类型 | 默认值 | 是否必填 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| element | String | '' | 是 | 画布的id |
| width | Number | 0 | 是 | 画布的宽以iphone6的375为基准其他机型按比例自动设置实际宽度 |
| height | Number | 0 | 是 | 画布的高,同上 |
| destZoom | Number | 3 | 否 | 输出的图片的像素密度,不建议传值,如果需要控制图片大小,可以适当减小 |
| zoom | Number | 1 | 否 | 画布整体缩放比例,不建议传值,会覆盖各种机型的适配 |
| translateX | Number | 0 | 否 | 画布整体横向位移 |
| translateY | Number | 0 | 否 | 画布整体纵向位移 |
| height | Number | height * 2 | 否 | 输出的图片的高度 |
| background | String | #ffffff | 否 | 画布的整体背景色 |
| gradientBackground | Object | null | 否 | 画布整体的渐变背景色 |
| finish | Function | null | 否 | 绘制成功后回调函数, 返回值url绘制图片的本地路径 |
| progress | Function | null | 否 | 绘制进度返回值percent0-100 |
| error | Function | null | 否 | 绘制失败后回调函数返回值object包含具体原因 |
绘制失败的原因如下:
| 错误码 | 原因 | 说明 |
| -------- | ----- | ---- |
| errcode | errmsg | e |
| 1000 | save canvas error | 保存图片失败 |
| 1001 | download pic error | 预下载图片失败 |
| 1002 | drawRect error | 绘制矩形失败 |
| 1003 | drawImage error | 绘制图片失败 |
| 1004 | drawText error | 绘制文本失败 |
| 1005 | drawCircle error | 绘制圆形图片失败 |
| 1006 | drawCircleImage error | 绘制圆形失败 |
| 1007 | drawLine error | 绘制线条失败 |
| 1008 | drawWxml error | 绘制Wxml失败 |
| 1009 | drawWxml preLoadImage error | 预下载Wxml图片失败 |
## 数据配置方式支持的格式
代码示例:
```javascript
let data = {
list: [{
type: 'rect',
x: 10,
y: 10,
style: {
width: 150,
height: 80,
fill: '#3762ab',
border: '10px solid #aaaaaa',
}
}
}
```
上述是一个矩形的创建方式,可看代码里的示例。下面是支持的属性:
### 矩形
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'rect',声明为绘制矩形 |
| x | Number | 是 | 坐标x |
| y | Number | 是 | 坐标y |
| style |
| width | Number | 是 | 宽 |
| height | Number | 是 | 高 |
| fill | String 或 Object | 否 | 填充颜色,支持渐变色 |
| border | String | 否 | 边框,需要严格遵循 __'10px dashed #540821'__ 格式 |
| boxShadow | String | 否 | 阴影,需要严格遵循 __'10 20 20 rgba(0, 0, 0, 0.4)'__ 格式 |
| dash | Array | 否 | 虚线边框的间距和偏移 |
### 圆形
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'circle',声明为绘制圆形 |
| x | Number | 是 | 坐标x |
| y | Number | 是 | 坐标y |
| style |
| r | Number | 是 | 半径 |
| fill | String 或 Object | 否 | 填充颜色,支持渐变色 |
| border | String | 否 | 边框,需要严格遵循 __'10px dashed #540821'__ 格式 |
| boxShadow | String | 否 | 阴影,需要严格遵循 __'10 20 20 rgba(0, 0, 0, 0.4)'__ 格式 |
| dash | Array | 否 | 虚线边框的间距和偏移 |
### 线条
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'line',声明为绘制线条 |
| x | Number | 是 | 起始坐标x |
| y | Number | 是 | 起始坐标y |
| x2 | Number | 是 | 终止坐标x |
| y2 | Number | 是 | 终止坐标y |
| style |
| width | Number | 是 | 线条宽度 |
| stroke | String 或 Object | 否 | 填充颜色,支持渐变色 |
| boxShadow | String | 否 | 阴影,需要严格遵循 __'10 20 20 rgba(0, 0, 0, 0.4)'__ 格式 |
| dash | Array | 否 | 有此属性则绘制虚线,传入值为虚线边框的间距和偏移 |
### 图片
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'image',声明为绘制图片 |
| x | Number | 是 | 坐标x |
| y | Number | 是 | 坐标y |
| url | String | 是 | 图片链接,支持 http/https 及本地图片域名需要在mp平台加入白名单 |
| style |
| width | Number | 是 | 宽 |
| height | Number | 是 | 高 |
| border | String | 否 | 边框,需要严格遵循 __'10px dashed #540821'__ 格式 |
| boxShadow | String | 否 | 阴影,需要严格遵循 __'10 20 20 rgba(0, 0, 0, 0.4)'__ 格式 |
| dash | Array | 否 | 虚线边框的间距和偏移 |
### 圆形图片
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'radius-image',声明为绘制圆形图片 |
| x | Number | 是 | 坐标x |
| y | Number | 是 | 坐标y |
| url | String | 是 | 图片链接,支持 http/https 及本地图片域名需要在mp平台加入白名单 |
| style |
| r | Number | 是 | 半径 |
| border | String | 否 | 边框,需要严格遵循 __'10px dashed #540821'__ 格式 |
| boxShadow | String | 否 | 阴影,需要严格遵循 __'10 20 20 rgba(0, 0, 0, 0.4)'__ 格式 |
| dash | Array | 否 | 虚线边框的间距和偏移 |
### 文本
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'text',声明为绘制文本 |
| x | Number | 是 | 坐标x |
| y | Number | 是 | 坐标y |
| text | String | 否 | 文本内容 |
| style |
| width | Number | 否 | 文本最大宽,超过则换行 |
| height | Number | 否 | 文本高度 |
| color | String | 否 | 字体颜色 |
| fontSize | Number | 否 | 字体大小默认14 |
| fontFamily | String | 否 | 字体样式 |
| lineHeight | Number | 否 | 字体行高默认14 * 1.2 |
| fontWeight | String | 否 | 字体粗细默认normal |
| lineClamp | Number | 否 | 文字的最大行数,超出则用 ... 截取 |
| whiteSpace | String | 否 | 是否换行默认wrap如果传入nowrap则不换行 |
| textAlign | String | 否 | 文本的水平对齐方式默认left |
| border | String | 否 | 边框,需要严格遵循 __'10px dashed #540821'__ 格式 |
| background | String | 否 | 字体背景色 |
| boxShadow | String | 否 | 阴影,需要严格遵循 __'10 20 20 rgba(0, 0, 0, 0.4)'__ 格式 |
| dash | Array | 否 | 虚线边框的间距和偏移 |
| padding | String | 否 | 内边距,'10 10 10 10', 与css有区别依次为左、上、右、下可以不带单位 |
此外,上述所有的元素都可以增加 __delay:true__ 属性,来实现延迟绘制。
## wxml转换的方式
如上面的使用示例声明type为wxml时会查询绘制元素节点的样式并绘制。下表是对应属性
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| type | String | 是 | 'wxml'声明转换wxml |
| x | Number | 是 | 坐标x用于修正位置 |
| y | Number | 是 | 坐标y用于修正位置 |
| class | String | 是 | 待查询绘制的节点类名,会查询所有相同的类名 |
| limit | String | 是 | 限定节点的外围容器,在取坐标时,取与它的相对位置 |
目前支持的wxml类型如下需要声明在节点上
### 图片
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| data-type | String | 是 | 'image',矩形图片 |
| data-url | String | 是 | 图片链接 |
| data-left | Number | 否 | 修正横坐标位置 |
| data-top | Number | 否 | 修正纵坐标位置 |
### 圆形图片
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| data-type | String | 是 | 'radius-image',圆形图片 |
| data-url | String | 是 | 图片链接 |
| data-left | Number | 否 | 修正横坐标位置 |
| data-top | Number | 否 | 修正纵坐标位置 |
### 背景图片
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| data-type | String | 是 | 'background-image',背景图片 |
| data-left | Number | 否 | 修正横坐标位置 |
| data-top | Number | 否 | 修正纵坐标位置 |
### 文本
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| data-type | String | 是 | 'text',文本 |
| data-text | String | 是 | 文本内容 |
| data-left | Number | 否 | 修正横坐标位置 |
| data-top | Number | 否 | 修正纵坐标位置 |
| data-padding | String | 否 | 内边距与style叠加 |
| data-background | String | 否 | 背景色 |
### 行内文本
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| data-type | String | 是 | 'inline-text',行内文本 |
| data-text | String | 是 | 文本内容 |
| data-left | Number | 否 | 修正横坐标位置 |
| data-top | Number | 否 | 修正纵坐标位置 |
| data-padding | String | 否 | 内边距与style叠加 |
| data-background | String | 否 | 背景色 |
### 行内图片
| 属性 | 类型 | 是否必填 | 说明 |
| -------- | ----- | ---- | --- |
| data-type | String | 是 | 'inline-image',矩形图片 |
| data-url | String | 是 | 图片链接 |
| data-left | Number | 否 | 修正横坐标位置 |
| data-top | Number | 否 | 修正纵坐标位置 |
行内文本与图片有特殊处理逻辑当top值相同时按照从左到右顺序排列可能会与展现有差异。
此外,上述所有的元素都可以增加 __delay:Number__ 属性,来实现延迟绘制, number范围1-100间接实现层级控制。
## Todo
> * 支持更多文本样式
> * 支持任意角度圆角

5
node_modules/wxml2canvas/app.js generated vendored

@ -1,5 +0,0 @@
App({
onLaunch () {
}
})

27
node_modules/wxml2canvas/app.json generated vendored

@ -1,27 +0,0 @@
{
"pages":[
"pages/wxml/index",
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Wxml2Canvas",
"navigationBarTextStyle":"black"
},
"tabBar": {
"color": "#444444",
"selectedColor": "#000000",
"backgroundColor": "#ffffff",
"borderStyle": "black",
"position": "top",
"list": [{
"text": "wxml转canvas",
"pagePath": "pages/wxml/index"
}, {
"text": "配置生成",
"pagePath": "pages/index/index"
}]
}
}

@ -1,3 +0,0 @@
import Wxml2Canvas from './src/index';
export default Wxml2Canvas;

@ -1,16 +0,0 @@
{
"name": "wxml2canvas",
"version": "1.0.1",
"description": "将wxml指定节点转换成canvas元素",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"wxml2canvas",
"wxml",
"canvas"
],
"author": "wg",
"license": "ISC"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

@ -1,411 +0,0 @@
import Wxml2Canvas from '../../src/index';
Page({
data: {
},
onLoad (res) {
this.drawImage1();
this.drawImage2();
this.drawImage3();
this.drawImage4();
this.drawImage5();
this.drawImage6();
this.drawImage7();
this.drawImage8();
},
drawImage1 () {
this.drawImage1 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas1',
gradientBackground: {
color: ['#27326b', '#540821'],
line: [0, 0, 0, 210]
},
finish(url) {
},
error (res) {
}
});
},
drawImage2 () {
this.drawImage2 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas2',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let data2 = {
list: [{
type: 'rect',
x: 10,
y: 10,
style: {
width: 150,
height: 80,
fill: {
color: ['#27326b', '#540821'],
line: [0, 0, 0, 110]
},
border: '10px solid #aaaaaa',
}
},{
type: 'rect',
x: 170,
y: 100,
style: {
width: 150,
height: 80,
fill: '#3762ab',
border: '10px dashed #540821',
boxShadow: '10 20 20 rgba(0, 0, 0, 0.4)',
// dash: [10, 20, 10]
}
}]
}
this.drawImage2.draw(data2);
},
drawImage3 () {
this.drawImage3 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas3',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let text = '一行很长很长很长很长很长很长很长很长很长很长的文字';
let data3 = {
list: [{
type: 'text',
text,
x: 0,
y: 0,
style: {
textAlign: 'left',
width: 130,
height: 80,
fontSize: 14,
lineHeight: 16,
fontWeight: 'bold',
boxShadow: '5 5 20 rgba(255, 0, 0, 0.5)',
}
}, {
type: 'text',
text,
x: 170,
y: 0,
style: {
textAlign: 'center',
width: 130,
fontSize: 14,
lineHeight: 16,
color: '#888888',
}
}, {
type: 'text',
text,
x: 0,
y: 70,
style: {
textAlign: 'right',
width: 130,
fontSize: 14,
lineHeight: 16,
fontFamily: 'Serif'
}
}, {
type: 'text',
text,
x: 170,
y: 70,
style: {
textAlign: 'center',
width: 130,
lineClamp: 2,
fontSize: 14,
lineHeight: 16,
}
}, {
type: 'text',
text,
x: 0,
y: 140,
style: {
textAlign: 'left',
width: 130,
fontSize: 14,
lineHeight: 16,
height: 60,
background: 'rgba(0, 111, 255, 0.5)',
color: '#ffffff'
}
}, {
type: 'text',
text,
x: 170,
y: 140,
style: {
textAlign: 'left',
width: 130,
background: 'rgba(255, 0, 0, 0.3)',
fontSize: 14,
lineHeight: 16,
height: 60,
border: '2px solid #000000',
padding: '5 10 0 10'
}
}]
}
this.drawImage3.draw(data3);
},
drawImage4 () {
this.drawImage4 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas4',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let data4 = {
list: [{
type: 'circle',
x: 30,
y: 30,
style: {
r: 40,
fill: {
color: ['#27326b', '#540821'],
line: [0, 0, 0, 110]
},
border: '10px solid #aaaaaa',
boxShadow: '10 10 20 rgba(0, 0, 0, 0.6)',
}
},{
type: 'circle',
x: 200,
y: 100,
style: {
r: 40,
fill: '#3762ab',
border: '10px dashed #540821',
// dash: [10, 20, 10]
}
}]
}
this.drawImage4.draw(data4);
},
drawImage5 () {
this.drawImage5 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas5',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let data5 = {
list: [{
type: 'line',
x: 30,
y: 30,
x2: 200,
y2: 30,
style: {
width: 10,
// stroke: '#3762ab',
stroke: {
color: ['#27326b', '#540821'],
line: [0, 0, 200, 10]
},
}
},{
type: 'line',
x: 30,
y: 100,
x2: 200,
y2: 100,
style: {
r: 40,
width: 10,
stroke: '#3762ab',
dash: [10, 10, 0],
boxShadow: '20 20 20 rgba(0, 0, 0, 0.3)',
}
}]
}
this.drawImage5.draw(data5);
},
drawImage6 () {
this.drawImage6 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas6',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let data6 = {
list: [{
type: 'image',
x: 10,
y: 10,
url: 'https://mmocgame.qpic.cn/wechatgame/duc2TvpEgSQCEa0WicosqlEgJiacYLaTLEDFB8Kq9Hr7LjAVhM8wu8TT77KqNezQnH/0',
style: {
width: 150,
height: 80,
border: '10px solid #aaaaaa',
boxShadow: '10 20 20 rgba(0, 0, 0, 0.4)',
}
},{
type: 'image',
x: 170,
y: 100,
url: './img/demo.png',
style: {
width: 150,
height: 80,
border: '10px dashed #540821',
// dash: [10, 20, 10]
}
}]
}
this.drawImage6.draw(data6);
},
drawImage7 () {
this.drawImage7 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas7',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let data7 = {
list: [{
type: 'radius-image',
x: 10,
y: 10,
url: './img/demo.png',
style: {
r: 40,
border: '10px solid #aaaaaa',
boxShadow: '10 10 20 rgba(0, 0, 0, 0.6)',
}
},{
type: 'radius-image',
x: 170,
y: 100,
url: './img/demo.png',
style: {
r: 40,
border: '10px dashed #540821',
// dash: [10, 20, 10]
}
}]
}
this.drawImage7.draw(data7);
},
drawImage8 () {
this.drawImage8 = new Wxml2Canvas({
width: 340,
height: 400,
element: 'canvas8',
background: '#f0f0f0',
finish(url) {
},
error (res) {
}
});
let style = {
text: {
textAlign: 'left',
width: 320,
fontSize: 16,
lineHeight: 25,
}
}
let text = [
'Wxml2Cavnas库是一个生成小程序分享图的通用方案提供了两种绘制方式',
'封装基础图形的绘制接口包括矩形、圆形、线条、图片、圆角图片、纯文本等使用时只需要声明元素类型并提供关键数据即可不需要再关注canvas的具体绘制过程',
'wxml直接转换成canvas元素使用时传入待绘制的wxml节点的class类名并且声明绘制此节点的类型图片、文字等会自动读取此节点的computedStyle利用这些数据完成元素的绘制。',
]
let height1 = 20 + Math.ceil(this.drawImage8.measureWidth(text[0], '16px pingfang') / style.text.width) * style.text.lineHeight;
let height2 = height1 + 10 + Math.ceil(this.drawImage8.measureWidth(text[1], '16px pingfang') / style.text.width) * style.text.lineHeight;
let data8 = {
list: [
{
type: 'text',
text: text[0],
x: 10,
y: 10,
style: style.text
}, {
type: 'text',
text: text[1],
x: 10,
y: height1,
style: style.text
}, {
type: 'image',
x: 10,
y: height2,
url: './img/demo.png',
style: {
width: 100,
height: 60,
}
}, {
type: 'text',
text: text[2],
x: 15,
y: height2 + 80,
style: style.text
}
]
}
this.drawImage8.draw(data8);
}
});

@ -1,10 +0,0 @@
<view class="share">
<canvas canvas-id="canvas1" class="share__canvas"></canvas>
<canvas canvas-id="canvas2" class="share__canvas"></canvas>
<canvas canvas-id="canvas4" class="share__canvas"></canvas>
<canvas canvas-id="canvas3" class="share__canvas"></canvas>
<canvas canvas-id="canvas5" class="share__canvas"></canvas>
<canvas canvas-id="canvas6" class="share__canvas"></canvas>
<canvas canvas-id="canvas7" class="share__canvas"></canvas>
<canvas canvas-id="canvas8" class="share__canvas share__canvas-long"></canvas>
</view>

@ -1,18 +0,0 @@
.share{
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
}
.share__canvas {
width: 680rpx;
height: 420rpx;
background: #f0f0f0;
margin-bottom: 60rpx;
}
.share__canvas-long {
height: 800rpx;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

@ -1,260 +0,0 @@
import Wxml2Canvas from '../../src/index';
Page({
data: {
imgs: []
},
onLoad (res) {
this.drawImage1();
setTimeout(() => {
this.drawImage2();
}, 300);
setTimeout(() => {
this.drawImage3();
}, 600)
setTimeout(() => {
this.drawImage4();
}, 900)
setTimeout(() => {
this.drawImage5();
}, 1200)
setTimeout(() => {
this.drawImage6();
}, 1500)
},
saveImage (evt) {
let index = evt.target.dataset.index;
wx.saveImageToPhotosAlbum({
filePath: this.data.imgs[index],
success(res) {
wx.showToast({
title: '保存成功',
icon: 'success'
})
},
fail () {
wx.showToast({
title: '保存失败',
icon: 'none'
})
}
})
},
drawImage1 () {
let self = this;
this.drawImage1 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas1',
background: '#f0f0f0',
progress (percent) {
},
finish(url) {
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas1 .draw_canvas',
limit: '.share__canvas1',
x: 0,
y: 0
}]
}
this.drawImage1.draw(data);
},
drawImage2 () {
let self = this;
this.drawImage2 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas2',
background: '#f0f0f0',
progress (percent) {
},
finish(url) {
console.log(url)
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas2 .draw_canvas',
limit: '.share__canvas2',
x: 0,
y: 0
}]
}
this.drawImage2.draw(data);
},
drawImage3 () {
let self = this;
this.drawImage3 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas3',
background: '#f0f0f0',
progress (percent) {
// console.log(percent)
},
finish(url) {
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas3 .draw_canvas',
limit: '.share__canvas3',
x: 0,
y: 0
}]
}
this.drawImage3.draw(data);
},
drawImage4 () {
let self = this;
this.drawImage4 = new Wxml2Canvas({
width: 340,
height: 400,
element: 'canvas4',
background: '#f0f0f0',
progress (percent) {
// console.log(percent)
},
finish(url) {
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas4 .draw_canvas',
limit: '.share__canvas4',
x: 0,
y: 0
}]
}
this.drawImage4.draw(data);
},
drawImage5 () {
let self = this;
this.drawImage5 = new Wxml2Canvas({
width: 340,
height: 210,
element: 'canvas5',
background: '#f0f0f0',
progress (percent) {
// console.log(percent)
},
finish(url) {
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas5 .draw_canvas',
limit: '.share__canvas5',
x: 0,
y: 0
}]
}
this.drawImage5.draw(data);
},
drawImage6 () {
let self = this;
this.drawImage6 = new Wxml2Canvas({
width: 340,
height: 450,
element: 'canvas6',
background: '#f0f0f0',
progress (percent) {
// console.log(percent)
},
finish(url) {
let imgs = self.data.imgs;
imgs.push(url);
self.setData({
imgs
})
},
error (res) {
}
});
let data = {
list: [{
type: 'wxml',
class: '.share__canvas6 .draw_canvas',
limit: '.share__canvas6',
x: 0,
y: 0
}]
}
this.drawImage6.draw(data);
}
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,40 +0,0 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"autoAudits": false
},
"compileType": "miniprogram",
"libVersion": "2.6.2",
"appid": "",
"projectname": "wxml2canvas",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}

File diff suppressed because it is too large Load Diff

@ -1,122 +0,0 @@
/**
* 获取字符的长度full为true时一个汉字算两个长度
* @param {String} str
* @param {Boolean} full
*/
function getTextLength (str, full) {
let len = 0;
for (let i = 0; i < str.length; i++) {
let c = str.charCodeAt(i);
//单字节加1
if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
len++;
}
else {
len += (full ? 2 : 1);
}
}
return len;
}
/**
* rgba(255, 255, 255, 1) => #ffffff
* @param {String} color
*/
function transferColor (color = '') {
let res = '#';
color = color.replace(/^rgba?\(/, '').replace(/\)$/, '');
color = color.split(', ');
color.length > 3 ? color.length = 3 : '';
for(let item of color) {
item = parseInt(item || 0);
if(item < 10) {
res += ('0' + item)
}else {
res += (item.toString(16))
}
}
return res;
}
function transferBorder (border = '') {
let res = border.match(/(\w+)px\s(\w+)\s(.*)/);
let obj = {};
if(res) {
obj = {
width: +res[1],
style: res[2],
color: res[3]
}
}
return res ? obj : null;
}
/**
* 内边距依次为上右下左
* @param {*} padding
*/
function transferPadding (padding = '0 0 0 0') {
padding = padding.split(' ');
for(let i = 0, len = padding.length; i < len; i++) {
padding[i] = +padding[i].replace('px', '');
}
return padding;
}
/**
* type1: 0, 25, 17, rgba(0, 0, 0, 0.3)
* type2: rgba(0, 0, 0, 0.3) 0px 25px 17px 0px => (0, 25, 17, rgba(0, 0, 0, 0.3))
* @param {*} shadow
*/
function transferBoxShadow(shadow = '', type) {
if(!shadow || shadow === 'none') return;
let color;
let split;
split = shadow.match(/(\w+)\s(\w+)\s(\w+)\s(rgb.*)/);
if (split) {
split.shift();
shadow = split;
color = split[3] || '#ffffff';
} else {
split = shadow.split(') ');
color = split[0] + ')'
shadow = split[1].split('px ');
}
return {
offsetX: +shadow[0] || 0,
offsetY: +shadow[1] || 0,
blur: +shadow[2] || 0,
color
}
}
function getUid(prefix) {
prefix = prefix || '';
return (
prefix +
'xxyxxyxx'.replace(/[xy]/g, c => {
let r = (Math.random() * 16) | 0;
let v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
})
);
}
export default {
getTextLength,
transferBorder,
transferColor,
transferPadding,
transferBoxShadow,
getUid
}

130
node_modules/wxmp-rsa/LICENSE generated vendored

@ -1,130 +0,0 @@
MIT License
Copyright (c) 2021 Neo Han
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.
File: /src/LICENSE.txt
The MIT License (MIT)
Copyright (c) 2015 Form.io
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.
File: /lib/jsrsasign/LICENSE.txt
CONTAINS CODE FROM YUI LIBRARY SEE LICENSE @ http://yuilibrary.com/license/
The 'jsrsasign'(RSA-Sign JavaScript Library) License
Copyright (c) 2010-2013 Kenji Urushima
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.
File: /lib/jsbn/LICENSE.txt
Licensing
---------
This software is covered under the following copyright:
/*
* Copyright (c) 2003-2005 Tom Wu
* All Rights Reserved.
*
* 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" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
* THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* In addition, the following condition applies:
*
* All redistributions must retain an intact copy of this copyright notice
* and disclaimer.
*/
Address all questions regarding this license to:
Tom Wu
tjw@cs.Stanford.EDU
File: /lib/asn1js/LICENSE.txt
ASN.1 JavaScript decoder
Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

77
node_modules/wxmp-rsa/README.md generated vendored

@ -1,77 +0,0 @@
# wxmp-rsa
### 1、简介
前端rsa加解密工具。
+ 基于[jsencrypt](https://github.com/travist/jsencrypt)修改扩展功能。
+ 兼容小程序环境压缩后60kb左右的大小节省小程序空间。
+ 支持超长文本加解密。
+ 支持中文字符的加解密。
### 2、安装
```
npm i wxmp-rsa -S
```
### 3、使用方式
(小程序使用之前需先使用开发者工具[构建npm](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html)
```js
// 导入包
import WxmpRsa from 'wxmp-rsa'
// 实例化rsa
const rsa = new WxmpRsa()
// 定义待加密的字符串
const str = '{"name":"neo"}'
// 定义公钥
const publicKey = `
-----BEGIN PUBLIC KEY-----
MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgFnWSUwsmGawhMJ30z6y5li2jcf1
m7rPMZcwZOS3To8bk3OBaMGhVEc1F8GtJBbc1rn/HCLNL9zrCy21EefJON8tRFcY
HnpseZSzh+349lIhS+MFw9x4JUddwSPDyxwha929cKzMuVoftu3CJ+kqDBVvxLk7
iDBzUMqW3Kgehk2TAgMBAAE=
-----END PUBLIC KEY-----
`
// 设置公钥
rsa.setPublicKey(publicKey)
// 加密
const cryptStr = rsa.encryptLong(str)
console.log('加密后的结果:', cryptStr)
// 定义私钥
const privateKey = `
-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgFnWSUwsmGawhMJ30z6y5li2jcf1m7rPMZcwZOS3To8bk3OBaMGh
VEc1F8GtJBbc1rn/HCLNL9zrCy21EefJON8tRFcYHnpseZSzh+349lIhS+MFw9x4
JUddwSPDyxwha929cKzMuVoftu3CJ+kqDBVvxLk7iDBzUMqW3Kgehk2TAgMBAAEC
gYBRChPeyk/EOrHX912xLpLKLguh+LY9g1B50ScChzUvtTGDPZaxLQYoogVHKhfn
I9nzuOS5pBzsDX9tAO0hCQzqfHgqRjn+vEgm1Ui+f0E3BVRnhobcJKZpZqlvCBR5
Gu2+zlrY4SeGq3AuQSr/A5FiB5k0RgsvNycDTjqyg7TXGQJBAJoZ8Yr0zakxT1I8
lVqsFbeNPtt8FNG2UgIlIs9RL7aXhw+Y3sWtk/kbaOXafSofu0NcQYx4Km3M3kiP
lcNfTJ8CQQCVPcaRpu+mprRgHS6s76Z668NaFsjX04CUUa0kCrey+Nf/SJJ3BkRH
M7GllZWuI/RSXs/F5N38p5bfkn7QZqaNAkBy3dHJZW8DpgjdYOFnhAxwFK39BwGx
zHhWtv26kWbCcTKwsp+jtB4vunm3k+RmiN6aeGM35L6jt+kdJ0JYLmo7AkBJpRZb
wZj5D8Jqu3vQ8uGgPr9DsYKinkgQ6M0bv/4uXwWXf+Rmv7zpteSv5UTbjfp+uzKk
YO/6QWj+InhZto3xAkAOA0i702dLHm5elLWvht7UEYIDEW1+rYGdbthmJBvT9sZh
VKL954Y9hDzBWepjYsBiJnmIkgeladPnU5025/G/
-----END RSA PRIVATE KEY-----
`
// 设置私钥
rsa.setPrivateKey(privateKey)
// 解密
const originalStr = rsa.decryptLong(cryptStr)
console.log('解密后的原始数据:', originalStr)
```
其他api参考[jsencrypt](https://github.com/travist/jsencrypt)插件
### 4、注意事项
+ 填空方式默认`pkcs1`,目前暂不支持其它填空方式。
### 5、更新提示
+ 之前偶现的加密异常的问题已于v2.0.0+版本中修复。
+ 之前偶现的解密后部分中文乱码的问题已于v2.1.0+版本中修复。
### 6、测试对比
推荐两个第三方rsa工具仅供参考。
+ 在线生成rsa公私钥http://travistidwell.com/jsencrypt/demo/ 推荐1024长度的密钥
+ 在线rsa加解密http://www.toolzl.com/tools/testrsa.html 117超长加密128超长解密

@ -1,205 +0,0 @@
import { b64tohex, hex2b64 } from "./lib/jsbn/base64";
import { JSEncryptRSAKey } from "./JSEncryptRSAKey";
import version from './version.json';
/**
*
* @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
* possible parameters are:
* - default_key_size {number} default: 1024 the key size in bit
* - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
* - log {boolean} default: false whether log warn/error or not
* @constructor
*/
var JSEncrypt = /** @class */ (function () {
function JSEncrypt(options) {
if (options === void 0) { options = {}; }
options = options || {};
this.default_key_size = options.default_key_size ? parseInt(options.default_key_size, 10) : 1024;
this.default_public_exponent = options.default_public_exponent || "010001"; // 65537 default openssl public exponent for rsa key type
this.log = options.log || false;
// The private and public key.
this.key = null;
}
/**
* Method to set the rsa key parameter (one method is enough to set both the public
* and the private key, since the private key contains the public key paramenters)
* Log a warning if logs are enabled
* @param {Object|string} key the pem encoded string or an object (with or without header/footer)
* @public
*/
JSEncrypt.prototype.setKey = function (key) {
if (this.log && this.key) {
console.warn("A key was already set, overriding existing.");
}
this.key = new JSEncryptRSAKey(key);
};
/**
* Proxy method for setKey, for api compatibility
* @see setKey
* @public
*/
JSEncrypt.prototype.setPrivateKey = function (privkey) {
// Create the key.
this.setKey(privkey);
};
/**
* Proxy method for setKey, for api compatibility
* @see setKey
* @public
*/
JSEncrypt.prototype.setPublicKey = function (pubkey) {
// Sets the public key.
this.setKey(pubkey);
};
/**
* Proxy method for RSAKey object's decrypt, decrypt the string using the private
* components of the rsa key object. Note that if the object was not set will be created
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
* @param {string} str base64 encoded crypted string to decrypt
* @return {string} the decrypted string
* @public
*/
JSEncrypt.prototype.decrypt = function (str) {
// Return the decrypted string.
try {
return this.getKey().decrypt(b64tohex(str));
}
catch (ex) {
return false;
}
};
/**
* Proxy method for RSAKey object's encrypt, encrypt the string using the public
* components of the rsa key object. Note that if the object was not set will be created
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
* @param {string} str the string to encrypt
* @return {string} the encrypted string encoded in base64
* @public
*/
JSEncrypt.prototype.encrypt = function (str) {
// Return the encrypted string.
try {
return hex2b64(this.getKey().encrypt(str));
}
catch (ex) {
return false;
}
};
// 超长文本加密
JSEncrypt.prototype.encryptLong = function (str) {
try {
return hex2b64(this.getKey().encryptLong(str));
}
catch (ex) {
return false;
}
};
// 超长文本解密
JSEncrypt.prototype.decryptLong = function (str) {
try {
return this.getKey().decryptLong(b64tohex(str));
}
catch (ex) {
return false;
}
};
/**
* Proxy method for RSAKey object's sign.
* @param {string} str the string to sign
* @param {function} digestMethod hash method
* @param {string} digestName the name of the hash algorithm
* @return {string} the signature encoded in base64
* @public
*/
JSEncrypt.prototype.sign = function (str, digestMethod, digestName) {
// return the RSA signature of 'str' in 'hex' format.
try {
return hex2b64(this.getKey().sign(str, digestMethod, digestName));
}
catch (ex) {
return false;
}
};
/**
* Proxy method for RSAKey object's verify.
* @param {string} str the string to verify
* @param {string} signature the signature encoded in base64 to compare the string to
* @param {function} digestMethod hash method
* @return {boolean} whether the data and signature match
* @public
*/
JSEncrypt.prototype.verify = function (str, signature, digestMethod) {
// Return the decrypted 'digest' of the signature.
try {
return this.getKey().verify(str, b64tohex(signature), digestMethod);
}
catch (ex) {
return false;
}
};
/**
* Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
* will be created and returned
* @param {callback} [cb] the callback to be called if we want the key to be generated
* in an async fashion
* @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
* @public
*/
JSEncrypt.prototype.getKey = function (cb) {
// Only create new if it does not exist.
if (!this.key) {
// Get a new private key.
this.key = new JSEncryptRSAKey();
if (cb && {}.toString.call(cb) === "[object Function]") {
this.key.generateAsync(this.default_key_size, this.default_public_exponent, cb);
return;
}
// Generate the key.
this.key.generate(this.default_key_size, this.default_public_exponent);
}
return this.key;
};
/**
* Returns the pem encoded representation of the private key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the private key WITH header and footer
* @public
*/
JSEncrypt.prototype.getPrivateKey = function () {
// Return the private representation of this key.
return this.getKey().getPrivateKey();
};
/**
* Returns the pem encoded representation of the private key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the private key WITHOUT header and footer
* @public
*/
JSEncrypt.prototype.getPrivateKeyB64 = function () {
// Return the private representation of this key.
return this.getKey().getPrivateBaseKeyB64();
};
/**
* Returns the pem encoded representation of the public key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the public key WITH header and footer
* @public
*/
JSEncrypt.prototype.getPublicKey = function () {
// Return the private representation of this key.
return this.getKey().getPublicKey();
};
/**
* Returns the pem encoded representation of the public key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the public key WITHOUT header and footer
* @public
*/
JSEncrypt.prototype.getPublicKeyB64 = function () {
// Return the private representation of this key.
return this.getKey().getPublicBaseKeyB64();
};
JSEncrypt.version = version.version;
return JSEncrypt;
}());
export { JSEncrypt };

@ -1,315 +0,0 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { hex2b64 } from "./lib/jsbn/base64";
import { Hex } from "./lib/asn1js/hex";
import { Base64 } from "./lib/asn1js/base64";
import { ASN1 } from "./lib/asn1js/asn1";
import { RSAKey } from "./lib/jsbn/rsa";
import { parseBigInt } from "./lib/jsbn/jsbn";
import { KJUR } from "./lib/jsrsasign/asn1-1.0";
/**
* Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object.
* This object is just a decorator for parsing the key parameter
* @param {string|Object} key - The key in string format, or an object containing
* the parameters needed to build a RSAKey object.
* @constructor
*/
var JSEncryptRSAKey = /** @class */ (function (_super) {
__extends(JSEncryptRSAKey, _super);
function JSEncryptRSAKey(key) {
var _this = _super.call(this) || this;
// Call the super constructor.
// RSAKey.call(this);
// If a key key was provided.
if (key) {
// If this is a string...
if (typeof key === "string") {
_this.parseKey(key);
}
else if (JSEncryptRSAKey.hasPrivateKeyProperty(key) ||
JSEncryptRSAKey.hasPublicKeyProperty(key)) {
// Set the values for the key.
_this.parsePropertiesFrom(key);
}
}
return _this;
}
/**
* Method to parse a pem encoded string containing both a public or private key.
* The method will translate the pem encoded string in a der encoded string and
* will parse private key and public key parameters. This method accepts public key
* in the rsaencryption pkcs #1 format (oid: 1.2.840.113549.1.1.1).
*
* @todo Check how many rsa formats use the same format of pkcs #1.
*
* The format is defined as:
* PublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* PublicKey BIT STRING
* }
* Where AlgorithmIdentifier is:
* AlgorithmIdentifier ::= SEQUENCE {
* algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
* parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
* }
* and PublicKey is a SEQUENCE encapsulated in a BIT STRING
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* it's possible to examine the structure of the keys obtained from openssl using
* an asn.1 dumper as the one used here to parse the components: http://lapo.it/asn1js/
* @argument {string} pem the pem encoded string, can include the BEGIN/END header/footer
* @private
*/
JSEncryptRSAKey.prototype.parseKey = function (pem) {
try {
var modulus = 0;
var public_exponent = 0;
var reHex = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/;
var der = reHex.test(pem) ? Hex.decode(pem) : Base64.unarmor(pem);
var asn1 = ASN1.decode(der);
// Fixes a bug with OpenSSL 1.0+ private keys
if (asn1.sub.length === 3) {
asn1 = asn1.sub[2].sub[0];
}
if (asn1.sub.length === 9) {
// Parse the private key.
modulus = asn1.sub[1].getHexStringValue(); // bigint
this.n = parseBigInt(modulus, 16);
public_exponent = asn1.sub[2].getHexStringValue(); // int
this.e = parseInt(public_exponent, 16);
var private_exponent = asn1.sub[3].getHexStringValue(); // bigint
this.d = parseBigInt(private_exponent, 16);
var prime1 = asn1.sub[4].getHexStringValue(); // bigint
this.p = parseBigInt(prime1, 16);
var prime2 = asn1.sub[5].getHexStringValue(); // bigint
this.q = parseBigInt(prime2, 16);
var exponent1 = asn1.sub[6].getHexStringValue(); // bigint
this.dmp1 = parseBigInt(exponent1, 16);
var exponent2 = asn1.sub[7].getHexStringValue(); // bigint
this.dmq1 = parseBigInt(exponent2, 16);
var coefficient = asn1.sub[8].getHexStringValue(); // bigint
this.coeff = parseBigInt(coefficient, 16);
}
else if (asn1.sub.length === 2) {
// Parse the public key.
var bit_string = asn1.sub[1];
var sequence = bit_string.sub[0];
modulus = sequence.sub[0].getHexStringValue();
this.n = parseBigInt(modulus, 16);
public_exponent = sequence.sub[1].getHexStringValue();
this.e = parseInt(public_exponent, 16);
}
else {
return false;
}
return true;
}
catch (ex) {
return false;
}
};
/**
* Translate rsa parameters in a hex encoded string representing the rsa key.
*
* The translation follow the ASN.1 notation :
* RSAPrivateKey ::= SEQUENCE {
* version Version,
* modulus INTEGER, -- n
* publicExponent INTEGER, -- e
* privateExponent INTEGER, -- d
* prime1 INTEGER, -- p
* prime2 INTEGER, -- q
* exponent1 INTEGER, -- d mod (p1)
* exponent2 INTEGER, -- d mod (q-1)
* coefficient INTEGER, -- (inverse of q) mod p
* }
* @returns {string} DER Encoded String representing the rsa private key
* @private
*/
JSEncryptRSAKey.prototype.getPrivateBaseKey = function () {
var options = {
array: [
new KJUR.asn1.DERInteger({ int: 0 }),
new KJUR.asn1.DERInteger({ bigint: this.n }),
new KJUR.asn1.DERInteger({ int: this.e }),
new KJUR.asn1.DERInteger({ bigint: this.d }),
new KJUR.asn1.DERInteger({ bigint: this.p }),
new KJUR.asn1.DERInteger({ bigint: this.q }),
new KJUR.asn1.DERInteger({ bigint: this.dmp1 }),
new KJUR.asn1.DERInteger({ bigint: this.dmq1 }),
new KJUR.asn1.DERInteger({ bigint: this.coeff })
]
};
var seq = new KJUR.asn1.DERSequence(options);
return seq.getEncodedHex();
};
/**
* base64 (pem) encoded version of the DER encoded representation
* @returns {string} pem encoded representation without header and footer
* @public
*/
JSEncryptRSAKey.prototype.getPrivateBaseKeyB64 = function () {
return hex2b64(this.getPrivateBaseKey());
};
/**
* Translate rsa parameters in a hex encoded string representing the rsa public key.
* The representation follow the ASN.1 notation :
* PublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* PublicKey BIT STRING
* }
* Where AlgorithmIdentifier is:
* AlgorithmIdentifier ::= SEQUENCE {
* algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
* parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
* }
* and PublicKey is a SEQUENCE encapsulated in a BIT STRING
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* @returns {string} DER Encoded String representing the rsa public key
* @private
*/
JSEncryptRSAKey.prototype.getPublicBaseKey = function () {
var first_sequence = new KJUR.asn1.DERSequence({
array: [
new KJUR.asn1.DERObjectIdentifier({ oid: "1.2.840.113549.1.1.1" }),
new KJUR.asn1.DERNull()
]
});
var second_sequence = new KJUR.asn1.DERSequence({
array: [
new KJUR.asn1.DERInteger({ bigint: this.n }),
new KJUR.asn1.DERInteger({ int: this.e })
]
});
var bit_string = new KJUR.asn1.DERBitString({
hex: "00" + second_sequence.getEncodedHex()
});
var seq = new KJUR.asn1.DERSequence({
array: [
first_sequence,
bit_string
]
});
return seq.getEncodedHex();
};
/**
* base64 (pem) encoded version of the DER encoded representation
* @returns {string} pem encoded representation without header and footer
* @public
*/
JSEncryptRSAKey.prototype.getPublicBaseKeyB64 = function () {
return hex2b64(this.getPublicBaseKey());
};
/**
* wrap the string in block of width chars. The default value for rsa keys is 64
* characters.
* @param {string} str the pem encoded string without header and footer
* @param {Number} [width=64] - the length the string has to be wrapped at
* @returns {string}
* @private
*/
JSEncryptRSAKey.wordwrap = function (str, width) {
width = width || 64;
if (!str) {
return str;
}
var regex = "(.{1," + width + "})( +|$\n?)|(.{1," + width + "})";
return str.match(RegExp(regex, "g")).join("\n");
};
/**
* Retrieve the pem encoded private key
* @returns {string} the pem encoded private key with header/footer
* @public
*/
JSEncryptRSAKey.prototype.getPrivateKey = function () {
var key = "-----BEGIN RSA PRIVATE KEY-----\n";
key += JSEncryptRSAKey.wordwrap(this.getPrivateBaseKeyB64()) + "\n";
key += "-----END RSA PRIVATE KEY-----";
return key;
};
/**
* Retrieve the pem encoded public key
* @returns {string} the pem encoded public key with header/footer
* @public
*/
JSEncryptRSAKey.prototype.getPublicKey = function () {
var key = "-----BEGIN PUBLIC KEY-----\n";
key += JSEncryptRSAKey.wordwrap(this.getPublicBaseKeyB64()) + "\n";
key += "-----END PUBLIC KEY-----";
return key;
};
/**
* Check if the object contains the necessary parameters to populate the rsa modulus
* and public exponent parameters.
* @param {Object} [obj={}] - An object that may contain the two public key
* parameters
* @returns {boolean} true if the object contains both the modulus and the public exponent
* properties (n and e)
* @todo check for types of n and e. N should be a parseable bigInt object, E should
* be a parseable integer number
* @private
*/
JSEncryptRSAKey.hasPublicKeyProperty = function (obj) {
obj = obj || {};
return (obj.hasOwnProperty("n") &&
obj.hasOwnProperty("e"));
};
/**
* Check if the object contains ALL the parameters of an RSA key.
* @param {Object} [obj={}] - An object that may contain nine rsa key
* parameters
* @returns {boolean} true if the object contains all the parameters needed
* @todo check for types of the parameters all the parameters but the public exponent
* should be parseable bigint objects, the public exponent should be a parseable integer number
* @private
*/
JSEncryptRSAKey.hasPrivateKeyProperty = function (obj) {
obj = obj || {};
return (obj.hasOwnProperty("n") &&
obj.hasOwnProperty("e") &&
obj.hasOwnProperty("d") &&
obj.hasOwnProperty("p") &&
obj.hasOwnProperty("q") &&
obj.hasOwnProperty("dmp1") &&
obj.hasOwnProperty("dmq1") &&
obj.hasOwnProperty("coeff"));
};
/**
* Parse the properties of obj in the current rsa object. Obj should AT LEAST
* include the modulus and public exponent (n, e) parameters.
* @param {Object} obj - the object containing rsa parameters
* @private
*/
JSEncryptRSAKey.prototype.parsePropertiesFrom = function (obj) {
this.n = obj.n;
this.e = obj.e;
if (obj.hasOwnProperty("d")) {
this.d = obj.d;
this.p = obj.p;
this.q = obj.q;
this.dmp1 = obj.dmp1;
this.dmq1 = obj.dmq1;
this.coeff = obj.coeff;
}
};
return JSEncryptRSAKey;
}(RSAKey));
export { JSEncryptRSAKey };

@ -1,3 +0,0 @@
import { JSEncrypt } from './JSEncrypt';
export { JSEncrypt };
export default JSEncrypt;

@ -1,565 +0,0 @@
// ASN.1 JavaScript decoder
// Copyright (c) 2008-2014 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
/*global oids */
import { Int10 } from "./int10";
var ellipsis = "\u2026";
var reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
var reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
function stringCut(str, len) {
if (str.length > len) {
str = str.substring(0, len) + ellipsis;
}
return str;
}
var Stream = /** @class */ (function () {
function Stream(enc, pos) {
this.hexDigits = "0123456789ABCDEF";
if (enc instanceof Stream) {
this.enc = enc.enc;
this.pos = enc.pos;
}
else {
// enc should be an array or a binary string
this.enc = enc;
this.pos = pos;
}
}
Stream.prototype.get = function (pos) {
if (pos === undefined) {
pos = this.pos++;
}
if (pos >= this.enc.length) {
throw new Error("Requesting byte offset " + pos + " on a stream of length " + this.enc.length);
}
return ("string" === typeof this.enc) ? this.enc.charCodeAt(pos) : this.enc[pos];
};
Stream.prototype.hexByte = function (b) {
return this.hexDigits.charAt((b >> 4) & 0xF) + this.hexDigits.charAt(b & 0xF);
};
Stream.prototype.hexDump = function (start, end, raw) {
var s = "";
for (var i = start; i < end; ++i) {
s += this.hexByte(this.get(i));
if (raw !== true) {
switch (i & 0xF) {
case 0x7:
s += " ";
break;
case 0xF:
s += "\n";
break;
default:
s += " ";
}
}
}
return s;
};
Stream.prototype.isASCII = function (start, end) {
for (var i = start; i < end; ++i) {
var c = this.get(i);
if (c < 32 || c > 176) {
return false;
}
}
return true;
};
Stream.prototype.parseStringISO = function (start, end) {
var s = "";
for (var i = start; i < end; ++i) {
s += String.fromCharCode(this.get(i));
}
return s;
};
Stream.prototype.parseStringUTF = function (start, end) {
var s = "";
for (var i = start; i < end;) {
var c = this.get(i++);
if (c < 128) {
s += String.fromCharCode(c);
}
else if ((c > 191) && (c < 224)) {
s += String.fromCharCode(((c & 0x1F) << 6) | (this.get(i++) & 0x3F));
}
else {
s += String.fromCharCode(((c & 0x0F) << 12) | ((this.get(i++) & 0x3F) << 6) | (this.get(i++) & 0x3F));
}
}
return s;
};
Stream.prototype.parseStringBMP = function (start, end) {
var str = "";
var hi;
var lo;
for (var i = start; i < end;) {
hi = this.get(i++);
lo = this.get(i++);
str += String.fromCharCode((hi << 8) | lo);
}
return str;
};
Stream.prototype.parseTime = function (start, end, shortYear) {
var s = this.parseStringISO(start, end);
var m = (shortYear ? reTimeS : reTimeL).exec(s);
if (!m) {
return "Unrecognized time: " + s;
}
if (shortYear) {
// to avoid querying the timer, use the fixed range [1970, 2069]
// it will conform with ITU X.400 [-10, +40] sliding window until 2030
m[1] = +m[1];
m[1] += (+m[1] < 70) ? 2000 : 1900;
}
s = m[1] + "-" + m[2] + "-" + m[3] + " " + m[4];
if (m[5]) {
s += ":" + m[5];
if (m[6]) {
s += ":" + m[6];
if (m[7]) {
s += "." + m[7];
}
}
}
if (m[8]) {
s += " UTC";
if (m[8] != "Z") {
s += m[8];
if (m[9]) {
s += ":" + m[9];
}
}
}
return s;
};
Stream.prototype.parseInteger = function (start, end) {
var v = this.get(start);
var neg = (v > 127);
var pad = neg ? 255 : 0;
var len;
var s = "";
// skip unuseful bits (not allowed in DER)
while (v == pad && ++start < end) {
v = this.get(start);
}
len = end - start;
if (len === 0) {
return neg ? -1 : 0;
}
// show bit length of huge integers
if (len > 4) {
s = v;
len <<= 3;
while (((+s ^ pad) & 0x80) == 0) {
s = +s << 1;
--len;
}
s = "(" + len + " bit)\n";
}
// decode the integer
if (neg) {
v = v - 256;
}
var n = new Int10(v);
for (var i = start + 1; i < end; ++i) {
n.mulAdd(256, this.get(i));
}
return s + n.toString();
};
Stream.prototype.parseBitString = function (start, end, maxLength) {
var unusedBit = this.get(start);
var lenBit = ((end - start - 1) << 3) - unusedBit;
var intro = "(" + lenBit + " bit)\n";
var s = "";
for (var i = start + 1; i < end; ++i) {
var b = this.get(i);
var skip = (i == end - 1) ? unusedBit : 0;
for (var j = 7; j >= skip; --j) {
s += (b >> j) & 1 ? "1" : "0";
}
if (s.length > maxLength) {
return intro + stringCut(s, maxLength);
}
}
return intro + s;
};
Stream.prototype.parseOctetString = function (start, end, maxLength) {
if (this.isASCII(start, end)) {
return stringCut(this.parseStringISO(start, end), maxLength);
}
var len = end - start;
var s = "(" + len + " byte)\n";
maxLength /= 2; // we work in bytes
if (len > maxLength) {
end = start + maxLength;
}
for (var i = start; i < end; ++i) {
s += this.hexByte(this.get(i));
}
if (len > maxLength) {
s += ellipsis;
}
return s;
};
Stream.prototype.parseOID = function (start, end, maxLength) {
var s = "";
var n = new Int10();
var bits = 0;
for (var i = start; i < end; ++i) {
var v = this.get(i);
n.mulAdd(128, v & 0x7F);
bits += 7;
if (!(v & 0x80)) { // finished
if (s === "") {
n = n.simplify();
if (n instanceof Int10) {
n.sub(80);
s = "2." + n.toString();
}
else {
var m = n < 80 ? n < 40 ? 0 : 1 : 2;
s = m + "." + (n - m * 40);
}
}
else {
s += "." + n.toString();
}
if (s.length > maxLength) {
return stringCut(s, maxLength);
}
n = new Int10();
bits = 0;
}
}
if (bits > 0) {
s += ".incomplete";
}
return s;
};
return Stream;
}());
export { Stream };
var ASN1 = /** @class */ (function () {
function ASN1(stream, header, length, tag, sub) {
if (!(tag instanceof ASN1Tag)) {
throw new Error("Invalid tag value.");
}
this.stream = stream;
this.header = header;
this.length = length;
this.tag = tag;
this.sub = sub;
}
ASN1.prototype.typeName = function () {
switch (this.tag.tagClass) {
case 0: // universal
switch (this.tag.tagNumber) {
case 0x00:
return "EOC";
case 0x01:
return "BOOLEAN";
case 0x02:
return "INTEGER";
case 0x03:
return "BIT_STRING";
case 0x04:
return "OCTET_STRING";
case 0x05:
return "NULL";
case 0x06:
return "OBJECT_IDENTIFIER";
case 0x07:
return "ObjectDescriptor";
case 0x08:
return "EXTERNAL";
case 0x09:
return "REAL";
case 0x0A:
return "ENUMERATED";
case 0x0B:
return "EMBEDDED_PDV";
case 0x0C:
return "UTF8String";
case 0x10:
return "SEQUENCE";
case 0x11:
return "SET";
case 0x12:
return "NumericString";
case 0x13:
return "PrintableString"; // ASCII subset
case 0x14:
return "TeletexString"; // aka T61String
case 0x15:
return "VideotexString";
case 0x16:
return "IA5String"; // ASCII
case 0x17:
return "UTCTime";
case 0x18:
return "GeneralizedTime";
case 0x19:
return "GraphicString";
case 0x1A:
return "VisibleString"; // ASCII subset
case 0x1B:
return "GeneralString";
case 0x1C:
return "UniversalString";
case 0x1E:
return "BMPString";
}
return "Universal_" + this.tag.tagNumber.toString();
case 1:
return "Application_" + this.tag.tagNumber.toString();
case 2:
return "[" + this.tag.tagNumber.toString() + "]"; // Context
case 3:
return "Private_" + this.tag.tagNumber.toString();
}
};
ASN1.prototype.content = function (maxLength) {
if (this.tag === undefined) {
return null;
}
if (maxLength === undefined) {
maxLength = Infinity;
}
var content = this.posContent();
var len = Math.abs(this.length);
if (!this.tag.isUniversal()) {
if (this.sub !== null) {
return "(" + this.sub.length + " elem)";
}
return this.stream.parseOctetString(content, content + len, maxLength);
}
switch (this.tag.tagNumber) {
case 0x01: // BOOLEAN
return (this.stream.get(content) === 0) ? "false" : "true";
case 0x02: // INTEGER
return this.stream.parseInteger(content, content + len);
case 0x03: // BIT_STRING
return this.sub ? "(" + this.sub.length + " elem)" :
this.stream.parseBitString(content, content + len, maxLength);
case 0x04: // OCTET_STRING
return this.sub ? "(" + this.sub.length + " elem)" :
this.stream.parseOctetString(content, content + len, maxLength);
// case 0x05: // NULL
case 0x06: // OBJECT_IDENTIFIER
return this.stream.parseOID(content, content + len, maxLength);
// case 0x07: // ObjectDescriptor
// case 0x08: // EXTERNAL
// case 0x09: // REAL
// case 0x0A: // ENUMERATED
// case 0x0B: // EMBEDDED_PDV
case 0x10: // SEQUENCE
case 0x11: // SET
if (this.sub !== null) {
return "(" + this.sub.length + " elem)";
}
else {
return "(no elem)";
}
case 0x0C: // UTF8String
return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
case 0x12: // NumericString
case 0x13: // PrintableString
case 0x14: // TeletexString
case 0x15: // VideotexString
case 0x16: // IA5String
// case 0x19: // GraphicString
case 0x1A: // VisibleString
// case 0x1B: // GeneralString
// case 0x1C: // UniversalString
return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
case 0x1E: // BMPString
return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
case 0x17: // UTCTime
case 0x18: // GeneralizedTime
return this.stream.parseTime(content, content + len, (this.tag.tagNumber == 0x17));
}
return null;
};
ASN1.prototype.toString = function () {
return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + ((this.sub === null) ? "null" : this.sub.length) + "]";
};
ASN1.prototype.toPrettyString = function (indent) {
if (indent === undefined) {
indent = "";
}
var s = indent + this.typeName() + " @" + this.stream.pos;
if (this.length >= 0) {
s += "+";
}
s += this.length;
if (this.tag.tagConstructed) {
s += " (constructed)";
}
else if ((this.tag.isUniversal() && ((this.tag.tagNumber == 0x03) || (this.tag.tagNumber == 0x04))) && (this.sub !== null)) {
s += " (encapsulates)";
}
s += "\n";
if (this.sub !== null) {
indent += " ";
for (var i = 0, max = this.sub.length; i < max; ++i) {
s += this.sub[i].toPrettyString(indent);
}
}
return s;
};
ASN1.prototype.posStart = function () {
return this.stream.pos;
};
ASN1.prototype.posContent = function () {
return this.stream.pos + this.header;
};
ASN1.prototype.posEnd = function () {
return this.stream.pos + this.header + Math.abs(this.length);
};
ASN1.prototype.toHexString = function () {
return this.stream.hexDump(this.posStart(), this.posEnd(), true);
};
ASN1.decodeLength = function (stream) {
var buf = stream.get();
var len = buf & 0x7F;
if (len == buf) {
return len;
}
// no reason to use Int10, as it would be a huge buffer anyways
if (len > 6) {
throw new Error("Length over 48 bits not supported at position " + (stream.pos - 1));
}
if (len === 0) {
return null;
} // undefined
buf = 0;
for (var i = 0; i < len; ++i) {
buf = (buf * 256) + stream.get();
}
return buf;
};
/**
* Retrieve the hexadecimal value (as a string) of the current ASN.1 element
* @returns {string}
* @public
*/
ASN1.prototype.getHexStringValue = function () {
var hexString = this.toHexString();
var offset = this.header * 2;
var length = this.length * 2;
return hexString.substr(offset, length);
};
ASN1.decode = function (str) {
var stream;
if (!(str instanceof Stream)) {
stream = new Stream(str, 0);
}
else {
stream = str;
}
var streamStart = new Stream(stream);
var tag = new ASN1Tag(stream);
var len = ASN1.decodeLength(stream);
var start = stream.pos;
var header = start - streamStart.pos;
var sub = null;
var getSub = function () {
var ret = [];
if (len !== null) {
// definite length
var end = start + len;
while (stream.pos < end) {
ret[ret.length] = ASN1.decode(stream);
}
if (stream.pos != end) {
throw new Error("Content size is not correct for container starting at offset " + start);
}
}
else {
// undefined length
try {
for (;;) {
var s = ASN1.decode(stream);
if (s.tag.isEOC()) {
break;
}
ret[ret.length] = s;
}
len = start - stream.pos; // undefined lengths are represented as negative values
}
catch (e) {
throw new Error("Exception while decoding undefined length content: " + e);
}
}
return ret;
};
if (tag.tagConstructed) {
// must have valid content
sub = getSub();
}
else if (tag.isUniversal() && ((tag.tagNumber == 0x03) || (tag.tagNumber == 0x04))) {
// sometimes BitString and OctetString are used to encapsulate ASN.1
try {
if (tag.tagNumber == 0x03) {
if (stream.get() != 0) {
throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
}
}
sub = getSub();
for (var i = 0; i < sub.length; ++i) {
if (sub[i].tag.isEOC()) {
throw new Error("EOC is not supposed to be actual content.");
}
}
}
catch (e) {
// but silently ignore when they don't
sub = null;
}
}
if (sub === null) {
if (len === null) {
throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
}
stream.pos = start + Math.abs(len);
}
return new ASN1(streamStart, header, len, tag, sub);
};
return ASN1;
}());
export { ASN1 };
var ASN1Tag = /** @class */ (function () {
function ASN1Tag(stream) {
var buf = stream.get();
this.tagClass = buf >> 6;
this.tagConstructed = ((buf & 0x20) !== 0);
this.tagNumber = buf & 0x1F;
if (this.tagNumber == 0x1F) { // long tag
var n = new Int10();
do {
buf = stream.get();
n.mulAdd(128, buf & 0x7F);
} while (buf & 0x80);
this.tagNumber = n.simplify();
}
}
ASN1Tag.prototype.isUniversal = function () {
return this.tagClass === 0x00;
};
ASN1Tag.prototype.isEOC = function () {
return this.tagClass === 0x00 && this.tagNumber === 0x00;
};
return ASN1Tag;
}());
export { ASN1Tag };

@ -1,88 +0,0 @@
// Base64 JavaScript decoder
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
var decoder;
export var Base64 = {
decode: function (a) {
var i;
if (decoder === undefined) {
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var ignore = "= \f\n\r\t\u00A0\u2028\u2029";
decoder = Object.create(null);
for (i = 0; i < 64; ++i) {
decoder[b64.charAt(i)] = i;
}
decoder['-'] = 62; //+
decoder['_'] = 63; //-
for (i = 0; i < ignore.length; ++i) {
decoder[ignore.charAt(i)] = -1;
}
}
var out = [];
var bits = 0;
var char_count = 0;
for (i = 0; i < a.length; ++i) {
var c = a.charAt(i);
if (c == "=") {
break;
}
c = decoder[c];
if (c == -1) {
continue;
}
if (c === undefined) {
throw new Error("Illegal character at offset " + i);
}
bits |= c;
if (++char_count >= 4) {
out[out.length] = (bits >> 16);
out[out.length] = (bits >> 8) & 0xFF;
out[out.length] = bits & 0xFF;
bits = 0;
char_count = 0;
}
else {
bits <<= 6;
}
}
switch (char_count) {
case 1:
throw new Error("Base64 encoding incomplete: at least 2 bits missing");
case 2:
out[out.length] = (bits >> 10);
break;
case 3:
out[out.length] = (bits >> 16);
out[out.length] = (bits >> 8) & 0xFF;
break;
}
return out;
},
re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
unarmor: function (a) {
var m = Base64.re.exec(a);
if (m) {
if (m[1]) {
a = m[1];
}
else if (m[2]) {
a = m[2];
}
else {
throw new Error("RegExp out of sync");
}
}
return Base64.decode(a);
}
};

@ -1,64 +0,0 @@
// Hex JavaScript decoder
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
var decoder;
export var Hex = {
decode: function (a) {
var i;
if (decoder === undefined) {
var hex = "0123456789ABCDEF";
var ignore = " \f\n\r\t\u00A0\u2028\u2029";
decoder = {};
for (i = 0; i < 16; ++i) {
decoder[hex.charAt(i)] = i;
}
hex = hex.toLowerCase();
for (i = 10; i < 16; ++i) {
decoder[hex.charAt(i)] = i;
}
for (i = 0; i < ignore.length; ++i) {
decoder[ignore.charAt(i)] = -1;
}
}
var out = [];
var bits = 0;
var char_count = 0;
for (i = 0; i < a.length; ++i) {
var c = a.charAt(i);
if (c == "=") {
break;
}
c = decoder[c];
if (c == -1) {
continue;
}
if (c === undefined) {
throw new Error("Illegal character at offset " + i);
}
bits |= c;
if (++char_count >= 2) {
out[out.length] = bits;
bits = 0;
char_count = 0;
}
else {
bits <<= 4;
}
}
if (char_count) {
throw new Error("Hex encoding incomplete: 4 bits missing");
}
return out;
}
};

@ -1,87 +0,0 @@
// Big integer base-10 printing library
// Copyright (c) 2014 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
var max = 10000000000000; // biggest integer that can still fit 2^53 when multiplied by 256
var Int10 = /** @class */ (function () {
function Int10(value) {
this.buf = [+value || 0];
}
Int10.prototype.mulAdd = function (m, c) {
// assert(m <= 256)
var b = this.buf;
var l = b.length;
var i;
var t;
for (i = 0; i < l; ++i) {
t = b[i] * m + c;
if (t < max) {
c = 0;
}
else {
c = 0 | (t / max);
t -= c * max;
}
b[i] = t;
}
if (c > 0) {
b[i] = c;
}
};
Int10.prototype.sub = function (c) {
// assert(m <= 256)
var b = this.buf;
var l = b.length;
var i;
var t;
for (i = 0; i < l; ++i) {
t = b[i] - c;
if (t < 0) {
t += max;
c = 1;
}
else {
c = 0;
}
b[i] = t;
}
while (b[b.length - 1] === 0) {
b.pop();
}
};
Int10.prototype.toString = function (base) {
if ((base || 10) != 10) {
throw new Error("only base 10 is supported");
}
var b = this.buf;
var s = b[b.length - 1].toString();
for (var i = b.length - 2; i >= 0; --i) {
s += (max + b[i]).toString().substring(1);
}
return s;
};
Int10.prototype.valueOf = function () {
var b = this.buf;
var v = 0;
for (var i = b.length - 1; i >= 0; --i) {
v = v * max + b[i];
}
return v;
};
Int10.prototype.simplify = function () {
var b = this.buf;
return (b.length == 1) ? b[0] : this;
};
return Int10;
}());
export { Int10 };

File diff suppressed because it is too large Load Diff

@ -1,76 +0,0 @@
import { int2char } from "./util";
var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var b64pad = "=";
export function hex2b64(h) {
var i;
var c;
var ret = "";
for (i = 0; i + 3 <= h.length; i += 3) {
c = parseInt(h.substring(i, i + 3), 16);
ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
}
if (i + 1 == h.length) {
c = parseInt(h.substring(i, i + 1), 16);
ret += b64map.charAt(c << 2);
}
else if (i + 2 == h.length) {
c = parseInt(h.substring(i, i + 2), 16);
ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
}
while ((ret.length & 3) > 0) {
ret += b64pad;
}
return ret;
}
// convert a base64 string to hex
export function b64tohex(s) {
var ret = "";
var i;
var k = 0; // b64 state, 0-3
var slop = 0;
for (i = 0; i < s.length; ++i) {
if (s.charAt(i) == b64pad) {
break;
}
var v = b64map.indexOf(s.charAt(i));
if (v < 0) {
continue;
}
if (k == 0) {
ret += int2char(v >> 2);
slop = v & 3;
k = 1;
}
else if (k == 1) {
ret += int2char((slop << 2) | (v >> 4));
slop = v & 0xf;
k = 2;
}
else if (k == 2) {
ret += int2char(slop);
ret += int2char(v >> 2);
slop = v & 3;
k = 3;
}
else {
ret += int2char((slop << 2) | (v >> 4));
ret += int2char(v & 0xf);
k = 0;
}
}
if (k == 1) {
ret += int2char(slop << 2);
}
return ret;
}
// convert a base64 string to a byte/number array
export function b64toBA(s) {
// piggyback on b64tohex for now, optimize later
var h = b64tohex(s);
var i;
var a = [];
for (i = 0; 2 * i < h.length; ++i) {
a[i] = parseInt(h.substring(2 * i, 2 * i + 2), 16);
}
return a;
}

File diff suppressed because it is too large Load Diff

@ -1,46 +0,0 @@
// prng4.js - uses Arcfour as a PRNG
var Arcfour = /** @class */ (function () {
function Arcfour() {
this.i = 0;
this.j = 0;
this.S = [];
}
// Arcfour.prototype.init = ARC4init;
// Initialize arcfour context from key, an array of ints, each from [0..255]
Arcfour.prototype.init = function (key) {
var i;
var j;
var t;
for (i = 0; i < 256; ++i) {
this.S[i] = i;
}
j = 0;
for (i = 0; i < 256; ++i) {
j = (j + this.S[i] + key[i % key.length]) & 255;
t = this.S[i];
this.S[i] = this.S[j];
this.S[j] = t;
}
this.i = 0;
this.j = 0;
};
// Arcfour.prototype.next = ARC4next;
Arcfour.prototype.next = function () {
var t;
this.i = (this.i + 1) & 255;
this.j = (this.j + this.S[this.i]) & 255;
t = this.S[this.i];
this.S[this.i] = this.S[this.j];
this.S[this.j] = t;
return this.S[(t + this.S[this.i]) & 255];
};
return Arcfour;
}());
export { Arcfour };
// Plug in your RNG constructor here
export function prng_newstate() {
return new Arcfour();
}
// Pool size must be a multiple of 4 and greater than 32.
// An array of bytes the size of the pool will be passed to init()
export var rng_psize = 256;

@ -1,56 +0,0 @@
// Random number generator - requires a PRNG backend, e.g. prng4.js
import { prng_newstate, rng_psize } from "./prng4";
var rng_state;
var rng_pool = null;
var rng_pptr;
// Initialize the pool with junk if needed.
if (rng_pool == null) {
rng_pool = [];
rng_pptr = 0;
var t = void 0;
// Use mouse events for entropy, if we do not have enough entropy by the time
// we need it, entropy will be generated by Math.random.
var count = 0;
var onMouseMoveListener = function (ev) {
count = count || 0;
if (count >= 256 || rng_pptr >= rng_psize) {
return;
}
try {
var mouseCoordinates = ev.x + ev.y;
rng_pool[rng_pptr++] = mouseCoordinates & 255;
count += 1;
}
catch (e) {
// Sometimes Firefox will deny permission to access event properties for some reason. Ignore.
}
};
}
function rng_get_byte() {
if (rng_state == null) {
rng_state = prng_newstate();
// At this point, we may not have collected enough entropy. If not, fall back to Math.random
while (rng_pptr < rng_psize) {
var random = Math.floor(65536 * Math.random());
rng_pool[rng_pptr++] = random & 255;
}
rng_state.init(rng_pool);
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) {
rng_pool[rng_pptr] = 0;
}
rng_pptr = 0;
}
// TODO: allow reseeding after first request
return rng_state.next();
}
var SecureRandom = /** @class */ (function () {
function SecureRandom() {
}
SecureRandom.prototype.nextBytes = function (ba) {
for (var i = 0; i < ba.length; ++i) {
ba[i] = rng_get_byte();
}
};
return SecureRandom;
}());
export { SecureRandom };

@ -1,471 +0,0 @@
// Depends on jsbn.js and rng.js
// Version 1.1: support utf-8 encoding in pkcs1pad2
// convert a (hex) string to a bignum object
import { BigInteger, nbi, parseBigInt } from "./jsbn";
import { SecureRandom } from "./rng";
// function linebrk(s,n) {
// var ret = "";
// var i = 0;
// while(i + n < s.length) {
// ret += s.substring(i,i+n) + "\n";
// i += n;
// }
// return ret + s.substring(i,s.length);
// }
// function byte2Hex(b) {
// if(b < 0x10)
// return "0" + b.toString(16);
// else
// return b.toString(16);
// }
function pkcs1pad1(s, n) {
if (n < s.length + 22) {
console.error("Message too long for RSA");
return null;
}
var len = n - s.length - 6;
var filler = "";
for (var f = 0; f < len; f += 2) {
filler += "ff";
}
var m = "0001" + filler + "00" + s;
return parseBigInt(m, 16);
}
// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
function pkcs1pad2(s, n) {
if (n < s.length + 11) { // TODO: fix for utf-8
console.error("Message too long for RSA");
return null;
}
var ba = [];
var i = s.length - 1;
while (i >= 0 && n > 0) {
var c = s.charCodeAt(i--);
if (c < 128) { // encode using utf-8
ba[--n] = c;
}
else if ((c > 127) && (c < 2048)) {
ba[--n] = (c & 63) | 128;
ba[--n] = (c >> 6) | 192;
}
else {
ba[--n] = (c & 63) | 128;
ba[--n] = ((c >> 6) & 63) | 128;
ba[--n] = (c >> 12) | 224;
}
}
ba[--n] = 0;
var rng = new SecureRandom();
var x = [];
while (n > 2) { // random non-zero pad
x[0] = 0;
while (x[0] == 0) {
rng.nextBytes(x);
}
ba[--n] = x[0];
}
ba[--n] = 2;
ba[--n] = 0;
return new BigInteger(ba);
}
// "empty" RSA key constructor
var RSAKey = /** @class */ (function () {
function RSAKey() {
this.n = null;
this.e = 0;
this.d = null;
this.p = null;
this.q = null;
this.dmp1 = null;
this.dmq1 = null;
this.coeff = null;
}
//#region PROTECTED
// protected
// RSAKey.prototype.doPublic = RSADoPublic;
// Perform raw public operation on "x": return x^e (mod n)
RSAKey.prototype.doPublic = function (x) {
return x.modPowInt(this.e, this.n);
};
// RSAKey.prototype.doPrivate = RSADoPrivate;
// Perform raw private operation on "x": return x^d (mod n)
RSAKey.prototype.doPrivate = function (x) {
if (this.p == null || this.q == null) {
return x.modPow(this.d, this.n);
}
// TODO: re-calculate any missing CRT params
var xp = x.mod(this.p).modPow(this.dmp1, this.p);
var xq = x.mod(this.q).modPow(this.dmq1, this.q);
while (xp.compareTo(xq) < 0) {
xp = xp.add(this.p);
}
return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq);
};
//#endregion PROTECTED
//#region PUBLIC
// RSAKey.prototype.setPublic = RSASetPublic;
// Set the public key fields N and e from hex strings
RSAKey.prototype.setPublic = function (N, E) {
if (N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N, 16);
this.e = parseInt(E, 16);
}
else {
console.error("Invalid RSA public key");
}
};
// RSAKey.prototype.encrypt = RSAEncrypt;
// Return the PKCS#1 RSA encryption of "text" as an even-length hex string
RSAKey.prototype.encrypt = function (text) {
var maxLength = (this.n.bitLength() + 7) >> 3;
var m = pkcs1pad2(text, maxLength);
if (m == null) {
return null;
}
var c = this.doPublic(m);
if (c == null) {
return null;
}
var h = c.toString(16);
var length = h.length;
// fix zero before result
for (var i = 0; i < maxLength * 2 - length; i++) {
h = "0" + h;
}
return h;
};
// RSAKey.prototype.setPrivate = RSASetPrivate;
// Set the private key fields N, e, and d from hex strings
RSAKey.prototype.setPrivate = function (N, E, D) {
if (N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N, 16);
this.e = parseInt(E, 16);
this.d = parseBigInt(D, 16);
}
else {
console.error("Invalid RSA private key");
}
};
// RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
// Set the private key fields N, e, d and CRT params from hex strings
RSAKey.prototype.setPrivateEx = function (N, E, D, P, Q, DP, DQ, C) {
if (N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N, 16);
this.e = parseInt(E, 16);
this.d = parseBigInt(D, 16);
this.p = parseBigInt(P, 16);
this.q = parseBigInt(Q, 16);
this.dmp1 = parseBigInt(DP, 16);
this.dmq1 = parseBigInt(DQ, 16);
this.coeff = parseBigInt(C, 16);
}
else {
console.error("Invalid RSA private key");
}
};
// RSAKey.prototype.generate = RSAGenerate;
// Generate a new random private key B bits long, using public expt E
RSAKey.prototype.generate = function (B, E) {
var rng = new SecureRandom();
var qs = B >> 1;
this.e = parseInt(E, 16);
var ee = new BigInteger(E, 16);
for (;;) {
for (;;) {
this.p = new BigInteger(B - qs, 1, rng);
if (this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) {
break;
}
}
for (;;) {
this.q = new BigInteger(qs, 1, rng);
if (this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) {
break;
}
}
if (this.p.compareTo(this.q) <= 0) {
var t = this.p;
this.p = this.q;
this.q = t;
}
var p1 = this.p.subtract(BigInteger.ONE);
var q1 = this.q.subtract(BigInteger.ONE);
var phi = p1.multiply(q1);
if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
this.n = this.p.multiply(this.q);
this.d = ee.modInverse(phi);
this.dmp1 = this.d.mod(p1);
this.dmq1 = this.d.mod(q1);
this.coeff = this.q.modInverse(this.p);
break;
}
}
};
// RSAKey.prototype.decrypt = RSADecrypt;
// Return the PKCS#1 RSA decryption of "ctext".
// "ctext" is an even-length hex string and the output is a plain string.
RSAKey.prototype.decrypt = function (ctext) {
var c = parseBigInt(ctext, 16);
var m = this.doPrivate(c);
if (m == null) {
return null;
}
return pkcs1unpad2(m, (this.n.bitLength() + 7) >> 3);
};
// Generate a new random private key B bits long, using public expt E
RSAKey.prototype.generateAsync = function (B, E, callback) {
var rng = new SecureRandom();
var qs = B >> 1;
this.e = parseInt(E, 16);
var ee = new BigInteger(E, 16);
var rsa = this;
// These functions have non-descript names because they were originally for(;;) loops.
// I don't know about cryptography to give them better names than loop1-4.
var loop1 = function () {
var loop4 = function () {
if (rsa.p.compareTo(rsa.q) <= 0) {
var t = rsa.p;
rsa.p = rsa.q;
rsa.q = t;
}
var p1 = rsa.p.subtract(BigInteger.ONE);
var q1 = rsa.q.subtract(BigInteger.ONE);
var phi = p1.multiply(q1);
if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
rsa.n = rsa.p.multiply(rsa.q);
rsa.d = ee.modInverse(phi);
rsa.dmp1 = rsa.d.mod(p1);
rsa.dmq1 = rsa.d.mod(q1);
rsa.coeff = rsa.q.modInverse(rsa.p);
setTimeout(function () { callback(); }, 0); // escape
}
else {
setTimeout(loop1, 0);
}
};
var loop3 = function () {
rsa.q = nbi();
rsa.q.fromNumberAsync(qs, 1, rng, function () {
rsa.q.subtract(BigInteger.ONE).gcda(ee, function (r) {
if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
setTimeout(loop4, 0);
}
else {
setTimeout(loop3, 0);
}
});
});
};
var loop2 = function () {
rsa.p = nbi();
rsa.p.fromNumberAsync(B - qs, 1, rng, function () {
rsa.p.subtract(BigInteger.ONE).gcda(ee, function (r) {
if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
setTimeout(loop3, 0);
}
else {
setTimeout(loop2, 0);
}
});
});
};
setTimeout(loop2, 0);
};
setTimeout(loop1, 0);
};
RSAKey.prototype.sign = function (text, digestMethod, digestName) {
var header = getDigestHeader(digestName);
var digest = header + digestMethod(text).toString();
var m = pkcs1pad1(digest, this.n.bitLength() / 4);
if (m == null) {
return null;
}
var c = this.doPrivate(m);
if (c == null) {
return null;
}
var h = c.toString(16);
if ((h.length & 1) == 0) {
return h;
}
else {
return "0" + h;
}
};
RSAKey.prototype.verify = function (text, signature, digestMethod) {
var c = parseBigInt(signature, 16);
var m = this.doPublic(c);
if (m == null) {
return null;
}
var unpadded = m.toString(16).replace(/^1f+00/, "");
var digest = removeDigestHeader(unpadded);
return digest == digestMethod(text).toString();
};
RSAKey.prototype.encryptLong = function (text) {
var _this = this;
var res = '';
var maxLen = ((this.n.bitLength() + 7) >> 3) - 11;
var textArr = this.setSplitChn(text, maxLen);
textArr.forEach(function (v) {
res += _this.encrypt(v);
});
return res;
};
RSAKey.prototype.decryptLong = function (ctext) {
var res = '';
var maxLen = (this.n.bitLength() + 7) >> 3;
var splitMaxLen = maxLen * 2;
if (ctext.length > splitMaxLen) {
var ctextArr = ctext.match(new RegExp('.{1,' + splitMaxLen + '}', 'g')) || [];
var mArr = [];
for (var i = 0; i < ctextArr.length; i++) {
var c = parseBigInt(ctextArr[i], 16);
var m = this.doPrivate(c);
if (m == null) {
return null;
}
mArr.push(m);
}
res = pkcs1unpad2Long(mArr, maxLen);
}
else {
res = this.decrypt(ctext);
}
return res;
};
RSAKey.prototype.setSplitChn = function (str, maxLen, res) {
if (res === void 0) { res = []; }
var arr = str.split('');
var len = 0;
for (var i = 0; i < arr.length; i++) {
var charCode = arr[i].charCodeAt(0);
if (charCode <= 0x007f) {
len += 1;
}
else if (charCode <= 0x07ff) {
len += 2;
}
else if (charCode <= 0xffff) {
len += 3;
}
else {
len += 4;
}
if (len > maxLen) {
var currentStr = str.substring(0, i);
res.push(currentStr);
return this.setSplitChn(str.substring(i), maxLen, res);
}
}
res.push(str);
return res;
};
return RSAKey;
}());
export { RSAKey };
// Undo PKCS#1 (type 2, random) padding and, if valid, return the plaintext
function pkcs1unpad2(d, n) {
var b = d.toByteArray();
var i = 0;
while (i < b.length && b[i] == 0) {
++i;
}
if (b.length - i != n - 1 || b[i] != 2) {
return null;
}
++i;
while (b[i] != 0) {
if (++i >= b.length) {
return null;
}
}
var ret = "";
while (++i < b.length) {
var c = b[i] & 255;
if (c < 128) { // utf-8 decode
ret += String.fromCharCode(c);
}
else if ((c > 191) && (c < 224)) {
ret += String.fromCharCode(((c & 31) << 6) | (b[i + 1] & 63));
++i;
}
else {
ret += String.fromCharCode(((c & 15) << 12) | ((b[i + 1] & 63) << 6) | (b[i + 2] & 63));
i += 2;
}
}
return ret;
}
function pkcs1unpad2Long(dArr, n) {
var bArr = [];
for (var j = 0; j < dArr.length; j++) {
var d = dArr[j];
var b_1 = d.toByteArray();
var i_1 = 0;
while (i_1 < b_1.length && b_1[i_1] == 0) {
++i_1;
}
if (b_1.length - i_1 != n - 1 || b_1[i_1] != 2) {
return null;
}
++i_1;
while (b_1[i_1] != 0) {
if (++i_1 >= b_1.length) {
return null;
}
}
bArr = bArr.concat(b_1.slice(i_1 + 1));
}
var b = bArr;
var i = -1;
var ret = "";
while (++i < b.length) {
var c = b[i] & 255;
if (c < 128) { // utf-8 decode
ret += String.fromCharCode(c);
}
else if ((c > 191) && (c < 224)) {
ret += String.fromCharCode(((c & 31) << 6) | (b[i + 1] & 63));
++i;
}
else {
ret += String.fromCharCode(((c & 15) << 12) | ((b[i + 1] & 63) << 6) | (b[i + 2] & 63));
i += 2;
}
}
return ret;
}
// https://tools.ietf.org/html/rfc3447#page-43
var DIGEST_HEADERS = {
md2: "3020300c06082a864886f70d020205000410",
md5: "3020300c06082a864886f70d020505000410",
sha1: "3021300906052b0e03021a05000414",
sha224: "302d300d06096086480165030402040500041c",
sha256: "3031300d060960864801650304020105000420",
sha384: "3041300d060960864801650304020205000430",
sha512: "3051300d060960864801650304020305000440",
ripemd160: "3021300906052b2403020105000414"
};
function getDigestHeader(name) {
return DIGEST_HEADERS[name] || "";
}
function removeDigestHeader(str) {
for (var name_1 in DIGEST_HEADERS) {
if (DIGEST_HEADERS.hasOwnProperty(name_1)) {
var header = DIGEST_HEADERS[name_1];
var len = header.length;
if (str.substr(0, len) == header) {
return str.substr(len);
}
}
}
return str;
}
// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
// function RSAEncryptB64(text) {
// var h = this.encrypt(text);
// if(h) return hex2b64(h); else return null;
// }
// public
// RSAKey.prototype.encrypt_b64 = RSAEncryptB64;

@ -1,58 +0,0 @@
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
export function int2char(n) {
return BI_RM.charAt(n);
}
//#region BIT_OPERATIONS
// (public) this & a
export function op_and(x, y) {
return x & y;
}
// (public) this | a
export function op_or(x, y) {
return x | y;
}
// (public) this ^ a
export function op_xor(x, y) {
return x ^ y;
}
// (public) this & ~a
export function op_andnot(x, y) {
return x & ~y;
}
// return index of lowest 1-bit in x, x < 2^31
export function lbit(x) {
if (x == 0) {
return -1;
}
var r = 0;
if ((x & 0xffff) == 0) {
x >>= 16;
r += 16;
}
if ((x & 0xff) == 0) {
x >>= 8;
r += 8;
}
if ((x & 0xf) == 0) {
x >>= 4;
r += 4;
}
if ((x & 3) == 0) {
x >>= 2;
r += 2;
}
if ((x & 1) == 0) {
++r;
}
return r;
}
// return number of 1 bits in x
export function cbit(x) {
var r = 0;
while (x != 0) {
x &= x - 1;
++r;
}
return r;
}
//#endregion BIT_OPERATIONS

File diff suppressed because it is too large Load Diff

@ -1,69 +0,0 @@
/*!
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.9.0
*/
export var YAHOO = {};
YAHOO.lang = {
/**
* Utility to set up the prototype, constructor and superclass properties to
* support an inheritance strategy that can chain constructors and methods.
* Static members will not be inherited.
*
* @method extend
* @static
* @param {Function} subc the object to modify
* @param {Function} superc the object to inherit
* @param {Object} overrides additional properties/methods to add to the
* subclass prototype. These will override the
* matching items obtained from the superclass
* if present.
*/
extend: function (subc, superc, overrides) {
if (!superc || !subc) {
throw new Error("YAHOO.lang.extend failed, please check that " +
"all dependencies are included.");
}
var F = function () { };
F.prototype = superc.prototype;
subc.prototype = new F();
subc.prototype.constructor = subc;
subc.superclass = superc.prototype;
if (superc.prototype.constructor == Object.prototype.constructor) {
superc.prototype.constructor = superc;
}
if (overrides) {
var i;
for (i in overrides) {
subc.prototype[i] = overrides[i];
}
/*
* IE will not enumerate native functions in a derived object even if the
* function was overridden. This is a workaround for specific functions
* we care about on the Object prototype.
* @property _IEEnumFix
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @static
* @private
*/
var _IEEnumFix = function () { }, ADD = ["toString", "valueOf"];
try {
if (/MSIE/.test(navigator.userAgent)) {
_IEEnumFix = function (r, s) {
for (i = 0; i < ADD.length; i = i + 1) {
var fname = ADD[i], f = s[fname];
if (typeof f === 'function' && f != Object.prototype[fname]) {
r[fname] = f;
}
}
};
}
}
catch (ex) { }
;
_IEEnumFix(subc.prototype, overrides);
}
}
};

@ -1,3 +0,0 @@
{
"version": "3.2.1"
}

@ -1,28 +0,0 @@
{
"name": "wxmp-rsa",
"version": "2.1.0",
"description": "兼容小程序环境的rsa加解密库支持超长文本和中文字符",
"author": "neohan",
"main": "dist/index.js",
"scripts": {
"build": "tsc"
},
"keywords": [
"wxmp",
"rsa",
"jsencrypt",
"crypt",
"miniprogram"
],
"license": "MIT",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git://github.com/neohan666/wxmp-rsa.git"
},
"devDependencies": {
"typescript": "^4.3.5"
}
}

20
package-lock.json generated

@ -9,10 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"tdesign-miniprogram": "^1.1.1",
"weapp-qrcode-canvas-2d": "^1.1.2",
"wxml2canvas": "^1.0.1",
"wxmp-rsa": "^2.1.0"
"tdesign-miniprogram": "^1.1.1"
}
},
"node_modules/dayjs": {
@ -27,21 +24,6 @@
"dependencies": {
"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/wxml2canvas": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/wxml2canvas/-/wxml2canvas-1.0.1.tgz",
"integrity": "sha512-AdWvxgTjJtW/m6Cki1cwGO0HOERKU8O9V3RcCz8UyqJbrPF7e8Nv27/epYiIs64HlbPTKWTLl7ECjQi6UVducA=="
},
"node_modules/wxmp-rsa": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/wxmp-rsa/-/wxmp-rsa-2.1.0.tgz",
"integrity": "sha512-VbWMJ+vf8t7G93sjkqjCn5yGy/Si3M8uD6OFebqjJWJ1R0WCyle7X6SNia7WWG6Qe1F2/OWxhbcSGA6ebUBwIA=="
}
}
}

@ -9,9 +9,6 @@
"author": "lsl",
"license": "ISC",
"dependencies": {
"tdesign-miniprogram": "^1.1.1",
"weapp-qrcode-canvas-2d": "^1.1.2",
"wxml2canvas": "^1.0.1",
"wxmp-rsa": "^2.1.0"
"tdesign-miniprogram": "^1.1.1"
}
}

@ -1,338 +1,18 @@
// pages/home/jl/index.js
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
import Toast from 'tdesign-miniprogram/toast/index';
Page({
/**
* 页面的初始数据
*/
data: {
singleShow:false,
loverShow:false,
xingxiangtu:{},
userInfo:{},
loverInfo:{},
hours:0,
minute:0,
minutes:0,
pickerValue: [0, 0],
prayTime:0, //祈祷时间
prayTimeStr: '选择祈祷时长' ,
prayerContent:'', //祈祷内容
showSexLogo:false,//不展示形象修改按钮
showPray:false, //显示祈祷弹层
showIsPray:false, //显示取消祈祷弹层
showEnergy:false, //显示赠送能量弹层
showEnergyToast:false, //显示赠送能量提示
showEnergySuccess:false, //赠送成功提示
showEnergyFail:false, //赠送成功提示
showInject:false, //显示注入能量
showInEnergy:false, //显示能量注入中
showScsEnergy:false, //显示注册成功提示
showTiming:false //显示祈祷时间弹层
},
ShowOrNotLogoS(){
this.setData({singleShow:!this.data.singleShow})
},
ShowOrNotLogoL(){
this.setData({loverShow:!this.data.loverShow})
},
doSetXxtAnimal(){
this.doSetXxt('animal')
},
doSetXxtMale(){
this.doSetXxt('male')
},
showTiming(){this.setData({showTiming : !this.data.showTiming})},
doSetXxtFemale(){
this.doSetXxt('female')
},
doSetXxt(e){
req.patchRequest('/api/user/curt',{spriteType:e}).then((res)=>{
if(res.data.code==200){
}
this.getUserInfo()
}).catch((err)=>{
console.log(err);
})
},
doSetXxtAnimalS(){
this.doSetXxtS('animal')
},
doSetXxtMaleS(){
this.doSetXxtS('male')
},
doSetXxtFemaleS(){
this.doSetXxtS('female')
},
doSetXxtS(e){
req.patchRequest('/api/user/curt/lover',{spriteType:e}).then((res)=>{
if(res.data.code==200){
}
this.getUserLoverInfo()
}).catch((err)=>{
console.log(err);
})
},
getXxObj(){/**获取形象对应的图片 */
req.getRequest('/api/dict/value/horoscope-resource',{}).then((res)=>{
if(res.data.code==200){
console.log(res.data.data);
const horoscopes = res.data.data
const type = this.data.userInfo.horoscope.name
this.setData({xingxiangtu: horoscopes[type].sprite})
}
}).catch((err)=>{
console.log(err);
})
},
ShowOrNotLogo(){
this.setData({showSexLogo:!this.data.showSexLogo})
},
getUserLoverInfo(){
req.getRequest('/api/user/curt/lover',{}).then((res)=>{
if(res.data.code==200){
this.setData({loverInfo:res.data.data})
}
}).catch((err)=>{
console.log(err);
})
},
getTextValue(e){
console.log(e.detail.value);
this.setData({
prayerContent:e.detail.value
})
console.log(this.data.prayerContent);
},
openEnergy(){
this.setData({
showEnergy:!this.data.showEnergy
})
},
cancelEnergy(){
this.setData({
showEnergy:!this.data.showEnergy
})
},
cancelEnergyToast(){
this.setData({
showEnergyToast:false,
showEnergyFail:false
})
},
openPray(){
if(this.data.userInfo.prayerEndTime){
this.setData({
showIsPray:!this.data.showIsPray
})
}else{
this.setData({
showPray:!this.data.showPray,
prayerContent:''
})
}
this.setData({showTiming: false})
},
onPickerChange(e){
console.log(e.detail.value);
const time = e.detail.value[0] + '小时' + e.detail.value[1] + '分钟'
this.setData({prayTimeStr: time})
if(e.detail.value[0] === this.data.hours){
this.setData({
minutes:this.data.minute
})
}else{
this.setData({
minutes:59
})
}
this.setData({
pickerValue: e.detail.value
})
},
openInject(){
this.setData({
showInject:!this.data.showInject
})
},
// 注入晶石
btnInject(){
// 判断是否有能量
if (this.data.userInfo.crystallineEnergy) {
this.setData({
showInject:!this.data.showInject,
showInEnergy:!this.data.showInEnergy
})
req.patchRequest('/api/user/curt/inject-energy-to-pendant',{}).then((res)=>{
console.log('能量注入成功');
})
setTimeout(()=>{
this.setData({
showInEnergy:!this.data.showInEnergy,
showScsEnergy:true
})
this.getUserInfo()
},2000)
}else{
this.setData({showInject: false})
Toast({
context: this,
selector: '#t-toast',
message: '能量不足',
});
}
},
// 关闭注入弹层
closeEnergy(){this.setData({showScsEnergy:false})},
getUserInfo(){
req.getRequest('/api/user/curt',{}).then((res)=>{
if(res.data.code===200){
// 获取已经祈祷时间
const now = new Date();
const startTime = new Date(res.data.data.prayerStartTime)
const diff = now.getTime() - startTime.getTime();
const hour = Math.floor(diff / (1000 * 60 * 60));
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
const formattedTime = `${hour.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
// 获取结束祈祷返回能量
const nowTime = new Date();
const endTime = new Date(res.data.data.prayerEndTime)
const TimeDiff = endTime.getTime() - nowTime.getTime();
this.setData({
prayTime: formattedTime,
energy: Math.floor(TimeDiff / 360000)
})
const pendantEnergy = res.data.data.crystallineEnergy
const hours = Math.floor(pendantEnergy * 6 / 60); // 计算小时数
const minute = pendantEnergy * 6 - hours * 60
if(hours>0){
this.setData({
minutes:59
})
}
if(hours<=0){
this.setData({
minutes:minute
})
}
this.setData({
userInfo:res.data.data,
hours:hours,
minute:minute,
pendantEnergy:pendantEnergy
})
this.getXxObj()
// console.log(this.data.userInfo);
}
}).catch((err)=>{
console.log(err);
})
},
go2Jlai(){
wx.navigateTo({
url: '/pages/home/jl/jlai/jlai'
})
},
btnOK(){
const prayerEnergy = (this.data.pickerValue[0]*60 + this.data.pickerValue[1])/6
if(this.data.userInfo.crystallineEnergy < 1){
return Toast({
context: this,
selector: '#t-toast',
message: '能量不足',
});
}
if(this.data.prayerContent === ''){
return Toast({
context: this,
selector: '#t-toast',
message: '祈祷内容不能为空',
});
}
if(this.data.prayerContent.length > 11){
return Toast({
context: this,
selector: '#t-toast',
message: '祈祷内容不能超过11个字',
});
}
req.patchRequest('/api/user/curt/prayer',{
prayerContent:this.data.prayerContent,
prayerEnergy:prayerEnergy
}).then((res) => {
if(res.data.code === 200){
Toast({
context: this,
selector: '#t-toast',
message: '祈祷成功',
});
}else{
Toast({
context: this,
selector: '#t-toast',
message: res.data.msg,
});
}
this.getUserInfo()
this.openPray()
}).catch((err) => {
console.log('祈祷失败',err);
})
this.setData({showTiming: false})
},
btnCancel(){
console.log('111');
req.patchRequest('/api/user/curt/prayer/stop',{}).then((res)=>{
Toast({
context: this,
selector: '#t-toast',
message: '已结束祈祷',
});
this.openPray()
this.getUserInfo()
})
},
btnShare(){
console.log('赠送能量');
req.patchRequest('/api/user/curt/give-crystalline-energy-to-lover',{}).then((res)=>{
console.log(res);
if(res.data.code === 200){
this.setData({
showEnergySuccess:!this.data.showEnergySuccess,
showEnergy:!this.data.showEnergy
})
this.getUserInfo()
this.getUserLoverInfo()
return setTimeout(()=>{
this.setData({
showEnergySuccess:!this.data.showEnergySuccess,
})
},2000)
}
this.setData({
showEnergy:!this.data.showEnergy,
showEnergyToast:!this.data.showEnergyToast,
toast:res.data.msg
})
}).catch((err)=>{
console.log('111');
this.setData({
showEnergyFail:!this.data.showEnergyFail,
showEnergy:!this.data.showEnergy
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getUserInfo()
this.getUserLoverInfo()
},
/**
@ -346,21 +26,21 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.getUserInfo()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
this.getUserInfo()
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
this.getUserInfo()
},
/**

@ -2,10 +2,6 @@
"usingComponents": {
"t-progress": "tdesign-miniprogram/progress/progress",
"t-popup": "tdesign-miniprogram/popup/popup",
"t-rate": "tdesign-miniprogram/rate/rate",
"t-image": "tdesign-miniprogram/image/image",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-toast": "tdesign-miniprogram/toast/toast",
"t-input": "tdesign-miniprogram/input/input"
"t-rate": "tdesign-miniprogram/rate/rate"
}
}

@ -1,281 +1,126 @@
<swiper class="call" bindtap="closeEnergy">
<swiper class="call">
  <swiper-item class="call1"><!--单人页面-->
<t-image class="tx" src="{{userInfo.avatar}}"></t-image>
<view class="txtext">{{userInfo.nick}}</view><!--头像名字-->
<view class="tx"></view><!--最上方头像栏-->
<view class="txtext">为七个字的头像</view><!--头像名字-->
<view class="gh"></view>
<div class="bkg3"></div><!--点点点,最底层背景图-->
<dic class="bkg1"></dic><!--黄色点背景图-->
<view class="gh"></view>
<view class="xxt" bindtap="ShowOrNotLogo">
<image src="{{xingxiangtu[userInfo.spriteType]}}"></image>
</view>
<view class="yan1" wx:if="{{showSexLogo}}" data-yan="animal" bindtap="doSetXxtAnimal"><!--动物形象-->
<view class="xxt"></view><!--形象图-->
<view class="yan1">
<view class="yan11"></view>
</view>
<view class="yan2" wx:if="{{showSexLogo}}" data-yan="male" bindtap="doSetXxtMale"><!--男性形象-->
<view class="yan2">
<view class="yan12"></view>
</view>
<view class="yan3" wx:if="{{showSexLogo}}" data-yan="female" bindtap="doSetXxtFemale"><!--女性形象-->
<view class="yan3">
<view class="yan13"></view>
</view>
<view class="dcleft">
<t-progress class="dcleft1" theme="circle" percentage="{{userInfo.crystallineEnergy}}" color="#f76229" label="" t-class-bar="dcleft1" />
<t-progress class="dcleft1" theme="circle" percentage="70" color="#f76229" label="" t-class-bar="dcleft1" />
<view class="dcbs"></view>
</view><!--下方左侧块-->
<!--下方左侧块-->
<t-progress class="dchx" percentage="{{userInfo.crystallineEnergy}}" trackColor="#EAC9FF" color="#f76229" label=""/><!--中间进度条-->
<view class="dchxtxt">{{userInfo.crystallineEnergy}}%</view>
<t-progress class="dcright1" theme="circle" percentage="{{userInfo.pendantEnergy}}" color="#FBB093" label="" t-class-bar="dcleft1" />
<t-progress class="dchx" percentage="70" trackColor="#EAC9FF" color="#f76229" label="" /><!--中间进度条-->
<view class="dchxtxt">70%</view>
<view class="dcright">
<view class="dcrightwjx" bindtap="openInject"></view><!--下方右侧五角星-->
<view class="dcrightwjx"></view><!--下方右侧五角星-->
</view><!--下方左侧块-->
<!-- 能量已满提示 -->
<view class="energy-full" wx:if="{{userInfo.crystallineEnergy===100}}">
<view>能量已经集满啦!</view>
<view>可以注入到水晶中</view>
<view>增强运势哦!</view>
</view>
<!-- 能量注入成功提示 -->
<view class="energy-complete" wx:if="{{showScsEnergy}}">
<view>能量已注入100%</view>
<view>守护时间为08小时00分</view>
</view>
<view class="dclefttxt">水晶能量</view><!--下方左侧块-->
<view class="dcrighttxt">能量注入</view><!--下方左侧块-->
</swiper-item>
  <swiper-item class="call1" wx:if='{{userInfo.loverId}}'><!--情侣页面-->
<!-- 未祈祷页面 -->
<view wx:if="{{ !userInfo.prayerEndTime }}">
<t-image class="txl" src="{{userInfo.avatar}}"></t-image>
<view class="txtextl">{{userInfo.nick}}</view><!--头像名字1-->
<view class="jiuchan"></view>
<t-image class="txr" shape="circle" src="{{loverInfo.avatar}}"></t-image><!--头像2-->
<view class="txtextr">{{loverInfo.nick}}</view><!--头像名字2-->
</view>
<!-- 有祈祷页面 -->
<view wx:else>
<t-image class="txl txl-qd" src="{{userInfo.avatar}}"></t-image>
<view class="txtextl-qd">
<t-icon name="chevron-right-double" size="24" color="#DE868F"/>
<view class="text-qd">
<view class="top">{{ userInfo.prayerContent }}</view>
<view>你已为Ta祈祷 {{prayTime}}</view>
</view>
<t-icon name="chevron-right-double" size="24" color="#DE868F"/>
</view>
<t-image class="txr txr-qd" shape="circle" src="{{loverInfo.avatar}}"></t-image><!--头像2-->
</view>
  <swiper-item class="call1"><!--情侣页面-->
<view class="txl"></view><!--头像1-->
<view class="txtextl">七个字的头像</view><!--头像名字1-->
<view class="jiuchan"></view>
<view class="txr"></view><!--头像2-->
<view class="txtextr">为七个字的头像</view><!--头像名字2-->
<dic class="bkg1"></dic><!--黄色点背景图-->
<div class="bkg3"></div><!--点点点,最底层背景图-->
<view class="xxtl" bindtap="ShowOrNotLogoS">
<image src="{{xingxiangtu[userInfo.spriteType]}}"></image><!--左侧人形象-->
</view>
<view class="xxtr" bindtap="ShowOrNotLogoL">
<image src="{{xingxiangtu[loverInfo.spriteType]}}"></image><!--右侧人形象-->
</view>
<view class="xxtl"></view><!--左侧人形象-->
<view class="xxtr"></view><!--右侧人形象-->
<view class="gh"></view><!--下方光环-->
<view class="yanql1" bindtap="doSetXxtFemale" wx:if="{{singleShow}}"><!--左侧女性按钮-->
<view class="yanql1">
<view class="yan13"></view>
</view>
<view class="yanql2" bindtap="doSetXxtAnimal" wx:if="{{singleShow}}"><!--左侧动物设置图标-->
<view class="yanql2">
<view class="yan11"></view>
</view>
<view class="yanql3" ></view>
<view class="yanql4" bindtap="doSetXxtFemaleS" wx:if="{{loverShow}}"><!--右侧女性图标设置-->
<view class="yanql3"></view>
<view class="yanql4">
<view class="yan13"></view>
</view>
<view class="yanql5" bindtap="doSetXxtAnimalS" wx:if="{{loverShow}}"><!--右侧动物图标设置-->
<view class="yanql5">
<view class="yan11"></view>
</view>
<view class="yanql6"></view>
<view class="yan1" bindtap="doSetXxtMale" wx:if="{{singleShow}}"><!--设置个人男性图标-->
<view class="yan1">
<view class="yan12"></view>
</view>
<view class="yan3" wx:if="{{loverShow}}" bindtap="doSetXxtMaleS"><!--设置右边男性图标-->
<view class="yan3">
<view class="yan12"></view>
</view>
<view class="dcleft">
<t-progress class="dcleft1" theme="circle" percentage="{{userInfo.crystallineEnergy}}" color="#f76229" label="" t-class-bar="dcleft1" />
<t-progress class="dcleft1" theme="circle" percentage="70" color="#f76229" label="" t-class-bar="dcleft1" />
<view class="dcbs"></view>
</view><!--下方左侧块-->
<!--下方左侧块-->
<view class="lovepic"></view>
<view class="dchxtxtql" bindtap="openPray" wx:if="{{ !userInfo.prayerEndTime }}">祈祷</view>
<view class="dchxtxtql" bindtap="openPray" wx:else>结束祈祷</view>
<view class="dchxtxtql">祈祷</view>
<view class="dcrightql">
<t-progress class="dcleft1" theme="circle" percentage="{{loverInfo.crystallineEnergy}}" color="#00A7FF" label="" t-class-bar="dcleft1" />
<view class="dcrbs" bindtap="openEnergy"></view>
<t-progress class="dcleft1" theme="circle" percentage="70" color="#00A7FF" label="" t-class-bar="dcleft1" />
<view class="dcrbs"></view>
</view><!--下方左侧块-->
<view class="dclefttxt">{{userInfo.crystallineEnergy}}%</view><!--下方左侧块-->
<view class="dcrighttxt">{{loverInfo.crystallineEnergy}}%</view><!--下方左侧块-->
<view class="dclefttxt">70%</view><!--下方左侧块-->
<view class="dcrighttxt">79%</view><!--下方左侧块-->
</swiper-item>
<swiper-item class="call1" wx:if='{{userInfo.loverId}}'><!--对方个人页面-->
<t-image class="tx" shape="circle" src="{{loverInfo.avatar}}"></t-image>
<view class="txtext">{{loverInfo.nick}}</view><!--头像名字-->
<swiper-item class="call1"><!--对方个人页面-->
<view class="tx"></view><!--最上方头像栏-->
<view class="txtext">为七个字的头像</view><!--头像名字-->
<view class="gh"></view>
<div class="bkg3"></div><!--点点点,最底层背景图-->
<dic class="bkg1"></dic><!--黄色点背景图-->
<view class="gh"></view>
<view class="xxtq" bindtap="ShowOrNotLogo">
<image src="{{xingxiangtu[loverInfo.spriteType]}}"></image> <!--形象图-->
</view>
<view class="xxtq"></view><!--形象图-->
<div class="k1">{{loverInfo.horoscope.number}}</div><!--幸运数字-->
<div class="k1">
</div>
<div class="ktext1">幸运数字</div>
<div class="ktext2">Ta的运势</div>
<div class="ktext3">幸运颜色</div>
<div class="k2" bindtap="ToastDialog">
<div class="k11"></div>
</div>
<div class="k3">{{loverInfo.horoscope.color}}</div>
<div class="k3"></div>
<t-popup class="ttpopup" visible="{{visible}}" bind:visible-change="onVisibleChange" placement="{{'center'}}">
<view class="ttpopup">
<view class="tips">Tips记得提醒ta哦</view>
<view class="ztys">{{loverInfo.horoscope.summary}}</view>
<view class="ztys"></view>
<view class="rjkzs"><t-rate value="3" icon="{{ ['star-filled', 'star'] }}" color="#FFFF00" /></view>
<view class="jkzs"></view>
<view class="aqzs"></view>
<view class="raqzs"><t-rate value="3" icon="{{ ['star-filled', 'star'] }}" color="#FFFF00" /></view>
<view class="cyzs"></view>
<view class="rcyzs"><t-rate value="3" icon="{{ ['star-filled', 'star'] }}" color="#FFFF00" /></view>
<view class="ysfgx"></view>
</view>
</t-popup>
</swiper-item>
</swiper>
<!-- 未祈祷弹层 -->
<view class="pray" wx:if="{{showPray}}">
<view class="dialog">
<view class="dialog-item">
<text>祈祷内容</text>
<textarea model:value="{{prayerContent}}" placeholder="请写下你要祈祷的内容" bindblur="getTextValue"></textarea>
</view>
<view class="dialog-item">
<text>祈祷时长</text>
<view class="duration" bindtap="showTiming">{{prayTimeStr}}<t-icon name="chevron-down" size="48rpx"/></view>
</view>
<view class="dialog-btn">
<button bindtap="openPray">取消</button>
<button bindtap="btnOK">发起祈祷</button>
</view>
</view>
</view>
<!-- 祈祷时间弹层 -->
<t-popup placement="bottom" visible="{{showTiming}}" showOverlay="{{false}}">
<view class="timing">
<view class="timing-title">你还有{{userInfo.crystallineEnergy}}%水晶能量,可为对方祈祷{{hours}}小时{{minute}}分</view>
<t-toast id="t-toast" />
<view class="picker">
<picker-view value="{{pickerValue}}" bindchange="onPickerChange" indicator-class="active">
<picker-view-column>
<view wx:for="{{hours + 1}}" wx:key="item" class="picker-item"> {{ item }} </view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{minutes + 1}}" wx:key="item" class="picker-item"> {{ item }} </view>
</picker-view-column>
</picker-view>
</view>
</view>
</t-popup>
<!-- 已祈祷弹层 -->
<view class="pray" wx:if="{{showIsPray}}">
<view class="dialog">
<t-toast id="t-toast" />
<view class="dialog-text">
<view>要结束祈祷吗?</view>
<view>将返还{{energy}}%星座能量</view>
<view>溢出能量将消失</view>
</view>
<view class="dialog-btn">
<button bindtap="openPray">返回</button>
<button bindtap="btnCancel">结束</button>
</view>
</view>
</view>
<!-- 赠送能量弹层 -->
<view class="pray" wx:if="{{showEnergy}}">
<view class="dialog">
<t-toast id="t-toast" />
<view class="dialog-text">
<view>你要将能量共享给对方吗?</view>
<view>溢出能量将保留</view>
</view>
<view class="dialog-btn">
<button bindtap="cancelEnergy">取消</button>
<button bindtap="btnShare">共享</button>
</view>
</view>
</view>
<!-- 赠送能量提示 -->
<view class="pray" wx:if="{{showEnergyToast}}">
<view class="dialog">
<t-toast id="t-toast" />
<view class="dialog-text">
<view>{{toast}}</view>
<view>无法进行共享哦!</view>
</view>
<view class="dialog-btn">
<button bindtap="cancelEnergyToast">好的</button>
</view>
</view>
</view>
<!-- 赠送能量成功 -->
<view class="energy-success" wx:if="{{showEnergySuccess}}">
<view>谢谢你送我的能量!</view>
<view>真是太好了~</view>
</view>
<!-- 赠送能量失败 -->
<view class="pray" wx:if="{{showEnergyFail}}">
<view class="dialog">
<t-toast id="t-toast" />
<view class="dialog-text">
<view>赠送能量失败啦~</view>
<view>是不是网络出问题了?</view>
</view>
<view class="dialog-btn">
<button bindtap="cancelEnergyToast">好的</button>
</view>
</view>
</view>
<!-- 能量注入 -->
<t-toast id="t-toast" />
<view class="pray" wx:if="{{showInject}}">
<view class="dialog">
<view class="dialog-text">
<view>你要将能量注入到晶石吗?</view>
<view>晶石将开启守护计时</view>
</view>
<view class="dialog-btn">
<button bindtap="openInject">取消</button>
<button bindtap="btnInject">开始注入</button>
</view>
</view>
</view>
<!-- 能量注入中 -->
<view class="in-energy" wx:if="{{showInEnergy}}">
<t-image src="/images/hourglass.gif"/>
<view>能量注入中……</view>
</view>
<div class="jltxt" bindtap="go2Jlai">精灵 AI</div>

@ -1,8 +1,4 @@
/* pages/home/jl/index.wxss */
page {
height: 100%;
}
.tx{
position:absolute;
width:72rpx;
@ -11,7 +7,7 @@ page {
margin-left:249.33rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/tx.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/tx.png);
}
.txtext{
@ -35,6 +31,7 @@ page {
position:absolute;
}
.t-progress__canvas--circle{
width:125.67rpx!important;
height:125.67rpx !important;
@ -42,13 +39,12 @@ page {
.dcright{
position:absolute;
width: 100rpx;
height: 100rpx;
margin-left: 528rpx;
margin-top: 1240rpx;
/* background-color: #f76229; */
width:116.67rpx;
height:116.67rpx;
margin-left: 520rpx;
margin-top:1232rpx;
background-color: #f76229;
border-radius: 58.335rpx;
z-index: 1;
}
.dclefttxt{
@ -76,11 +72,11 @@ page {
position:absolute;
width:68rpx;
height:78.67rpx;
margin-left: 18rpx;
margin-top: 14rpx;
margin-left:24rpx;
margin-top:18.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/wjx.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/wjx.png);
}
.dchx{
@ -110,9 +106,10 @@ page {
margin-left: 29.33rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/bs.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bs.png);
}
.gh{
position:absolute;
width:750rpx;
@ -120,19 +117,16 @@ page {
margin-top:1070.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/gh.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/gh.png);
}
.call{
position: absolute;
margin: 0;
padding: 0;
width:750rpx;
height: 100%;
/* height:1624rpx!important; */
height:1624rpx;
overflow: hidden;
padding: 0!important;
margin: 0!important;
}
.call1{
@ -163,7 +157,7 @@ page {
margin-left: 32.33rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/rbs.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/rbs.png);
}
.lovepic{
@ -174,7 +168,7 @@ page {
margin-left:235.33rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/pulse.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/pulse.png);
}
.dchxtxtql{
@ -188,6 +182,7 @@ page {
font-size: 27rpx;
}
.txl{
position:absolute;
width:72rpx;
@ -196,13 +191,7 @@ page {
margin-left:218rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/tx.png);
}
.txl-qd {
position: absolute;
left: 80rpx;
margin-left:0;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/tx.png);
}
.txr{
@ -213,52 +202,19 @@ page {
margin-left:400.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/tx.png);
}
.txr-qd {
position: absolute;
right: 80rpx;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/tx.png);
}
.txtextl{
position:absolute;
width:166rpx;
width:772rpx;
height:72rpx;
line-height:72rpx;
color: #9a9a9a;
margin-top:142.67rpx;
margin-left:36rpx;
font-size: 27rpx;
text-align: right;
}
.txtextl-qd{
position: absolute;
top: 130rpx;
left: 154rpx;
width: 444rpx;
height: 90rpx;
display: flex;
align-items: center;
}
.text-qd {
width: 360rpx;
color: rgba(108, 108, 108, 1);
font-size: 14px;
}
.text-qd .top {
color: #DE868F;
}
.text-qd view {
display: flex;
justify-content: center;
align-items: center;
}
.jiuchan{
position: absolute;
width:47.33rpx;
@ -267,7 +223,7 @@ page {
margin-left: 322.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/jiuchan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/jiuchan.png);
}
@ -290,7 +246,7 @@ page {
margin-left: 322.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/bkg3.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bkg3.png);
}
.xxt{
@ -301,38 +257,28 @@ page {
margin-left: 212rpx;
background-repeat: no-repeat;
background-size:100% 100%;
}
.xxt image {
width: 100%;
height: 100%;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/szn.png);
}
.yan1{
position: absolute;
width:114rpx;
height:116rpx;
display: flex;
align-items: center;
justify-content: center;
height:116.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
margin-top: 837.33rpx;
margin-left:118.67rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.yan2{
position: absolute;
width:114rpx;
height:116rpx;
display: flex;
align-items: center;
justify-content: center;
height:116.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
margin-top: 837.33rpx;
margin-left:318rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.yan3{
position: absolute;
@ -340,12 +286,9 @@ page {
height:116.67rpx;
margin-top: 837.33rpx;
margin-left:517.33rpx;
display: flex;
align-items: center;
justify-content: center;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.bkg1{
@ -356,7 +299,7 @@ page {
margin-left:46rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/bkg1.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bkg1.png);
}
.bkg3{
@ -367,120 +310,106 @@ page {
margin-left:42rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/bkg3.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bkg3.png);
}
.yan11{
position: absolute;
width:46rpx;
height:46rpx;
width:46.67rpx;
height:46.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/paw.png);
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:46rpx;
height:46rpx;
position: absolute;
width:46.67rpx;
height:46.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/male.png);
margin-top: 33.33rpx;
margin-left:34.33rpx;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/male.png);
}
.yan13{
width:36rpx;
height:46rpx;
position: absolute;
width:46.67rpx;
height:46.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-size: contain;
background-image: url(https://wish-assets.windymuse.com.cn/xy/female.png);
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:326rpx;
height:772rpx;
margin-top: 326rpx;
width:326.67rpx;
height:771.33rpx;
margin-top: 326.67rpx;
margin-left: 88rpx;
background-repeat: no-repeat;
background-size:100% 100%;
}
.xxtl image {
width: 100%;
height: 100%;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/szn.png);
}
.xxtr{
position: absolute;
width:326rpx;
height:782rpx;
margin-top: 326rpx;
margin-left: 356rpx;
width:323.33rpx;
height:787.33rpx;
margin-top: 308.67rpx;
margin-left: 355.33rpx;
background-repeat: no-repeat;
background-size:100% 100%;
}
.xxtr image {
width: 100%;
height: 100%;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/xxtr.png);
}
.yanql1{
position: absolute;
width:114rpx;
height:116rpx;
display: flex;
align-items: center;
justify-content: center;
height:116.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
margin-top: 492rpx;
margin-left:86.67rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.yanql2{
position: absolute;
width:114rpx;
height:116rpx;
display: flex;
align-items: center;
justify-content: center;
height:116.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
margin-top: 663.33rpx;
margin-left:38.67rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.yanql4{
position: absolute;
width:114rpx;
height:116rpx;
display: flex;
align-items: center;
justify-content: center;
height:116.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
margin-top: 492rpx;
margin-left:550.67rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.yanql5{
position: absolute;
width:114rpx;
height:116rpx;
display: flex;
align-items: center;
justify-content: center;
height:116.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
margin-top: 663.33rpx;
margin-left:598rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
.xxtq{
@ -491,11 +420,7 @@ page {
margin-left: 212rpx;
background-repeat: no-repeat;
background-size:100% 100%;
}
.xxtq image{
width: 100%;
height: 100%;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/xxtr.png);
}
.k1{
@ -508,12 +433,7 @@ page {
margin-left: 114.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/circle.png);
color: rgba(248, 99, 42, 1);
font-size: 36px;
font-family: SourceHanSansSC-regular;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/circle.png);
}
@ -525,7 +445,7 @@ font-family: SourceHanSansSC-regular;
margin-left: 318rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yan.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yan.png);
}
@ -539,9 +459,7 @@ font-family: SourceHanSansSC-regular;
margin-left: 520.67rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/circle.png);
color: rgba(108, 108, 108, 1);
font-size: 16px;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/circle.png);
}
@ -553,7 +471,7 @@ font-size: 16px;
margin-left: 36rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/yst.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/yst.png);
}
@ -599,17 +517,16 @@ font-size: 16px;
.ztys{
position: absolute;
width: 542.67rpx;
height: 290rpx;
display: flex;
flex-direction: column;
background-repeat: no-repeat;
background-size:100% 100%;
left: 46rpx;
top:98rpx;
width: 284px;
height: 159px;
line-height: 50rpx;
color: rgba(108, 108, 108, 1);
font-size: 16px;
left: 0;
right: 0;
margin: 84rpx auto;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xzt/ztys.png);
}
.jkzs{
@ -622,7 +539,7 @@ font-size: 16px;
background-size:100% 100%;
margin-left:97.33rpx;
margin-top: 589.33rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/jkzs.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/jkzs.png);
}
.aqzs{
@ -635,7 +552,7 @@ font-size: 16px;
background-size:100% 100%;
margin-left:97.33rpx;
margin-top: 653.33rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/aqzs.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/aqzs.png);
}
.cyzs{
@ -648,7 +565,7 @@ font-size: 16px;
background-size:100% 100%;
margin-left:97.33rpx;
margin-top: 717.33rpx;
background-image: url(https://wish-assets.windymuse.com.cn/xy/cyzs.png);
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/xy/cyzs.png);
}
.rjkzs{
@ -688,261 +605,3 @@ font-size: 16px;
margin-top: 708.33rpx;
}
.jltxt{
position: absolute;
right: 0;
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;
}
.tips{
position: absolute;
left: 46rpx;
top: 36rpx;
width: 119px;
height: 18px;
color: rgba(248, 99, 42, 1);
font-size: 12px;
text-align: left;
font-family: SourceHanSansSC-regular;
}
.ysfgx{
position: absolute;
left: 90rpx;
top: 486rpx;
width: 240px;
height: 11px;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/ysfgx.png);
}
/* 弹层 */
.pray {
display: flex;
justify-content: center;
}
.dialog {
position: absolute;
bottom: 500rpx;
width: 648rpx;
height: 484rpx;
padding: 50rpx;
z-index: 999;
box-sizing: border-box;
line-height: 20px;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.4);
}
.dialog-item {
display: flex;
justify-content: space-between;
margin-bottom: 38rpx;
}
.dialog-item textarea {
width: 400rpx;
height: 142rpx;
padding: 20rpx;
line-height: 40rpx;
box-sizing: border-box;
border-radius: 10px;
background-color: rgba(255, 255, 255, 1);
color: #9A9A9A;
font-size: 14px;
text-align: right;
border: 1px solid rgba(236, 236, 236, 1);
}
.dialog-item text {
padding-top: 16rpx;
color: #6C6C6C;
font-size: 16px;
text-align: center;
}
.dialog-item .duration {
width: 400rpx;
height: 80rpx;
display: flex;
justify-content: flex-end;
align-items: center;
padding-right: 20rpx;
box-sizing: border-box;
border-radius: 10px;
color: rgba(154, 154, 154, 1);
font-size: 14px;
border: 1px solid rgba(236, 236, 236, 1);
}
.dialog-btn {
display: flex;
justify-content: center;
align-items: center;
}
.dialog-btn button {
width: 210rpx;
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);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 14px;
}
.dialog-text {
height: 300rpx;
color: rgba(108, 108, 108, 1);
font-size: 18px;
text-align: center;
font-weight: 400;
padding-top: 60rpx;
box-sizing: border-box;
}
.dialog-text view {
margin-bottom: 30rpx;
}
.timing {
position: absolute;
bottom: 0;
width: 100%;
height: 434rpx;
z-index: 999;
line-height: 20px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
}
.timing .picker{
padding: 0 28px;
box-sizing: border-box;
}
.timing .timing-title {
height: 70rpx;
display: flex;
justify-content: center;
align-items: center;
color: #9A9A9A;
font-size: 14px;
border: 1px solid #F1F1F1;
}
.active {
background-color: #F1F1F1;
z-index: 0;
}
.picker-item {
display: flex;
align-items: center;
justify-content: center;
}
picker-view-column {
height: 364rpx;
}
.energy-success {
position: absolute;
top: 500rpx;
right: 30rpx;
width: 286rpx;
height: 160rpx;
opacity: 0.9;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
color: #6C6C6C;
font-size: 14px;
padding: 36rpx 0 0 20rpx;
box-sizing: border-box;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.4);
}
.energy-full {
position: absolute;
top: 500rpx;
right: 230rpx;
width: 286rpx;
height: 160rpx;
opacity: 0.9;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
color: #6C6C6C;
font-size: 14px;
padding: 18rpx 0 0 20rpx;
box-sizing: border-box;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.4);
}
.energy-complete {
position: absolute;
top: 500rpx;
right: 230rpx;
width: 336rpx;
height: 160rpx;
opacity: 0.9;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
color: #6C6C6C;
font-size: 14px;
padding: 36rpx 0 0 20rpx;
box-sizing: border-box;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.4);
z-index: 999;
}
.in-energy {
position: absolute;
top: 500rpx;
right: 130rpx;
width: 484rpx;
height: 434rpx;
padding-top: 80rpx;
box-sizing: border-box;
font-size: 18px;
color: #6C6C6C;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.4);
}
.in-energy .t-image {
width: 200rpx;
height: 200rpx;
}
.dcright1 {
position: absolute;
top: 1232rpx;
right: 109rpx;
}
.dcright1 .t-progress__canvas--inner {
background-color: #f76229 !important;
}

@ -1,66 +0,0 @@
// pages/home/jl/jlai.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -1,3 +0,0 @@
{
"usingComponents": {}
}

@ -1,2 +0,0 @@
<!--pages/home/jl/jlai.wxml-->
<text>pages/home/jl/jlai.wxml</text>

@ -1 +0,0 @@
/* pages/home/jl/jlai.wxss */

@ -1,155 +0,0 @@
// pages/home/jl/jlai/jlai.js
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
Page({
/**
* 页面的初始数据
*/
data: {
isAdd:false,
times:0,//非会员聊天次数
chatList:[],
ltinfo:'',
isBlank:true,//没有聊天
userInfo:{},
stxx:false,
},
addClick(){
console.log('点击了加号')
this.setData({isAdd:true})
},
noaddClick(){
console.log('点击了加号')
this.setData({isAdd:false})
},
dovipTips(){
wx: wx.showToast({
title: '请购买会员或聊天次数',
icon:'none',
})
},
go2Member(){
console.log('一天啊啊啊')
wx.navigateTo({
url: '/pages/home/me/member/member'
})
},
doLt(e){/**点击快捷选项 */
console.log('到此一游')
this.setData({ltinfo:e.target.dataset.lt})
},
go2BB(e){/**鼠标回显事件 */
// this.setData({ltinfo:e.detail.value})
},
go2Send(e){/**发送消息 */
this.setData({isBlank:false})
if(e.target.dataset.lt==''){
wx: wx.showToast({
title: '聊天内容不能为空',
icon:'none',
})
}else{
this.setData({
chatList:this.data.chatList.concat({'type':1,'value':e.target.dataset.lt})
})
let that = this
req.postRequest('/api/v1/chat-records/completions',{'content':e.target.dataset.lt}).then((res)=>{
console.log(res)
console.log(res.data)
if(res.data.code==500){
console.log('500状态码')
wx: wx.showToast({
title: '获取星座精灵AI聊天消息超时',
icon:'none',
})
}
if(res.data.code==200){
this.setData({times:res.data.data.freeChatCount})
console.log(res)
this.setData({
chatList:this.data.chatList.concat({'type':2,'value':res.data.data.content})
})
}
console.log(this.userInfo);
}).catch((err)=>{
console.log(err);
})
this.setData({ltinfo:''})
}
},
getUserInfo(){
req.getRequest('/api/user/curt',{}).then((res)=>{
if(res.data.code==200){
this.setData({userInfo:res.data.data})
if(!res.data.data.isChatVip){
this.setData({times:res.data.data.freeChatCount})
}
console.log(this.data.times)
}
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() {
}
})

@ -1,7 +0,0 @@
{
"usingComponents": {
"t-image": "tdesign-miniprogram/image/image",
"t-input": "tdesign-miniprogram/input/input",
"t-textarea": "tdesign-miniprogram/textarea/textarea"
}
}

@ -1,82 +0,0 @@
<!--pages/home/jl/jlai/jlai.wxml-->
<view class="reback" bindtap="go2Reback"></view><!--左上角返回图标-->
<view class="title">星座精灵AI</view><!--标题星座精灵AI-->
<view wx:if="{{!userInfo.isChatVip}}" class="mfcs">免费次数剩余:{{times}}条</view><!--非会员展示剩余免费次数-->
<!--没有聊天初次展示-->
<view class="ltkjj" wx:if="{{isBlank&&times!=0}}">
<view class="ltat ltxzys" data-lt="星座运势" bindtap="doLt">星座运势</view>
<view class="ltat ltxzzb" data-lt="星座占卜" bindtap="doLt">星座占卜</view>
<view class="ltat lttlzb" data-lt="塔罗占卜" bindtap="doLt">塔罗占卜</view>
<view class="ltat ltqgqs" data-lt="情感倾诉" bindtap="doLt">情感倾诉</view>
<view class="ltat ltwm" data-lt="我和Ta未来会怎样" bindtap="doLt">我和Ta未来会怎样</view>
<view class="ltat wzmxyx" data-lt="文字冒险游戏" bindtap="doLt">文字冒险游戏</view>
<view class="ltat ltqs" data-lt="帮我写一封情书" bindtap="doLt">帮我写一封情书</view>
<t-image src="https://wish-assets.windymuse.com.cn/xy/jlaitx.png" shape="circle" class="tximg"></t-image>
<view class="ltwzk">你好,我是你的星座守护精灵。除此之外,我还可以帮你解答更多问题。快来跟我聊聊吧!
</view>
</view>
<!--不是会员,进来就没有聊天次数了-->
<view class="ltkjj1" wx:if="{{isBlank&&userInfo.freeChatCount==0&&!isChatVip}}">
<view class="ltat ltxzys" >星座运势</view>
<view class="ltat ltxzzb" >星座占卜</view>
<view class="ltat lttlzb" >塔罗占卜</view>
<view class="ltat ltqgqs" >情感倾诉</view>
<view class="ltat ltwm">我和Ta未来会怎样</view>
<view class="ltat wzmxyx" >文字冒险游戏</view>
<view class="ltat ltqs" >帮我写一封情书</view>
<t-image src="https://wish-assets.windymuse.com.cn/xy/jlaitx.png" shape="circle" class="tximg"></t-image>
<view class="ltwzk">你好,我是你的星座守护精灵。除此之外,我还可以帮你解答更多问题。快来跟我聊聊吧!
</view>
<view class="kthybtn" bindtap="go2Member">开通会员</view>
<view class="kthytips" >开通会员享不限次畅聊</view>
<view class="hyhgtx" bindtap="go2Member"></view>
</view>
<view class="chatbox" wx:if="{{chatList&&(!isBlank)}}"><!--聊天内容-->
<view class="chatbox1" wx:for="{{chatList}}" wx:key="index">
<t-image src="https://wish-assets.windymuse.com.cn/xy/jlaitx.png" shape="circle" class="chattoux" wx:if="{{item.type==2}}"></t-image>
<t-image src="{{userInfo.avatar}}" class="chattoux" wx:if="{{item.type==1}}"></t-image>
<view class="chatinfo">{{item.value}}</view>
</view>
<view class="dd1"></view>
</view>
<!--不是会员且聊天次数为0-->
<view class="ltk1" wx:if="{{!isChatVip&&times==0}}" bindtap="dovipTips">
<view class="ltk1txt">
<t-textarea class="ltk1txt1" model:value="{{ltinfo}}" placeholder="请开通会员或购买次数" bindblur="go2BB" data-lt="{{ltinfo}}" disabled></t-textarea>
</view>
<view class="fsan" data-lt="{{ltinfo}}"></view><!--发送按钮-->
<view class="addbtn"></view><!--加号按钮-->
</view>
<!--是会员或者剩余聊天次数不为0 加号缩回-->
<view class="ltk1" wx:if="{{isChatVip||times!=0}}" wx:if="{{!isAdd}}">
<view class="ltk1txt">
<t-textarea class="ltk1txt1" model:value="{{ltinfo}}" placeholder="输入聊天内容" bindblur="go2BB" data-lt="{{ltinfo}}" bindchange="go2BB"></t-textarea>
</view>
<view class="fsan" bindtap="go2Send" data-lt="{{ltinfo}}"></view><!--发送按钮-->
<view class="addbtn" bindtap="addClick"></view><!--加号按钮-->
</view>
<!--是会员或者剩余聊天次数不为0 加号没有缩回-->
<view class="ltk112" wx:if="{{isChatVip||times!=0}}" wx:if="{{isAdd}}">
<view class="ltk1txt">
<t-textarea class="ltk1txt1" model:value="{{ltinfo}}" placeholder="输入聊天内容" bindblur="go2BB" data-lt="{{ltinfo}}" bindchange="go2BB"></t-textarea>
</view>
<view class="fsan" bindtap="go2Send" data-lt="{{ltinfo}}"></view><!--发送按钮-->
<view class="addbtn" bindtap="noaddClick"></view><!--加号按钮-->
</view>
<!--是会员或者剩余聊天次数不为0 加号没有缩回 快捷键-->
<view class="myshkjj" wx:if="{{isAdd}}">
<view class="myshkjj-container">
<view class="myshkjjco myshkjjxzys" data-lt="星座运势" bindtap="doLt">星座运势</view>
<view class="myshkjjco myshkjjxxzb" data-lt="星座占卜" bindtap="doLt">星座占卜</view>
<view class="myshkjjco myshkjjtlzb" data-lt="塔罗占卜" bindtap="doLt">塔罗占卜</view>
<view class="myshkjjco myshkjjwzmxyx" data-lt="文字冒险游戏" bindtap="doLt">文字冒险游戏</view>
<view class="myshkjjco myshkjjbwxyfqs" data-lt="帮我写一封情书" bindtap="doLt">帮我写一封情书</view>
<view class="myshkjjco myshkjjwhtwlhzy" data-lt="我和Ta未来会怎样" bindtap="doLt">我和Ta未来会怎样</view>
<view class="myshkjjco myshkjjqgqs" data-lt="情感倾诉" bindtap="doLt">情感倾诉</view>
</view>
</view>

@ -1,355 +0,0 @@
/* pages/home/jl/jlai/jlai.wxss */
page {
width: 100%;
height: 100%;
overflow: hidden;
}
.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://wish-assets.windymuse.com.cn/xy/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;
}
.mfcs{
position: absolute;
left: 0px;
top: 188rpx;
width: 100%;
height: 88rpx;
line-height: 88rpx;
opacity: 0.8;
background: linear-gradient(222.54deg, rgba(248,99,42,1) 14.03%,rgba(249,135,89,1) 85.21%);
text-align: center;
color: rgba(255, 255, 255, 1);
font-size: 14px;
}
.ltkjj{
position: absolute;
left: 32rpx;
top: 328rpx;
width: 686rpx;
height: 764rpx;
line-height: 40rpx;
opacity: 0.9;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
font-size: 14px;
text-align: center;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.2);
font-family: Arial;
}
.ltkjj1{
position: absolute;
left: 32rpx;
top: 328rpx;
width: 686rpx;
height: 1000rpx;
line-height: 20px;
opacity: 0.9;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
font-size: 14px;
text-align: center;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.2);
font-family: Arial;
}
.ltat{
position: absolute;
height: 100rpx;
line-height: 100rpx;
opacity: 0.9;
border-radius: 50rpx;
background: linear-gradient(222.69deg, rgba(248,99,42,1) 14.04%,rgba(249,135,89,1) 88.56%);
color: rgba(16, 16, 16, 1);
font-size: 12px;
text-align: center;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
font-family: Arial;
color: rgba(255, 255, 255, 1);
font-size: 14px;
text-align: center;
font-family: SourceHanSansSC-regular;
}
.ltxzys{
left: 38rpx;
top: 64rpx;
width: 196rpx;
}
.ltxzzb{
left: 250rpx;
top: 64rpx;
width: 196rpx;
}
.lttlzb{
top: 64rpx;
width: 196rpx;
left: 462rpx;
}
.ltqgqs{
width:236rpx;
left:38rpx;
top:228rpx;
}
.ltwm{
left:320rpx;
top:228rpx;
width:335rpx;
}
.wzmxyx{
left:38rpx;
width:274rpx;
top:392rpx;
}
.ltqs{
left:344rpx;
width:306rpx;
top:392rpx;
}
.tximg{
position: absolute;
left: 38rpx;
top: 556rpx;
width: 84rpx;
height: 84rpx;
border: 3px solid rgba(161, 134, 81, 1);
background-color: coral;
}
.ltwzk{
position: absolute;
left: 154rpx;
top: 556rpx;
width: 482rpx;
height: 144rpx;
color: rgba(108, 108, 108, 1);
font-size: 17px;
line-height: 43rpx;
text-align: justify;
font-family: SourceHanSansSC-regular;
}
.ltk1{
position: absolute;
left: 0px;
top: 1444rpx;
width: 100%;
height: 180rpx;
line-height: 20px;
background-color: rgba(248, 248, 248, 1);
text-align: center;
border: 1px solid rgba(255, 0, 0, 0);
}
.ltk1txt{
position: absolute;
left: 32rpx;
top: 14rpx;
width: 530rpx;
height: 84rpx;
border-radius: 5px;
color: rgba(136, 136, 136, 1);
font-size: 14px;
text-align: left;
font-family: Arial;
border: 1px solid rgba(255, 0, 0, 0);
}
.t-textarea{
margin: 0!important;
padding: 0!important;
height:84rpx;
line-height: 84rpx!important;
}
.ltk1txt1{
width: 530rpx;
height: 84rpx;
}
.t-textarea__label{
height:84rpx;
line-height: 84rpx!important;
}
.fsan{
position: absolute;
left: 664rpx;
top: 32rpx;
width: 54rpx;
height: 54rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/chatbtn.png);
}
.addbtn{
position: absolute;
left: 586rpx;
top: 30rpx;
width: 54rpx;
height: 54rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/addbtn.png);
}
.chatbox{
position: absolute;
top:264rpx;
width:750rpx;
height:1360rpx;
overflow: auto;
}
.chatbox1{
width:750rpx;
height:148rpx;
display: block;
}
.chattoux{
margin-left: 32rpx;
margin-top: 32rpx;
width: 84rpx;
height: 84rpx;
display: online;
}
.chatinfo{
margin-left: 74px;
margin-top: -70rpx;
width: 280px;
height: 90px;
color: rgba(79, 79, 79, 1);
font-size: 17px;
text-align: justify;
font-family: SourceHanSansSC-regular;
}
.dd1{
width:750rpx;
height:160rpx;
}
.kthybtn{
position: absolute;
left: 224rpx;
top: 826rpx;
width: 240rpx;
height: 70rpx;
line-height: 70rpx;
border-radius: 10px;
background: linear-gradient(222.54deg, rgba(248,99,42,1) 14.03%,rgba(249,135,89,1) 85.21%);
color: rgba(16, 16, 16, 1);
font-size: 12px;
text-align: center;
font-family: Arial;
color: rgba(255, 255, 255, 1);
font-size: 14px;
text-align: center;
font-family: SourceHanSansSC-medium;
}
.kthytips{
position: absolute;
top: 898rpx;
width: 686rpx;
height: 20px;
color: rgba(108, 108, 108, 1);
font-size: 12px;
text-align: center;
font-family: SourceHanSansSC-regular;
}
.hyhgtx{
position: absolute;
left: 392rpx;
top: 742rpx;
width: 120rpx;
height: 127rpx;
background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://wish-assets.windymuse.com.cn/xy/hyhg.png);
}
.ltk112{
position: absolute;
left: 0;
top: 1224rpx;
width: 100%;
height: 110rpx;
line-height: 40rpx;
background-color: rgba(248, 248, 248, 1);
text-align: center;
border: 1px solid rgba(255, 0, 0, 0);
}
.myshkjj{
position: absolute;
top: 1340rpx;
width: 100%; /* 容器宽度 */
overflow-x: scroll; /* 横向滚动 */
}
.myshkjj-container {
width: 990rpx;
height: 200rpx;
padding-top: 20rpx;
display: flex;
flex-wrap: wrap;
}
.myshkjjco{
margin-left: 30rpx;
height: 60rpx;
border-radius: 48rpx;
background: linear-gradient(222.69deg, rgba(248,99,42,1) 14.04%,rgba(249,135,89,1) 88.56%);
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
color: rgba(255, 255, 255, 1);
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
}
.myshkjjxzys{
width: 176rpx;
}
.myshkjjxxzb{
width: 176rpx;
}
.myshkjjtlzb{
width: 178rpx;
}
.myshkjjwzmxyx{
width: 274rpx;
}
.myshkjjbwxyfqs{
width: 306rpx;
}
.myshkjjwhtwlhzy{
width: 334rpx;
}
.myshkjjqgqs{
width: 236rpx;
}

@ -1,66 +0,0 @@
// pages/home/me/cjwt/cjwt.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -1,4 +0,0 @@
{
"navigationBarTitleText": "常见问题",
"usingComponents": {}
}

@ -1,5 +0,0 @@
<!--pages/home/me/cjwt/cjwt.wxml 常见问题-->
<!--<!--<!--<web-view src="https://xzjl-api.windymuse.cn/"></web-view>-->
<view>跳转页面,待完善</view>-->
<view>跳转页面,待完善</view>-->
<view>跳转页面,待完善</view>

@ -1 +0,0 @@
/* pages/home/me/cjwt/cjwt.wxss */

@ -1,175 +0,0 @@
// pages/home/me/grzl/grzl.js
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
Page({
/**
* 页面的初始数据
*/
data: {
avatars:[
'https://wish-assets.windymuse.com.cn/xy/tx1.png',
'https://wish-assets.windymuse.com.cn/xy/tx2.png',
'https://wish-assets.windymuse.com.cn/xy/tx3.png',
'https://wish-assets.windymuse.com.cn/xy/tx4.png',
'https://wish-assets.windymuse.com.cn/xy/tx5.png',
'https://wish-assets.windymuse.com.cn/xy/tx6.png',
'https://wish-assets.windymuse.com.cn/xy/tx1.png',
'https://wish-assets.windymuse.com.cn/xy/tx2.png',
'https://wish-assets.windymuse.com.cn/xy/tx3.png',
],
sexs:[{label:'男生',value:'male'},{label:'女生',value:'female'}],
sexVisible:false,
note:'',
cVisible:false,
userInfo:{},
endDate:new Date().getTime()
},
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) {/**修改日期 */
console.log(e);
const { value } = e.detail;
console.log(value);
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',{birthday:format(value)}).then((res)=>{
console.log(res);
if(res.data.code==200){
this.setData({userInfo:res.data.data})
wx.showToast({
title:'修改成功',
icon: 'none',
duration: 1000
})
this.getUserInfo()
}
}).catch((err)=>{
console.log(err);
})
},
changeSex(){
this.setData({sexVisible:true})
console.log('修改性别')
},
doChangeName1(e){
if (e.detail.value !== this.data.userInfo.nick) {
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() {
}
})

@ -1,9 +0,0 @@
{
"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",
"t-date-time-picker": "tdesign-miniprogram/date-time-picker/date-time-picker"
}
}

@ -1,67 +0,0 @@
<view class="xgzl-container">
<!-- 头部返回 -->
<view class="xgzl-header">
<view class="reback" bindtap="go2Reback"></view>
<view class="title">修改资料</view>
</view>
<!-- 头像 -->
<view class="xgzl-img">
<view class="cameralogo"><view class="cameralogo-img"></view></view>
<image class="avatar1" src="{{userInfo.avatar}}"></image>
<input focus="doChangeName1" class="nickname" name="nick" placeholder="昵称不能为空" maxlength="7" value="{{userInfo.nick}}" bindblur="doChangeName1"></input>
</view>
<!-- 精灵头像 -->
<view class="xgzl-sculpture">
<view class="jltxtxt">精灵头像</view>
<view class="txcheck-box">
<view class="txcheck">
<view wx:for="{{avatars}}" class="itemxx"><image class="iii" src="{{item}}" data-img="{{item}}" bindtap="changeAvatar"></image></view>
</view>
</view>
</view>
<!-- <form bindsubmit="go2UpdateUserInfo"></form> -->
<!-- 数据表单 -->
<view class="xgzl-data">
<view class="data-item">
<view class="xbwz">性别</view>
<view class="xbtxt" bindtap="changeSex">{{userInfo.spriteType=='male'?'男生':'女生'}}</view>
</view>
<view class="data-item">
<view class="srwz">生日</view>
<view class="srtxt" bindtap="handleCalendar">{{userInfo.birthday ? userInfo.birthday : '点击选择日期'}}</view>
</view>
<view class="data-item">
<view class="xzwz">星座</view>
<view class="ssxz">{{userInfo.birthdayConstellation}}</view>
</view>
</view>
<!-- <t-calendar visible="{{cVisible}}" bind:confirm="changeDate" minDate="{{minDate}}" maxDate="{{maxDate}}"/> -->
<t-date-time-picker
title="选择日期"
visible="{{cVisible}}"
mode="date"
format="YYYY-MM-DD"
value="{{userInfo.birthday}}"
bind:confirm="changeDate"
start="1980-1-1"
end="{{endDate}}"
/>
<t-picker
visible="{{sexVisible}}"
value="{{cityValue}}"
data-key="city"
title="选择性别"
cancelBtn="取消"
confirmBtn="确认"
bind:confirm="onColumnChange"
>
<t-picker-item options="{{sexs}}" />
</t-picker>
</view>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save