Header.vue 76 KB

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