draw.vue 58 KB

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