zydx-plus 1.32.299 → 1.32.301
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/package.json
CHANGED
|
@@ -131,6 +131,8 @@ import * as PdfJs from 'pdfjs-dist/legacy/build/pdf.js' // 注意导入的写法
|
|
|
131
131
|
PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
|
|
132
132
|
const jsdelivr = '/zydx/static/cmaps/'
|
|
133
133
|
|
|
134
|
+
let pdfs = null
|
|
135
|
+
|
|
134
136
|
export default {
|
|
135
137
|
name: "zydx-flip",
|
|
136
138
|
data() {
|
|
@@ -188,7 +190,7 @@ export default {
|
|
|
188
190
|
textHeight: 0,
|
|
189
191
|
textDownX: 0,
|
|
190
192
|
textDownY: 0,
|
|
191
|
-
textMoveStart: false
|
|
193
|
+
textMoveStart: false
|
|
192
194
|
}
|
|
193
195
|
},
|
|
194
196
|
props: {
|
|
@@ -241,7 +243,7 @@ export default {
|
|
|
241
243
|
},
|
|
242
244
|
source: {
|
|
243
245
|
handler: function () {
|
|
244
|
-
this.
|
|
246
|
+
this.sourceUrl()
|
|
245
247
|
},
|
|
246
248
|
deep: true,
|
|
247
249
|
immediate: true
|
|
@@ -936,6 +938,7 @@ export default {
|
|
|
936
938
|
}
|
|
937
939
|
},
|
|
938
940
|
flipLeft(e, v) {
|
|
941
|
+
console.log(e)
|
|
939
942
|
if (e > this.pdfPages) {
|
|
940
943
|
this.pageIndex = this.pdfPages
|
|
941
944
|
return
|
|
@@ -952,6 +955,7 @@ export default {
|
|
|
952
955
|
}
|
|
953
956
|
},
|
|
954
957
|
flipRight(e, v) {
|
|
958
|
+
console.log(e)
|
|
955
959
|
if (e < 1) {
|
|
956
960
|
this.pageIndex = 1
|
|
957
961
|
return
|
|
@@ -967,65 +971,67 @@ export default {
|
|
|
967
971
|
})
|
|
968
972
|
}
|
|
969
973
|
},
|
|
970
|
-
|
|
971
|
-
this.mouse()
|
|
974
|
+
sourceUrl() {
|
|
972
975
|
if (this.source === '' || this.source === undefined || this.source === null) return
|
|
973
976
|
let that = this
|
|
974
|
-
|
|
975
|
-
if (that.imgArr[that.pageIndex - 1] !== undefined) {
|
|
976
|
-
that.oneShow = that.pageIndex !== 1
|
|
977
|
-
}
|
|
977
|
+
that.loading = true
|
|
978
978
|
const loadingTask = PdfJs.getDocument({
|
|
979
|
-
url:
|
|
979
|
+
url: that.source,
|
|
980
980
|
cMapUrl: jsdelivr,
|
|
981
981
|
cMapPacked: true
|
|
982
982
|
})
|
|
983
983
|
loadingTask.promise.then((pdf) => {
|
|
984
|
+
pdfs = pdf
|
|
984
985
|
that.pdfPages = pdf.numPages // 获取pdf文件的总页数
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
986
|
+
that.readPdf(pdf)
|
|
987
|
+
})
|
|
988
|
+
},
|
|
989
|
+
readPdf() {
|
|
990
|
+
let that = this
|
|
991
|
+
this.mouse()
|
|
992
|
+
pdfs.getPage(that.pageIndex).then(function (page) {
|
|
993
|
+
let canvas = document.getElementById(that.id)
|
|
994
|
+
let canvas2 = document.getElementById(`${that.id}2`)
|
|
995
|
+
that.ctx = canvas.getContext('2d');
|
|
996
|
+
let ctx2 = canvas2.getContext('2d');
|
|
997
|
+
let viewport = page.getViewport({scale: that.scales})
|
|
998
|
+
canvas.width = viewport.width * that.sratio
|
|
999
|
+
canvas.height = viewport.height * that.sratio
|
|
1000
|
+
canvas.style.width = viewport.width + 'px'
|
|
1001
|
+
canvas.style.height = viewport.height + 'px'
|
|
1002
|
+
canvas2.width = viewport.width * that.sratio
|
|
1003
|
+
canvas2.height = viewport.height * that.sratio
|
|
1004
|
+
canvas2.style.width = viewport.width + 'px'
|
|
1005
|
+
canvas2.style.height = viewport.height + 'px'
|
|
1006
|
+
that.canvasStyle = {
|
|
1007
|
+
width: viewport.width + 'px',
|
|
1008
|
+
height: viewport.height + 'px',
|
|
1009
|
+
marginLeft: -(viewport.width / 2) + 'px',
|
|
1010
|
+
widthCanvas: viewport.width * that.sratio,
|
|
1011
|
+
heightCanvas: viewport.height * that.sratio
|
|
1012
|
+
}
|
|
1013
|
+
let renderContext = {
|
|
1014
|
+
canvasContext: ctx2,
|
|
1015
|
+
viewport: viewport,
|
|
1016
|
+
transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
|
|
1017
|
+
}
|
|
1018
|
+
page.render(renderContext)
|
|
1019
|
+
that.loading = false
|
|
1020
|
+
if (that.oneIndex === 'right') {
|
|
1021
|
+
that.flipRights = true
|
|
1022
|
+
that.flipLefts = false
|
|
1023
|
+
} else {
|
|
1024
|
+
that.flipRights = false
|
|
1025
|
+
that.flipLefts = true
|
|
1026
|
+
}
|
|
1027
|
+
// 获取canvas的base64数据
|
|
1028
|
+
setTimeout(() => {
|
|
1029
|
+
that.flipRights = false
|
|
1030
|
+
that.flipLefts = false
|
|
1031
|
+
that.oneShow = false
|
|
1032
|
+
that.imgArr[that.pageIndex] = canvas2.toDataURL('image/jpeg', 1)
|
|
1033
|
+
that.processing()
|
|
1034
|
+
}, 1000)
|
|
1029
1035
|
})
|
|
1030
1036
|
}
|
|
1031
1037
|
}
|
|
@@ -1251,7 +1257,7 @@ export default {
|
|
|
1251
1257
|
display: inline-block;
|
|
1252
1258
|
margin: 0 auto;
|
|
1253
1259
|
position: relative;
|
|
1254
|
-
|
|
1260
|
+
//cursor: none;
|
|
1255
1261
|
}
|
|
1256
1262
|
|
|
1257
1263
|
.but-wrap {
|
|
@@ -8,7 +8,7 @@ render(divNode, document.body)
|
|
|
8
8
|
const container = divNode.el
|
|
9
9
|
|
|
10
10
|
// 导出函数可通过调用 Confirm() 函数动态创建 XtxConfirm 组件
|
|
11
|
-
const Confirm = ({ type, url ,title,radioArr,checkboxArr,submitText,cancelText,closeShow, promptContent, middle, cancelShow, inputArr }) => {
|
|
11
|
+
const Confirm = ({ type, url ,title,radioArr,checkboxArr,submitText,cancelText,closeShow, promptContent, middle, cancelShow, inputArr, countdown }) => {
|
|
12
12
|
// 返回 Promise 对象
|
|
13
13
|
return new Promise((resolve, reject) => {
|
|
14
14
|
// 2. 点击确认按钮,触发resolve同时销毁组件
|
|
@@ -49,7 +49,7 @@ const Confirm = ({ type, url ,title,radioArr,checkboxArr,submitText,cancelText,c
|
|
|
49
49
|
render(null, container)
|
|
50
50
|
}
|
|
51
51
|
// 1. 创建 XtxConfirm 组件
|
|
52
|
-
const VNode = createVNode(XtxConfirm, { type, url ,title, submitText, cancelText, closeShow,promptContent,radioArr,checkboxArr, middle, cancelShow, inputArr, submit, cancel, close })
|
|
52
|
+
const VNode = createVNode(XtxConfirm, { type, url ,title, submitText, cancelText, closeShow,promptContent,radioArr,checkboxArr, middle, cancelShow, inputArr,countdown, submit, cancel, close })
|
|
53
53
|
render(VNode, container)
|
|
54
54
|
})
|
|
55
55
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<div class="tip-boxContent">
|
|
10
10
|
<div class="tap-p" ref="tapP">
|
|
11
11
|
<div class="tip-title2" ref="tipTitle" v-if="type === 'text'"
|
|
12
|
-
:style="{'text-align': (middles)? 'center': 'left', 'text-indent': indent? '2em': '0' }"
|
|
12
|
+
:style="{'text-align': (middles)? 'center': 'left', 'text-indent': indent? '2em': '0' }">{{ promptContent }} {{ countdown === 0?'':`(${timeo}s)` }}</div>
|
|
13
13
|
<div class="tip-img" v-if="type === 'img'">
|
|
14
14
|
<img :src="url" alt=""/>
|
|
15
15
|
</div>
|
|
@@ -94,6 +94,8 @@ import Select from '../../select/src/select.vue'
|
|
|
94
94
|
import Calendar from '../../calendar/src/Calendar'
|
|
95
95
|
import Year from '../../year/src/year'
|
|
96
96
|
|
|
97
|
+
let timeStop = null
|
|
98
|
+
|
|
97
99
|
export default {
|
|
98
100
|
name: 'zydx-tip-box',
|
|
99
101
|
components: {Select, Calendar,Year},
|
|
@@ -103,7 +105,8 @@ export default {
|
|
|
103
105
|
tipYear: false,
|
|
104
106
|
fileName: '',
|
|
105
107
|
middles: this.middle,
|
|
106
|
-
indent: false
|
|
108
|
+
indent: false,
|
|
109
|
+
timeo: 0
|
|
107
110
|
}
|
|
108
111
|
},
|
|
109
112
|
props: {
|
|
@@ -123,6 +126,10 @@ export default {
|
|
|
123
126
|
type: String,
|
|
124
127
|
default: '默认文字'
|
|
125
128
|
},
|
|
129
|
+
countdown: { // 倒计时
|
|
130
|
+
type: Number,
|
|
131
|
+
default: 0
|
|
132
|
+
},
|
|
126
133
|
middle: { // 弹窗中间的文字内容是居中 还是居左 默认居中
|
|
127
134
|
type: Boolean,
|
|
128
135
|
default: true
|
|
@@ -180,9 +187,26 @@ export default {
|
|
|
180
187
|
this.indent = true
|
|
181
188
|
}
|
|
182
189
|
}
|
|
190
|
+
if(this.countdown > 0) {
|
|
191
|
+
this.timeo = this.countdown
|
|
192
|
+
this.countdownFun()
|
|
193
|
+
}
|
|
183
194
|
})
|
|
184
195
|
},
|
|
196
|
+
beforeUnmount() {
|
|
197
|
+
clearInterval(timeStop)
|
|
198
|
+
},
|
|
185
199
|
methods: {
|
|
200
|
+
countdownFun() {
|
|
201
|
+
let that = this
|
|
202
|
+
timeStop = setInterval(function(){
|
|
203
|
+
that.timeo--;
|
|
204
|
+
if (that.timeo <= 0) {
|
|
205
|
+
clearInterval(timeStop)
|
|
206
|
+
that.cancel()
|
|
207
|
+
}
|
|
208
|
+
},1000)
|
|
209
|
+
},
|
|
186
210
|
checkboxTao(index) {
|
|
187
211
|
this.checkboxArr[index].checked = !this.checkboxArr[index].checked
|
|
188
212
|
},
|