exports.ids = [24]; exports.modules = { /***/ 203: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--6!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/PriceToImg.vue?vue&type=template&id=2e991f10 var render = function render() { var _vm = this, _c = _vm._self._c; return _c('div', { ref: "printArea", staticStyle: { "font-family": "ProximaNova-Regular", "background-color": "#fff", "padding": "20px", "word-break": "break-word", "box-sizing": "border-box" } }, [_vm._ssrNode("
" + (_vm.isImgSrc ? "" : "") + "

" + _vm._ssrEscape(_vm._s(_vm.pageData.product_code)) + " " + _vm._ssrEscape(_vm._s(_vm.pageData.product_name)) + "

" + _vm._s(_vm.comInfo.description) + "

Specifications

" + _vm._ssrList(_vm.headerColumns, function (item, key) { return ""; }) + "" + _vm._ssrList(_vm.headerColumns, function (item, key) { return ""; }) + "
" + _vm._ssrEscape(_vm._s(item.label)) + "
" + (_vm.specificationsObj[item.prop] ? "
" + (item.prop != 'addonArr' ? "" + _vm._ssrEscape(_vm._s(_vm.specificationsObj[item.prop])) + "" : _vm._ssrList(_vm.specificationsObj.addonArr, function (opt, idx) { return "
" + _vm._ssrEscape(_vm._s(opt)) + "
"; })) + "
" : "-") + "

Quote

" + (_vm.comLocationNum !== 1 ? "Quote Total" : "") + " " + _vm._ssrList(_vm.tableColumns, function (item, key) { return "" + _vm._ssrEscape(_vm._s(item.label)) + ""; }) + " " + _vm._ssrList(_vm.tableData, function (row) { return "" + _vm._ssrList(_vm.tableColumns, function (column) { return "" + _vm._ssrEscape("\n " + _vm._s(row[column.prop].includes('.') ? '£' : '') + " " + _vm._s(row[column.prop] ? row[column.prop] : '0.00') + "\n ") + ""; }) + ""; }) + "
" + (_vm.emailForm.Comments ? "

" + _vm._ssrEscape(_vm._s(_vm.emailForm.Comments)) + "

" : ""))]); }; var staticRenderFns = []; // CONCATENATED MODULE: ./components/PriceToImg.vue?vue&type=template&id=2e991f10 // EXTERNAL MODULE: external "html2canvas" var external_html2canvas_ = __webpack_require__(142); var external_html2canvas_default = /*#__PURE__*/__webpack_require__.n(external_html2canvas_); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/PriceToImg.vue?vue&type=script&lang=js /* harmony default export */ var PriceToImgvue_type_script_lang_js = ({ props: { pageData: { type: Object, default: {} }, specificationsObj: { type: Object, default: {} }, tableData: { type: Array, default: [] }, tableColumns: { type: Array, default: [] }, comLocationNum: { type: Number, default: 1 }, emailForm: { type: Object, default: {} }, loading: { type: Boolean, default: false }, isImgSrc: { type: Boolean, default: true }, width: { type: String, default: '100%' } }, data() { return { headerColumns: [{ label: "LeadTime", prop: "time", type: "pre" //去掉$符号 }, { label: "Model", prop: "model", type: "pre" //去掉$符号 }, { label: "Decoration", prop: "decoration", type: "pre" //去掉$符号 }, { label: "Add On", prop: "addonArr", type: "pre" //去掉$符号 }] }; }, computed: { comInfo() { var _this$pageData; return (_this$pageData = this.pageData) === null || _this$pageData === void 0 ? void 0 : _this$pageData.main; }, comWidth() { return 100 / this.tableColumns.length + '%'; } }, created() { if (!this.isImgSrc) { this.getBase64Image(this.comInfo.image, 'productImg'); } }, methods: { getColumnHeaderStyle(column) { if (column.prop === 'project') { return { 'font-weight': 'bold' }; } return {}; }, //Base64生成产品图片,因为跨域 getBase64Image(url, ref) { var that = this; var image = new Image(); image.src = url + '?v=' + Math.random(); // 处理缓存 image.crossOrigin = '*'; // 支持跨域图片 image.onload = function () { var base64 = that.drawBase64Image(image); that.$refs[ref].src = base64; }; }, drawBase64Image(img) { var canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; var ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0, img.width, img.height); var dataURL = canvas.toDataURL('image/png'); return dataURL; }, htmlToPdf(title) { const element = this.$refs.printArea; const clientWidth = element.offsetWidth; const clientHeight = element.offsetHeight; const kh = [clientWidth, clientHeight]; const opts = { scale: 1.5, // 缩放比例,提高生成图片清晰度 useCORS: true, // 允许加载跨域的图片 // allowTaint: true, // 允许图片跨域,和 useCORS 二者不可共同使用 tainttest: true, // 检测每张图片已经加载完成 logging: true // 日志开关,发布的时候记得改成 false }; external_html2canvas_default()(element, opts).then(canvas => { const dataURL = canvas.toDataURL('image/png'); this.downloadImage(dataURL, kh, title); this.$emit('update:loading', false); }).catch(() => { this.$emit('update:loading', false); // Bus.$emit("finishDownload"); }); }, getUrlBase64(url, kh) { return new Promise(resolve => { let canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); const img = new Image(); img.crossOrigin = 'Anonymous'; // 允许跨域 img.src = url; img.onload = () => { // eslint-disable-next-line prefer-destructuring canvas.height = kh[1]; // eslint-disable-next-line prefer-destructuring canvas.width = kh[0]; ctx.drawImage(img, 0, 0, kh[0], kh[1]); const dataURL = canvas.toDataURL('image/png'); canvas = null; resolve(dataURL); }; }); }, downloadImage(imgUrl, kh, title) { this.getUrlBase64(imgUrl, kh).then(base64 => { const link = document.createElement('a'); link.href = base64; link.download = `${title}.png`; link.click(); }); } } }); // CONCATENATED MODULE: ./components/PriceToImg.vue?vue&type=script&lang=js /* harmony default export */ var components_PriceToImgvue_type_script_lang_js = (PriceToImgvue_type_script_lang_js); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(2); // CONCATENATED MODULE: ./components/PriceToImg.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( components_PriceToImgvue_type_script_lang_js, render, staticRenderFns, false, null, null, "dda7dca6" ) /* harmony default export */ var PriceToImg = __webpack_exports__["default"] = (component.exports); /***/ }) };; //# sourceMappingURL=price-to-img.js.map