uview-plus 3.4.39 → 3.4.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +10 -0
- package/components/u-action-sheet/u-action-sheet.vue +0 -1
- package/components/u-album/u-album.vue +0 -2
- package/components/u-alert/u-alert.vue +0 -1
- package/components/u-avatar/u-avatar.vue +0 -1
- package/components/u-avatar-group/u-avatar-group.vue +0 -1
- package/components/u-back-top/u-back-top.vue +0 -1
- package/components/u-badge/u-badge.vue +0 -1
- package/components/u-box/u-box.vue +0 -1
- package/components/u-button/u-button.vue +0 -2
- package/components/u-calendar/header.vue +0 -1
- package/components/u-calendar/month.vue +0 -1
- package/components/u-calendar/u-calendar.vue +0 -2
- package/components/u-car-keyboard/u-car-keyboard.vue +0 -1
- package/components/u-card/u-card.vue +0 -2
- package/components/u-cell/u-cell.vue +0 -1
- package/components/u-cell-group/u-cell-group.vue +0 -1
- package/components/u-checkbox/u-checkbox.vue +0 -1
- package/components/u-checkbox-group/u-checkbox-group.vue +0 -1
- package/components/u-circle-progress/u-circle-progress.vue +0 -1
- package/components/u-code/u-code.vue +0 -1
- package/components/u-code-input/u-code-input.vue +0 -1
- package/components/u-col/u-col.vue +0 -1
- package/components/u-collapse/u-collapse.vue +0 -1
- package/components/u-collapse-item/u-collapse-item.vue +0 -1
- package/components/u-column-notice/u-column-notice.vue +0 -1
- package/components/u-count-down/u-count-down.vue +0 -1
- package/components/u-count-to/u-count-to.vue +0 -2
- package/components/u-datetime-picker/u-datetime-picker.vue +0 -1
- package/components/u-divider/u-divider.vue +0 -1
- package/components/u-dropdown/u-dropdown.vue +0 -1
- package/components/u-dropdown-item/u-dropdown-item.vue +0 -1
- package/components/u-empty/u-empty.vue +0 -1
- package/components/u-float-button/u-float-button.vue +0 -2
- package/components/u-form-item/u-form-item.vue +0 -1
- package/components/u-gap/u-gap.vue +0 -1
- package/components/u-grid/u-grid.vue +0 -1
- package/components/u-grid-item/u-grid-item.vue +0 -1
- package/components/u-icon/u-icon.vue +0 -1
- package/components/u-image/u-image.vue +0 -2
- package/components/u-index-anchor/u-index-anchor.vue +0 -1
- package/components/u-index-item/u-index-item.vue +0 -1
- package/components/u-index-list/u-index-list.vue +0 -1
- package/components/u-input/u-input.vue +0 -2
- package/components/u-keyboard/u-keyboard.vue +0 -1
- package/components/u-lazy-load/u-lazy-load.vue +0 -2
- package/components/u-line/u-line.vue +0 -1
- package/components/u-line-progress/u-line-progress.vue +0 -1
- package/components/u-link/u-link.vue +0 -1
- package/components/u-list/u-list.vue +0 -1
- package/components/u-list-item/u-list-item.vue +0 -1
- package/components/u-loading-icon/u-loading-icon.vue +0 -1
- package/components/u-loading-page/u-loading-page.vue +0 -2
- package/components/u-loadmore/u-loadmore.vue +0 -1
- package/components/u-modal/u-modal.vue +0 -1
- package/components/u-navbar/u-navbar.vue +0 -1
- package/components/u-navbar-mini/u-navbar-mini.vue +0 -1
- package/components/u-no-network/u-no-network.vue +0 -1
- package/components/u-notice-bar/u-notice-bar.vue +0 -1
- package/components/u-notify/u-notify.vue +0 -1
- package/components/u-number-box/u-number-box.vue +0 -2
- package/components/u-number-keyboard/u-number-keyboard.vue +0 -1
- package/components/u-overlay/u-overlay.vue +0 -1
- package/components/u-picker/u-picker.vue +0 -1
- package/components/u-picker-column/u-picker-column.vue +0 -1
- package/components/u-popup/u-popup.vue +0 -1
- package/components/u-qrcode/qrcode.js +120 -57
- package/components/u-qrcode/u-qrcode.vue +121 -17
- package/components/u-radio/u-radio.vue +0 -1
- package/components/u-radio-group/u-radio-group.vue +0 -1
- package/components/u-rate/u-rate.vue +0 -1
- package/components/u-read-more/u-read-more.vue +0 -2
- package/components/u-row/u-row.vue +0 -1
- package/components/u-row-notice/u-row-notice.vue +0 -1
- package/components/u-scroll-list/u-scroll-list.vue +0 -2
- package/components/u-search/u-search.vue +0 -1
- package/components/u-skeleton/u-skeleton.vue +0 -1
- package/components/u-slider/u-slider.vue +0 -1
- package/components/u-steps/u-steps.vue +0 -1
- package/components/u-steps-item/u-steps-item.vue +0 -1
- package/components/u-subsection/u-subsection.vue +0 -2
- package/components/u-swipe-action-item/u-swipe-action-item.vue +0 -1
- package/components/u-swiper/u-swiper.vue +0 -1
- package/components/u-swiper-indicator/u-swiper-indicator.vue +0 -1
- package/components/u-switch/u-switch.vue +0 -1
- package/components/u-tabbar/u-tabbar.vue +0 -1
- package/components/u-tabbar-item/u-tabbar-item.vue +0 -1
- package/components/u-table/u-table.vue +0 -1
- package/components/u-tabs/u-tabs.vue +0 -1
- package/components/u-tag/u-tag.vue +0 -1
- package/components/u-td/u-td.vue +0 -1
- package/components/u-text/u-text.vue +4 -6
- package/components/u-textarea/u-textarea.vue +9 -11
- package/components/u-th/u-th.vue +0 -1
- package/components/u-toast/u-toast.vue +2 -2
- package/components/u-toolbar/u-toolbar.vue +0 -1
- package/components/u-tooltip/u-tooltip.vue +0 -1
- package/components/u-tr/u-tr.vue +0 -1
- package/components/u-transition/u-transition.vue +114 -3
- package/components/u-upload/u-upload.vue +0 -1
- package/components/u-view/u-view.vue +0 -2
- package/components/u-waterfall/u-waterfall.vue +0 -2
- package/index.scss +2 -1
- package/libs/util/gcanvas/bridge/bridge-weex.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
- package/libs/util/gcanvas/context-webgl/Program.js +0 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
- package/libs/util/gcanvas/env/canvas.js +0 -0
- package/libs/util/gcanvas/env/image.js +0 -0
- package/libs/util/gcanvas/env/tool.js +0 -0
- package/libs/util/gcanvas/index.js +0 -0
- package/package.json +1 -1
- package/types/comps/qrcode.d.ts +77 -0
- package/types/comps.d.ts +1 -0
|
@@ -1037,6 +1037,9 @@ let QRCode = {};
|
|
|
1037
1037
|
showLoading: opt.showLoading,
|
|
1038
1038
|
loadingText: opt.loadingText,
|
|
1039
1039
|
};
|
|
1040
|
+
|
|
1041
|
+
let canvas = null;
|
|
1042
|
+
|
|
1040
1043
|
if (typeof opt === 'string') { // 只编码ASCII字符串
|
|
1041
1044
|
opt = {
|
|
1042
1045
|
text: opt
|
|
@@ -1083,8 +1086,24 @@ let QRCode = {};
|
|
|
1083
1086
|
}
|
|
1084
1087
|
return options.foreground;
|
|
1085
1088
|
}
|
|
1089
|
+
|
|
1090
|
+
let getCanvas = async (id) => {
|
|
1091
|
+
return new Promise((resolve, reject)=>{
|
|
1092
|
+
try {
|
|
1093
|
+
const query = uni.createSelectorQuery().in(this.options.context);
|
|
1094
|
+
query.select(`#${id}`)
|
|
1095
|
+
.fields({ node: true, size: true })
|
|
1096
|
+
.exec((res) => {
|
|
1097
|
+
resolve(res[0].node)
|
|
1098
|
+
})
|
|
1099
|
+
}
|
|
1100
|
+
catch (e) {
|
|
1101
|
+
console.error("createCanvasContextFail",e)
|
|
1102
|
+
}
|
|
1103
|
+
})
|
|
1104
|
+
}
|
|
1086
1105
|
// 创建canvas
|
|
1087
|
-
let createCanvas = function (options) {
|
|
1106
|
+
let createCanvas = async function (options) {
|
|
1088
1107
|
if(options.showLoading){
|
|
1089
1108
|
uni.showLoading({
|
|
1090
1109
|
title: options.loadingText,
|
|
@@ -1094,9 +1113,21 @@ let QRCode = {};
|
|
|
1094
1113
|
var ctx = '';
|
|
1095
1114
|
if (options.nvueContext) {
|
|
1096
1115
|
ctx = options.nvueContext;
|
|
1097
|
-
} else {
|
|
1098
|
-
ctx = uni.createCanvasContext(options.canvasId, options.context);
|
|
1099
1116
|
}
|
|
1117
|
+
else {
|
|
1118
|
+
// 获取canvas node节点
|
|
1119
|
+
canvas = await getCanvas(options.canvasId);
|
|
1120
|
+
// #ifdef MP
|
|
1121
|
+
// 不清楚是小程序的bug还是什么原因,canvas的node节点宽高和设置的宽高不一致 重新设置下
|
|
1122
|
+
canvas.width = options.size;
|
|
1123
|
+
canvas.height = options.size;
|
|
1124
|
+
// #endif
|
|
1125
|
+
ctx = canvas.getContext('2d');
|
|
1126
|
+
}
|
|
1127
|
+
// 设置组件中data里面的ctx
|
|
1128
|
+
options.context.ctx = ctx;
|
|
1129
|
+
options.context.canvas = canvas;
|
|
1130
|
+
|
|
1100
1131
|
var count = qrCodeAlg.getModuleCount();
|
|
1101
1132
|
var ratioSize = options.size;
|
|
1102
1133
|
var ratioImgSize = options.imageSize;
|
|
@@ -1107,14 +1138,18 @@ let QRCode = {};
|
|
|
1107
1138
|
for (var row = 0; row < count; row++) {
|
|
1108
1139
|
for (var col = 0; col < count; col++) {
|
|
1109
1140
|
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
|
|
1110
|
-
var h = (Math.ceil((row + 1) *
|
|
1141
|
+
var h = (Math.ceil((row + 1) * tileH) - Math.floor(row * tileH));
|
|
1111
1142
|
var foreground = getForeGround({
|
|
1112
1143
|
row: row,
|
|
1113
1144
|
col: col,
|
|
1114
1145
|
count: count,
|
|
1115
1146
|
options: options
|
|
1116
1147
|
});
|
|
1117
|
-
|
|
1148
|
+
if (options.nvueContext) {
|
|
1149
|
+
ctx.setFillStyle(qrCodeAlg.modules[row][col] ? foreground : options.background);
|
|
1150
|
+
} else {
|
|
1151
|
+
ctx.fillStyle = qrCodeAlg.modules[row][col] ? foreground : options.background;
|
|
1152
|
+
}
|
|
1118
1153
|
ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h);
|
|
1119
1154
|
}
|
|
1120
1155
|
}
|
|
@@ -1122,12 +1157,33 @@ let QRCode = {};
|
|
|
1122
1157
|
var x = Number(((ratioSize - ratioImgSize) / 2).toFixed(2));
|
|
1123
1158
|
var y = Number(((ratioSize - ratioImgSize) / 2).toFixed(2));
|
|
1124
1159
|
drawRoundedRect(ctx, x, y, ratioImgSize, ratioImgSize, 2, 6, true, true)
|
|
1125
|
-
|
|
1160
|
+
if (options.nvueContext) {
|
|
1161
|
+
ctx.drawImage(options.image, x, y, ratioImgSize, ratioImgSize);
|
|
1162
|
+
}
|
|
1163
|
+
else {
|
|
1164
|
+
// #ifdef H5
|
|
1165
|
+
const img = new Image();
|
|
1166
|
+
// #endif
|
|
1167
|
+
// #ifndef H5
|
|
1168
|
+
const img = canvas.createImage();
|
|
1169
|
+
// #endif
|
|
1170
|
+
img.onload = () => {
|
|
1171
|
+
ctx.drawImage(img, x, y, ratioImgSize, ratioImgSize);
|
|
1172
|
+
};
|
|
1173
|
+
img.src = options.image;
|
|
1174
|
+
}
|
|
1126
1175
|
// 画圆角矩形
|
|
1127
1176
|
function drawRoundedRect(ctxi, x, y, width, height, r, lineWidth, fill, stroke) {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1177
|
+
if (options.nvueContext) {
|
|
1178
|
+
ctxi.setLineWidth(lineWidth);
|
|
1179
|
+
ctxi.setFillStyle(options.background);
|
|
1180
|
+
ctxi.setStrokeStyle(options.background);
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
ctxi.lineWidth = lineWidth;
|
|
1184
|
+
ctxi.fillStyle = options.background;
|
|
1185
|
+
ctxi.strokeStyle = options.background;
|
|
1186
|
+
}
|
|
1131
1187
|
ctxi.beginPath(); // draw top and top right corner
|
|
1132
1188
|
ctxi.moveTo(x + r, y);
|
|
1133
1189
|
ctxi.lineTo(x + width, y); // move to top-right corner
|
|
@@ -1152,57 +1208,64 @@ let QRCode = {};
|
|
|
1152
1208
|
}
|
|
1153
1209
|
}
|
|
1154
1210
|
setTimeout(() => {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
);
|
|
1174
|
-
} else {
|
|
1175
|
-
uni.canvasToTempFilePath({
|
|
1176
|
-
width: options.width,
|
|
1177
|
-
height: options.height,
|
|
1178
|
-
destWidth: options.width,
|
|
1179
|
-
destHeight: options.height,
|
|
1180
|
-
canvasId: options.canvasId,
|
|
1181
|
-
quality: Number(1),
|
|
1182
|
-
success: function (res) {
|
|
1183
|
-
if (options.cbResult) {
|
|
1184
|
-
// 由于官方还没有统一此接口的输出字段,所以先判定下 支付宝为 res.apFilePath
|
|
1185
|
-
if (!empty(res.tempFilePath)) {
|
|
1186
|
-
options.cbResult(res.tempFilePath)
|
|
1187
|
-
} else if (!empty(res.apFilePath)) {
|
|
1188
|
-
options.cbResult(res.apFilePath)
|
|
1189
|
-
} else {
|
|
1211
|
+
// canvas2 绘制是自动的不需要手动绘制
|
|
1212
|
+
if(options.nvueContext){
|
|
1213
|
+
ctx.draw(true, () => {
|
|
1214
|
+
// 保存到临时区域
|
|
1215
|
+
setTimeout(() => {
|
|
1216
|
+
if (options.nvueContext) {
|
|
1217
|
+
ctx.toTempFilePath(
|
|
1218
|
+
0,
|
|
1219
|
+
0,
|
|
1220
|
+
options.width,
|
|
1221
|
+
options.height,
|
|
1222
|
+
options.width,
|
|
1223
|
+
options.height,
|
|
1224
|
+
"",
|
|
1225
|
+
1,
|
|
1226
|
+
function(res) {
|
|
1227
|
+
if (options.cbResult) {
|
|
1190
1228
|
options.cbResult(res.tempFilePath)
|
|
1191
1229
|
}
|
|
1192
1230
|
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1231
|
+
);
|
|
1232
|
+
} else {
|
|
1233
|
+
uni.canvasToTempFilePath({
|
|
1234
|
+
width: options.width,
|
|
1235
|
+
height: options.height,
|
|
1236
|
+
destWidth: options.width,
|
|
1237
|
+
destHeight: options.height,
|
|
1238
|
+
canvasId: options.canvasId,
|
|
1239
|
+
quality: Number(1),
|
|
1240
|
+
success: function (res) {
|
|
1241
|
+
if (options.cbResult) {
|
|
1242
|
+
// 由于官方还没有统一此接口的输出字段,所以先判定下 支付宝为 res.apFilePath
|
|
1243
|
+
if (!empty(res.tempFilePath)) {
|
|
1244
|
+
options.cbResult(res.tempFilePath)
|
|
1245
|
+
} else if (!empty(res.apFilePath)) {
|
|
1246
|
+
options.cbResult(res.apFilePath)
|
|
1247
|
+
} else {
|
|
1248
|
+
options.cbResult(res.tempFilePath)
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
},
|
|
1252
|
+
fail: function (res) {
|
|
1253
|
+
if (options.cbResult) {
|
|
1254
|
+
options.cbResult(res)
|
|
1255
|
+
}
|
|
1256
|
+
},
|
|
1257
|
+
complete: function () {
|
|
1258
|
+
uni.hideLoading();
|
|
1259
|
+
},
|
|
1260
|
+
}, options.context);
|
|
1261
|
+
}
|
|
1262
|
+
}, options.text.length + 100);
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
else{
|
|
1266
|
+
options.cbResult("")
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1206
1269
|
}, options.usingComponents ? 0 : 150);
|
|
1207
1270
|
}
|
|
1208
1271
|
createCanvas(this.options);
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-qrcode"
|
|
2
|
+
<view class="u-qrcode"
|
|
3
|
+
:id="rootId"
|
|
4
|
+
:style="{
|
|
5
|
+
width: useRootHeightAndWidth ? '100%' : 'auto',
|
|
6
|
+
height: useRootHeightAndWidth ? '100%' : 'auto',
|
|
7
|
+
}"
|
|
8
|
+
@longpress="longpress">
|
|
3
9
|
<view class="u-qrcode__content" @click="preview">
|
|
4
10
|
<!-- #ifndef APP-NVUE -->
|
|
5
|
-
<canvas
|
|
6
|
-
|
|
11
|
+
<canvas
|
|
12
|
+
class="u-qrcode__canvas"
|
|
13
|
+
:id="cid"
|
|
14
|
+
:canvas-id="cid"
|
|
15
|
+
type="2d"
|
|
16
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }" />
|
|
7
17
|
<!-- #endif -->
|
|
8
18
|
<!-- #ifdef APP-NVUE -->
|
|
9
19
|
<gcanvas class="u-qrcode__canvas" ref="gcanvess"
|
|
10
|
-
:style="{ width:
|
|
20
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
|
|
11
21
|
</gcanvas>
|
|
12
22
|
<!-- #endif -->
|
|
13
23
|
<view v-if="showLoading && loading" class="u-qrcode__loading"
|
|
14
|
-
:style="{ width:
|
|
24
|
+
:style="{ width: sizeLocal + unit, height: sizeLocal + unit }">
|
|
15
25
|
<up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
|
|
16
26
|
</view>
|
|
17
|
-
<!-- <image v-show="show" :src="result" :style="{ width: size + unit, height: size + unit }" /> -->
|
|
18
27
|
</view>
|
|
19
|
-
|
|
20
|
-
v-model:show="popupShow" @select="selectClick">
|
|
21
|
-
</up-action-sheet> -->
|
|
28
|
+
|
|
22
29
|
</view>
|
|
23
30
|
</template>
|
|
24
31
|
|
|
@@ -103,8 +110,13 @@ export default {
|
|
|
103
110
|
type: Boolean,
|
|
104
111
|
default: false
|
|
105
112
|
},
|
|
113
|
+
// 是否使用根节点宽高
|
|
114
|
+
useRootHeightAndWidth: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: () => false
|
|
117
|
+
},
|
|
106
118
|
},
|
|
107
|
-
emits: ['result', '
|
|
119
|
+
emits: ['result', 'longpressCallback'],
|
|
108
120
|
data() {
|
|
109
121
|
return {
|
|
110
122
|
loading: false,
|
|
@@ -115,12 +127,21 @@ export default {
|
|
|
115
127
|
name: '保存二维码',
|
|
116
128
|
}
|
|
117
129
|
],
|
|
130
|
+
rootId: `rootId${Number(Math.random() * 100).toFixed(0)}`,
|
|
118
131
|
ganvas: null,
|
|
119
132
|
context: '',
|
|
120
|
-
canvasObj: {}
|
|
133
|
+
canvasObj: {},
|
|
134
|
+
sizeLocal: this.size,
|
|
135
|
+
ctx: null, // ctx 在new Qrcode 时js文件内部设置
|
|
136
|
+
canvas: null, // ctx 在new Qrcode 时js文件内部设置
|
|
121
137
|
}
|
|
122
138
|
},
|
|
123
|
-
|
|
139
|
+
async mounted(){
|
|
140
|
+
// 如果使用根节点的宽高 则 重新设置 size
|
|
141
|
+
if(this.useRootHeightAndWidth){
|
|
142
|
+
await this.setNewSize()
|
|
143
|
+
}
|
|
144
|
+
|
|
124
145
|
// #ifdef APP-NVUE
|
|
125
146
|
/*获取元素引用*/
|
|
126
147
|
this.ganvas = this.$refs["gcanvess"]
|
|
@@ -135,7 +156,9 @@ export default {
|
|
|
135
156
|
if (this.loadMake) {
|
|
136
157
|
if (!this._empty(this.val)) {
|
|
137
158
|
setTimeout(() => {
|
|
138
|
-
|
|
159
|
+
setTimeout(()=>{
|
|
160
|
+
this._makeCode()
|
|
161
|
+
})
|
|
139
162
|
}, 0);
|
|
140
163
|
}
|
|
141
164
|
}
|
|
@@ -155,7 +178,7 @@ export default {
|
|
|
155
178
|
showLoading: false, // 是否显示loading
|
|
156
179
|
loadingText: that.loadingText, // loading文字
|
|
157
180
|
text: that.val, // 生成内容
|
|
158
|
-
size: that.
|
|
181
|
+
size: that.sizeLocal, // 二维码大小
|
|
159
182
|
background: that.background, // 背景色
|
|
160
183
|
foreground: that.foreground, // 前景色
|
|
161
184
|
pdground: that.pdground, // 定位角点颜色
|
|
@@ -219,9 +242,90 @@ export default {
|
|
|
219
242
|
url: this.result
|
|
220
243
|
}, e)
|
|
221
244
|
},
|
|
222
|
-
longpress() {
|
|
223
|
-
|
|
245
|
+
async longpress() {
|
|
246
|
+
if (this.context) {
|
|
247
|
+
this.ctx.toTempFilePath(
|
|
248
|
+
0,
|
|
249
|
+
0,
|
|
250
|
+
this.sizeLocal,
|
|
251
|
+
this.sizeLocal,
|
|
252
|
+
this.sizeLocal,
|
|
253
|
+
this.sizeLocal,
|
|
254
|
+
"",
|
|
255
|
+
1,
|
|
256
|
+
res => {
|
|
257
|
+
this.$emit('longpressCallback', res.tempFilePath)
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const canvas = await this.getNode(this.cId,true);
|
|
263
|
+
// #ifdef MP-TOUTIAO || H5
|
|
264
|
+
this.$emit('longpressCallback', this.ctx.canvas.toDataURL("image/png", 1));
|
|
265
|
+
// #endif
|
|
266
|
+
|
|
267
|
+
// #ifndef MP-TOUTIAO || H5
|
|
268
|
+
uni.canvasToTempFilePath(
|
|
269
|
+
{
|
|
270
|
+
canvas,
|
|
271
|
+
success :res => {
|
|
272
|
+
console.log(res.tempFilePath)
|
|
273
|
+
this.$emit('longpressCallback', res.tempFilePath)
|
|
274
|
+
},
|
|
275
|
+
fail: err =>{
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
this)
|
|
279
|
+
// #endif
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
224
283
|
},
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 使用根节点宽高 设置新的size
|
|
287
|
+
* @return {Promise<void>}
|
|
288
|
+
*/
|
|
289
|
+
async setNewSize(){
|
|
290
|
+
const rootNode = await this.getNode(this.rootId,false);
|
|
291
|
+
const { width , height } = rootNode;
|
|
292
|
+
// 将最短的设置为二维码 的size
|
|
293
|
+
if(width > height){
|
|
294
|
+
this.sizeLocal = height
|
|
295
|
+
}
|
|
296
|
+
else{
|
|
297
|
+
this.sizeLocal = width
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* 获取节点
|
|
303
|
+
* @param id 节点id
|
|
304
|
+
* @param isCanvas 是否为Canvas节点
|
|
305
|
+
* @return {Promise<unknown>}
|
|
306
|
+
*/
|
|
307
|
+
async getNode(id,isCanvas){
|
|
308
|
+
return new Promise((resolve, reject)=>{
|
|
309
|
+
try {
|
|
310
|
+
const query = uni.createSelectorQuery().in(this);
|
|
311
|
+
query.select(`#${id}`)
|
|
312
|
+
.fields({ node: true, size: true })
|
|
313
|
+
.exec((res) => {
|
|
314
|
+
if(isCanvas){
|
|
315
|
+
resolve(res[0].node)
|
|
316
|
+
}
|
|
317
|
+
else{
|
|
318
|
+
resolve(res[0])
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
console.error("获取节点失败",e)
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
},
|
|
328
|
+
|
|
225
329
|
selectClick(index) {
|
|
226
330
|
switch (index) {
|
|
227
331
|
case 0:
|
|
@@ -250,7 +354,7 @@ export default {
|
|
|
250
354
|
rt = false
|
|
251
355
|
}
|
|
252
356
|
return rt
|
|
253
|
-
}
|
|
357
|
+
},
|
|
254
358
|
},
|
|
255
359
|
watch: {
|
|
256
360
|
size: function (n, o) {
|
package/components/u-td/u-td.vue
CHANGED
|
@@ -120,11 +120,11 @@ export default {
|
|
|
120
120
|
}
|
|
121
121
|
// 占满剩余空间
|
|
122
122
|
if (this.flex1) {
|
|
123
|
-
style.flex = 1;
|
|
124
|
-
// #ifndef APP-NVUE
|
|
125
|
-
style.width = '100%';
|
|
123
|
+
style.flex = 1;
|
|
124
|
+
// #ifndef APP-NVUE
|
|
125
|
+
style.width = '100%';
|
|
126
126
|
// #endif
|
|
127
|
-
}
|
|
127
|
+
}
|
|
128
128
|
return style;
|
|
129
129
|
},
|
|
130
130
|
valueStyle() {
|
|
@@ -175,8 +175,6 @@ export default {
|
|
|
175
175
|
</script>
|
|
176
176
|
|
|
177
177
|
<style lang="scss" scoped>
|
|
178
|
-
@import '../../libs/css/components.scss';
|
|
179
|
-
|
|
180
178
|
.u-text {
|
|
181
179
|
@include flex(row);
|
|
182
180
|
align-items: center;
|