Header.vue 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764
  1. <template>
  2. <div class="app-header">
  3. <a class="logo" :href="enterprise.home" target="_blank">
  4. <img src="/favicon.ico" />
  5. <span> {{ enterprise.name }}</span>
  6. </a>
  7. <t-dropdown
  8. :minColumnWidth="200"
  9. :maxHeight="560"
  10. :delay2="[10, 150]"
  11. overlayClassName="header-dropdown"
  12. trigger1="click"
  13. >
  14. <a> 文件 </a>
  15. <t-dropdown-menu>
  16. <t-dropdown-item @click="newFile">
  17. <a>新建文件</a>
  18. </t-dropdown-item>
  19. <t-dropdown-item @click="load(true)">
  20. <a>打开文件</a>
  21. </t-dropdown-item>
  22. <t-dropdown-item divider="true" @click="load">
  23. <a>导入文件</a>
  24. </t-dropdown-item>
  25. <t-dropdown-item>
  26. <a @click="save()">保存</a>
  27. </t-dropdown-item>
  28. <t-dropdown-item>
  29. <a @click="save(SaveType.SaveAs, '', undefined, 1)">另存为</a>
  30. </t-dropdown-item>
  31. <t-dropdown-item divider="true">
  32. <a @click="downloadJson">下载JSON文件</a>
  33. </t-dropdown-item>
  34. <t-dropdown-item>
  35. <a @click="downloadZip">
  36. <div class="flex">
  37. 导出为ZIP文件 <span class="flex-grow"></span>
  38. <span><label>VIP</label></span>
  39. </div>
  40. </a>
  41. </t-dropdown-item>
  42. <t-dropdown-item>
  43. <a @click="downloadHtml">
  44. <div class="flex">
  45. 下载离线部署包 <span class="flex-grow"></span>
  46. <span><label>企</label></span>
  47. </div>
  48. </a>
  49. </t-dropdown-item>
  50. <t-dropdown-item>
  51. <a @click="downloadVue3">
  52. <div class="flex">
  53. 下载Vue3组件包 <span class="flex-grow"></span>
  54. <span><label>企</label></span>
  55. </div>
  56. </a>
  57. </t-dropdown-item>
  58. <t-dropdown-item>
  59. <a @click="downloadVue2">
  60. <div class="flex">
  61. 下载Vue2组件包 <span class="flex-grow"></span>
  62. <span><label>企</label></span>
  63. </div>
  64. </a>
  65. </t-dropdown-item>
  66. <t-dropdown-item divider="true">
  67. <a @click="downloadReact">
  68. <div class="flex">
  69. 下载React组件包 <span class="flex-grow"></span>
  70. <span><label>企</label></span>
  71. </div>
  72. </a>
  73. </t-dropdown-item>
  74. <t-dropdown-item>
  75. <a @click="downloadPng">下载为PNG</a>
  76. </t-dropdown-item>
  77. <t-dropdown-item divider="true">
  78. <a @click="downloadSvg">下载为SVG</a>
  79. </t-dropdown-item>
  80. <t-dropdown-item>
  81. <a @click="switchTheme('light')">明亮主题</a>
  82. </t-dropdown-item>
  83. <t-dropdown-item>
  84. <a @click="switchTheme('dark')">暗黑主题</a>
  85. </t-dropdown-item>
  86. </t-dropdown-menu>
  87. </t-dropdown>
  88. <t-dropdown
  89. :minColumnWidth="180"
  90. :maxHeight="500"
  91. :delay2="[10, 150]"
  92. overlayClassName="header-dropdown"
  93. >
  94. <a> 编辑 </a>
  95. <t-dropdown-menu>
  96. <t-dropdown-item>
  97. <a @click="onUndo">
  98. <div class="flex">
  99. 撤销 <span class="flex-grow"></span> Ctrl + Z
  100. </div>
  101. </a>
  102. </t-dropdown-item>
  103. <t-dropdown-item divider="true">
  104. <a @click="onRedo">
  105. <div class="flex">
  106. 重做 <span class="flex-grow"></span> Ctrl + Y
  107. </div>
  108. </a>
  109. </t-dropdown-item>
  110. <t-dropdown-item>
  111. <a @click="onCut">
  112. <div class="flex">
  113. 剪切 <span class="flex-grow"></span> Ctrl + X
  114. </div>
  115. </a>
  116. </t-dropdown-item>
  117. <t-dropdown-item>
  118. <a @click="onCopy">
  119. <div class="flex">
  120. 复制 <span class="flex-grow"></span> Ctrl + C
  121. </div>
  122. </a>
  123. </t-dropdown-item>
  124. <t-dropdown-item divider="true">
  125. <a @click="onPaste">
  126. <div class="flex">
  127. 粘贴 <span class="flex-grow"></span> Ctrl + V
  128. </div>
  129. </a>
  130. </t-dropdown-item>
  131. <t-dropdown-item>
  132. <a @click="onAll">
  133. <div class="flex">
  134. 全选 <span class="flex-grow"></span> Ctrl + A
  135. </div>
  136. </a>
  137. </t-dropdown-item>
  138. <t-dropdown-item>
  139. <a @click="onDelete">
  140. <div class="flex">删除 <span class="flex-grow"></span> DELETE</div>
  141. </a>
  142. </t-dropdown-item>
  143. </t-dropdown-menu>
  144. </t-dropdown>
  145. <t-dropdown
  146. :minColumnWidth="180"
  147. :maxHeight="500"
  148. :delay2="[10, 150]"
  149. overlayClassName="header-dropdown"
  150. >
  151. <a> 工具 </a>
  152. <t-dropdown-menu>
  153. <t-dropdown-item>
  154. <a @click="onScaleWindow">窗口大小</a>
  155. </t-dropdown-item>
  156. <t-dropdown-item>
  157. <a @click="onScaleUp">放大</a>
  158. </t-dropdown-item>
  159. <t-dropdown-item>
  160. <a @click="onScaleDown">缩小</a>
  161. </t-dropdown-item>
  162. <t-dropdown-item divider="true">
  163. <a @click="onScaleFull">100%视图</a>
  164. </t-dropdown-item>
  165. <t-dropdown-item>
  166. <a @click="showMap">
  167. <div class="flex middle">
  168. 鹰眼地图 <span class="flex-grow"></span>
  169. <!-- <t-icon v-show="map" name="check" /> -->
  170. <check-icon v-show="map" />
  171. </div>
  172. </a>
  173. </t-dropdown-item>
  174. <t-dropdown-item divider="true">
  175. <a @click="showMagnifier">
  176. <div class="flex middle">
  177. 放大镜 <span class="flex-grow"></span>
  178. <!-- <t-icon v-show="magnifier" name="check" /> -->
  179. <check-icon v-show="magnifier" />
  180. </div>
  181. </a>
  182. </t-dropdown-item>
  183. <t-dropdown-item>
  184. <a @click="onAutoAnchor">
  185. <div class="flex middle">
  186. 自动锚点 <span class="flex-grow"></span>
  187. <!-- <t-icon v-show="autoAnchor" name="check" /> -->
  188. <check-icon v-show="autoAnchor" />
  189. </div>
  190. </a>
  191. </t-dropdown-item>
  192. <t-dropdown-item divider="true">
  193. <a @click="onDisableAnchor">
  194. <div class="flex middle">
  195. 显示锚点 <span class="flex-grow"></span>
  196. <!-- <t-icon v-show="showAnchor" name="check" /> -->
  197. <check-icon v-show="showAnchor" />
  198. </div>
  199. </a>
  200. </t-dropdown-item>
  201. <t-dropdown-item>
  202. <a @click="onToggleAnchor">
  203. <div
  204. class="flex"
  205. :style="{
  206. color: showAnchor ? '' : '#4f5b75',
  207. }"
  208. >
  209. 添加/删除锚点 <span class="flex-grow"></span> A
  210. </div>
  211. </a>
  212. </t-dropdown-item>
  213. </t-dropdown-menu>
  214. </t-dropdown>
  215. <t-dropdown
  216. :minColumnWidth="180"
  217. :maxHeight="500"
  218. :delay2="[10, 150]"
  219. overlayClassName="header-dropdown"
  220. >
  221. <a> 帮助 </a>
  222. <t-dropdown-menu>
  223. <t-dropdown-item
  224. v-for="item in enterprise.helps"
  225. :divider="item.divider"
  226. >
  227. <a :href="item.url" target="_blank">{{ item.name }}</a>
  228. </t-dropdown-item>
  229. </t-dropdown-menu>
  230. </t-dropdown>
  231. <div style="width: 148px; flex-shrink: 0"></div>
  232. <input v-model="meta2dData.name" @change="onInputName($event)" />
  233. <a :href="enterprise.account" target="_blank">
  234. <!-- <t-icon name="home" /> -->
  235. <home-icon />
  236. 账户中心
  237. </a>
  238. <a :href="enterprise['v']" target="_blank" class="active">
  239. <!-- <t-icon name="desktop" /> -->
  240. <desktop-icon />
  241. 大屏可视化
  242. </a>
  243. <a :href="enterprise['3d']" target="_blank">
  244. <!-- <t-icon name="control-platform" /> -->
  245. <control-platform-icon />
  246. 3D可视化
  247. </a>
  248. <a :href="enterprise['2d']" target="_blank">
  249. <!-- <t-icon name="app" /> -->
  250. <app-icon />
  251. 2D可视化
  252. </a>
  253. <t-dropdown
  254. v-if="user.id"
  255. :minColumnWidth="200"
  256. :maxHeight="500"
  257. :delay2="[10, 150]"
  258. overlayClassName="custom-dropdown header"
  259. >
  260. <a style="margin-left: 32px; margin-right: 12px">
  261. <t-avatar
  262. size="small"
  263. :image="user.avatarUrl ? user.avatarUrl : baseUrl + 'img/avatar.png'"
  264. />
  265. </a>
  266. <t-dropdown-menu>
  267. <t-dropdown-item divider="true">
  268. <a :href="enterprise.account" target="_blank">
  269. {{ user.username }}
  270. <label
  271. class="ml-16 vip-label"
  272. :style="{
  273. color: user.limit > 1 ? '#ff4000' : '#D5C781',
  274. background: user.limit > 1 ? '#ff400030' : '#D5C78133',
  275. }"
  276. >VIP</label
  277. >
  278. </a>
  279. </t-dropdown-item>
  280. <t-dropdown-item divider="true">
  281. <a :href="`${enterprise.account}/v`" target="_blank"> 我的大屏 </a>
  282. </t-dropdown-item>
  283. <t-dropdown-item>
  284. <a :href="`${enterprise.account}/account/teams`" target="_blank">
  285. 我的团队
  286. </a>
  287. </t-dropdown-item>
  288. <t-dropdown-item>
  289. <a :href="`${enterprise.account}/account/info`" target="_blank">
  290. 账号信息
  291. </a>
  292. </t-dropdown-item>
  293. <t-dropdown-item divider="true">
  294. <a :href="`${enterprise.account}/account/security`" target="_blank">
  295. 安全设置
  296. </a>
  297. </t-dropdown-item>
  298. <t-dropdown-item>
  299. <a @click="logout">退出</a>
  300. </t-dropdown-item>
  301. </t-dropdown-menu>
  302. </t-dropdown>
  303. <div class="flex middle" v-else>
  304. <a class="button primary solid" style="width: 80px" :href="login()">
  305. 登录
  306. </a>
  307. </div>
  308. </div>
  309. <t-dialog
  310. v-if="payListDialog.show"
  311. v-model:visible="payListDialog.show"
  312. class="pay-dialog"
  313. :close-on-overlay-click="false"
  314. :top="95"
  315. :width="700"
  316. :cancel-btn="{
  317. content: '下载试用',
  318. variant: 'outline',
  319. style: {
  320. width: '100px',
  321. color:'#707B8F',
  322. marginRight:'8px'
  323. }
  324. }"
  325. confirm-btn="去支付"
  326. @cancel="downloadTrial"
  327. @close="payListDialog.show = false"
  328. @confirm="prePay"
  329. >
  330. <template #header>
  331. <div>
  332. <span style="vertical-align: middle">{{ payListDialog.title }}</span>
  333. <!-- <t-tooltip content="这是Tooltip内容"> -->
  334. <!-- @vue-ignore -->
  335. <a
  336. :href="payListDialog.href"
  337. target="_blank"
  338. class="hover"
  339. >
  340. <HelpCircleIcon class="hover" style="margin-left:12px;" />
  341. </a>
  342. <!-- </t-tooltip> -->
  343. </div>
  344. </template>
  345. <div class="pay-box">
  346. <div class="pay-title">{{ payListDialog.title }}</div>
  347. <div class="pay-price">
  348. <p>¥</p>
  349. <p>{{ data.deploy.price }}</p>
  350. </div>
  351. </div>
  352. <div class="pay-box pay-diagram">
  353. <div class="pay-up">
  354. <div class="pay-title">
  355. <t-checkbox v-model="data.payDiagram.checked"> 企业图形库
  356. </t-checkbox>
  357. <ChevronDownIcon @click="data.payDiagram.expend=false" v-if="data.payDiagram.expend" />
  358. <ChevronRightIcon @click="data.payDiagram.expend=true" v-else />
  359. </div>
  360. <div class="pay-price">
  361. <p>¥</p>
  362. <p>{{ data.payDiagram.price }}</p>
  363. </div>
  364. </div>
  365. <div v-if="data.payDiagram.expend" class="pay-down">
  366. <div v-for="item in data.payDiagram.list">
  367. <img v-if="item.img" :src="item.img" />
  368. <div v-else-if="item.svg" v-html="item.svg" ></div>
  369. <svg v-else class="l-icon" aria-hidden="true">
  370. <use :xlink:href="'#' + iotPensMap[item.name]?.icon"></use>
  371. </svg>
  372. </div>
  373. <p v-if="data.payDiagram.payAll">
  374. 【说明】检查到当前项目为老版本格式,需要购买整套SVG线性图元。
  375. </p>
  376. </div>
  377. </div>
  378. <div class="pay-footer">
  379. 合计
  380. <div>
  381. <p>¥</p>
  382. <p>{{ data.deploy.price+(data.payDiagram.checked?data.payDiagram.price:0) }}</p>
  383. </div>
  384. </div>
  385. </t-dialog>
  386. <t-dialog
  387. v-if="downloadZipDialog.show"
  388. v-model:visible="downloadZipDialog.show"
  389. class="pay-dialog"
  390. :close-on-overlay-click="false"
  391. :top="95"
  392. :width="700"
  393. :cancel-btn="{
  394. content: '直接下载',
  395. variant: 'outline',
  396. style: {
  397. width: '100px',
  398. color:'#707B8F',
  399. marginRight:'8px'
  400. }
  401. }"
  402. :confirm-btn="downloadZipDialog.checked?'去支付':null"
  403. @close="downloadZipDialog.show = false"
  404. @confirm="prePayDownloadZip"
  405. @cancel="doDownloadZip"
  406. >
  407. <template #header>
  408. <div>
  409. <span style="vertical-align: middle">导出为Zip文件</span>
  410. <t-tooltip content="这是Tooltip内容">
  411. <a
  412. :href="`https://doc${rootDomain}/document/155692631#%E5%AF%BC%E5%87%BA%E4%B8%BAZip%E6%96%87%E4%BB%B6`"
  413. target="_blank"
  414. class="hover"
  415. >
  416. <HelpCircleIcon style="margin-left:12px;" />
  417. </a>
  418. </t-tooltip>
  419. </div>
  420. </template>
  421. <div class="pay-box pay-diagram" style="font-size: 14px;
  422. line-height: 30px;
  423. color: #6E7B91;">
  424. Zip包仅包含数据文件和图片文件,不包含js等依赖库。
  425. <div >- 注意</div>Zip包用于平台(已包含js等依赖库)的快捷导入导出项目,无法作为独立部署包使用。
  426. <p v-if="downloadZipDialog.hasJs">
  427. <p>- 当前图纸包含js企业图形依赖库。</p>
  428. 项目中打开如果没有js企业图形依赖库,对应的图元将无法显示。
  429. 推荐下载为离线部署包(包含js企业图形依赖库)。
  430. </p>
  431. </div>
  432. <div class="pay-box pay-diagram">
  433. <div class="pay-up">
  434. <div class="pay-title">
  435. <t-checkbox v-model="downloadZipDialog.checked"> 企业图形库
  436. </t-checkbox>
  437. <ChevronDownIcon @click="downloadZipDialog.expend=false" v-if="downloadZipDialog.expend" />
  438. <ChevronRightIcon @click="downloadZipDialog.expend=true" v-else />
  439. </div>
  440. <div class="pay-price">
  441. <p>¥</p>
  442. <p>{{ downloadZipDialog.price }}</p>
  443. </div>
  444. </div>
  445. <div v-if="downloadZipDialog.expend" class="pay-down">
  446. <div v-for="item in downloadZipDialog.list">
  447. <img :src="item" />
  448. </div>
  449. </div>
  450. </div>
  451. <div class="pay-footer">
  452. 合计
  453. <div>
  454. <p>¥</p>
  455. <p>{{downloadZipDialog.checked? downloadZipDialog.price:0 }}</p>
  456. </div>
  457. </div>
  458. </t-dialog>
  459. <t-dialog
  460. v-if="wechatPayDialog.show"
  461. v-model:visible="wechatPayDialog.show"
  462. class="pay-dialog"
  463. header="乐吾乐收银台"
  464. :close-on-overlay-click="false"
  465. :top="95"
  466. :width="700"
  467. confirm-btn="支付完成"
  468. :cancel-btn="null"
  469. @close="wechatPayDialog.show = false"
  470. :footer="false"
  471. >
  472. <Pay
  473. :order="data.order"
  474. :alipay-url="data.order.alipayUrl"
  475. :code-url="data.order.codeUrl"
  476. @success="onSuccess"
  477. />
  478. </t-dialog>
  479. </template>
  480. <script lang="ts" setup>
  481. import {
  482. reactive,
  483. ref,
  484. onBeforeMount,
  485. onUnmounted,
  486. nextTick,
  487. computed,
  488. } from 'vue';
  489. import { useRouter, useRoute } from 'vue-router';
  490. import { useUser } from '@/services/user';
  491. import { MessagePlugin } from 'tdesign-vue-next';
  492. import {
  493. Meta2dBackData,
  494. dealwithFormatbeforeOpen,
  495. gotoAccount,
  496. checkData,
  497. } from '@/services/utils';
  498. import { readFile } from '@/services/file';
  499. import { compareVersion, baseVer, upgrade } from '@/services/upgrade';
  500. import { parseSvg } from '@meta2d/svg';
  501. import { Pen, getGlobalColor, isShowChild } from '@meta2d/core';
  502. import { cdn, upCdn } from '@/services/api';
  503. // import JSZip from 'jszip';
  504. import axios from 'axios';
  505. import { switchTheme } from '@/services/theme';
  506. import { noLoginTip } from '@/services/utils';
  507. import {
  508. save,
  509. blank,
  510. newFile,
  511. SaveType,
  512. onScaleFull,
  513. onScaleWindow,
  514. showMagnifier,
  515. showMap,
  516. drawPen,
  517. map,
  518. magnifier,
  519. useDot,
  520. delAttrs,
  521. // useAssets,
  522. // autoSaveAS
  523. } from '@/services/common';
  524. import { useEnterprise } from '@/services/enterprise';
  525. import {
  526. CheckIcon,
  527. HomeIcon,
  528. DesktopIcon,
  529. ControlPlatformIcon,
  530. AppIcon,
  531. ChevronRightIcon,
  532. ChevronDownIcon,
  533. HelpCircleIcon
  534. } from 'tdesign-icons-vue-next';
  535. import {
  536. getDownloadList,
  537. getPayList,
  538. getComponentPurchased,
  539. get2dComponentJs,
  540. getTemPngs,
  541. getGoods,
  542. // preFrameDownload,
  543. zipBkImg,
  544. zipImages,
  545. Frame,
  546. img_cdn,
  547. img_upCdn,
  548. getDeployGoods,
  549. getFrameDownloadList
  550. } from '@/services/download';
  551. import { formComponents, rootDomain } from '@/services/defaults';
  552. import Pay from './Pay.vue';
  553. import {getNetJsDiagram} from '@/services/material';
  554. import { useMeta2dData } from '@/services/common';
  555. const { enterprise } = useEnterprise();
  556. const router = useRouter();
  557. const route = useRoute();
  558. const { meta2dData, setMeta2dData } = useMeta2dData();
  559. const baseUrl = import.meta.env.BASE_URL || '/';
  560. // const { assets, getAssets } = useAssets();
  561. const { user, signout } = useUser();
  562. const { setDot } = useDot();
  563. const data = reactive<any>({
  564. name: '新建项目',
  565. order: {
  566. codeUrl: '',
  567. id: '', //订单id
  568. },
  569. goods: [], //所有商品类型
  570. purchasedList: [], //已经购买的列表
  571. deploy:{
  572. price:400,
  573. },
  574. payDiagram: {
  575. price: 400,
  576. checked:true,
  577. expend:false,
  578. list:[],
  579. payAll:false
  580. },
  581. payGoods:{},
  582. });
  583. onBeforeMount(async () => {
  584. // getAssets();
  585. // getNetJsDiagram();
  586. });
  587. const logout = () => {
  588. signout();
  589. meta2d.emit('logout');
  590. };
  591. const onInputName = (e) => {
  592. // (meta2d.store.data as Meta2dBackData).name = data.name;
  593. setMeta2dData({ name: e.target.value });
  594. setDot(true);
  595. };
  596. const initMeta2dName = () => {
  597. data.name = (meta2d.store.data as Meta2dBackData).name || '';
  598. setMeta2dData({ name: (meta2d.store.data as Meta2dBackData).name || '新建项目' });
  599. };
  600. let downloadList = new Set<any>();
  601. let iframeNum = 0;
  602. let compareNum = 0;
  603. const prePayList = reactive({
  604. pngs: new Set<string>(),
  605. jsPens: new Set<string>(),
  606. iotPens: new Set<string>(),
  607. svgPens: new Set<string>(),
  608. });
  609. let payListNum = 0;
  610. let comparePayListNum = 0;
  611. // let purchasedList = []; //已购买列表
  612. const iotPensMap = {};
  613. let downloadType: Frame = null;
  614. // const payPrice = ref(0);
  615. const getIotPensMap = () => {
  616. formComponents.forEach((item) => {
  617. item.list.forEach((_item) => {
  618. iotPensMap[_item.data.name] = { name: _item.name, icon: _item.icon };
  619. });
  620. });
  621. };
  622. nextTick(() => {
  623. meta2d.on('opened', initMeta2dName);
  624. window.addEventListener('message', dealWithMessage);
  625. getIotPensMap();
  626. });
  627. const dealWithMessage = async (e) => {
  628. if (
  629. typeof e.data !== 'string' ||
  630. !e.data ||
  631. e.data.startsWith('setImmediate')
  632. ) {
  633. return;
  634. }
  635. try {
  636. let data = JSON.parse(e.data);
  637. if (typeof data === 'object') {
  638. if (data.type) {
  639. if (data.name === 'download') {
  640. let list = data.data;
  641. let folderName =downloadType===Frame.vue3?'meta2d-vue3':downloadType===Frame.vue2?'meta2d-vue2': 'meta2d-react';
  642. list.forEach((item) => {
  643. if(item.path.startsWith('/meta3d/')){
  644. item.path = `/${folderName}/public/${item.path}`;
  645. }
  646. });
  647. downloadList = new Set([...downloadList, ...list]);
  648. compareNum += 1;
  649. if (compareNum >= iframeNum) {
  650. saveDownload();
  651. }
  652. } else if (data.name === 'payList') {
  653. prePayList.pngs = new Set([...prePayList.pngs, ...data.data.pngs]);
  654. prePayList.jsPens = new Set([
  655. ...prePayList.jsPens,
  656. ...data.data.jsPens,
  657. ]);
  658. prePayList.iotPens = new Set([
  659. ...prePayList.iotPens,
  660. ...data.data.iotPens,
  661. ]);
  662. prePayList.svgPens = new Set([
  663. ...prePayList.svgPens,
  664. ...data.data.svgPens,
  665. ]);
  666. comparePayListNum += 1;
  667. if (comparePayListNum >= payListNum) {
  668. await showPayListDialog();
  669. }
  670. }
  671. // else if(data.name==='saveas'){
  672. // await autoSaveAS(data.id);
  673. // }
  674. } else {
  675. meta2d.emit(data.name);
  676. }
  677. } else {
  678. meta2d.emit(data);
  679. }
  680. } catch (e) {
  681. console.info(e);
  682. }
  683. };
  684. onUnmounted(() => {
  685. meta2d.off('opened', initMeta2dName);
  686. window.removeEventListener('message', dealWithMessage);
  687. });
  688. const login = () => {
  689. if(import.meta.env.BASE_URL.startsWith('/') ){
  690. return `${enterprise['account']}?cb=${encodeURIComponent(location.href)}`;
  691. }else{
  692. return `https://account${rootDomain}/login?cb=${encodeURIComponent(location.href)}`;
  693. }
  694. };
  695. function load(isNew = false) {
  696. const input = document.createElement('input');
  697. input.type = 'file';
  698. input.onchange = (event) => {
  699. const elem = event.target as HTMLInputElement;
  700. if (elem.files && elem.files[0]) {
  701. // 路由跳转 可能在 openFile 后执行
  702. if (elem.files[0].name.endsWith('.json')) {
  703. blank();
  704. openJson(elem.files[0]);
  705. if (isNew) {
  706. router.push({
  707. path: '/',
  708. query: {
  709. r: Date.now() + '',
  710. },
  711. });
  712. }
  713. } else if (elem.files[0].name.endsWith('.svg')) {
  714. MessagePlugin.info(
  715. '可二次编辑但转换存在损失,若作为图片使用,请使用右侧属性面板的上传图片功能'
  716. );
  717. openSvg(elem.files[0]);
  718. } else if (elem.files[0].name.endsWith('.zip')) {
  719. blank();
  720. router.push({
  721. path: '/',
  722. query: {
  723. r: Date.now() + '',
  724. },
  725. });
  726. setTimeout(() => {
  727. openZip(elem.files[0]);
  728. }, 500);
  729. } else {
  730. MessagePlugin.info('打开文件只支持 json,svg,zip 格式');
  731. }
  732. }
  733. };
  734. input.click();
  735. }
  736. const openJson = async (file: File) => {
  737. const text = await readFile(file);
  738. try {
  739. let data: Meta2dBackData = JSON.parse(text);
  740. if (!data.name) {
  741. data.name = file.name.replace('.json', '');
  742. }
  743. if (!data.version || compareVersion(data.version, baseVer) === -1) {
  744. // 如果版本号不存在或者版本号 version < 1.0.0
  745. data = upgrade(data, baseVer);
  746. }
  747. dealwithFormatbeforeOpen(data);
  748. for (const k of delAttrs) {
  749. delete (data as any)[k];
  750. }
  751. meta2d.open(data);
  752. } catch (e) {
  753. console.error(e);
  754. }
  755. };
  756. const openSvg = async (file: File) => {
  757. const text = await readFile(file);
  758. const pens: Pen[] = parseSvg(text);
  759. meta2d.canvas.addCaches = pens;
  760. MessagePlugin.info('svg转换成功,请点击画布决定放置位置');
  761. };
  762. const openZip = async (file: File) => {
  763. if (!(user && user.id)) {
  764. MessagePlugin.warning(noLoginTip);
  765. return;
  766. }
  767. // if (!user.isVip) {
  768. // gotoAccount();
  769. // return;
  770. // }
  771. if (!user.vip) {
  772. MessagePlugin.info('需要开通普通会员~');
  773. gotoAccount();
  774. return;
  775. }
  776. const { default: JSZip } = await import('jszip');
  777. const zip = new JSZip();
  778. await zip.loadAsync(file);
  779. let dataStr = '';
  780. for (const key in zip.files) {
  781. if (zip.files[key].dir) {
  782. continue;
  783. }
  784. if (key.endsWith('.json')) {
  785. // 认为只有一个 json 文件
  786. // dataStr = await zip.file(key).async('string');
  787. break;
  788. }
  789. }
  790. if (!dataStr) {
  791. return false;
  792. }
  793. for (const key in zip.files) {
  794. if (zip.files[key].dir) {
  795. continue;
  796. }
  797. // let _png = key.indexOf('/png');
  798. // let _img = key.indexOf('/img');
  799. // let _image = key.indexOf('/image');
  800. // let _file = key.indexOf('/file');
  801. let _keyLower = key.toLowerCase();
  802. // if (!key.endsWith('.json') && (_png !== -1 || _img !== -1 || _image !== -1 || _file !== -1)) {
  803. if (
  804. _keyLower.endsWith('.png') ||
  805. _keyLower.endsWith('.svg') ||
  806. _keyLower.endsWith('.gif') ||
  807. _keyLower.endsWith('.jpg') ||
  808. _keyLower.endsWith('.jpeg')
  809. ) {
  810. let filename = key.substr(key.lastIndexOf('/') + 1);
  811. const extPos = filename.lastIndexOf('.');
  812. let ext = '';
  813. if (extPos > 0) {
  814. ext = filename.substr(extPos);
  815. }
  816. filename = filename.substring(0, extPos > 8 ? 8 : extPos);
  817. // 上传文件
  818. const result: any = {};
  819. // await upload(
  820. // // await zip.file(key).async('blob'),
  821. // true,
  822. // filename + ext,
  823. // "/2D/默认"
  824. // );
  825. let _key = key;
  826. // if (_png) {
  827. // _key = key.substring(_png);
  828. // } else if (_image) {
  829. // _key = key.substring(_png);
  830. // } else if (_img) {
  831. // _key = key.substring(_img);
  832. // } else if (_file) {
  833. // _key = key.substring(_file);
  834. // }
  835. if (result) {
  836. if (dataStr.replaceAll) {
  837. //'le5le.meta2d'
  838. dataStr = dataStr.replaceAll(_key.slice(12), result.url);
  839. } else {
  840. while (dataStr.includes(_key)) {
  841. dataStr = dataStr.replace(_key.slice(12), result.url);
  842. // 正则 gm 在特殊情况下报错,例如如下场景
  843. /**
  844. *    
  845. const data = '{"image":"/image/materials/IoT-Chemical(化学)/Air stripper 2(汽提塔2).svg"}';
  846. const key = '/image/materials/IoT-Chemical(化学)/Air stripper 2(汽提塔2).svg';
  847. data.replace(key, '123');
  848. data.replaceAll(key, '123')
  849. data.replace(new RegExp(key, 'gm'), '123');
  850. data.replace(new RegExp(key, 'g'), '123');
  851. */
  852. }
  853. }
  854. }
  855. }
  856. }
  857. try {
  858. let data: Meta2dBackData = JSON.parse(dataStr);
  859. if (data) {
  860. if (!data.name) {
  861. data.name = file.name.replace('.zip', '');
  862. }
  863. if (!data.version || compareVersion(data.version, baseVer) === -1) {
  864. // 如果版本号不存在或者版本号 version < 1.0.0
  865. data = upgrade(data, baseVer);
  866. }
  867. dealwithFormatbeforeOpen(data);
  868. const delAttrs = [
  869. 'userId',
  870. 'shared',
  871. 'team',
  872. 'owner',
  873. 'username',
  874. 'editor',
  875. 'editorId',
  876. 'editorName',
  877. 'createdAt',
  878. 'folder',
  879. 'image',
  880. 'id',
  881. '_id',
  882. 'view',
  883. 'updatedAt',
  884. 'star',
  885. 'recommend',
  886. ];
  887. for (const k of delAttrs) {
  888. delete (data as any)[k];
  889. }
  890. meta2d.open(data);
  891. }
  892. } catch (e) {
  893. return false;
  894. }
  895. };
  896. const downloadJson = () => {
  897. const data: Meta2dBackData = meta2d.data();
  898. if (data._id) delete data._id;
  899. if (data.id) delete data.id;
  900. checkData(data);
  901. import('file-saver').then(({ saveAs }) => {
  902. saveAs(
  903. new Blob(
  904. [JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')],
  905. {
  906. type: 'text/plain;charset=utf-8',
  907. }
  908. ),
  909. `${data.name || 'le5le.meta2d'}.json`
  910. );
  911. });
  912. };
  913. const downloadZip = async () => {
  914. if (!(user && user.id)) {
  915. MessagePlugin.warning(noLoginTip);
  916. return;
  917. }
  918. // if (!user.isVip) {
  919. // // gotoAccount();
  920. // return;
  921. // }
  922. if(!meta2d.store.data.pens.length){
  923. MessagePlugin.info('画布没有画笔!');
  924. return;
  925. }
  926. if (!user.vip) {
  927. MessagePlugin.info('需要开通会员~');
  928. gotoAccount();
  929. return;
  930. }
  931. preDownloadZip();
  932. return;
  933. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  934. const [{ default: JSZip }, { saveAs }] = await Promise.all([
  935. import('jszip'),
  936. import('file-saver'),
  937. ]);
  938. const zip: any = new JSZip();
  939. const data: Meta2dBackData = meta2d.data();
  940. let _fileName =
  941. (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  942. 'le5le.meta2d';
  943. const _zip = zip.folder(`${_fileName}`);
  944. if (data._id) delete data._id;
  945. if (data.id) delete data.id;
  946. checkData(data);
  947. _zip.file(
  948. `${_fileName}.json`,
  949. JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  950. );
  951. await zipBkImg(_zip);
  952. await zipImages(_zip, meta2d.store.data.pens);
  953. const blob = await zip.generateAsync({ type: 'blob' });
  954. saveAs(blob, `${_fileName}.zip`);
  955. };
  956. const preDownloadZip =async () =>{
  957. const meta2dData = meta2d.data();
  958. let payList = getPayList(meta2dData);
  959. let purchased =await getComponentPurchased({
  960. pngs: payList.pngs,
  961. jsPens: [],
  962. iotPens: [],
  963. svgPens: [],
  964. });
  965. downloadZipDialog.checked = true;
  966. if(payList.jsPens.length||payList.iotPens.length||payList.svgPens.length){
  967. downloadZipDialog.hasJs = true;
  968. }else{
  969. downloadZipDialog.hasJs = false;
  970. }
  971. let names = purchased.map((item) => item.name);
  972. data.goods = await getGoods();
  973. let list = payList.pngs.filter((item) => !names.includes(item));
  974. if(!list.length){
  975. doDownloadZip();
  976. }else{
  977. let unitPrice = data.goods.find((item)=>item.type==='图片图元').unitPrice;
  978. downloadZipDialog.price = unitPrice*list.length;
  979. downloadZipDialog.show = true;
  980. downloadZipDialog.list = list;
  981. }
  982. }
  983. const prePayDownloadZip = async ()=>{
  984. if(downloadZipDialog.checked){
  985. const res: any = await axios.post('/api/order/deployment/submit', {
  986. goods:{},
  987. '2ds':downloadZipDialog.list.map((item)=>{return { type: '图片图元', name: item}}),
  988. });
  989. wechatPayDialog.show = true;
  990. wechatPayDialog.isZip = true;
  991. data.order = res;
  992. }else {
  993. doDownloadZip();
  994. }
  995. }
  996. const doDownloadZip = async ()=>{
  997. downloadZipDialog.show = false;
  998. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  999. const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1000. import('jszip'),
  1001. import('file-saver'),
  1002. ]);
  1003. const zip: any = new JSZip();
  1004. const data: Meta2dBackData = meta2d.data();
  1005. let _fileName =
  1006. (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1007. 'le5le.meta2d';
  1008. const _zip = zip.folder(`${_fileName}`);
  1009. if (data._id) delete data._id;
  1010. if (data.id) delete data.id;
  1011. checkData(data);
  1012. _zip.file(
  1013. `${_fileName}.json`,
  1014. JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  1015. );
  1016. await zipBkImg(_zip);
  1017. await zipImages(_zip, meta2d.store.data.pens);
  1018. const blob = await zip.generateAsync({ type: 'blob' });
  1019. saveAs(blob, `${_fileName}.zip`);
  1020. }
  1021. // const zip3D = (name: string) => {
  1022. // const pen_3d = meta2d.store.data.pens.filter(
  1023. // (pen) =>
  1024. // pen.name === 'iframe' &&
  1025. // (pen.tags.includes('meta3d') || pen.iframe.indexOf('3d') !== -1)
  1026. // );
  1027. // if (pen_3d && pen_3d.length) {
  1028. // //存在3d场景
  1029. // pen_3d.forEach((pen) => {
  1030. // //发送消息
  1031. // let params = queryURLParams(pen.iframe.split('?')[1]);
  1032. // (
  1033. // pen.calculative.singleton.div.children[0] as HTMLIFrameElement
  1034. // ).contentWindow.postMessage(
  1035. // JSON.stringify({
  1036. // type: 1,
  1037. // name,
  1038. // id: params.id,
  1039. // }),
  1040. // '*'
  1041. // );
  1042. // });
  1043. // }
  1044. // };
  1045. // const zip2D = (name: string) => {
  1046. // const pen_2d = meta2d.store.data.pens.filter(
  1047. // (pen) =>
  1048. // pen.name === 'iframe' &&
  1049. // (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
  1050. // pen.iframe.indexOf('/2d/') !== -1 ||
  1051. // pen.iframe.indexOf('v.le5le.com') !== -1 ||
  1052. // pen.iframe.indexOf('/v/') !== -1)
  1053. // );
  1054. // if (pen_2d && pen_2d.length) {
  1055. // //存在3d场景
  1056. // pen_2d.forEach((pen) => {
  1057. // //发送消息
  1058. // // let params = queryURLParams(pen.iframe.split('?')[1]);
  1059. // (
  1060. // pen.calculative.singleton.div.children[0] as HTMLIFrameElement
  1061. // ).contentWindow.postMessage(
  1062. // JSON.stringify({
  1063. // name,
  1064. // type: 1,
  1065. // }),
  1066. // '*'
  1067. // );
  1068. // });
  1069. // }
  1070. // }
  1071. function queryURLParams(value?: string) {
  1072. let url = value || window.location.href.split('?')[1];
  1073. const urlSearchParams = new URLSearchParams(url);
  1074. const params = Object.fromEntries(urlSearchParams.entries());
  1075. return params;
  1076. }
  1077. const downloadHtml = async () => {
  1078. if (!(user && user.id)) {
  1079. MessagePlugin.warning(noLoginTip);
  1080. return;
  1081. }
  1082. downloadType = Frame.html;
  1083. await preGetPayList();
  1084. };
  1085. const preGetPayList = async () => {
  1086. //图形库需要购买
  1087. const meta2dData = meta2d.data();
  1088. if(!meta2dData.pens.length){
  1089. MessagePlugin.info('画布没有画笔!');
  1090. return;
  1091. }
  1092. let list = getPayList(meta2dData);
  1093. prePayList.pngs = new Set(list.pngs);
  1094. prePayList.jsPens = new Set(list.jsPens);
  1095. prePayList.iotPens = new Set(list.iotPens);
  1096. prePayList.svgPens = new Set(list.svgPens);
  1097. downloadList = new Set();
  1098. //向iframe发送消息
  1099. payListNum = 0;
  1100. comparePayListNum = 0;
  1101. const pen_pay = meta2dData.pens.filter(
  1102. (pen) =>
  1103. pen.name === 'iframe' &&
  1104. (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
  1105. pen.iframe.indexOf('/2d') !== -1 || pen.iframe.indexOf('data=2d') !== -1 ||
  1106. pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
  1107. pen.iframe.indexOf('/view/v') !== -1 ||pen.iframe.indexOf('data=v') !== -1 ||
  1108. pen.iframe.indexOf('/preview') !== -1)
  1109. );
  1110. if (pen_pay && pen_pay.length) {
  1111. pen_pay.forEach((pen) => {
  1112. //发送消息
  1113. (
  1114. meta2d.store.pens[pen.id].calculative.singleton.div
  1115. .children[0] as HTMLIFrameElement
  1116. ).contentWindow.postMessage(
  1117. JSON.stringify({
  1118. name: 'prePayList',
  1119. type: 1,
  1120. }),
  1121. '*'
  1122. );
  1123. payListNum += 1;
  1124. });
  1125. }
  1126. if (payListNum === 0) {
  1127. await showPayListDialog();
  1128. }
  1129. };
  1130. const showPayListDialog = async () => {
  1131. //下载离线部署包
  1132. const deploys =await getDeployGoods();
  1133. const pen_3d = meta2d.store.data.pens.filter(
  1134. (pen) =>
  1135. pen.name === 'iframe' &&
  1136. (pen.iframe.indexOf(`3d${rootDomain}`) !== -1 ||
  1137. pen.iframe.indexOf('/3d') !== -1)
  1138. );
  1139. const pen_2d = meta2d.store.data.pens.filter(
  1140. (pen) =>
  1141. pen.name === 'iframe' &&
  1142. (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
  1143. pen.iframe.indexOf('/2d') !== -1)
  1144. );
  1145. const pen_v = meta2d.store.data.pens.filter(
  1146. (pen) =>
  1147. pen.name === 'iframe' &&
  1148. (pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
  1149. pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1)
  1150. );
  1151. let price = 0;
  1152. data.payDiagram.checked = true;
  1153. data.payDiagram.expend = false;
  1154. data.payGoods ={}
  1155. deploys.forEach((item) => {
  1156. if(item.name==="3D离线部署下载"){
  1157. price+=item.price*pen_3d.length;
  1158. if(pen_3d.length){
  1159. data.payGoods[item.id]=pen_3d.length;
  1160. }
  1161. }else if(item.name==="2D离线部署下载"){
  1162. price+=item.price*pen_2d.length;
  1163. if(pen_2d.length){
  1164. data.payGoods[item.id]=pen_2d.length;
  1165. }
  1166. }else if(item.name==="大屏离线部署下载"){
  1167. price+=item.price*(pen_v.length+1);
  1168. data.payGoods[item.id]=pen_v.length+1;
  1169. }
  1170. });
  1171. data.deploy.price = price;
  1172. //图形库
  1173. data.goods = await getGoods();
  1174. data.purchasedList = await getComponentPurchased(prePayList);
  1175. data.payDiagram.list =[];
  1176. data.payDiagram.payAll = false;
  1177. data.goods.forEach((goods)=>{
  1178. let purchased = data.purchasedList?.filter(
  1179. (_item) => _item.type === goods.type
  1180. );
  1181. let names = purchased.map((item) => item.name);
  1182. let list = [];
  1183. if(goods.type==='图片图元'){
  1184. list = [...prePayList.pngs];
  1185. }else if(goods.type==='JS线性图元'){
  1186. list = [...prePayList.jsPens];
  1187. }else if(goods.type==='SVG线性图元'){
  1188. list = [...prePayList.svgPens];
  1189. }else if(goods.type==='控件'){
  1190. list = [...prePayList.iotPens];
  1191. }
  1192. let num =0;
  1193. if (goods.type==='SVG线性图元'&&[...prePayList.svgPens].includes('*')) {
  1194. //需要购买全部
  1195. num = goods.count-names.length;
  1196. data.payDiagram.payAll = true;
  1197. }else{
  1198. list.forEach((item)=>{
  1199. if(!names.includes(item)){
  1200. if(goods.type==='控件'){
  1201. data.payDiagram.list.push({
  1202. name:item
  1203. });
  1204. }else if(goods.type==='JS线性图元'){
  1205. data.payDiagram.list.push({
  1206. svg:globalThis.jsPensMap?globalThis.jsPensMap[item]:item
  1207. });
  1208. }else{
  1209. data.payDiagram.list.push({
  1210. img:item
  1211. });
  1212. }
  1213. num+=1;
  1214. }
  1215. })};
  1216. goods.num = num;
  1217. })
  1218. price = 0;
  1219. data.goods.forEach((item, index) => {
  1220. price += item.num * item.unitPrice;
  1221. });
  1222. data.payDiagram.price = price;
  1223. // data.goods.forEach((item, index) => {
  1224. // item.checked = true;
  1225. // let purchased = data.purchasedList?.filter(
  1226. // (_item) => _item.type === item.type
  1227. // );
  1228. // if (index === 0) {
  1229. // item.total = [...prePayList.pngs].length;
  1230. // item.unPurchased = item.total - purchased.length;
  1231. // } else if (index === 1) {
  1232. // item.total = [...prePayList.iotPens].length;
  1233. // item.unPurchased = item.total - purchased.length;
  1234. // } else if (index === 3) {
  1235. // item.total = [...prePayList.jsPens].length;
  1236. // item.unPurchased = item.total - purchased.length;
  1237. // } else if (index === 2) {
  1238. // if (purchased.length === 1 && !purchased[0].name) {
  1239. // //说明已经购买全部 //TODO
  1240. // item.total = item.count;
  1241. // item.unPurchased = 0;
  1242. // } else {
  1243. // //需要购买全部
  1244. // if ([...prePayList.svgPens].includes('*')) {
  1245. // item.total = item.count;
  1246. // item.unPurchased = item.total;
  1247. // } else {
  1248. // item.total = [...prePayList.svgPens].length;
  1249. // item.unPurchased = item.total - purchased.length;
  1250. // }
  1251. // }
  1252. // }
  1253. // });
  1254. payListDialog.show = true;
  1255. switch (downloadType) {
  1256. case Frame.html:
  1257. payListDialog.title = '下载离线部署包';
  1258. payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BD%E7%A6%BB%E7%BA%BF%E9%83%A8%E7%BD%B2%E5%8C%85`;
  1259. payListDialog.downloadUrl =img_cdn+ '/deployment/大厦电力管理系统(html).zip';
  1260. break;
  1261. case Frame.vue2:
  1262. payListDialog.title = '下载vue2组件包';
  1263. payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BDVue2%E7%BB%84%E4%BB%B6%E5%8C%85`;
  1264. payListDialog.downloadUrl = img_cdn+ '/deployment/大厦电力管理系统(vue2).zip';
  1265. break;
  1266. case Frame.vue3:
  1267. payListDialog.title = '下载vue3组件包';
  1268. payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BDVue3%E7%BB%84%E4%BB%B6%E5%8C%85`;
  1269. payListDialog.downloadUrl = img_cdn+ '/deployment/大厦电力管理系统(vue3).zip';
  1270. break;
  1271. case Frame.react:
  1272. payListDialog.title = '下载react组件包';
  1273. payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BDReact%E7%BB%84%E4%BB%B6%E5%8C%85`;
  1274. payListDialog.downloadUrl = img_cdn+ '/deployment/大厦电力管理系统(react).zip';
  1275. break;
  1276. }
  1277. // let price = 0;
  1278. // if (price === 0) {
  1279. // skipPay(); //如果计算价格为0,直接下载
  1280. // } else {
  1281. // payListDialog.show = true;
  1282. // }
  1283. };
  1284. const preDownload =() => {
  1285. iframeNum = 0;
  1286. compareNum = 0;
  1287. const meta2dData:any = meta2d.data();
  1288. meta2dData.userId = user.id;
  1289. const pen_3d = meta2dData.pens.filter(
  1290. (pen) =>
  1291. pen.name === 'iframe' &&
  1292. (pen.iframe.indexOf(`3d${rootDomain}`) !== -1 ||
  1293. pen.iframe.indexOf('/3d') !== -1)
  1294. );
  1295. if (pen_3d && pen_3d.length) {
  1296. //存在3d场景
  1297. if (pen_3d.length === 1) {
  1298. let params = queryURLParams(pen_3d[0].iframe.split('?')[1]);
  1299. meta2d.store.pens[
  1300. pen_3d[0].id
  1301. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1302. JSON.stringify({
  1303. name: 'deploy',
  1304. // id: params.id,
  1305. type: 1, //用于区分是系统消息
  1306. path: `3d`,
  1307. }),
  1308. '*'
  1309. );
  1310. pen_3d[0].iframe = '/view?data=3d';
  1311. } else {
  1312. pen_3d.forEach((pen) => {
  1313. //发送消息
  1314. let params = queryURLParams(pen.iframe.split('?')[1]);
  1315. (
  1316. meta2d.store.pens[pen.id].calculative.singleton.div
  1317. .children[0] as HTMLIFrameElement
  1318. ).contentWindow.postMessage(
  1319. JSON.stringify({
  1320. name: 'deploy',
  1321. // id: params.id,
  1322. type: 1,
  1323. path: `3d-${params.id}`,
  1324. }),
  1325. '*'
  1326. );
  1327. pen.iframe = `/view?data=3d-${params.id}`;
  1328. });
  1329. }
  1330. iframeNum += pen_3d.length;
  1331. }
  1332. const pen_2d = meta2dData.pens.filter(
  1333. (pen) =>
  1334. pen.name === 'iframe' &&
  1335. (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
  1336. pen.iframe.indexOf('/2d') !== -1)
  1337. );
  1338. if (pen_2d && pen_2d.length) {
  1339. //存在3d场景
  1340. if (pen_2d.length === 1) {
  1341. let params = queryURLParams(pen_2d[0].iframe.split('?')[1]);
  1342. meta2d.store.pens[
  1343. pen_2d[0].id
  1344. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1345. JSON.stringify({
  1346. name: 'downloadHtml',
  1347. id: params.id,
  1348. type: 1,
  1349. path: `2d`,
  1350. }),
  1351. '*'
  1352. );
  1353. pen_2d[0].iframe = '/view?data=2d';
  1354. } else {
  1355. pen_2d.forEach((pen) => {
  1356. //发送消息
  1357. let params = queryURLParams(pen.iframe.split('?')[1]);
  1358. (
  1359. meta2d.store.pens[pen.id].calculative.singleton.div
  1360. .children[0] as HTMLIFrameElement
  1361. ).contentWindow.postMessage(
  1362. JSON.stringify({
  1363. name: 'downloadHtml',
  1364. // id: params.id,
  1365. type: 1,
  1366. path: `2d-${params.id}`,
  1367. }),
  1368. '*'
  1369. );
  1370. pen.iframe = `/view?data=2d-${params.id}`;
  1371. });
  1372. }
  1373. iframeNum += pen_2d.length;
  1374. }
  1375. const pen_v = meta2dData.pens.filter(
  1376. (pen) =>
  1377. pen.name === 'iframe' &&
  1378. (pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
  1379. pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1)
  1380. );
  1381. if (pen_v && pen_v.length) {
  1382. //存在3d场景
  1383. pen_v.forEach((pen) => {
  1384. //发送消息
  1385. let params = queryURLParams(pen.iframe.split('?')[1]);
  1386. (
  1387. meta2d.store.pens[pen.id].calculative.singleton.div
  1388. .children[0] as HTMLIFrameElement
  1389. ).contentWindow.postMessage(
  1390. JSON.stringify({
  1391. name: 'downloadHtml',
  1392. // id: params.id,
  1393. type: 1,
  1394. path: `v-${params.id}`,
  1395. }),
  1396. '*'
  1397. );
  1398. pen.iframe = `/view?data=v-${params.id}`;
  1399. });
  1400. iframeNum += pen_v.length;
  1401. }
  1402. downloadList = getDownloadList(meta2dData,undefined);
  1403. if (iframeNum === 0) {
  1404. //如果没有嵌入场景
  1405. saveDownload();
  1406. } else {
  1407. setTimeout(() => {
  1408. if (compareNum < iframeNum) {
  1409. //message阻塞/报错的情况
  1410. saveDownload();
  1411. }
  1412. }, 10000);
  1413. }
  1414. };
  1415. const preFrameDownload = async () => {
  1416. iframeNum = 0;
  1417. compareNum = 0;
  1418. const meta2dData:any = meta2d.data();
  1419. meta2dData.userId = user.id;
  1420. const pen_3d = meta2dData.pens.filter(
  1421. (pen) =>
  1422. pen.name === 'iframe' &&
  1423. (pen.iframe.indexOf(`3d${rootDomain}`) !== -1 ||
  1424. pen.iframe.indexOf('/3d') !== -1)
  1425. );
  1426. let name_3d = (downloadType===Frame.vue3?'toVue3':downloadType===Frame.vue2?'toVue2':'toReact');
  1427. let flag_3d = false; //标记是否存在3d场景
  1428. if (pen_3d && pen_3d.length) {
  1429. //存在3d场景
  1430. if (pen_3d.length === 1) {
  1431. let params = queryURLParams(pen_3d[0].iframe.split('?')[1]);
  1432. meta2d.store.pens[
  1433. pen_3d[0].id
  1434. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1435. JSON.stringify({
  1436. name: name_3d,
  1437. type: 1, //用于区分是系统消息
  1438. path: `3d`,
  1439. }),
  1440. '*'
  1441. );
  1442. pen_3d[0].iframe = '/3d?id=3d';
  1443. } else {
  1444. pen_3d.forEach((pen) => {
  1445. //发送消息
  1446. let params = queryURLParams(pen.iframe.split('?')[1]);
  1447. (
  1448. meta2d.store.pens[pen.id].calculative.singleton.div
  1449. .children[0] as HTMLIFrameElement
  1450. ).contentWindow.postMessage(
  1451. JSON.stringify({
  1452. name:name_3d,
  1453. // id: params.id,
  1454. type: 1,
  1455. path: `3d-${params.id}`,
  1456. }),
  1457. '*'
  1458. );
  1459. pen.iframe = `/3d?id=3d-${params.id}`;
  1460. });
  1461. }
  1462. iframeNum += pen_3d.length;
  1463. flag_3d = true;
  1464. }
  1465. const pen_2d = meta2dData.pens.filter(
  1466. (pen) =>
  1467. pen.name === 'iframe' &&
  1468. (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
  1469. pen.iframe.indexOf('/2d') !== -1)
  1470. );
  1471. let name_2d = (downloadType===Frame.vue3?'downloadVue3':downloadType===Frame.vue2?'downloadVue2':'downloadReact');
  1472. if (pen_2d && pen_2d.length) {
  1473. //存在3d场景
  1474. if (pen_2d.length === 1) {
  1475. let params = queryURLParams(pen_2d[0].iframe.split('?')[1]);
  1476. meta2d.store.pens[
  1477. pen_2d[0].id
  1478. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1479. JSON.stringify({
  1480. name: name_2d,
  1481. id: params.id,
  1482. type: 1,
  1483. path: `2d`,
  1484. }),
  1485. '*'
  1486. );
  1487. pen_2d[0].iframe = '/2d?id=2d';
  1488. } else {
  1489. pen_2d.forEach((pen) => {
  1490. //发送消息
  1491. let params = queryURLParams(pen.iframe.split('?')[1]);
  1492. (
  1493. meta2d.store.pens[pen.id].calculative.singleton.div
  1494. .children[0] as HTMLIFrameElement
  1495. ).contentWindow.postMessage(
  1496. JSON.stringify({
  1497. name:name_2d,
  1498. // id: params.id,
  1499. type: 1,
  1500. path: `2d-${params.id}`,
  1501. }),
  1502. '*'
  1503. );
  1504. pen.iframe = `/2d?id=2d-${params.id}`;
  1505. });
  1506. }
  1507. iframeNum += pen_2d.length;
  1508. }
  1509. const pen_v = meta2dData.pens.filter(
  1510. (pen) =>
  1511. pen.name === 'iframe' &&
  1512. (pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
  1513. pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1||pen.iframe.indexOf('/preview') !== -1)
  1514. );
  1515. if (pen_v && pen_v.length) {
  1516. //存在大屏场景
  1517. pen_v.forEach((pen) => {
  1518. //发送消息
  1519. let params = queryURLParams(pen.iframe.split('?')[1]);
  1520. (
  1521. meta2d.store.pens[pen.id].calculative.singleton.div
  1522. .children[0] as HTMLIFrameElement
  1523. ).contentWindow.postMessage(
  1524. JSON.stringify({
  1525. name: name_2d,
  1526. // id: params.id,
  1527. type: 1,
  1528. path: `v-${params.id}`,
  1529. }),
  1530. '*'
  1531. );
  1532. pen.iframe = `/2d?id=v-${params.id}`;
  1533. });
  1534. iframeNum += pen_v.length;
  1535. }
  1536. downloadList = getFrameDownloadList(meta2dData,undefined,downloadType,flag_3d);
  1537. if (iframeNum === 0) {
  1538. //如果没有嵌入场景
  1539. saveDownload();
  1540. } else {
  1541. setTimeout(() => {
  1542. if (compareNum < iframeNum) {
  1543. //message阻塞/报错的情况
  1544. saveDownload();
  1545. }
  1546. }, 10000);
  1547. }
  1548. }
  1549. const saveDownload = async () => {
  1550. const list = [...downloadList];
  1551. //控件
  1552. let jsPath= '';
  1553. let jsPensPath = '';
  1554. switch (downloadType) {
  1555. case Frame.html:
  1556. jsPath = '/view/js/2d-components.js';
  1557. jsPensPath = `/view/js/1.js`;
  1558. break;
  1559. case Frame.vue2:
  1560. jsPath = '/meta2d-vue2/public/js/2d-components.js';
  1561. jsPensPath = `/meta2d-vue2/public/js/1.js`;
  1562. break;
  1563. case Frame.vue3:
  1564. jsPath = '/meta2d-vue3/public/js/2d-components.js';
  1565. jsPensPath = `/meta2d-vue3/public/js/1.js`;
  1566. break;
  1567. case Frame.react:
  1568. jsPath = '/meta2d-react/public/js/2d-components.js';
  1569. jsPensPath = `/meta2d-react/public/js/1.js`;
  1570. break;
  1571. }
  1572. const js = await get2dComponentJs([...prePayList.iotPens]);
  1573. list.push({
  1574. data: js,
  1575. path:jsPath,
  1576. });
  1577. ///png图形库
  1578. const pngs = await getTemPngs([...prePayList.pngs]);
  1579. list.forEach((item) => {
  1580. if(item.url){
  1581. let url =item.url.replace(img_cdn, '').replace(img_upCdn, '')
  1582. if (pngs[url]) {
  1583. item.url = pngs[url];
  1584. }
  1585. }
  1586. });
  1587. //js线性图元
  1588. const res: any = await axios.post('/api/paid/2d/component?pageSize=1000', {
  1589. type: 'JS线性图元',
  1590. });
  1591. let purchased = res.list.map((item) => item.name);
  1592. let arr = [];
  1593. [...prePayList.jsPens].forEach((item) => {
  1594. if(purchased.includes(item)){
  1595. arr.push(item);
  1596. }
  1597. });
  1598. const res_list: Blob = await axios.post(
  1599. '/api/2d/tools',
  1600. {
  1601. list: arr.map((item) => {
  1602. return {
  1603. type: 'JS线性图元',
  1604. name: item,
  1605. };
  1606. }),
  1607. },
  1608. {
  1609. responseType: 'blob',
  1610. }
  1611. );
  1612. list.push({
  1613. data: res_list,
  1614. path: jsPensPath,
  1615. });
  1616. //SVG线性图元
  1617. if ([...prePayList.svgPens].length) {
  1618. // let purchased = data.purchasedList?.filter(
  1619. // (_item) => _item.type === 'SVG线性图元'
  1620. // );
  1621. const res: any = await axios.post('/api/paid/2d/component?pageSize=1000', {
  1622. type: 'SVG线性图元',
  1623. });
  1624. let purchased = res.list;
  1625. let count = data.goods.find((item) => item.type === 'SVG线性图元').count;
  1626. if(purchased.length === count){
  1627. // if (purchased.length === 1 && !purchased[0].name) {
  1628. //已经购买全部
  1629. list.forEach((item) => {
  1630. if (item.data &&
  1631. (item.path.indexOf('/projects/2d') !== -1 || item.path.indexOf('/projects/v') !== -1 || item.path.indexOf('/public/json')!==-1) &&
  1632. item.path.indexOf('/projects/v/png/') === -1 && item.path.indexOf('/projects/2d/png/') === -1) {
  1633. //清空所有svgpath
  1634. let meta2dData = JSON.parse(item.data);
  1635. for (let key of Object.keys(meta2dData.paths)) {
  1636. let path = meta2dData.paths[key];
  1637. if (
  1638. path.indexOf('-1.18Zm4-1') !== -1 ||
  1639. path.indexOf('-1.19Zm4-1') !== -1 ||
  1640. path.indexOf('2.85ZM') !== -1 ||
  1641. path.indexOf('-1-2.39.3') !== -1
  1642. ) {
  1643. meta2dData.paths[key] = '';
  1644. }
  1645. }
  1646. item.data = JSON.stringify(meta2dData);
  1647. }
  1648. });
  1649. } else {
  1650. let svgnames = purchased.map(i=>i.name);
  1651. list.forEach((item) => {
  1652. if (
  1653. item.data &&
  1654. (item.path.indexOf('/projects/2d') !== -1 || item.path.indexOf('/projects/v') !== -1 || item.path.indexOf('/public/json')!==-1) &&
  1655. item.path.indexOf('/projects/v/png/') === -1 && item.path.indexOf('/projects/2d/png/') === -1
  1656. ) {
  1657. //2d 图纸数据
  1658. let meta2dData = JSON.parse(item.data);
  1659. meta2dData.pens.forEach((pen) => {
  1660. if (pen.name === 'svgPath' && pen.svgUrl) {
  1661. if (svgnames.includes(pen.svgUrl.replace(img_cdn, ''))) {
  1662. pen.pathId = null;
  1663. }
  1664. }
  1665. });
  1666. item.data = JSON.stringify(meta2dData);
  1667. }
  1668. });
  1669. }
  1670. }
  1671. //开始下载list
  1672. const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1673. import('jszip'),
  1674. import('file-saver'),
  1675. ]);
  1676. const zip = new JSZip();
  1677. await Promise.all(
  1678. list.map(async (item: any) => {
  1679. if (item.url) {
  1680. //接口请求
  1681. try{
  1682. const res: Blob = await axios.get(item.url.startsWith('/')?(cdn+item.url):item.url, {
  1683. responseType: 'blob',
  1684. });
  1685. zip.file(item.path, res, { createFolders: true });
  1686. }catch(e){
  1687. console.log(e);
  1688. }
  1689. } else if (item.data) {
  1690. //直接写数据
  1691. zip.file(item.path, item.data, { createFolders: true });
  1692. }
  1693. })
  1694. );
  1695. let _fileName =
  1696. (meta2d.store.data.name &&
  1697. meta2d.store.data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1698. 'le5le.meta2d';
  1699. const blob = await zip.generateAsync({ type: 'blob' });
  1700. saveAs(blob, `${_fileName}.zip`);
  1701. };
  1702. // const _downloadHtml = async () => {
  1703. // if (!(user && user.id)) {
  1704. // MessagePlugin.warning(noLoginTip);
  1705. // return;
  1706. // }
  1707. // // if (!user.isVip) {
  1708. // // gotoAccount();
  1709. // // return;
  1710. // // }
  1711. // if (user.vipDesc !== '超级会员' && user.vipDesc !== '旗舰会员') {
  1712. // MessagePlugin.info('需要开通超级会员~');
  1713. // gotoAccount();
  1714. // return;
  1715. // }
  1716. // frameFlag = -1;
  1717. // MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  1718. // const data: Meta2dBackData = meta2d.data();
  1719. // if (data._id) delete data._id;
  1720. // if (data.id) delete data.id;
  1721. // if (data.image) delete data.image;
  1722. // checkData(data);
  1723. // const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1724. // import('jszip'),
  1725. // import('file-saver'),
  1726. // ]);
  1727. // const zip = new JSZip();
  1728. // let _fileName =
  1729. // (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1730. // 'le5le.meta2d';
  1731. // //处理cdn图片地址
  1732. // const _zip: any = zip.folder(`${_fileName}`);
  1733. // _zip.file(
  1734. // 'data.json',
  1735. // JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  1736. // );
  1737. // await Promise.all([
  1738. // zipBkImg(_zip),
  1739. // zipImages(_zip, meta2d.store.data.pens),
  1740. // zipFiles(_zip),
  1741. // ]);
  1742. // const blob = await zip.generateAsync({ type: 'blob' });
  1743. // saveAs(blob, `${_fileName}.zip`);
  1744. // };
  1745. // async function zipBkImg(zip: JSZip) {
  1746. // let img = meta2d.store.data.bkImage;
  1747. // if (img) {
  1748. // if (img.startsWith('/') || img.startsWith(cdn) || img.startsWith(upCdn)) {
  1749. // const pngs = await getTemPngs([img.replace(cdn, '').replace(upCdn, '')]);
  1750. // await zipImage(zip, img, pngs[img.replace(cdn, '').replace(upCdn, '')]);
  1751. // }
  1752. // }
  1753. // }
  1754. // enum Frame {
  1755. // vue2,
  1756. // vue3,
  1757. // react,
  1758. // html
  1759. // }
  1760. const downloadVue3 = async () => {
  1761. downloadAsFrame(Frame.vue3);
  1762. };
  1763. const downloadVue2 = async () => {
  1764. downloadAsFrame(Frame.vue2);
  1765. };
  1766. const downloadReact = async () => {
  1767. downloadAsFrame(Frame.react);
  1768. };
  1769. async function downloadAsFrame(type: Frame) {
  1770. if (!(user && user.id)) {
  1771. MessagePlugin.warning(noLoginTip);
  1772. return;
  1773. }
  1774. // if (user.vipDesc !== '旗舰会员') {
  1775. // MessagePlugin.info('需要开通旗舰会员~');
  1776. // gotoAccount();
  1777. // return;
  1778. // }
  1779. downloadType = type;
  1780. await preGetPayList();
  1781. }
  1782. // const preFrameDownload = async (type: Frame) => {
  1783. // frameFlag = type;
  1784. // MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  1785. // zip3D(
  1786. // type === Frame.vue3 ? 'toVue3' : type === Frame.vue2 ? 'toVue2' : 'toReact'
  1787. // );
  1788. // zip2D(
  1789. // type === Frame.vue3 ? 'downloadVue3' : type === Frame.vue2 ? 'downloadVue2' : 'downloadReact'
  1790. // );
  1791. // const data: any = meta2d.data();
  1792. // if (data._id) delete data._id;
  1793. // if (data.id) delete data.id;
  1794. // if (data.image) delete data.image;
  1795. // data.userId = user.id;
  1796. // checkData(data);
  1797. // const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1798. // import('jszip'),
  1799. // import('file-saver'),
  1800. // ]);
  1801. // const zip = new JSZip();
  1802. // let _fileName =
  1803. // (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1804. // 'le5le.meta2d';
  1805. // //处理付费svg
  1806. // if (Object.keys(data.paths).length >= 3) {
  1807. // //简单判断有无svg图元
  1808. // const res: any = await axios.post('/api/paid/2d/component', {
  1809. // type: 'SVG线性图元',
  1810. // });
  1811. // if (res.list.length === 1 && !res.list[0].name) {
  1812. // //已经购买全部
  1813. // for (let key of Object.keys(data.paths)) {
  1814. // let path = data.paths[key];
  1815. // if (
  1816. // path.indexOf('-1.18Zm4-1') !== -1 ||
  1817. // path.indexOf('-1.19Zm4-1') !== -1 ||
  1818. // path.indexOf('2.85ZM') !== -1 ||
  1819. // path.indexOf('-1-2.39.3') !== -1
  1820. // ) {
  1821. // data.paths[key] = '';
  1822. // }
  1823. // }
  1824. // } else {
  1825. // //购买部分
  1826. // let purchasedList = res.list.map((i) => i.name);
  1827. // data.pens.forEach((pen) => {
  1828. // if (pen.name === 'svgPath' && pen.svgUrl) {
  1829. // if (purchasedList.includes(pen.svgUrl)) {
  1830. // pen.pathId = null;
  1831. // }
  1832. // }
  1833. // });
  1834. // }
  1835. // }
  1836. // const _zip: any = zip.folder(`${_fileName}`);
  1837. // _zip.file(
  1838. // `${type === Frame.vue3
  1839. // ? 'meta2d-vue3'
  1840. // : type === Frame.vue2
  1841. // ? 'meta2d-vue2'
  1842. // : 'meta2d-react'
  1843. // }/public/json/data.json`,
  1844. // JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  1845. // );
  1846. // await Promise.all([
  1847. // zipJs(_zip),
  1848. // zipBkImg(_zip),
  1849. // zipImages(_zip, meta2d.store.data.pens),
  1850. // type === Frame.vue3
  1851. // ? zipVue3Files(_zip)
  1852. // : type === Frame.vue2
  1853. // ? zipVue2Files(_zip)
  1854. // : zipReactFiles(_zip),
  1855. // zipIotPens(_zip),
  1856. // ]);
  1857. // const blob = await zip.generateAsync({ type: 'blob' });
  1858. // saveAs(blob, `${_fileName}.zip`);
  1859. // frameFlag = -1;
  1860. // }
  1861. // async function zipIotPens(zip: JSZip) {
  1862. // //处理控件
  1863. // const js = await get2dComponentJs();
  1864. // zip.file(`${frameFlag === Frame.vue3
  1865. // ? 'meta2d-vue3'
  1866. // : frameFlag === Frame.vue2
  1867. // ? 'meta2d-vue2'
  1868. // : 'meta2d-react'
  1869. // }/public/js/2d-components.js`, js, { createFolders: true });
  1870. // const res: Blob = await axios.get('/view/js/r.js', {
  1871. // responseType: 'blob',
  1872. // });
  1873. // zip.file(`${frameFlag === Frame.vue3
  1874. // ? 'meta2d-vue3'
  1875. // : frameFlag === Frame.vue2
  1876. // ? 'meta2d-vue2'
  1877. // : 'meta2d-react'
  1878. // }/public/js/r.js`, res, { createFolders: true });
  1879. // }
  1880. // async function zipJs(zip: JSZip) {
  1881. // const files = ['/view/js/marked.min.js', '/view/js/lcjs.iife.js'];
  1882. // await Promise.all(
  1883. // files.map(async (filePath) => {
  1884. // const res: Blob = await axios.get(filePath, {
  1885. // responseType: 'blob',
  1886. // });
  1887. // zip.file(
  1888. // `${frameFlag === Frame.vue3
  1889. // ? 'meta2d-vue3'
  1890. // : frameFlag === Frame.vue2
  1891. // ? 'meta2d-vue2'
  1892. // : 'meta2d-react'
  1893. // }/public` + filePath.replace('/view', ''),
  1894. // res,
  1895. // { createFolders: true }
  1896. // );
  1897. // })
  1898. // );
  1899. // }
  1900. // async function _zipVue3Files(zip: JSZip) {
  1901. // const files = [
  1902. // '/view/js/marked.min.js',
  1903. // '/view/js/lcjs.iife.js',
  1904. // '/view/vue3/Meta2d.vue',
  1905. // '/view/index.html',
  1906. // '/view/js/meta2d.js',
  1907. // '/view/使用说明.md',
  1908. // ] as const;
  1909. // // 文件同时加载
  1910. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1911. // }
  1912. //新
  1913. // async function zipVue3Files(zip: JSZip) {
  1914. // const files = [
  1915. // '/view/meta2d-vue3/src/components/Meta2d.vue',
  1916. // '/view/meta2d-vue3/src/App.vue',
  1917. // '/view/meta2d-vue3/src/main.js',
  1918. // '/view/meta2d-vue3/src/style.css',
  1919. // '/view/meta2d-vue3/index.html',
  1920. // '/view/meta2d-vue3/package.json',
  1921. // '/view/meta2d-vue3/README.md',
  1922. // '/view/meta2d-vue3/vite.config.js',
  1923. // ] as const;
  1924. // // 文件同时加载
  1925. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1926. // }
  1927. // async function _zipVue2Files(zip: JSZip) {
  1928. // const files = [
  1929. // '/view/js/marked.min.js',
  1930. // '/view/js/lcjs.iife.js',
  1931. // '/view/vue2/Meta2d.vue',
  1932. // '/view/index.html',
  1933. // '/view/js/meta2d.js',
  1934. // '/view/使用说明.md',
  1935. // ] as const;
  1936. // // 文件同时加载
  1937. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1938. // }
  1939. // async function zipVue2Files(zip: JSZip) {
  1940. // const files = [
  1941. // '/view/meta2d-vue2/src/components/Meta2d.vue',
  1942. // '/view/meta2d-vue2/src/App.vue',
  1943. // '/view/meta2d-vue2/src/main.js',
  1944. // // '/view/meta2d-vue2/src/style.css',
  1945. // '/view/meta2d-vue2/public/index.html',
  1946. // '/view/meta2d-vue2/package.json',
  1947. // '/view/meta2d-vue2/README.md',
  1948. // // '/view/meta2d-vue3/vite.config.js',
  1949. // ] as const;
  1950. // // 文件同时加载
  1951. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1952. // }
  1953. // async function _zipReactFiles(zip: JSZip) {
  1954. // const files = [
  1955. // '/view/js/marked.min.js',
  1956. // '/view/js/lcjs.iife.js',
  1957. // '/view/react/Meta2d.jsx',
  1958. // '/view/react/Meta2d.css',
  1959. // '/view/index.html',
  1960. // '/view/js/meta2d.js',
  1961. // '/view/使用说明.md',
  1962. // ] as const;
  1963. // // 文件同时加载
  1964. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1965. // }
  1966. // async function zipReactFiles(zip: JSZip) {
  1967. // const files = [
  1968. // '/view/meta2d-react/src/index.css',
  1969. // '/view/meta2d-react/src/index.js',
  1970. // '/view/meta2d-react/src/Meta2d.css',
  1971. // '/view/meta2d-react/src/Meta2d.jsx',
  1972. // '/view/meta2d-react/package.json',
  1973. // '/view/meta2d-react/README.md',
  1974. // '/view/meta2d-react/public/index.html',
  1975. // ] as const;
  1976. // // 文件同时加载
  1977. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1978. // }
  1979. // async function zipFiles(zip: JSZip) {
  1980. // const files = [
  1981. // '/view/js/marked.min.js',
  1982. // '/view/js/lcjs.iife.js',
  1983. // '/view/js/index.js',
  1984. // '/view/js/meta2d.js',
  1985. // '/view/index.html',
  1986. // '/view/index.css',
  1987. // '/view/favicon.ico',
  1988. // '/view/使用说明.pdf',
  1989. // ] as const;
  1990. // // 文件同时加载
  1991. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1992. // }
  1993. // async function zipFile(zip: JSZip, filePath: string) {
  1994. // const res: Blob = await axios.get(
  1995. // (cdn ? cdn + '/v' : import.meta.env.BASE_URL.slice(0, -1)) + filePath,
  1996. // {
  1997. // responseType: 'blob',
  1998. // }
  1999. // );
  2000. // zip.file(filePath.replace('/view', ''), res, { createFolders: true });
  2001. // }
  2002. // /**
  2003. // * 图片放到 zip 里
  2004. // * @param pens 可以是非具有 calculative 的 pen
  2005. // */
  2006. // async function zipImages(zip: JSZip, pens: Pen[]) {
  2007. // if (!pens) {
  2008. // return;
  2009. // }
  2010. // // 不止 image 上有图片, strokeImage ,backgroundImage 也有图片
  2011. // const imageKeys = [
  2012. // {
  2013. // string: 'image',
  2014. // },
  2015. // { string: 'strokeImage' },
  2016. // { string: 'backgroundImage' },
  2017. // ] as const;
  2018. // const images: string[] = [];
  2019. // for (const pen of pens) {
  2020. // for (const i of imageKeys) {
  2021. // const image = pen[i.string];
  2022. // if (image) {
  2023. // // HTMLImageElement 无法精确控制图片格式
  2024. // if (
  2025. // image.startsWith('/') ||
  2026. // image.startsWith(cdn) ||
  2027. // image.startsWith(upCdn)
  2028. // ) {
  2029. // // 只考虑相对路径下的 image ,绝对路径图片无需下载
  2030. // if (!images.includes(image)) {
  2031. // images.push(image);
  2032. // }
  2033. // }
  2034. // }
  2035. // }
  2036. // // 无需递归遍历子节点,现在所有的节点都在外层
  2037. // }
  2038. // //付费pngs
  2039. // const pngs = await getTemPngs(images.map(i => i.replace(cdn, '').replace(upCdn, '')));
  2040. // await Promise.all(images.map((image) => zipImage(zip, image, pngs[image.replace(cdn, '').replace(upCdn, '')])));
  2041. // }
  2042. // async function zipImage(zip: JSZip, image: string, temImage?: string) {
  2043. // const res: Blob = await axios.get(temImage || image, {
  2044. // responseType: 'blob',
  2045. // // params: {
  2046. // // isZip: true,
  2047. // // },
  2048. // });
  2049. // zip.file(
  2050. // (frameFlag === -1
  2051. // ? ''
  2052. // : `${frameFlag === Frame.vue3
  2053. // ? 'meta2d-vue3'
  2054. // : frameFlag === Frame.vue2
  2055. // ? 'meta2d-vue2'
  2056. // : 'meta2d-react'
  2057. // }/public`) + (cdn ? image.replace(cdn, '').replace(upCdn, '') : image),
  2058. // res,
  2059. // {
  2060. // createFolders: true,
  2061. // }
  2062. // );
  2063. // }
  2064. const downloadImageTips =
  2065. '无法下载,宽度不合法,画布可能没有画笔/画布大小超出浏览器最大限制';
  2066. const downloadPng = () => {
  2067. if (!meta2d.store.data.pens.length) {
  2068. MessagePlugin.warning(downloadImageTips);
  2069. return;
  2070. }
  2071. try {
  2072. meta2d.downloadPng();
  2073. } catch (e) {
  2074. MessagePlugin.warning(downloadImageTips);
  2075. }
  2076. };
  2077. async function getIconDefs(url: string) {
  2078. let res: any = await axios.get(url);
  2079. let str = res.match(/@font-face([\s\S]*?)\}/)[1];
  2080. str = `@font-face ${str} }`;
  2081. return str;
  2082. }
  2083. const downloadSvg = async () => {
  2084. // await import('@/assets/canvas2svg');
  2085. for (const pen of meta2d.store.data.pens) {
  2086. if (pen.calculative.img) {
  2087. //重新生成绘制图片
  2088. pen.onRenderPenRaw?.(pen);
  2089. }
  2090. }
  2091. if (!C2S) {
  2092. MessagePlugin.error('请先加载乐吾乐官网下的canvas2svg.js');
  2093. return;
  2094. }
  2095. const rect: any = meta2d.getRect();
  2096. if (!isFinite(rect.width)) {
  2097. MessagePlugin.error(downloadImageTips);
  2098. return;
  2099. }
  2100. rect.x -= 10;
  2101. rect.y -= 10;
  2102. const ctx = new C2S(rect.width + 20, rect.height + 20);
  2103. ctx.textBaseline = 'middle';
  2104. ctx.strokeStyle = getGlobalColor(meta2d.store);
  2105. for (const pen of meta2d.store.data.pens) {
  2106. // 不使用 calculative.inView 的原因是,如果 pen 在 view 之外,那么它的 calculative.inView 为 false,但是它的绘制还是需要的
  2107. if (!isShowChild(pen, meta2d.store) || pen.visible == false) {
  2108. continue;
  2109. }
  2110. meta2d.renderPenRaw(ctx, pen, rect);
  2111. }
  2112. let mySerializedSVG = ctx.getSerializedSvg();
  2113. let icon_pens = meta2d.store.data.pens.filter(
  2114. (item) => item.iconFamily && item.icon
  2115. );
  2116. if (icon_pens && icon_pens.length > 0) {
  2117. let iconList = [
  2118. '/icon/国家电网/iconfont.css',
  2119. '/icon/电气工程/iconfont.css',
  2120. '/icon/通用图标/iconfont.css',
  2121. ];
  2122. let defsList: any = await Promise.all(
  2123. iconList.map((item) => getIconDefs(item))
  2124. );
  2125. mySerializedSVG = mySerializedSVG.replace(
  2126. '<defs/>',
  2127. `<defs>
  2128. <style type="text/css">
  2129. ${defsList.join('\n')}
  2130. </style>
  2131. {{bk}}
  2132. </defs>
  2133. {{bkRect}}`
  2134. );
  2135. }
  2136. /* mySerializedSVG = mySerializedSVG.replace(
  2137. '<defs/>',
  2138. `<defs>
  2139. <style type="text/css">
  2140. @font-face {
  2141. font-family: 'ticon';
  2142. src: url('icon/通用图标/iconfont.ttf') format('truetype');
  2143. }
  2144. </style>
  2145. {{bk}}
  2146. </defs>
  2147. {{bkRect}}`
  2148. );
  2149. */
  2150. if (meta2d.store.data.background) {
  2151. mySerializedSVG = mySerializedSVG.replace('{{bk}}', '');
  2152. mySerializedSVG = mySerializedSVG.replace(
  2153. '{{bkRect}}',
  2154. `<rect x="0" y="0" width="100%" height="100%" fill="${meta2d.store.data.background}"></rect>`
  2155. );
  2156. } else {
  2157. mySerializedSVG = mySerializedSVG.replace('{{bk}}', '');
  2158. mySerializedSVG = mySerializedSVG.replace('{{bkRect}}', '');
  2159. }
  2160. mySerializedSVG = mySerializedSVG.replace(/--le5le--/g, '&#x');
  2161. const urlObject: any = (window as any).URL || window;
  2162. const export_blob = new Blob([mySerializedSVG]);
  2163. const url = urlObject.createObjectURL(export_blob);
  2164. const a = document.createElement('a');
  2165. a.setAttribute(
  2166. 'download',
  2167. `${(meta2d.store.data as Meta2dBackData).name || 'le5le.meta2d'}.svg`
  2168. );
  2169. a.setAttribute('href', url);
  2170. const evt = document.createEvent('MouseEvents');
  2171. evt.initEvent('click', true, true);
  2172. a.dispatchEvent(evt);
  2173. };
  2174. const onUndo = () => {
  2175. meta2d.undo();
  2176. };
  2177. const onRedo = () => {
  2178. meta2d.redo();
  2179. };
  2180. const onCut = () => {
  2181. meta2d.cut();
  2182. };
  2183. const onCopy = () => {
  2184. meta2d.copy();
  2185. };
  2186. const onPaste = () => {
  2187. meta2d.paste();
  2188. };
  2189. const onAll = () => {
  2190. meta2d.activeAll();
  2191. };
  2192. const onDelete = () => {
  2193. meta2d.delete();
  2194. };
  2195. const onToggleAnchor = () => {
  2196. //取消连线状态
  2197. // meta2d.store.options.disableAnchor = false;
  2198. if (!meta2d.store.options.disableAnchor) {
  2199. meta2d.canvas.drawingLineName && drawPen();
  2200. meta2d.toggleAnchorMode();
  2201. }
  2202. };
  2203. const onAddAnchorHand = () => {
  2204. meta2d.addAnchorHand();
  2205. };
  2206. const onRemoveAnchorHand = () => {
  2207. meta2d.removeAnchorHand();
  2208. };
  2209. const onToggleAnchorHand = () => {
  2210. meta2d.toggleAnchorHand();
  2211. };
  2212. const onScaleUp = () => {
  2213. const _scale = meta2d.store.data.scale + 0.1;
  2214. meta2d.scale(_scale);
  2215. };
  2216. const onScaleDown = () => {
  2217. const _scale = meta2d.store.data.scale - 0.1;
  2218. meta2d.scale(_scale);
  2219. };
  2220. const autoAnchor = ref(true);
  2221. const onAutoAnchor = () => {
  2222. meta2d.store.options.autoAnchor = !meta2d.store.options.autoAnchor;
  2223. autoAnchor.value = meta2d.store.options.autoAnchor;
  2224. };
  2225. const showAnchor = ref(false);
  2226. const onDisableAnchor = () => {
  2227. meta2d.store.options.disableAnchor = !meta2d.store.options.disableAnchor;
  2228. changeDisableAnchor();
  2229. };
  2230. const changeDisableAnchor = () => {
  2231. const { disableAnchor, autoAnchor } = meta2d.store.options;
  2232. showAnchor.value = !disableAnchor || false;
  2233. if (disableAnchor && autoAnchor) {
  2234. // 禁用瞄点开了,需要关闭自动瞄点
  2235. onAutoAnchor();
  2236. }
  2237. };
  2238. const payListDialog = reactive({
  2239. show: false,
  2240. title:'',
  2241. href:'',
  2242. downloadUrl:''
  2243. });
  2244. const downloadZipDialog = reactive({
  2245. show: false,
  2246. checked:true,
  2247. expend:false,
  2248. price:0,
  2249. list:[],
  2250. hasJs:false,
  2251. });
  2252. const prePay = async () => {
  2253. let list = [];
  2254. let names = data.purchasedList.map((item) => item.name);
  2255. if(data.payDiagram.checked){
  2256. prePayList.pngs.forEach((item) => {
  2257. if(!names.includes(item)){
  2258. list.push({
  2259. type: '图片图元',
  2260. name: item,
  2261. });
  2262. }
  2263. });
  2264. prePayList.jsPens.forEach((item) => {
  2265. if(!names.includes(item)){
  2266. list.push({
  2267. type: 'JS线性图元',
  2268. name: item,
  2269. });
  2270. }
  2271. });
  2272. prePayList.iotPens.forEach((item) => {
  2273. if(!names.includes(item)){
  2274. list.push({
  2275. type: '控件',
  2276. name: item,
  2277. });
  2278. }
  2279. });
  2280. if ([...prePayList.svgPens].includes('*')) {
  2281. list.push({
  2282. type: 'SVG线性图元',
  2283. });
  2284. } else {
  2285. prePayList.svgPens.forEach((item) => {
  2286. if(!names.includes(item)){
  2287. list.push({
  2288. type: 'SVG线性图元',
  2289. name: item,
  2290. });
  2291. }
  2292. });
  2293. }
  2294. }
  2295. const res: any = await axios.post('/api/order/deployment/submit', {
  2296. goods:data.payGoods,
  2297. '2ds':list,
  2298. });
  2299. wechatPayDialog.show = true;
  2300. data.order = res;
  2301. };
  2302. const downloadTrial = () => {
  2303. MessagePlugin.info('正在下载中,可能需要几分钟,请耐心等待...');
  2304. //下载试用版
  2305. window.open(payListDialog.downloadUrl, '_blank');
  2306. }
  2307. const skipPay = () => {
  2308. //跳过支付,直接下载
  2309. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  2310. if (downloadType === Frame.html) {
  2311. preDownload();
  2312. } else {
  2313. preFrameDownload();
  2314. }
  2315. };
  2316. const finishPay = async () => {
  2317. // let id = data.order.id;
  2318. // const result: { state: number } = await axios.post('/api/order/pay/state', {
  2319. // id,
  2320. // });
  2321. // if (result && result.state) {
  2322. MessagePlugin.success('支付成功');
  2323. wechatPayDialog.show = false;
  2324. if(wechatPayDialog.isZip){
  2325. // downloadZipDialog.show = false;
  2326. wechatPayDialog.isZip = false;
  2327. doDownloadZip();
  2328. }else{
  2329. payListDialog.show = false;
  2330. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  2331. if (downloadType === Frame.html) {
  2332. preDownload();
  2333. } else {
  2334. preFrameDownload();
  2335. }
  2336. }
  2337. // } else {
  2338. // MessagePlugin.error('支付失败');
  2339. // // wechatPayDialog.show = false;
  2340. // }
  2341. };
  2342. const finalPrice = computed(() => {
  2343. let total = 0;
  2344. let price = 0;
  2345. data.goods.forEach((item, index) => {
  2346. if (item.checked) {
  2347. total += item.unPurchased;
  2348. price += item.unPurchased * item.unitPrice;
  2349. }
  2350. });
  2351. return {
  2352. total,
  2353. price,
  2354. };
  2355. });
  2356. const wechatPayDialog = reactive({
  2357. show: false,
  2358. isZip:false
  2359. });
  2360. const emit = defineEmits(['success']);
  2361. const onSuccess = (success: boolean) => {
  2362. finishPay();
  2363. emit('success', success);
  2364. };
  2365. </script>
  2366. <style lang="postcss" scoped>
  2367. .app-header {
  2368. display: flex;
  2369. height: 40px;
  2370. background-color: var(--color-background);
  2371. position: relative;
  2372. z-index: 2;
  2373. .logo {
  2374. display: flex;
  2375. padding: 0 16px;
  2376. align-items: center;
  2377. font-size: 14px;
  2378. font-weight: 500;
  2379. img {
  2380. height: 20px;
  2381. margin-right: 6px;
  2382. }
  2383. }
  2384. a {
  2385. display: flex;
  2386. padding: 0 8px;
  2387. margin: 0 8px;
  2388. align-items: center;
  2389. color: var(--color);
  2390. text-decoration: none;
  2391. white-space: nowrap;
  2392. &:hover {
  2393. color: var(--color-primary);
  2394. }
  2395. svg {
  2396. font-size: 15px;
  2397. margin: 2px 4px 0 0;
  2398. }
  2399. &.active {
  2400. background-color: var(--color-primary);
  2401. color: #ffffff;
  2402. }
  2403. }
  2404. input {
  2405. font-size: var(--font-size);
  2406. flex-grow: 1;
  2407. background: none;
  2408. outline: none;
  2409. border: none;
  2410. text-align: center;
  2411. color: var(--color-title);
  2412. }
  2413. }
  2414. .pay-box{
  2415. background: rgba(175,202,255,0.04);
  2416. border-radius: 4px;
  2417. margin-bottom:24px;
  2418. padding:20px 24px;
  2419. position:relative;
  2420. display:flex;
  2421. .pay-up{
  2422. display:flex;
  2423. }
  2424. :deep(.t-checkbox__label){
  2425. font-size: 16px;
  2426. color: #6e7b91;
  2427. margin-left:16px;
  2428. }
  2429. .pay-title{
  2430. font-size: 16px;
  2431. color: #6e7b91;
  2432. .t-icon{
  2433. margin-top:-5px;
  2434. margin-left:12px;
  2435. }
  2436. :deep(.t-checkbox__input){
  2437. background:#fff0;
  2438. }
  2439. :deep(.t-is-checked){
  2440. .t-checkbox__input{
  2441. background:var(--color-primary);
  2442. }
  2443. }
  2444. }
  2445. .pay-price{
  2446. position:absolute;
  2447. right:24px;
  2448. color:#4480F9;
  2449. display:flex;
  2450. p:nth-child(2){
  2451. font-size: 20px;
  2452. }
  2453. }
  2454. .pay-down{
  2455. margin-top:16px;
  2456. display:flex;
  2457. flex-wrap:wrap;
  2458. /* justify-content:space-between; */
  2459. /* padding-top:24px; */
  2460. max-height: 200px;
  2461. overflow-y: scroll;
  2462. &>div{
  2463. width: 48px;
  2464. height: 48px;
  2465. background: #1c283b;
  2466. border-radius: 4px;
  2467. margin-right:2.5px;
  2468. margin-bottom:2.5px;
  2469. &:nth-child(12n){
  2470. margin-right: 0px;
  2471. }
  2472. img{
  2473. margin:4px;
  2474. width:40px;
  2475. height:40px;
  2476. }
  2477. .l-icon{
  2478. /* width: 80px; */
  2479. /* height: 80px; */
  2480. /* margin:8px; */
  2481. font-size:24px;
  2482. margin:12px;
  2483. }
  2484. &>div{
  2485. margin: 8px 12px;
  2486. }
  2487. }
  2488. &>p{
  2489. display: block;
  2490. margin-top:8px;
  2491. width:100%;
  2492. }
  2493. }
  2494. }
  2495. .pay-footer{
  2496. display:flex;
  2497. margin-bottom: -48px;
  2498. margin-left:24px;
  2499. font-size: 14px;
  2500. &>div{
  2501. color:#4480F9;
  2502. display:flex;
  2503. p:nth-child(2){
  2504. font-size: 24px;
  2505. font-weight: 800;
  2506. margin-top:-3px;
  2507. }
  2508. p:nth-child(1){
  2509. margin:0px 4px;
  2510. }
  2511. }
  2512. }
  2513. .pay-diagram{
  2514. flex-direction:column;
  2515. }
  2516. /* .pay-dialog {
  2517. background-color: red;
  2518. } */
  2519. /* .pay-body {
  2520. height: 300px;
  2521. overflow-y: scroll;
  2522. margin-bottom: 30px;
  2523. .t-collapse {
  2524. border: 0px;
  2525. :deep(.t-collapse-panel__wrapper .t-collapse-panel__header) {
  2526. border-bottom: 0px;
  2527. }
  2528. :deep(.t-collapse-panel__wrapper .t-collapse-panel__body) {
  2529. background: #fff0;
  2530. border-bottom: 0px;
  2531. .t-collapse-panel__content {
  2532. padding: 0;
  2533. color: #c1c8d7;
  2534. }
  2535. }
  2536. }
  2537. } */
  2538. /* .pay-line {
  2539. display: flex;
  2540. height: 54px;
  2541. background-color: #afcaff0a;
  2542. margin-top: 1px;
  2543. div {
  2544. width: 30%;
  2545. text-align: center;
  2546. line-height: 54px;
  2547. :deep(.t-image) {
  2548. width: 40px;
  2549. height: 40px;
  2550. margin-top: 7px;
  2551. }
  2552. :deep(.pay-svg) {
  2553. .t-image {
  2554. background: #fff;
  2555. }
  2556. }
  2557. .l-icon {
  2558. width: 40px;
  2559. height: 40px;
  2560. margin-top: 7px;
  2561. width: 30%;
  2562. }
  2563. }
  2564. .pay-p{
  2565. overflow:hidden;
  2566. text-overflow:ellipsis;
  2567. white-space:nowrap;
  2568. }
  2569. & > div:first-child {
  2570. width: 40%;
  2571. display: flex;
  2572. }
  2573. } */
  2574. /* .pay-tip {
  2575. height: 54px;
  2576. width: 100%;
  2577. position: relative;
  2578. p {
  2579. position: absolute;
  2580. right: 16px;
  2581. color: var(--color-desc);
  2582. }
  2583. }
  2584. .pay-footer {
  2585. margin-bottom: -42px;
  2586. position: relative;
  2587. .pay-price {
  2588. position: absolute;
  2589. right: 215px;
  2590. margin-left: 50px;
  2591. align-items: flex-end;
  2592. line-height: 10px;
  2593. p{
  2594. vertical-align: bottom;
  2595. line-height: normal;
  2596. }
  2597. p:nth-child(2) {
  2598. font-size: 32px;
  2599. font-weight: Semibold;
  2600. color: #4480f9;
  2601. line-height: 20px;
  2602. }
  2603. p:nth-child(1) {
  2604. font-size: 14px;
  2605. color: #4480f9;
  2606. }
  2607. }
  2608. } */
  2609. /* .pay-title {
  2610. margin: 18px 0px 12px 18px;
  2611. } */
  2612. </style>