draw2.vue 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753
  1. <template>
  2. <view class="outer">
  3. <view style="color: #fff;">
  4. <tn-nav-bar backgroundColor="#207CF7" :bottomShadow="false">AI绘图</tn-nav-bar>
  5. <view :style="{ height: tobheight + 'px' }"></view>
  6. </view>
  7. <!-- 绘画引导界面 -->
  8. <view class="addmask" v-if="showHuiHuaLead">
  9. <view class="leadBg">
  10. <view class="leadBox1" v-if="showLead1"
  11. :style="{'background-image': `url(${leadBaseUrl}hh_lead1.png)`}">
  12. <view class="nextBtn" @click="nextLead">
  13. </view>
  14. </view>
  15. <view class="leadBox2" v-if="showLead2"
  16. :style="{'background-image': `url(${leadBaseUrl}hh_lead_2.png)`}">
  17. <view class="nextBtn" @click="finishLead">
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <u-notice-bar bgColor='#C6D6E4' color='#3F5465' :text="noticebar" step speed="800"></u-notice-bar>
  23. <view style="margin: 30rpx 30rpx 0;">
  24. <tn-subsection :list="tabslist" :current="current" mode="button" :borderRadius="50"
  25. backgroundColor="#207CF7" @change="getsubsection" buttonColor="tn-cool-bg-color-7"
  26. inactiveColor="#FFFFFF" activeColor="#357aba"></tn-subsection>
  27. </view>
  28. <view class="ysBox" v-if="current==0">
  29. <div class="selBox">
  30. <div class="title">
  31. <div class="le">
  32. 模板选择
  33. </div>
  34. <div class="selList" @click.stop="">
  35. <div class="item" v-for="(item,index) in selOptList" @click.stop="handleOpenOpt(index)">
  36. {{item}}
  37. <img src="@/static/arrD.png" alt="" class="arrD" />
  38. </div>
  39. </div>
  40. </div>
  41. <div class="addPo">
  42. <div class="optDetailBox" v-if="showRule" @click.stop="closeOver">
  43. <div class="con" @click.stop="">
  44. <div class="optList" @click.stop="">
  45. <div class="item" @click.stop="handleOrder(item,index)" v-for="(item,index) in rules"
  46. :class="[item==seledRule?'item_a':'']">
  47. {{item}}
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="optDetailBox" v-if="showThem" @click.stop="closeOver">
  53. <div class="con" @click.stop="">
  54. <div class="optList" @click.stop="">
  55. <div class="item" @click.stop="handleSelStyle(item)" v-for="(item,index) in styles"
  56. :class="[item.id==seledStyle.id?'item_a':'']">
  57. {{item.title}}
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="optDetailBox" v-if="showSex" @click.stop="closeOver">
  63. <div class="con" @click.stop="">
  64. <div class="optList" @click.stop="">
  65. <div class="item" @click.stop="handleSelSex(item,index)" v-for="(item,index) in sexList"
  66. :class="[item==seledSex?'item_a':'']">
  67. {{item}}
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="conList">
  74. <div class="item" v-for="(item,index) in cankaoImgList.slice(0,8)"
  75. @click="handleSelModal(item,index)">
  76. <div class="top" :class="[item.id==seledCankaoImg.id?'item_a':'']"
  77. :style="{backgroundImage:`url(${item.path})`}">
  78. <img v-if="item.id==seledCankaoImg.id" src="@/static/b_seled.png" alt="" class="tag" />
  79. </div>
  80. <div class="name">
  81. {{item.title}}
  82. </div>
  83. </div>
  84. </div>
  85. <div class="addLpd">
  86. <div class="moreBtn" @click="handleMorePopup">
  87. 更多
  88. </div>
  89. </div>
  90. <!-- <u-button @click="test">测试压缩</u-button> -->
  91. <div class="upTitle">
  92. 上传图片
  93. </div>
  94. <div class="tipAndUpBox">
  95. <div class="left">
  96. <div class="item" v-for="(item,index) in tipList">
  97. <img src="@/static/renx.png" alt="" />
  98. {{item}}
  99. </div>
  100. <div class=" item xxsm" @click="toYszDetail">
  101. <!-- <div class="pimg"></div> -->
  102. <img class="xxsmInfo" src="@/static/b_info.png" alt="" />
  103. <span>详细说明</span>
  104. </div>
  105. </div>
  106. <div class="upList">
  107. <div class="upBox">
  108. <div class="up1 up " @click.stop="upYsImg(0)" :class="[myModal?'up_a':'']"
  109. :style="{'background-image':`url(${myModal})`}">
  110. <span v-if="!myModal&&!showUpLoading1">点击<br>上传模板</span>
  111. <img src="@/static/b_camera.png" alt="" class="camera" />
  112. <div v-if="myModal" class="del" @click.stop="myModal='';">
  113. <u-icon name="trash" @click.stop="myModal='';" color="#1F79F0" size="20"></u-icon>
  114. </div>
  115. <u-loading-icon v-if="showUpLoading1" class="loading" text='' textSize="18"
  116. mode="circle" vertical duration="1000"></u-loading-icon>
  117. </div>
  118. <div class="des">
  119. 上传模板
  120. </div>
  121. </div>
  122. <div class="upBox">
  123. <div class="up2 up" :class="[myPhoto?'up_a':'']"
  124. :style="{'background-image':`url(${myPhoto})`}" @click.stop="upYsImg(1)">
  125. <span v-if="!myPhoto&&!showUpLoading2">点击<br>上传照片</span>
  126. <img src="@/static/b_camera.png" alt="" class="camera" />
  127. <div v-if="myPhoto" class="del" @click.stop="myPhoto=''">
  128. <u-icon @click.stop="myPhoto=''" name="trash" color="#1F79F0" size="20"></u-icon>
  129. </div>
  130. <u-loading-icon v-if="showUpLoading2" class="loading" text='' textSize="18"
  131. mode="circle" vertical duration="1000"></u-loading-icon>
  132. </div>
  133. <div class="des">
  134. 上传照片
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="line"></div>
  140. <div class="tipBox">
  141. <img src="@/static/b_info.png" alt="" />
  142. 模板可直接选择上面的现成模板,可点击自己上传<br>
  143. 仅支持JPG/PNG格式,大小10M以下
  144. </div>
  145. <!-- <div class="ysBtn" @click="genYishuZhao">
  146. 生成艺术照
  147. </div> -->
  148. <view class="dygbhg">
  149. <navigator class="whole" open-type="navigateBack">退出</navigator>
  150. <view @click="genYishuZhao" class="distinguish">生成艺术照 |
  151. <!-- 需要消耗{{ plan.unlock_aipainting*form.samples}}{{appInfo.number_alias ? appInfo.number_alias : '点数'}} -->
  152. 需要消耗1{{appInfo.number_alias ? appInfo.number_alias : '点数'}}
  153. </view>
  154. </view>
  155. </div>
  156. </view>
  157. <view class="directask" v-if="current!=0" style="padding-top: 0;">
  158. <!-- <view v-if="modelslist.length>0" class="cu-form-group"> -->
  159. <view class="cu-form-group">
  160. <view class="cu-title flxe align-center justify-between">
  161. <view class="title flxe align-center">模型选择</view>
  162. <block v-if="showmj==1">
  163. <u-tag v-if="userData.vip_info&&userData.is_validity>0"
  164. :text="(userData.vip_info.mj_type == 'time'?'今日':'会员')+'剩余mj绘画:'+(userData.vip_info.mj_times==-1?'无限量':userData.vip_info.mj_times-userData.vip_info.mj_used+'次')"
  165. plain shape="circle" plainFill color="#207CF7" borderColor="#207CF7"
  166. bgColor="#207CF714"></u-tag>
  167. </block>
  168. <block v-else-if="showmj==2">
  169. <u-tag v-if="userData.vip_info&&userData.is_validity>0"
  170. :text="(userData.vip_info.sd_type == 'time'?'今日':'会员')+'剩余sd绘画:'+(userData.vip_info.sd_times == -1?'无限量':userData.vip_info.sd_times-userData.vip_info.sd_used+'次')"
  171. plain shape="circle" plainFill color="#207CF7" borderColor="#207CF7"
  172. bgColor="#207CF714"></u-tag>
  173. </block>
  174. </view>
  175. <view class="engine-container" @click="showmode = true" v-if="current==2">
  176. <view class="model_view">模型:{{xzmodels}}</view>
  177. <u-icon name="arrow-down-fill" color="#9e9e9e"></u-icon>
  178. </view>
  179. </view>
  180. <!-- mj模型选择新调整 -->
  181. <view class="mjSelBox" v-if="current==1">
  182. <view class="mjitem" v-for="(item,index) in modelslist"
  183. @click="modelsid = index,showmode = false,form.model_id = item.model_id.toString(),xzmodels = item.name,form.name = item.name"
  184. :style="{'border-color':index==modelsid?'#1F79F0':'','background-image':`url(${item.title=='官方V5.1'?'../../static/scy.png':'../../static/ecy.png'})`}">
  185. <view class="topRight" style="background-image: url('../../static/sjx.png')">
  186. </view>
  187. <view class="bar">
  188. {{item.title=='官方V5.1'?'卡通动漫':'真实风格'}}
  189. </view>
  190. </view>
  191. </view>
  192. <view class="cu-form-group" :style="engineid != 0 ? 'margin-top: 20rpx' : ''"
  193. style="padding-top: 0;padding-bottom: 0;">
  194. <view class="cu-title flxe align-center justify-between">
  195. <view class="title flxe align-center">画面描述</view>
  196. </view>
  197. <view class="textarea-container">
  198. <textarea class="textarea" v-model="keywords" cursor-spacing="30rpx" :maxlength="500"
  199. placeholder-style="color: #9e9e9e;font-size:28rpx"
  200. placeholder="输入你的创意,支持中英文,用逗号分隔,关键词越多越精确,关键词越少AI自由发挥越多,如:最好的质量,城市,大雨,远景,赛博朋克" value="keywords"
  201. @input="textareainput" />
  202. <view class="textareaoperate tn-flex align-center justify-between">
  203. <!-- <view @click="getincrease" class="increase">描述增幅</view> -->
  204. <view @click="show_gpt = true" class="increase tn-main-gradient-orangeyellow">咒语助手</view>
  205. <view class="tn-flex align-center" style="color: #9e9e9e;">
  206. <view class="">{{cursor}}/500</view>
  207. <view style="margin: 0 20rpx;">||</view>
  208. <u-icon @click="keywords = '',galleryid ='',cursor = 0" name="trash-fill" color="#9e9e9e"
  209. size="24"></u-icon>
  210. </view>
  211. </view>
  212. </view>
  213. <view v-if="gallerylist.length>0" class="try-tips">
  214. <scroll-view class="scroll-view" scroll-x="true">
  215. <block v-for="(item,index) in gallerylist" :key="index">
  216. <view @click="tapgallery(index)" class="scroll-item"
  217. :style="{background: galleryid == item.id?'#207CF7':'',color: galleryid == item.id?'#fff':''}">
  218. {{item.name}}
  219. </view>
  220. </block>
  221. </scroll-view>
  222. <view class="change" @click="initWords"><text class="tn-icon-circle-arrow tn-color-cat"
  223. style="font-size: 34rpx;"></text></view>
  224. </view>
  225. </view>
  226. <!-- mj和sd展示 -->
  227. <view v-if="showmj!=0" class="cu-form-group" style="padding-top: 0;padding-bottom: 0;">
  228. <view class="cu-title">
  229. <view class="title flxe align-center">图片比例</view>
  230. </view>
  231. <view class="flxe proportion">
  232. <view class="radio flxe align-center justify-center flxe-column"
  233. :class="ratioIndex == 0 ? 'active' : ''" @click="ratio(0)">
  234. <view class="cu-proportion flxe align-center justify-center">
  235. <view class="proportion1"></view>
  236. </view>
  237. <view class="describe">1:1</view>
  238. </view>
  239. <view class="radio flxe align-center justify-center flxe-column"
  240. :class="ratioIndex == 1 ? 'active' : ''" @click="ratio(1)">
  241. <view class="cu-proportion flxe align-center justify-center">
  242. <view class="proportion2"></view>
  243. </view>
  244. <view class="describe">3:4</view>
  245. </view>
  246. <view class="radio flxe align-center justify-center flxe-column"
  247. :class="ratioIndex == 2 ? 'active' : ''" @click="ratio(2)">
  248. <view class="cu-proportion flxe align-center justify-center">
  249. <view class="proportion3"></view>
  250. </view>
  251. <view class="describe">4:3</view>
  252. </view>
  253. <view v-if="showmj==1" class="radio flxe align-center justify-center flxe-column"
  254. :class="ratioIndex == 3 ? 'active' : ''" @click="ratio(3)">
  255. <view class="cu-proportion flxe align-center justify-center">
  256. <view class="proportion2"></view>
  257. </view>
  258. <view class="describe">9:16</view>
  259. </view>
  260. <view v-if="showmj==1" class="radio flxe align-center justify-center flxe-column"
  261. :class="ratioIndex == 4 ? 'active' : ''" @click="ratio(4)">
  262. <view class="cu-proportion flxe align-center justify-center">
  263. <view class="proportion3"></view>
  264. </view>
  265. <view class="describe">16:9</view>
  266. </view>
  267. </view>
  268. </view>
  269. <!-- sd和mj都要展示 -->
  270. <view class="cu-form-group" style="padding-top: 0;padding-bottom: 0;">
  271. <view class="cu-title">
  272. <view class="title flxe align-center">参考图(可选)</view>
  273. </view>
  274. <view class="desc-tips">AI绘画时会参考您所上传的参考图的风格进行构图</view>
  275. <view class="cu-upload flxe align-center justify-center">
  276. <image class="upload-img" :src="refer_img" v-if="refer_img" mode="aspectFill"
  277. @click="preViewImg(refer_img)"></image>
  278. <view class="upload-delete tn-icon-delete tn-color-cat" style="font-size: 40rpx;" v-if="refer_img"
  279. @click="deleteImg()"></view>
  280. <view class="flxe flxe-column align-center" v-else @click="uploadImg(engineid)">
  281. <u-icon name="plus-circle-fill" color="#207CF7" size="28"></u-icon>
  282. <view class="upload">上传图片</view>
  283. </view>
  284. </view>
  285. </view>
  286. <!-- sd和mj都要展示 -->
  287. <view class="cu-form-group" v-if="current!=0" style="padding-top: 0;padding-bottom: 0;">
  288. <view class="cu-title">
  289. <view class="title flxe align-center">生成数量</view>
  290. </view>
  291. <view class="flxe generate">
  292. <block v-if="showmj==2">
  293. <view class="xz_generate flxe align-center justify-center"
  294. :class="form.samples == 1 ? 'xz_gactive' : ''" @click="form.samples = 1">
  295. <view :style="{color: form.samples == 1 ? '#207CF7':''}">1张</view>
  296. </view>
  297. </block>
  298. <block v-else-if="showmj==1">
  299. <view class="xz_generate flxe align-center justify-center"
  300. :class="form.samples == 4 ? 'xz_gactive' : ''" @click="form.samples = 4">
  301. <view :style="{color: form.samples == 4 ? '#207CF7':''}">4张</view>
  302. </view>
  303. </block>
  304. </view>
  305. </view>
  306. </view>
  307. <!-- 底部按钮区域 -->
  308. <view class="dygbhg" v-if="current!=0">
  309. <navigator class="whole" open-type="navigateBack">退出</navigator>
  310. <block v-if="showmj==1">
  311. <view
  312. v-if="userData.vip_info&&userData.is_validity>0&&userData.vip_info.mj_times-userData.vip_info.mj_used>0 ||userData.vip_info&&userData.is_validity>0&&userData.vip_info.mj_times == -1"
  313. @click="createClick" class="distinguish">立即生成</view>
  314. <view v-else @click="createClick" class="distinguish">生成 |
  315. 需要消耗{{ plan.unlock_mj_aipainting}}{{appInfo.number_alias ? appInfo.number_alias : '点数'}}</view>
  316. </block>
  317. <block v-else-if="showmj==2">
  318. <view
  319. v-if="userData.vip_info&&userData.is_validity>0&&userData.vip_info.sd_times-userData.vip_info.sd_used>0 ||userData.vip_info&&userData.is_validity>0&&userData.vip_info.sd_times == -1"
  320. @click="createClick" class="distinguish">立即生成</view>
  321. <view v-else @click="createClick" class="distinguish">生成 |
  322. 需要消耗{{ plan.unlock_aipainting*form.samples}}{{appInfo.number_alias ? appInfo.number_alias : '点数'}}
  323. </view>
  324. </block>
  325. </view>
  326. <u-loading-page :loading="loading" loading-text="正在加载" icon-size="35" bgColor="#1a1a1a" color="#fff"
  327. loadingColor="#fff"></u-loading-page>
  328. <u-popup :show="showmode" @close="showmode = false" safeAreaInsetTop :round="15" closeable>
  329. <view class="select u-flex justify-center"><text>选择模型</text></view>
  330. <scroll-view scroll-y="true" class="scroll_mode">
  331. <view class="tn-flex justify-between flex-wrap">
  332. <block v-for="(item,index) in modelslist" :key="index">
  333. <view v-if="item.title" class="card" :style="{borderColor: modelsid == index?'#207CF7':''}"
  334. @click="modelsid = index,showmode = false,form.model_id = item.model_id.toString(),xzmodels = item.name,form.name = item.name">
  335. <u-swiper :list="item.imgs" radius="0" height="110"
  336. :indicator="item.imgs.length>1?true:false" indicatorMode="line" circular></u-swiper>
  337. <view class="card-info">
  338. <view class="card-info-title">{{item.title=='官方V5.1'?'Niji 5':item.title}}</view>
  339. <view class="card-info-desc">{{item.name}}</view>
  340. </view>
  341. </view>
  342. </block>
  343. </view>
  344. </scroll-view>
  345. </u-popup>
  346. <u-popup :show="show_gpt" @close="show_gpt = false" mode="center" :round="10" closeable safeAreaInsetTop>
  347. <view class="gpt-select">
  348. <view class="gpt-title"><u--text text="咒语助手" iconStyle="font-size: 20px" color="#1a1a1a" bold size="18"
  349. lineHeight="30"></u--text></view>
  350. <u--text text="针对AI绘画场景下的gpt模型,能够生成高质量的描述词" color="#9e9e9e" size="14" lineHeight="30"></u--text>
  351. <!-- <u--text text="输入你的创意 想象" iconStyle="font-size: 20px" bold size="16" lineHeight="30"></u--text> -->
  352. <view class="gpt-textarea-container"><u--textarea v-model="gpt_keywords" placeholder="输入你的创意 想象"
  353. count></u--textarea></view>
  354. <view class="use-gpt">
  355. <u-button :text="appInfo.number_alias ? '灵感一现(消耗1'+appInfo.number_alias+')':'灵感一现(消耗1点数)'"
  356. shape="circle" color="linear-gradient(to right, rgb(255, 202, 40), rgb(255, 167, 38))"
  357. @click="getGpt"></u-button>
  358. </view>
  359. <view class="gpt-textarea-container" style="margin-bottom: 20rpx;"><u--textarea height="200"
  360. v-model="gpt_text" v-if="gpt_text"></u--textarea></view>
  361. <u-button type="success" @click="setGpt" plain text="使用" shape="circle" v-if="gpt_text"></u-button>
  362. </view>
  363. </u-popup>
  364. <u-popup :closeOnClickOverlay="true" :show="showMorePopup" @close="showMorePopup = false" mode="bottom"
  365. :round="10" :closeable="false" safeAreaInsetTop>
  366. <div class="cankaoImgBox">
  367. <div class="top">
  368. <div class="title">
  369. 模板选择
  370. </div>
  371. <img src="@/static/b_info.png" alt="" />
  372. <span>选择后直接作为生成照片参照</span>
  373. </div>
  374. <div class="conList">
  375. <div class="item" v-for="(item,index) in cankaoImgList" @click="handleSelMoreModal(item,index)">
  376. <div class="top" :class="[item.id==seledCankaoImg_temp.id?'item_a':'']"
  377. :style="{backgroundImage:`url(${item.path})`}">
  378. <img v-if="item.id==seledCankaoImg_temp.id" src="@/static/b_seled.png" alt="" class="tag" />
  379. </div>
  380. <div class="name">
  381. {{item.title}}
  382. </div>
  383. </div>
  384. </div>
  385. <div class="btnBox">
  386. <div class="left" @click="showMorePopup=false">
  387. 取消
  388. </div>
  389. <div class="right" @click="handleConfirmSel">
  390. 确定
  391. </div>
  392. </div>
  393. </div>
  394. </u-popup>
  395. <wike-model v-if="signShow" :authorize="false" :title="signTitle" btnText="立即获取" @save="signSign"
  396. @close="signShow = false"></wike-model>
  397. <wike-modal-qrcode :qrcode="gzhqrcode" :showconcern="showconcern"
  398. @concernclose="concernclose"></wike-modal-qrcode>
  399. <!-- <wike-tabbar :onTabbar="true" :isShowAnimate="true"></wike-tabbar> -->
  400. <!-- <u-picker :show="showmode" :columns="modelslist" keyName="name" @cancel="showmode = false"></u-picker> -->
  401. </view>
  402. </template>
  403. <script>
  404. import BaseUrl from '@/common/config.js';
  405. import {
  406. mapMutations,
  407. mapActions,
  408. mapState,
  409. mapGetters
  410. } from 'vuex';
  411. import {
  412. apiurl
  413. } from '@/common/request/request';
  414. import {
  415. translateapp,
  416. translate,
  417. mp_compressImage
  418. } from "@/utils/compress.js"
  419. let rewardedVideoAd = null;
  420. export default {
  421. mixins: [],
  422. components: {},
  423. data() {
  424. return {
  425. leadBaseUrl: BaseUrl.leadBaseUrl,
  426. // 艺术照
  427. tipList: ['五官清晰', '人像正面', '人脸无遮挡', '照片清晰'],
  428. showUpLoading1: false,
  429. showUpLoading2: false,
  430. // modal: '',
  431. myModal: '',
  432. myPhoto: '',
  433. selOptList: [
  434. '排序规则',
  435. '主题风格',
  436. '性别',
  437. ],
  438. sexList: [
  439. '男',
  440. '女',
  441. '全部'
  442. ],
  443. cankaoImgList: [],
  444. seledCankaoImg: null,
  445. seledCankaoImg_temp: {
  446. id: -1
  447. },
  448. rules: [
  449. '降序',
  450. '升序',
  451. ],
  452. seledRule: '降序',
  453. styles: [
  454. ],
  455. seledStyle: '国风',
  456. seledSex: '',
  457. showRule: false,
  458. showThem: false,
  459. showSex: false,
  460. showMorePopup: false,
  461. showHuiHuaLead: false,
  462. showLead2: false,
  463. showLead1: true,
  464. signShow: false,
  465. signTitle: '',
  466. tobheight: 45,
  467. platform: this.$platform.get(),
  468. indexList: [],
  469. show_gpt: false,
  470. gpt_keywords: '',
  471. gpt_text: '',
  472. cursor: 0,
  473. form: {
  474. name: '',
  475. init_image: '',
  476. prompt: '',
  477. width: '',
  478. height: '',
  479. guidance_scale: '7',
  480. samples: '1',
  481. model_id: '',
  482. scheduler: 'DDPMScheduler',
  483. type: 'text2img',
  484. num_inference_steps: '30',
  485. // lora_model:'guofeng3-lora'
  486. },
  487. word: [],
  488. sentence: [],
  489. enable_face_enhance: false,
  490. is_last_layer_skip: false,
  491. ratioIndex: 0,
  492. isConnected: true, //是否有网
  493. page: 1,
  494. loadmore: 'loading',
  495. loading: true,
  496. slider: 50,
  497. value2: '',
  498. keywords: '',
  499. increase: '',
  500. noincrease: '',
  501. increaseswitch: false,
  502. keyword: ['莫斯科', '日落', '橄榄树', '椰子树', '小兔子梵高', '海底世界', '星球'],
  503. custyle: [{
  504. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/18134196791680595205.png',
  505. title: '真人模型'
  506. }, {
  507. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/17763741241683163592.png',
  508. title: '宠物模型'
  509. }, {
  510. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/4740030011682234157.png',
  511. title: '漫画模型'
  512. }, {
  513. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/20527297251680823430.png',
  514. title: '海底模型'
  515. }],
  516. showcoin: false,
  517. addSuc: false,
  518. plan: {},
  519. // needCoin: 0,
  520. cos_img: '',
  521. cos_id: 0,
  522. refer_img: '',
  523. refer_id: 0,
  524. // engine: 'sd',
  525. engine: 'ys',
  526. showmj: 0,
  527. current: 0,
  528. engineid: 0,
  529. needCoin: 0,
  530. gallerylist: [],
  531. galleryid: '',
  532. modelslist: [],
  533. modelsid: 0,
  534. xzmodels: '',
  535. showmode: false,
  536. noticebar: ['精美图片需要时间打磨,预计20秒-120秒出图',
  537. // '图片生成中请不要退出,否则可能会生成失败'
  538. ],
  539. tabslist: ['艺术照', 'MJ绘图', 'SD绘图'],
  540. curNow: 0,
  541. cardswiper: [
  542. 'https://cos.iseeds.xyz/cover/3.0-1.jpg',
  543. 'https://cos.iseeds.xyz/cover/hhjmix-3.png',
  544. 'https://cos.iseeds.xyz/style/gufeng1.png',
  545. ],
  546. showconcern: false,
  547. gzhqrcode: '',
  548. proportion: ''
  549. };
  550. },
  551. computed: {
  552. ...mapGetters(['appInfo', 'homeTemplate', 'userInfo', 'isLogin', 'userData'])
  553. },
  554. async onLoad() {
  555. console.log('isLogin================', this.isLogin);
  556. this.getTempLiast({
  557. // sex: 1,
  558. init: true
  559. })
  560. this.showHuiHuaLead = !uni.getStorageSync('showHuiHuaLead')
  561. console.log("uni.getStorageSync('showHuiHuaLead')", uni.getStorageSync('showHuiHuaLead'));
  562. if (this.platform == 'wxMiniProgram') {
  563. var menumtop = uni.getMenuButtonBoundingClientRect().top - uni.getSystemInfoSync().statusBarHeight;
  564. var paddingtop = uni.getSystemInfoSync().statusBarHeight + menumtop;
  565. this.tobheight = menumtop + paddingtop + uni.getMenuButtonBoundingClientRect().height;
  566. }
  567. if (this.$Route.query.prompt) {
  568. this.keywords = this.$Route.query.prompt
  569. if (this.$Route.query.refImg == "undefined") {
  570. // this.refer_img = ''
  571. } else {
  572. this.refer_img = this.$Route.query.refImg
  573. }
  574. this.cursor = this.$Route.query.prompt.length
  575. this.current = this.$Route.query.engine == 'rh' ? 0 : this.$Route.query.engine == 'mj' ? 1 : 2
  576. this.showmj = this.$Route.query.engine == 'rh' ? 0 : this.$Route.query.engine == 'mj' ? 1 : 2
  577. if (this.$Route.query.engine == 'sd') {
  578. this.form.samples = 1
  579. this.engine = 'sd'
  580. this.modelslist = []
  581. this.getModels();
  582. } else if (this.$Route.query.engine == 'mj') {
  583. this.form.samples = 4
  584. this.engine = 'mj'
  585. this.modelslist = []
  586. this.getModels();
  587. } else {
  588. // 艺术照-----创作相似待处理
  589. // this.$Route.query.rh_modalurl
  590. }
  591. } else {
  592. // rh优先展示
  593. this.getsubsection({
  594. index: 0
  595. })
  596. }
  597. this.gallery();
  598. this.getModels();
  599. this.getPlan()
  600. },
  601. onShow() {
  602. // 网络变化检测
  603. uni.onNetworkStatusChange(res => {
  604. this.isConnected = res.isConnected;
  605. });
  606. if (this.isLogin) {
  607. this.getUserData();
  608. }
  609. this.systemwechat()
  610. },
  611. onReady() {
  612. // #ifdef MP-WEIXIN
  613. if (wx.createRewardedVideoAd && this.appInfo.video_status == 1) {
  614. rewardedVideoAd = wx.createRewardedVideoAd({
  615. adUnitId: this.appInfo.video_id
  616. });
  617. rewardedVideoAd.onLoad(() => {
  618. console.log('onLoad event emit');
  619. });
  620. rewardedVideoAd.onError(err => {
  621. console.log('onError event emit', err);
  622. });
  623. rewardedVideoAd.onClose(res => {
  624. if (res && res.isEnded) {
  625. // 正常播放结束,可以下发游戏奖励
  626. this.memberAddCoin();
  627. this.showcoin = false;
  628. } else {
  629. // 播放中途退出,不下发游戏奖励
  630. uni.showToast({
  631. title: '看完广告后才可获得积分哦',
  632. icon: 'none'
  633. });
  634. }
  635. });
  636. }
  637. // #endif
  638. this.loading = false;
  639. },
  640. methods: {
  641. ...mapActions(['appInit', 'logout', 'getUserInfo', 'getUserData']),
  642. toYszDetail() {
  643. uni.previewImage({
  644. urls: ['https://oaigc.oss-cn-chengdu.aliyuncs.com/face/demo.jpg'],
  645. longPressActions: {
  646. itemList: ['发送给朋友', '保存图片', '收藏'],
  647. success: function(data) {},
  648. fail: function(err) {}
  649. }
  650. });
  651. },
  652. handleOrder(item, index) {
  653. this.seledRule = item
  654. this.showRule = false
  655. let p = {
  656. order: this.seledRule == '降序' ? 0 : 1,
  657. init: false
  658. }
  659. if (this.seledStyle.id != -1) {
  660. p['styleId'] = this.seledStyle.id
  661. }
  662. if (this.seledSex != '全部') {
  663. p['sex'] = this.seledSex == '男' ? 0 : 1
  664. }
  665. this.getTempLiast(p)
  666. },
  667. handleSelStyle(item) {
  668. this.seledStyle = item
  669. this.showThem = false
  670. let p = {
  671. order: this.seledRule == '降序' ? 0 : 1,
  672. init: false
  673. }
  674. if (this.seledStyle.id != -1) {
  675. p['styleId'] = this.seledStyle.id
  676. }
  677. if (this.seledSex != '全部') {
  678. p['sex'] = this.seledSex == '男' ? 0 : 1
  679. }
  680. this.getTempLiast(p)
  681. },
  682. handleSelSex(item, index) {
  683. this.seledSex = item
  684. this.showSex = false
  685. let p = {
  686. order: this.seledRule == '降序' ? 0 : 1,
  687. init: false
  688. }
  689. if (this.seledStyle.id != -1) {
  690. p['styleId'] = this.seledStyle.id
  691. }
  692. if (this.seledSex != '全部') {
  693. p['sex'] = this.seledSex == '男' ? 0 : 1
  694. }
  695. this.getTempLiast(p)
  696. },
  697. async getTempLiast(p = {}) {
  698. console.log('getTempLiast----参数', p);
  699. uni.showLoading({
  700. title: '模板加载中...'
  701. })
  702. let res = await this.$http('ys.templateList', p)
  703. if (res.code == 0) {
  704. this.cankaoImgList = res.msg.data
  705. this.styles = [...res.msg.style, {
  706. id: -1,
  707. title: '全部'
  708. }]
  709. if (p.init) {
  710. this.seledStyle = {
  711. id: -1,
  712. title: '全部'
  713. }
  714. this.seledSex = '全部'
  715. }
  716. // 当没有点击创作相似,直接进入时
  717. if (!this.$Route.query.rh_modalurl) {
  718. this.seledCankaoImg = this.cankaoImgList[0]
  719. this.seledCankaoImg_temp = this.cankaoImgList[0]
  720. this.myModal = this.cankaoImgList[0].path
  721. console.log('直接进入', this.$Route.query.rh_modalId);
  722. } else {
  723. // 如果使用了模版
  724. if (this.$Route.query.rh_modalId != -1) {
  725. let sameCankaoImg = this.cankaoImgList.find((item, index) => {
  726. return item.id == this.$Route.query.rh_modalId
  727. })
  728. this.seledCankaoImg = sameCankaoImg
  729. this.seledCankaoImg_temp = sameCankaoImg
  730. this.myModal = sameCankaoImg.path
  731. console.log('使用了模版', this.$Route.query.rh_modalId);
  732. // 用户自己上传的模版图
  733. } else {
  734. console.log('用户自己上传的模版图', this.$Route.query.rh_modalId);
  735. this.seledCankaoImg = {
  736. id: -1
  737. }
  738. this.seledCankaoImg_temp = {
  739. id: -1
  740. }
  741. this.myModal = this.$Route.query.rh_modalurl
  742. }
  743. }
  744. uni.hideLoading()
  745. console.log('艺术照模板列表返回值---', this.cankaoImgList, res);
  746. }
  747. },
  748. handleSelModal(item, index) {
  749. this.seledCankaoImg = item;
  750. this.myModal = item.path;
  751. if (this.seledCankaoImg_temp.id == item.id) {
  752. uni.previewImage({
  753. urls: [item.path],
  754. longPressActions: {
  755. itemList: ['发送给朋友', '保存图片', '收藏'],
  756. success: function(data) {
  757. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  758. },
  759. fail: function(err) {
  760. console.log(err.errMsg);
  761. }
  762. }
  763. });
  764. }
  765. this.seledCankaoImg_temp = item;
  766. },
  767. handleSelMoreModal(item, index) {
  768. if (this.seledCankaoImg_temp.id == item.id) {
  769. uni.previewImage({
  770. urls: [item.path],
  771. longPressActions: {
  772. itemList: ['发送给朋友', '保存图片', '收藏'],
  773. success: function(data) {
  774. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  775. },
  776. fail: function(err) {
  777. console.log(err.errMsg);
  778. }
  779. }
  780. });
  781. }
  782. this.seledCankaoImg_temp = item
  783. },
  784. async genYishuZhao() {
  785. if (!this.myModal) {
  786. return uni.showToast({
  787. title: '请上传模板图',
  788. icon: 'none'
  789. })
  790. }
  791. if (!this.myPhoto) {
  792. return uni.showToast({
  793. title: '请上传照片',
  794. icon: 'none'
  795. })
  796. }
  797. if (!uni.getStorageSync('token')) {
  798. uni.navigateTo({
  799. url: '/pages/user/signin'
  800. });
  801. uni.setStorageSync('route', '/pages/painting/draw');
  802. return;
  803. }
  804. // 金币余额校验
  805. if (this.userData.coin == 0) {
  806. var alias = this.appInfo.number_alias ? this.appInfo.number_alias : '点数';
  807. this.signTitle =
  808. "<p style='font-weight: 550;font-size: 16px;'>灵感一现需要<span style='color: #207CF7;padding: 0 4px;'>" +
  809. 1 + "</span><span>" + alias +
  810. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  811. this.userData.coin + "</span><span>" + alias + "</span>,不支持会员时长,无法生成,快去获取<span>" + alias +
  812. "</span>吧</p>"
  813. this.signShow = true
  814. return;
  815. }
  816. let p = {
  817. templateUrl: this.myModal,
  818. userUrl: this.myPhoto,
  819. }
  820. getApp().ysParmas = p
  821. uni.navigateTo({
  822. // url: '/pages/painting/ys?ysParmas=' + JSON.stringify(p),
  823. url: '/pages/painting/ys',
  824. })
  825. console.log('生成艺术照参数', p);
  826. },
  827. // 处理图片压缩
  828. // test() {
  829. // let _this = this
  830. // uni.chooseImage({
  831. // count: 1, //默认9
  832. // sizeType: ['original', 'compressed'],
  833. // sourceType: ['camera', 'album'],
  834. // success: function(res) {
  835. // translate(res.tempFilePaths[0], 0.3, ' ', imgUrl => {
  836. // uni.previewImage({
  837. // urls: [imgUrl],
  838. // longPressActions: {
  839. // itemList: ['发送给朋友', '保存图片', '收藏'],
  840. // success: function(data) {
  841. // console.log('选中了第' + (data.tapIndex + 1) +
  842. // '个按钮,第' + (data.index + 1) + '张图片');
  843. // },
  844. // fail: function(err) {
  845. // console.log(err.errMsg);
  846. // }
  847. // }
  848. // });
  849. // })
  850. // }
  851. // });
  852. // },
  853. upYsImg(type) {
  854. if (type == 0 && this.myModal) {
  855. return uni.previewImage({
  856. urls: [this.myModal],
  857. longPressActions: {
  858. itemList: ['发送给朋友', '保存图片', '收藏'],
  859. success: function(data) {
  860. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  861. },
  862. fail: function(err) {
  863. console.log(err.errMsg);
  864. }
  865. }
  866. });
  867. }
  868. if (type == 1 && this.myPhoto) {
  869. return uni.previewImage({
  870. urls: [this.myPhoto],
  871. longPressActions: {
  872. itemList: ['发送给朋友', '保存图片', '收藏'],
  873. success: function(data) {
  874. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  875. },
  876. fail: function(err) {
  877. console.log(err.errMsg);
  878. }
  879. }
  880. });
  881. }
  882. let that = this;
  883. uni.chooseImage({
  884. count: 1,
  885. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  886. sourceType: ['camera', 'album'], //从相册选择
  887. success: function(res) {
  888. console.log('上传参考图返回值:', res, res.tempFiles[0].name.toLowerCase());
  889. if (!(res.tempFiles[0].name.toLowerCase().endsWith('.png') || res.tempFiles[0].name
  890. .toLowerCase().endsWith(
  891. '.jpeg') || res.tempFiles[0].name.toLowerCase().endsWith('.jpg'))) {
  892. uni.showToast({
  893. title: '上传失败,请上传png、jpg和jpeg格式的图片',
  894. icon: 'none',
  895. duration: 2000
  896. })
  897. return
  898. }
  899. console.log(res.tempFiles[0].size, res.tempFiles[0].size / 1048576);
  900. if (res.tempFiles[0].size > 10 * 1048576) {
  901. return uni.showToast({
  902. title: '上传失败,图片大小超10M',
  903. icon: 'none',
  904. duration: 2000
  905. })
  906. }
  907. /**
  908. * H5端图片压缩
  909. * 参数说明:
  910. * imgSrc 图片url
  911. * scale缩放比例 0-1
  912. * type 返回图片类型:base64、blob(默认blob)
  913. * callback 回调设置返回值
  914. */
  915. // uni.showLoading({
  916. // title: '图片压缩中...'
  917. // });
  918. // translate(res.tempFilePaths[0], 0.3, ' ', imgUrl => {
  919. // uni.hideLoading()
  920. // console.log('imgUrl', imgUrl);
  921. // if (type == 0) {
  922. // that.showUpLoading1 = true
  923. // } else {
  924. // that.showUpLoading2 = true
  925. // }
  926. // uni.uploadFile({
  927. // url: apiurl('common/upload'),
  928. // filePath: imgUrl,
  929. // name: 'file',
  930. // formData: {
  931. // accept: 'image',
  932. // upload_type: 'ali-oss'
  933. // },
  934. // success: res2 => {
  935. // let a = JSON.parse(res2.data);
  936. // if (a.code == 0) {
  937. // console.log('JSON.parse(res2.data)', a);
  938. // if (type == 0) {
  939. // that.seledCankaoImg = {
  940. // id: -1
  941. // }
  942. // that.myModal = a.data.path;
  943. // that.showUpLoading1 = false
  944. // } else {
  945. // that.myPhoto = a.data.path;
  946. // that.showUpLoading2 = false
  947. // }
  948. // } else {
  949. // uni.showToast({
  950. // title: '上传图片失败',
  951. // icon: 'none'
  952. // });
  953. // }
  954. // }
  955. // });
  956. // })
  957. // 原图片上传逻辑
  958. const path = res.tempFilePaths[0];
  959. console.log('path===================', path);
  960. if (type == 0) {
  961. that.showUpLoading1 = true
  962. } else {
  963. that.showUpLoading2 = true
  964. }
  965. uni.uploadFile({
  966. url: apiurl('common/upload'),
  967. filePath: path,
  968. name: 'file',
  969. formData: {
  970. accept: 'image',
  971. upload_type: 'ali-oss'
  972. },
  973. success: res2 => {
  974. let a = JSON.parse(res2.data);
  975. if (a.code == 0) {
  976. console.log('JSON.parse(res2.data)', a);
  977. if (type == 0) {
  978. that.seledCankaoImg = {
  979. id: -1
  980. }
  981. that.myModal = a.data.path;
  982. that.showUpLoading1 = false
  983. } else {
  984. that.myPhoto = a.data.path;
  985. that.showUpLoading2 = false
  986. }
  987. } else {
  988. uni.showToast({
  989. title: '上传图片失败',
  990. icon: 'none'
  991. });
  992. }
  993. }
  994. });
  995. }
  996. });
  997. },
  998. handleConfirmSel() {
  999. this.showMorePopup = false
  1000. this.seledCankaoImg = this.seledCankaoImg_temp
  1001. // this.modal = ''
  1002. this.myModal = this.seledCankaoImg_temp.path
  1003. },
  1004. handleMorePopup() {
  1005. this.showMorePopup = true
  1006. },
  1007. closeOver() {
  1008. this.showRule = false
  1009. this.showThem = false
  1010. this.showSex = false
  1011. },
  1012. handleOpenOpt(index) {
  1013. if (index == 0) {
  1014. this.showRule = !this.showRule
  1015. this.showThem = false
  1016. this.showSex = false
  1017. } else if (index == 1) {
  1018. this.showRule = false
  1019. this.showThem = !this.showThem
  1020. this.showSex = false
  1021. } else if (index == 2) {
  1022. this.showRule = false
  1023. this.showThem = false
  1024. this.showSex = !this.showSex
  1025. }
  1026. console.log('index============', index, this.showRule, this.showThem, this.showSex);
  1027. },
  1028. nextLead() {
  1029. this.showLead1 = false
  1030. this.showLead2 = true
  1031. },
  1032. finishLead() {
  1033. this.showHuiHuaLead = false
  1034. this.showLead2 = false
  1035. uni.setStorageSync('showHuiHuaLead', true)
  1036. },
  1037. signSign() {
  1038. uni.navigateTo({
  1039. url: '/pages/user/member/member'
  1040. });
  1041. this.signShow = false
  1042. },
  1043. systemwechat() {
  1044. this.$http('conf.getGroupConf', {
  1045. group: 'system.wechat'
  1046. }).then(res => {
  1047. if (res.code == 0) {
  1048. this.gzhqrcode = res.data.qrcode_path
  1049. const focuson = uni.getStorageSync('focuson');
  1050. // console.log(focuson);
  1051. if (!focuson) {
  1052. if (this.gzhqrcode) {
  1053. if (this.isLogin && this.appInfo.is_show_logged_qrcode == 1) {
  1054. this.showconcern = true
  1055. }
  1056. }
  1057. }
  1058. }
  1059. })
  1060. },
  1061. concernclose() {
  1062. this.showconcern = false
  1063. },
  1064. getsubsection(e) {
  1065. this.showmj = e.index
  1066. this.current = e.index
  1067. console.log('this.current---------------', this.current);
  1068. this.modelsid = 0
  1069. if (e.index == 0) {
  1070. // 新增艺术照类型
  1071. this.form.samples = 1
  1072. this.engine = 'ys'
  1073. this.modelslist = []
  1074. this.getModels();
  1075. } else if (e.index == 1) {
  1076. this.form.samples = 4
  1077. this.engine = 'mj'
  1078. this.modelslist = []
  1079. this.getModels();
  1080. } else if (e.index == 2) {
  1081. this.form.samples = 1
  1082. this.engine = 'sd'
  1083. this.modelslist = []
  1084. this.getModels();
  1085. }
  1086. this.initWords()
  1087. },
  1088. async getGpt() {
  1089. if (!this.isLogin) {
  1090. uni.navigateTo({
  1091. url: '/pages/user/signin'
  1092. });
  1093. uni.setStorageSync('route', '/pages/painting/draw');
  1094. return;
  1095. }
  1096. if (!this.gpt_keywords) {
  1097. uni.showToast({
  1098. title: '请填写描述词',
  1099. icon: 'none'
  1100. });
  1101. return;
  1102. }
  1103. if (this.userData.coin == 0) {
  1104. var alias = this.appInfo.number_alias ? this.appInfo.number_alias : '点数';
  1105. this.signTitle =
  1106. "<p style='font-weight: 550;font-size: 16px;'>灵感一现需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1107. 1 + "</span><span>" + alias +
  1108. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  1109. this.userData.coin + "</span><span>" + alias + "</span>,不支持会员时长,无法生成,快去获取<span>" + alias +
  1110. "</span>吧</p>"
  1111. this.signShow = true
  1112. return;
  1113. }
  1114. uni.showLoading({
  1115. title: '内容审核中...'
  1116. })
  1117. // #ifdef H5
  1118. let check = this.appInfo.is_h5_filter && this.appInfo.is_h5_filter == 1 ? await this.getcheckText(this
  1119. .gpt_keywords) :
  1120. 1;
  1121. // #endif
  1122. // #ifdef MP-WEIXIN
  1123. let check = await this.getcheckText(this.gpt_keywords);
  1124. // #endif
  1125. if (check == 1) {
  1126. uni.showLoading({
  1127. title: '咒语生成中...'
  1128. })
  1129. this.$http('gallery.chat', {
  1130. prompt: this.gpt_keywords
  1131. }).then(res => {
  1132. if (res.code == 0) {
  1133. this.gpt_text = res.data;
  1134. uni.hideLoading();
  1135. } else {
  1136. uni.hideLoading();
  1137. uni.showToast({
  1138. title: '使用咒语失败,请尝试重试',
  1139. icon: 'none'
  1140. });
  1141. }
  1142. });
  1143. }
  1144. },
  1145. setGpt() {
  1146. // console.log(this.gpt_text.indexOf("英文:"));
  1147. if (this.gpt_text.indexOf("英文:") != -1) {
  1148. let index = this.gpt_text.indexOf("英文:");
  1149. let text = this.gpt_text.substring(index + 3);
  1150. // console.log(text);
  1151. this.keywords = text
  1152. this.cursor = this.keywords.length
  1153. // console.log(this.keywords.length);
  1154. } else {
  1155. let text = this.gpt_text;
  1156. this.keywords = text
  1157. this.cursor = this.keywords.length
  1158. }
  1159. this.show_gpt = false
  1160. },
  1161. textareainput(e) {
  1162. // console.log(e.detail.cursor);
  1163. this.cursor = e.detail.cursor
  1164. },
  1165. sectionChange(index) {
  1166. this.curNow = index;
  1167. },
  1168. gallery() {
  1169. let that = this;
  1170. this.$http('gallery.getWords').then(res => {
  1171. if (res.code == 0) {
  1172. this.gallerylist = res.data
  1173. }
  1174. });
  1175. },
  1176. getModels() {
  1177. let that = this;
  1178. this.$http('gallery.getModels', {
  1179. engine: that.engine
  1180. }).then(res => {
  1181. if (res.code == 0) {
  1182. uni.setNavigationBarTitle({
  1183. title: this.appInfo.site_name
  1184. });
  1185. if (that.engine == "mj") {
  1186. this.modelslist = res.data.reverse()
  1187. } else if (that.engine == "sd") {
  1188. this.modelslist = res.data
  1189. } else {
  1190. this.modelslist = res.data
  1191. }
  1192. this.form.model_id = this.modelslist[this.modelsid].model_id.toString()
  1193. this.form.name = this.modelslist[this.modelsid].name
  1194. this.xzmodels = this.modelslist[this.modelsid].name
  1195. if (this.$Route.query.model_name) {
  1196. for (var ty = 0; ty < this.modelslist.length; ty++) {
  1197. if (this.$Route.query.model_name == this.modelslist[ty].name) {
  1198. this.modelsid = ty
  1199. this.form.model_id = this.modelslist[ty].model_id.toString()
  1200. this.xzmodels = this.modelslist[ty].name
  1201. this.form.name = this.modelslist[ty].name
  1202. }
  1203. }
  1204. }
  1205. console.log('模型列表---', this.modelslist);
  1206. }
  1207. });
  1208. },
  1209. tapgallery(e) {
  1210. // console.log(this.gallerylist[e].guide.slice(0,500));
  1211. this.keywords = this.gallerylist[e].guide.slice(0, 500)
  1212. this.galleryid = this.gallerylist[e].id
  1213. this.cursor = this.keywords.length
  1214. },
  1215. changepolish() {
  1216. // console.log(e);
  1217. uni.showLoading({
  1218. title: '描述增幅中...'
  1219. })
  1220. this.$http('gallery.chat', {
  1221. prompt: this.keywords
  1222. }).then(res => {
  1223. if (res.code == 0) {
  1224. // this.increaseswitch = e
  1225. // this.increase = res.data
  1226. this.keywords = res.data
  1227. }
  1228. });
  1229. // if(e){
  1230. // if(this.increase){
  1231. // this.keywords = this.increase
  1232. // return;
  1233. // }
  1234. // this.increaseswitch = false
  1235. // uni.showLoading({
  1236. // title:'描述增幅中...'
  1237. // })
  1238. // this.noincrease = this.keywords
  1239. // this.$http('gallery.chat', {prompt:this.keywords}).then(res => {
  1240. // if (res.code == 0) {
  1241. // this.increaseswitch = e
  1242. // this.increase = res.data
  1243. // this.keywords = res.data
  1244. // }
  1245. // });
  1246. // return;
  1247. // }
  1248. // this.keywords = this.noincrease
  1249. },
  1250. getincrease() {
  1251. var that = this;
  1252. if (!this.keywords) {
  1253. uni.showToast({
  1254. title: '请输入描述',
  1255. icon: 'none'
  1256. })
  1257. return;
  1258. }
  1259. uni.showModal({
  1260. confirmText: '立即增幅',
  1261. // showCancel:false,
  1262. confirmColor: '#207CF7',
  1263. content: '如果你正在寻找灵感,或懒得输入描述词,开启描述增幅GTP模型将自动根据你的输入的描述词为你补充描述词',
  1264. title: '提示',
  1265. success(res) {
  1266. if (res.confirm) {
  1267. that.changepolish()
  1268. }
  1269. }
  1270. });
  1271. },
  1272. // loadmores() {
  1273. // for (let i = 0; i < 30; i++) {
  1274. // this.indexList.push({
  1275. // url: this.urls[uni.$u.random(0, this.urls.length - 1)]
  1276. // });
  1277. // }
  1278. // },
  1279. getPlan() {
  1280. this.$http('conf.getGroupConf', {
  1281. group: 'system.plan'
  1282. }).then(res => {
  1283. if (res.code == 0) {
  1284. this.plan = res.data;
  1285. uni.setNavigationBarTitle({
  1286. title: this.appInfo.site_name
  1287. });
  1288. // console.log(this.plan);
  1289. }
  1290. });
  1291. },
  1292. initWords() {
  1293. this.gallerylist = uni.$u.randomArray(this.gallerylist)
  1294. },
  1295. ratio(e) {
  1296. this.ratioIndex = e;
  1297. },
  1298. onExtend(e) {
  1299. if (e == 0) {
  1300. this.form.enable_face_enhance = !this.enable_face_enhance;
  1301. } else {
  1302. this.form.is_last_layer_skip = !this.is_last_layer_skip;
  1303. }
  1304. },
  1305. onWords(e) {
  1306. this.keywords = this.keywords ? this.keywords + ',' + e : e;
  1307. },
  1308. async createClick() {
  1309. if (this.current != 0) {
  1310. var that = this;
  1311. if (!this.isLogin) {
  1312. uni.navigateTo({
  1313. url: '/pages/user/signin'
  1314. });
  1315. uni.setStorageSync('route', '/pages/painting/draw');
  1316. return;
  1317. }
  1318. if (that.appInfo.time_member && that.appInfo.time_member == 1) {
  1319. if (that.showmj == 1) {
  1320. if (that.userData.vip_info && that.userData.is_validity > 0 && that.userData.vip_info
  1321. .mj_used ==
  1322. that.userData.vip_info.mj_times && this.userData.coin < this.plan.unlock_mj_aipainting
  1323. ) {
  1324. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1325. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的绘画<span>" + alias +
  1326. // "</span>不足或会员套餐内剩余绘画次数不足,无法生成绘画</p>"
  1327. this.signTitle =
  1328. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1329. that.plan.unlock_mj_aipainting + "</span><span>" + alias +
  1330. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  1331. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  1332. this.signShow = true
  1333. return;
  1334. }
  1335. if (that.userData.is_validity == 0 && this.userData.coin < this.plan
  1336. .unlock_mj_aipainting) {
  1337. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1338. this.signTitle =
  1339. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1340. that.plan.unlock_mj_aipainting + "</span><span>" + alias +
  1341. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  1342. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  1343. this.signShow = true
  1344. return;
  1345. }
  1346. } else if (that.showmj == 2) {
  1347. if (that.userData.vip_info && that.userData.is_validity > 0 && that.userData.vip_info
  1348. .sd_used == that.userData.vip_info
  1349. .sd_times && this.userData.coin < (this.plan.unlock_aipainting * this.form.samples)) {
  1350. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1351. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的绘画<span>" + alias +
  1352. // "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  1353. this.signTitle =
  1354. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1355. (this.plan.unlock_aipainting * this.form.samples) + "</span><span>" + alias +
  1356. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  1357. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  1358. this.signShow = true
  1359. return;
  1360. }
  1361. if (that.userData.is_validity == 0 && this.userData.coin < (this.plan.unlock_aipainting *
  1362. this
  1363. .form.samples)) {
  1364. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1365. this.signTitle =
  1366. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1367. (this.plan.unlock_aipainting * this.form.samples) + "</span><span>" + alias +
  1368. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  1369. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  1370. this.signShow = true
  1371. return;
  1372. }
  1373. }
  1374. } else {
  1375. if (that.showmj == 1 && this.userData.coin < this.plan.unlock_mj_aipainting) {
  1376. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1377. this.signTitle =
  1378. "<p style='font-weight: 550;font-size: 16px;'>mj绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1379. this.plan.unlock_mj_aipainting + "</span><span>" + alias +
  1380. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  1381. this.userData.coin + "</span><span>" + alias + "</span>,无法生成绘画,快去获取<span>" + alias +
  1382. "</span>吧</p>"
  1383. this.signShow = true
  1384. return;
  1385. }
  1386. if (that.showmj == 2 && this.userData.coin < (this.plan.unlock_aipainting * this.form
  1387. .samples)) {
  1388. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1389. this.signTitle =
  1390. "<p style='font-weight: 550;font-size: 16px;'>sd绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  1391. this.plan.unlock_aipainting * this.form.samples + "</span><span>" + alias +
  1392. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  1393. this.userData.coin + "</span><span>" + alias + "</span>,无法生成绘画,快去获取<span>" + alias +
  1394. "</span>吧</p>"
  1395. this.signShow = true
  1396. return;
  1397. }
  1398. }
  1399. if (!this.keywords) {
  1400. uni.showToast({
  1401. title: '请输入画面描述词',
  1402. icon: 'none'
  1403. });
  1404. return;
  1405. }
  1406. if (!this.form.model_id) {
  1407. uni.showToast({
  1408. title: '请选择绘图模型',
  1409. icon: 'none'
  1410. });
  1411. return;
  1412. } else {
  1413. uni.showLoading({
  1414. title: '内容审核中...'
  1415. })
  1416. // #ifdef H5
  1417. let check = this.appInfo.is_h5_filter && this.appInfo.is_h5_filter == 1 ? await this
  1418. .getcheckText(
  1419. this.keywords) :
  1420. 1;
  1421. // #endif
  1422. // #ifdef MP-WEIXIN
  1423. let check = await this.getcheckText(this.keywords);
  1424. // #endif
  1425. if (check == 1) {
  1426. this.aiPlay(this.refer_img + ' ' + this.keywords);
  1427. }
  1428. }
  1429. }
  1430. },
  1431. getcheckText(e) {
  1432. var that = this;
  1433. return new Promise((resolve, reject) => {
  1434. that.$http('ai.checkText', {
  1435. prompt: e
  1436. }).then(res => {
  1437. if (res.code == 0) {
  1438. resolve(1);
  1439. }
  1440. })
  1441. });
  1442. },
  1443. gallerychat() {
  1444. uni.showLoading({
  1445. title: '润色中...'
  1446. })
  1447. this.$http('gallery.chat', {
  1448. prompt: this.keywords
  1449. }).then(res => {
  1450. if (res.code == 0) {
  1451. this.aiPlay(res.data);
  1452. }
  1453. });
  1454. },
  1455. aiPlay(e) {
  1456. let that = this;
  1457. that.form.prompt = e;
  1458. switch (this.ratioIndex) {
  1459. case 0:
  1460. that.form.width = '512';
  1461. that.form.height = '512';
  1462. that.proportion = '';
  1463. break;
  1464. case 1:
  1465. that.form.width = '512';
  1466. that.form.height = '768';
  1467. that.proportion = ' --ar 3:4';
  1468. break;
  1469. case 2:
  1470. that.form.width = '768';
  1471. that.form.height = '512';
  1472. that.proportion = ' --ar 4:3';
  1473. break;
  1474. case 3:
  1475. that.form.width = '512';
  1476. that.form.height = '1024';
  1477. that.proportion = ' --ar 9:16';
  1478. break;
  1479. case 4:
  1480. that.form.width = '1024';
  1481. that.form.height = '512';
  1482. that.proportion = ' --ar 16:9';
  1483. break;
  1484. }
  1485. if (that.refer_img) {
  1486. that.form.init_image = that.refer_img;
  1487. that.form.type = 'img2img';
  1488. } else {
  1489. that.form.type = 'text2img';
  1490. }
  1491. that.form.keywords = that.keywords
  1492. console.log(that.form);
  1493. uni.navigateTo({
  1494. url: that.showmj == 1 ? '/pages/painting/generate?prompt=' + (that.form.prompt + (that
  1495. .proportion ?
  1496. that.proportion : '')) +
  1497. '&model_id=' + (that.modelslist.length > 0 ? this.form.model_id : '') + '&version=' + (that
  1498. .modelslist.length > 0 ? that.modelslist[this.modelsid].version : '-- v5') +
  1499. '&needCoin=' + that.plan.unlock_mj_aipainting +
  1500. `&refImg=${that.refer_img?that.refer_img:''}&keywords=${that.keywords}` : that.showmj ==
  1501. 2 ?
  1502. '/pages/painting/details?form=' + JSON
  1503. .stringify(this.form) : '/pages/ys/ys'
  1504. });
  1505. console.log('创作相似url传递的参数:', this.form);
  1506. },
  1507. close_blur_view() {
  1508. this.showcoin = false;
  1509. },
  1510. toMember() {
  1511. uni.navigateTo({
  1512. url: '/pages/member/member'
  1513. });
  1514. },
  1515. toWelfare() {
  1516. uni.switchTab({
  1517. url: '/pages/welfare/welfare'
  1518. });
  1519. },
  1520. showVideoAd() {
  1521. if (rewardedVideoAd) {
  1522. uni.showToast({
  1523. title: '广告拉取中',
  1524. icon: 'none'
  1525. });
  1526. rewardedVideoAd.show().catch(() => {
  1527. // 失败重试
  1528. rewardedVideoAd
  1529. .load()
  1530. .then(() => rewardedVideoAd.show())
  1531. .catch(err => {
  1532. console.log('激励视频 广告显示失败');
  1533. uni.showToast({
  1534. title: '广告显示失败',
  1535. icon: 'none'
  1536. });
  1537. });
  1538. });
  1539. }
  1540. },
  1541. memberAddCoin() {
  1542. this.$http('member.addCoin', {
  1543. type: 'video'
  1544. }).then(res => {
  1545. if (res.code == 0) {
  1546. uni.showToast({
  1547. title: '获得积分+' + res.data
  1548. });
  1549. // let coin = {coin: this.userData.coin+1}
  1550. // that.$store.commit('userData',coin)
  1551. this.getUserInfo();
  1552. } else {
  1553. uni.showToast({
  1554. title: '获得积分失败',
  1555. icon: 'none'
  1556. });
  1557. }
  1558. });
  1559. },
  1560. uploadImg(engineid) {
  1561. let that = this;
  1562. uni.chooseImage({
  1563. count: 1, //count: 6, //默认9
  1564. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  1565. sourceType: ['album'], //从相册选择
  1566. success: function(res) {
  1567. console.log('上传参考图返回值:', res.tempFiles[0].name, res.tempFiles[0].name.toLowerCase());
  1568. if (!(res.tempFiles[0].name.toLowerCase().endsWith('.png') || res.tempFiles[0].name
  1569. .toLowerCase().endsWith(
  1570. '.jpeg') || res.tempFiles[0].name.toLowerCase().endsWith('.jpg'))) {
  1571. uni.showToast({
  1572. title: '上传失败,请上传png、jpg和jpeg格式的图片',
  1573. icon: 'none',
  1574. duration: 2000
  1575. })
  1576. return
  1577. }
  1578. const path = res.tempFilePaths[0];
  1579. uni.uploadFile({
  1580. url: apiurl('common/upload'),
  1581. filePath: path,
  1582. // name: 'img',
  1583. // formData: {
  1584. // platform: $platform.get(),
  1585. // accept: 'image'
  1586. // },
  1587. name: 'file',
  1588. formData: {
  1589. accept: 'image',
  1590. upload_type: 'ali-oss'
  1591. },
  1592. success: res2 => {
  1593. let a = JSON.parse(res2.data);
  1594. if (a.code == 0) {
  1595. // if (engineid == 0) {
  1596. // that.cos_img = a.data.path;
  1597. // that.cos_id = a.data.id;
  1598. // } else {
  1599. that.refer_img = a.data.path;
  1600. that.refer_id = a.data.id;
  1601. that.form.refer_img = a.data.path
  1602. // }
  1603. } else {
  1604. uni.showToast({
  1605. title: '上传图片失败',
  1606. icon: 'none'
  1607. });
  1608. }
  1609. }
  1610. });
  1611. }
  1612. });
  1613. },
  1614. preViewImg(img) {
  1615. uni.previewImage({
  1616. urls: [img],
  1617. longPressActions: {
  1618. itemList: ['发送给朋友', '保存图片', '收藏'],
  1619. success: function(data) {},
  1620. fail: function(err) {
  1621. console.log(err.errMsg);
  1622. }
  1623. }
  1624. });
  1625. },
  1626. deleteImg() {
  1627. // if (engineid == 0) {
  1628. // this.cos_img = '';
  1629. // this.cos_id = 0;
  1630. // } else {
  1631. this.refer_img = '';
  1632. this.form.refer_img = ''
  1633. this.form.init_image = ''
  1634. // this.refer_id = 0;
  1635. // }
  1636. },
  1637. open() {
  1638. // console.log('open');
  1639. },
  1640. }
  1641. };
  1642. </script>
  1643. <style lang="scss" scoped>
  1644. @import './draw.scss';
  1645. </style>