Header.vue 77 KB

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