Header.vue 75 KB

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