draw.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  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. <u-notice-bar bgColor='#C6D6E4' color='#3F5465' :text="noticebar" step speed="800"></u-notice-bar>
  8. <view style="margin: 30rpx 30rpx 0;">
  9. <tn-subsection :list="tabslist" :current="current" mode="button" :borderRadius="50"
  10. backgroundColor="#207CF7" @change="getsubsection" buttonColor="tn-cool-bg-color-7"
  11. inactiveColor="#FFFFFF" activeColor="#357aba"></tn-subsection>
  12. </view>
  13. <view class="directask">
  14. <view v-if="modelslist.length>0" class="cu-form-group">
  15. <view class="cu-title flxe align-center justify-between">
  16. <view class="title flxe align-center">模型选择</view>
  17. <block v-if="showmj">
  18. <u-tag v-if="userData.vip_info&&userData.is_validity>0"
  19. :text="(userData.vip_info.mj_type == 'time'?'今日':'会员')+'剩余mj绘画:'+(userData.vip_info.mj_times==-1?'无限量':userData.vip_info.mj_times-userData.vip_info.mj_used+'次')"
  20. plain shape="circle" plainFill color="#207CF7" borderColor="#207CF7"
  21. bgColor="#207CF714"></u-tag>
  22. </block>
  23. <block v-else>
  24. <u-tag v-if="userData.vip_info&&userData.is_validity>0"
  25. :text="(userData.vip_info.sd_type == 'time'?'今日':'会员')+'剩余sd绘画:'+(userData.vip_info.sd_times == -1?'无限量':userData.vip_info.sd_times-userData.vip_info.sd_used+'次')"
  26. plain shape="circle" plainFill color="#207CF7" borderColor="#207CF7"
  27. bgColor="#207CF714"></u-tag>
  28. </block>
  29. </view>
  30. <view class="engine-container" @click="showmode = true" v-if="current==0">
  31. <view class="model_view">模型:{{xzmodels}}</view>
  32. <u-icon name="arrow-down-fill" color="#9e9e9e"></u-icon>
  33. </view>
  34. </view>
  35. <!-- mj模型选择新调整 -->
  36. <view class="mjSelBox" v-if="current==1">
  37. <!-- <view class="mjitem" v-for="(item,index) in modelslist"
  38. @click="modelsid = index,showmode = false,form.model_id = item.model_id.toString(),xzmodels = item.name,form.name = item.name"
  39. :style="{'border-color':index==modelsid?'#1F79F0':'','background-image':`url(${item.imgs[0]})`}"> -->
  40. <view class="mjitem" v-for="(item,index) in modelslist"
  41. @click="modelsid = index,showmode = false,form.model_id = item.model_id.toString(),xzmodels = item.name,form.name = item.name"
  42. :style="{'border-color':index==modelsid?'#1F79F0':'','background-image':`url(${item.title=='官方V5.1'?'../../static/scy.png':'../../static/ecy.png'})`}">
  43. <view class="topRight" style="background-image: url('../../static/sjx.png')">
  44. </view>
  45. <view class="bar">
  46. {{item.title=='官方V5.1'?'二次元模型':'三次元写实'}}
  47. </view>
  48. </view>
  49. </view>
  50. <view class="cu-form-group" :style="engineid != 0 ? 'margin-top: 20rpx' : ''">
  51. <view class="cu-title flxe align-center justify-between">
  52. <view class="title flxe align-center">画面描述</view>
  53. <!-- <u-icon @click="keywords = '',galleryid =''" name="trash-fill" color="#9e9e9e" size="24"></u-icon> -->
  54. </view>
  55. <view class="textarea-container">
  56. <textarea class="textarea" v-model="keywords" cursor-spacing="30rpx" :maxlength="500"
  57. placeholder-style="color: #9e9e9e;font-size:28rpx"
  58. placeholder="输入你的创意,支持中英文,用逗号分隔,关键词越多越精确,关键词越少AI自由发挥越多,如:最好的质量,城市,大雨,远景,赛博朋克" value="keywords"
  59. @input="textareainput" />
  60. <view class="textareaoperate tn-flex align-center justify-between">
  61. <!-- <view @click="getincrease" class="increase">描述增幅</view> -->
  62. <view @click="show_gpt = true" class="increase tn-main-gradient-orangeyellow">咒语助手</view>
  63. <view class="tn-flex align-center" style="color: #9e9e9e;">
  64. <view class="">{{cursor}}/500</view>
  65. <view style="margin: 0 20rpx;">||</view>
  66. <u-icon @click="keywords = '',galleryid ='',cursor = 0" name="trash-fill" color="#9e9e9e"
  67. size="24"></u-icon>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- <view class="tn-flex align-center justify-between polish">
  72. <view class="tn-flex">
  73. <view style="margin-right: 10rpx;">描述增幅</view>
  74. <u-icon @click="getincrease" name="question-circle" color="#909399" size="20"></u-icon>
  75. </view>
  76. <u-switch size="26" space="2" activeColor="#f9ae3d" inactiveColor="#f1f1f1" v-model="increaseswitch" @change="changepolish"></u-switch>
  77. </view> -->
  78. <!-- <view v-if="gallerylist.length>0&&!showmj" class="try-tips"> -->
  79. <view v-if="gallerylist.length>0" class="try-tips">
  80. <scroll-view class="scroll-view" scroll-x="true">
  81. <block v-for="(item,index) in gallerylist" :key="index">
  82. <view @click="tapgallery(index)" class="scroll-item"
  83. :style="{background: galleryid == item.id?'#207CF7':'',color: galleryid == item.id?'#fff':''}">
  84. {{item.name}}
  85. </view>
  86. </block>
  87. </scroll-view>
  88. <view class="change" @click="initWords"><text class="tn-icon-circle-arrow tn-color-cat"
  89. style="font-size: 34rpx;"></text></view>
  90. </view>
  91. </view>
  92. <!-- <view class="words-ocntainer">
  93. <view class="sentences">
  94. <view class="item" v-for="(item, index) in sentence" :key="index" @click="onWords(item)">{{ item }}</view>
  95. </view>
  96. <view class="tags">
  97. <view class="item" v-for="(item, index) in word" :key="index" @click="onWords(item)">{{ item }}</view>
  98. </view>
  99. </view> -->
  100. <!-- <view class="cu-form-group" style="margin-bottom: 0;">
  101. <view class="cu-title"><view class="title flxe align-center">风格选择</view></view>
  102. </view> -->
  103. <!-- <view class="cu-form-group">
  104. <view class="cu-title flxe align-center justify-between">
  105. <view class="title flxe align-center">风格选择</view>
  106. </view>
  107. <scroll-view class="scrollview" scroll-x="true" style="height: 140rpx;">
  108. <block v-for="(item, index) in custyle" :key="index">
  109. <view class="scrollstyle">
  110. <image :src="item.img" mode="aspectFill"></image>
  111. <view>{{ item.title }}</view>
  112. </view>
  113. </block>
  114. </scroll-view>
  115. </view> -->
  116. <!-- <view class="cu-form-group" v-if="engineid == 1 || engineid == 2">
  117. <view class="cu-title"><view class="title flxe align-center">智能拓展</view></view>
  118. <scroll-view class="scrollview" scroll-x="true">
  119. <view class="scrollitems" :class="form.enable_face_enhance ? 'active' : ''" @click="onExtend(0)">面部强化</view>
  120. <view class="scrollitems" :class="form.is_last_layer_skip ? 'active' : ''" @click="onExtend(1)">色彩狂化</view>
  121. </scroll-view>
  122. </view> -->
  123. <view v-if="!showmj" class="cu-form-group">
  124. <view class="cu-title">
  125. <view class="title flxe align-center">图片比例</view>
  126. </view>
  127. <view class="flxe proportion">
  128. <view class="radio flxe align-center justify-center flxe-column"
  129. :class="ratioIndex == 0 ? 'active' : ''" @click="ratio(0)">
  130. <view class="cu-proportion flxe align-center justify-center">
  131. <view class="proportion1"></view>
  132. </view>
  133. <view class="describe">1:1</view>
  134. </view>
  135. <view class="radio flxe align-center justify-center flxe-column"
  136. :class="ratioIndex == 1 ? 'active' : ''" @click="ratio(1)">
  137. <view class="cu-proportion flxe align-center justify-center">
  138. <view class="proportion2"></view>
  139. </view>
  140. <view class="describe">3:4</view>
  141. </view>
  142. <view class="radio flxe align-center justify-center flxe-column"
  143. :class="ratioIndex == 2 ? 'active' : ''" @click="ratio(2)">
  144. <view class="cu-proportion flxe align-center justify-center">
  145. <view class="proportion3"></view>
  146. </view>
  147. <view class="describe">4:3</view>
  148. </view>
  149. <!-- <view class="radio flxe align-center justify-center flxe-column" :class="ratioIndex == 3 ? 'active' : ''" @click="ratio(3)">
  150. <view class="cu-proportion flxe align-center justify-center"><view class="proportion2"></view></view>
  151. <view class="describe">9:16</view>
  152. </view>
  153. <view class="radio flxe align-center justify-center flxe-column" :class="ratioIndex == 4 ? 'active' : ''" @click="ratio(4)">
  154. <view class="cu-proportion flxe align-center justify-center"><view class="proportion3"></view></view>
  155. <view class="describe">16:9</view>
  156. </view> -->
  157. </view>
  158. </view>
  159. <view class="cu-form-group">
  160. <view class="cu-title">
  161. <view class="title flxe align-center">参考图(可选)</view>
  162. </view>
  163. <view class="desc-tips">AI绘画时会参考您所上传的参考图的风格进行构图</view>
  164. <view class="cu-upload flxe align-center justify-center">
  165. <image class="upload-img" :src="refer_img" v-if="refer_img" mode="aspectFill"
  166. @click="preViewImg(refer_img)"></image>
  167. <view class="upload-delete tn-icon-delete tn-color-cat" style="font-size: 40rpx;" v-if="refer_img"
  168. @click="deleteImg()"></view>
  169. <view class="flxe flxe-column align-center" v-else @click="uploadImg(engineid)">
  170. <u-icon name="plus-circle-fill" color="#207CF7" size="28"></u-icon>
  171. <view class="upload">上传图片</view>
  172. </view>
  173. </view>
  174. </view>
  175. <!-- <view class="cu-form-group">
  176. <view class="cu-title"><view class="title flxe align-center">参考图相似度</view></view>
  177. <view class="desc-tips">相似度越高越遵照原图风格,越低越有创意</view>
  178. <u-slider v-if="engineid == 0" v-model="form.fidelity" showValue activeColor="#207CF7" blockColor="#207CF7" min="0" max="100"></u-slider>
  179. <u-slider v-else v-model="form.init_strength" showValue activeColor="#207CF7" blockColor="#207CF7" min="0" max="70"></u-slider>
  180. </view> -->
  181. <view class="cu-form-group">
  182. <view class="cu-title">
  183. <view class="title flxe align-center">生成数量</view>
  184. </view>
  185. <view class="flxe generate">
  186. <block v-if="!showmj">
  187. <view class="xz_generate flxe align-center justify-center"
  188. :class="form.samples == 1 ? 'xz_gactive' : ''" @click="form.samples = 1">
  189. <view :style="{color: form.samples == 1 ? '#207CF7':''}">1张</view>
  190. </view>
  191. <!-- <view class="xz_generate flxe align-center justify-center" :class="form.samples == 2 ? 'xz_gactive' : ''" @click="form.samples = 2">
  192. <view :style="{color: form.samples == 2 ? '#207CF7':''}">2张</view>
  193. </view>
  194. <view class="xz_generate flxe align-center justify-center" :class="form.samples == 3 ? 'xz_gactive' : ''" @click="form.samples = 3">
  195. <view :style="{color: form.samples == 3 ? '#207CF7':''}">3张</view>
  196. </view> -->
  197. </block>
  198. <block v-else>
  199. <view class="xz_generate flxe align-center justify-center"
  200. :class="form.samples == 4 ? 'xz_gactive' : ''" @click="form.samples = 4">
  201. <view :style="{color: form.samples == 4 ? '#207CF7':''}">4张</view>
  202. </view>
  203. </block>
  204. </view>
  205. </view>
  206. <!-- <view class="footer">
  207. <view @click="createClick" class="Btn1" :data-styleid="1" hoverClass="active">
  208. <view class="create">
  209. <view>生成 | 需要消耗{{ needCoin }}积分</view>
  210. </view>
  211. </view>
  212. </view> -->
  213. </view>
  214. <view class="dygbhg">
  215. <navigator class="whole" open-type="navigateBack">退出</navigator>
  216. <block v-if="showmj">
  217. <view
  218. 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"
  219. @click="createClick" class="distinguish">立即生成</view>
  220. <view v-else @click="createClick" class="distinguish">生成 |
  221. 需要消耗{{ plan.unlock_mj_aipainting}}{{appInfo.number_alias ? appInfo.number_alias : '点数'}}</view>
  222. </block>
  223. <block v-else>
  224. <view
  225. 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"
  226. @click="createClick" class="distinguish">立即生成</view>
  227. <view v-else @click="createClick" class="distinguish">生成 |
  228. 需要消耗{{ plan.unlock_aipainting*form.samples}}{{appInfo.number_alias ? appInfo.number_alias : '点数'}}
  229. </view>
  230. </block>
  231. </view>
  232. <u-loading-page :loading="loading" loading-text="正在加载" icon-size="35" bgColor="#1a1a1a" color="#fff"
  233. loadingColor="#fff"></u-loading-page>
  234. <u-popup :show="showmode" @close="showmode = false" safeAreaInsetTop :round="15" closeable>
  235. <view class="select u-flex justify-center"><text>选择模型</text></view>
  236. <scroll-view scroll-y="true" class="scroll_mode">
  237. <view class="tn-flex justify-between flex-wrap">
  238. <block v-for="(item,index) in modelslist" :key="index">
  239. <view v-if="item.title" class="card" :style="{borderColor: modelsid == index?'#207CF7':''}"
  240. @click="modelsid = index,showmode = false,form.model_id = item.model_id.toString(),xzmodels = item.name,form.name = item.name">
  241. <u-swiper :list="item.imgs" radius="0" height="110"
  242. :indicator="item.imgs.length>1?true:false" indicatorMode="line" circular></u-swiper>
  243. <view class="card-info">
  244. <view class="card-info-title">{{item.title=='官方V5.1'?'Niji 5':item.title}}</view>
  245. <view class="card-info-desc">{{item.name}}</view>
  246. </view>
  247. </view>
  248. </block>
  249. </view>
  250. </scroll-view>
  251. </u-popup>
  252. <u-popup :show="show_gpt" @close="show_gpt = false" mode="center" :round="10" closeable safeAreaInsetTop>
  253. <view class="gpt-select">
  254. <view class="gpt-title"><u--text text="咒语助手" iconStyle="font-size: 20px" color="#1a1a1a" bold size="18"
  255. lineHeight="30"></u--text></view>
  256. <u--text text="针对AI绘画场景下的gpt模型,能够生成高质量的描述词" color="#9e9e9e" size="14" lineHeight="30"></u--text>
  257. <!-- <u--text text="输入你的创意 想象" iconStyle="font-size: 20px" bold size="16" lineHeight="30"></u--text> -->
  258. <view class="gpt-textarea-container"><u--textarea v-model="gpt_keywords" placeholder="输入你的创意 想象"
  259. count></u--textarea></view>
  260. <view class="use-gpt">
  261. <u-button :text="appInfo.number_alias ? '灵感一现(消耗1'+appInfo.number_alias+')':'灵感一现(消耗1点数)'"
  262. shape="circle" color="linear-gradient(to right, rgb(255, 202, 40), rgb(255, 167, 38))"
  263. @click="getGpt"></u-button>
  264. </view>
  265. <view class="gpt-textarea-container" style="margin-bottom: 20rpx;"><u--textarea height="200"
  266. v-model="gpt_text" v-if="gpt_text"></u--textarea></view>
  267. <u-button type="success" @click="setGpt" plain text="使用" shape="circle" v-if="gpt_text"></u-button>
  268. </view>
  269. </u-popup>
  270. <wike-model v-if="signShow" :authorize="false" :title="signTitle" btnText="立即获取" @save="signSign"
  271. @close="signShow = false"></wike-model>
  272. <wike-modal-qrcode :qrcode="gzhqrcode" :showconcern="showconcern"
  273. @concernclose="concernclose"></wike-modal-qrcode>
  274. <!-- <wike-tabbar :onTabbar="true" :isShowAnimate="true"></wike-tabbar> -->
  275. <!-- <u-picker :show="showmode" :columns="modelslist" keyName="name" @cancel="showmode = false"></u-picker> -->
  276. <!-- 绘画引导界面 -->
  277. <div class="leadBg" v-if="showHuiHuaLead">
  278. <div class="leadBox1" v-if="showLead1">
  279. <div class="nextBtn" @click="nextLead">
  280. </div>
  281. </div>
  282. <div class="leadBox2" v-if="showLead2">
  283. <div class="nextBtn" @click="finishLead">
  284. </div>
  285. </div>
  286. </div>
  287. </view>
  288. </template>
  289. <script>
  290. import {
  291. mapMutations,
  292. mapActions,
  293. mapState,
  294. mapGetters
  295. } from 'vuex';
  296. import {
  297. apiurl
  298. } from '@/common/request/request';
  299. let rewardedVideoAd = null;
  300. export default {
  301. mixins: [],
  302. components: {},
  303. data() {
  304. return {
  305. showHuiHuaLead: false,
  306. showLead2: false,
  307. showLead1: true,
  308. signShow: false,
  309. signTitle: '',
  310. tobheight: 45,
  311. platform: this.$platform.get(),
  312. indexList: [],
  313. show_gpt: false,
  314. gpt_keywords: '',
  315. gpt_text: '',
  316. cursor: 0,
  317. form: {
  318. // is_anime: true,
  319. // style: '',
  320. // task: 'txt2img',
  321. // act: '',
  322. // fidelity: 50,
  323. // text: '',
  324. // prompt: '',
  325. // init_image: '',
  326. // init_strength: 50,
  327. // guidence_scale: 15,
  328. // ratio: 2,
  329. // enable_face_enhance: false,
  330. // is_last_layer_skip: false,
  331. // engine: 'stable_diffusion'
  332. name: '',
  333. init_image: '',
  334. prompt: '',
  335. width: '',
  336. height: '',
  337. guidance_scale: '7',
  338. samples: '1',
  339. model_id: '',
  340. scheduler: 'DDPMScheduler',
  341. type: 'text2img',
  342. num_inference_steps: '30',
  343. // lora_model:'guofeng3-lora'
  344. },
  345. word: [],
  346. sentence: [],
  347. enable_face_enhance: false,
  348. is_last_layer_skip: false,
  349. ratioIndex: 0,
  350. isConnected: true, //是否有网
  351. page: 1,
  352. loadmore: 'loading',
  353. loading: true,
  354. slider: 50,
  355. value2: '',
  356. keywords: '',
  357. increase: '',
  358. noincrease: '',
  359. increaseswitch: false,
  360. keyword: ['莫斯科', '日落', '橄榄树', '椰子树', '小兔子梵高', '海底世界', '星球'],
  361. custyle: [{
  362. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/18134196791680595205.png',
  363. title: '真人模型'
  364. }, {
  365. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/17763741241683163592.png',
  366. title: '宠物模型'
  367. }, {
  368. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/4740030011682234157.png',
  369. title: '漫画模型'
  370. }, {
  371. img: 'https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/20527297251680823430.png',
  372. title: '海底模型'
  373. }],
  374. showcoin: false,
  375. addSuc: false,
  376. plan: {},
  377. // needCoin: 0,
  378. cos_img: '',
  379. cos_id: 0,
  380. refer_img: '',
  381. refer_id: 0,
  382. engine: 'sd',
  383. engineid: 0,
  384. needCoin: 0,
  385. gallerylist: [],
  386. galleryid: '',
  387. modelslist: [],
  388. modelsid: 0,
  389. xzmodels: '',
  390. showmode: false,
  391. noticebar: ['精美图片需要时间打磨,预计20秒-120秒出图',
  392. // '图片生成中请不要退出,否则可能会生成失败'
  393. ],
  394. tabslist: ['StableDiffusion绘图', 'MidJourney绘图'],
  395. curNow: 0,
  396. cardswiper: [
  397. 'https://cos.iseeds.xyz/cover/3.0-1.jpg',
  398. 'https://cos.iseeds.xyz/cover/hhjmix-3.png',
  399. 'https://cos.iseeds.xyz/style/gufeng1.png',
  400. ],
  401. showmj: false,
  402. current: 1,
  403. showconcern: false,
  404. gzhqrcode: '',
  405. proportion: ''
  406. };
  407. },
  408. computed: {
  409. ...mapGetters(['appInfo', 'homeTemplate', 'userInfo', 'isLogin', 'userData'])
  410. },
  411. onLoad() {
  412. this.showHuiHuaLead = !uni.getStorageSync('showHuiHuaLead')
  413. console.log("uni.getStorageSync('showHuiHuaLead')", uni.getStorageSync('showHuiHuaLead'));
  414. // mj优先展示
  415. this.getsubsection({
  416. index: 1
  417. })
  418. if (this.platform == 'wxMiniProgram') {
  419. var menumtop = uni.getMenuButtonBoundingClientRect().top - uni.getSystemInfoSync().statusBarHeight;
  420. var paddingtop = uni.getSystemInfoSync().statusBarHeight + menumtop;
  421. this.tobheight = menumtop + paddingtop + uni.getMenuButtonBoundingClientRect().height;
  422. }
  423. if (this.$Route.query.prompt) {
  424. this.keywords = this.$Route.query.prompt
  425. if (this.$Route.query.refImg == "undefined") {
  426. // this.refer_img = ''
  427. } else {
  428. this.refer_img = this.$Route.query.refImg
  429. }
  430. this.cursor = this.$Route.query.prompt.length
  431. this.current = this.$Route.query.engine == 'sd' ? 0 : 1
  432. this.showmj = this.$Route.query.engine == 'sd' ? false : true
  433. if (this.$Route.query.engine == 'sd') {
  434. this.form.samples = 1
  435. this.engine = 'sd'
  436. this.modelslist = []
  437. this.getModels();
  438. } else {
  439. this.form.samples = 4
  440. this.engine = 'mj'
  441. this.modelslist = []
  442. this.getModels();
  443. }
  444. }
  445. this.gallery();
  446. this.getModels();
  447. this.getPlan()
  448. },
  449. onShow() {
  450. // 网络变化检测
  451. uni.onNetworkStatusChange(res => {
  452. this.isConnected = res.isConnected;
  453. });
  454. if (this.isLogin) {
  455. this.getUserData();
  456. }
  457. this.systemwechat()
  458. },
  459. onReady() {
  460. // #ifdef MP-WEIXIN
  461. if (wx.createRewardedVideoAd && this.appInfo.video_status == 1) {
  462. rewardedVideoAd = wx.createRewardedVideoAd({
  463. adUnitId: this.appInfo.video_id
  464. });
  465. rewardedVideoAd.onLoad(() => {
  466. console.log('onLoad event emit');
  467. });
  468. rewardedVideoAd.onError(err => {
  469. console.log('onError event emit', err);
  470. });
  471. rewardedVideoAd.onClose(res => {
  472. if (res && res.isEnded) {
  473. // 正常播放结束,可以下发游戏奖励
  474. this.memberAddCoin();
  475. this.showcoin = false;
  476. } else {
  477. // 播放中途退出,不下发游戏奖励
  478. uni.showToast({
  479. title: '看完广告后才可获得积分哦',
  480. icon: 'none'
  481. });
  482. }
  483. });
  484. }
  485. // #endif
  486. this.loading = false;
  487. },
  488. methods: {
  489. ...mapActions(['appInit', 'logout', 'getUserInfo', 'getUserData']),
  490. nextLead() {
  491. this.showLead1 = false
  492. this.showLead2 = true
  493. },
  494. finishLead() {
  495. this.showHuiHuaLead = false
  496. this.showLead2 = false
  497. uni.setStorageSync('showHuiHuaLead', true)
  498. },
  499. signSign() {
  500. uni.navigateTo({
  501. url: '/pages/user/member/member'
  502. });
  503. this.signShow = false
  504. },
  505. systemwechat() {
  506. this.$http('conf.getGroupConf', {
  507. group: 'system.wechat'
  508. }).then(res => {
  509. if (res.code == 0) {
  510. this.gzhqrcode = res.data.qrcode_path
  511. const focuson = uni.getStorageSync('focuson');
  512. // console.log(focuson);
  513. if (!focuson) {
  514. if (this.gzhqrcode) {
  515. if (this.isLogin && this.appInfo.is_show_logged_qrcode == 1) {
  516. this.showconcern = true
  517. }
  518. }
  519. }
  520. }
  521. })
  522. },
  523. concernclose() {
  524. this.showconcern = false
  525. },
  526. getsubsection(e) {
  527. // if (this.keywords) {
  528. // this.keywords = ''
  529. // }
  530. this.showmj = e.index == 1 ? true : false
  531. this.current = e.index
  532. this.modelsid = 0
  533. if (e.index == 1) {
  534. this.form.samples = 4
  535. this.engine = 'mj'
  536. this.modelslist = []
  537. this.getModels();
  538. } else {
  539. this.form.samples = 1
  540. this.engine = 'sd'
  541. this.modelslist = []
  542. this.getModels();
  543. }
  544. this.initWords()
  545. },
  546. async getGpt() {
  547. if (!this.isLogin) {
  548. uni.navigateTo({
  549. url: '/pages/user/signin'
  550. });
  551. uni.setStorageSync('route', '/pages/painting/draw');
  552. return;
  553. }
  554. if (!this.gpt_keywords) {
  555. uni.showToast({
  556. title: '请填写描述词',
  557. icon: 'none'
  558. });
  559. return;
  560. }
  561. if (this.userData.coin == 0) {
  562. var alias = this.appInfo.number_alias ? this.appInfo.number_alias : '点数';
  563. this.signTitle =
  564. "<p style='font-weight: 550;font-size: 16px;'>灵感一现需要<span style='color: #207CF7;padding: 0 4px;'>" +
  565. 1 + "</span><span>" + alias +
  566. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  567. this.userData.coin + "</span><span>" + alias + "</span>,不支持会员时长,无法生成,快去获取<span>" + alias +
  568. "</span>吧</p>"
  569. this.signShow = true
  570. return;
  571. }
  572. uni.showLoading({
  573. title: '内容审核中...'
  574. })
  575. // #ifdef H5
  576. let check = this.appInfo.is_h5_filter && this.appInfo.is_h5_filter == 1 ? await this.getcheckText(this
  577. .gpt_keywords) :
  578. 1;
  579. // #endif
  580. // #ifdef MP-WEIXIN
  581. let check = await this.getcheckText(this.gpt_keywords);
  582. // #endif
  583. if (check == 1) {
  584. uni.showLoading({
  585. title: '咒语生成中...'
  586. })
  587. this.$http('gallery.chat', {
  588. prompt: this.gpt_keywords
  589. }).then(res => {
  590. if (res.code == 0) {
  591. this.gpt_text = res.data;
  592. uni.hideLoading();
  593. } else {
  594. uni.hideLoading();
  595. uni.showToast({
  596. title: '使用咒语失败,请尝试重试',
  597. icon: 'none'
  598. });
  599. }
  600. });
  601. }
  602. },
  603. setGpt() {
  604. // console.log(this.gpt_text.indexOf("英文:"));
  605. if (this.gpt_text.indexOf("英文:") != -1) {
  606. let index = this.gpt_text.indexOf("英文:");
  607. let text = this.gpt_text.substring(index + 3);
  608. // console.log(text);
  609. this.keywords = text
  610. this.cursor = this.keywords.length
  611. // console.log(this.keywords.length);
  612. } else {
  613. let text = this.gpt_text;
  614. this.keywords = text
  615. this.cursor = this.keywords.length
  616. }
  617. this.show_gpt = false
  618. },
  619. textareainput(e) {
  620. // console.log(e.detail.cursor);
  621. this.cursor = e.detail.cursor
  622. },
  623. sectionChange(index) {
  624. this.curNow = index;
  625. },
  626. gallery() {
  627. let that = this;
  628. this.$http('gallery.getWords').then(res => {
  629. if (res.code == 0) {
  630. this.gallerylist = res.data
  631. }
  632. });
  633. },
  634. getModels() {
  635. let that = this;
  636. this.$http('gallery.getModels', {
  637. engine: that.engine
  638. }).then(res => {
  639. if (res.code == 0) {
  640. uni.setNavigationBarTitle({
  641. title: this.appInfo.site_name
  642. });
  643. if (that.engine == "mj") {
  644. this.modelslist = res.data.reverse()
  645. } else {
  646. this.modelslist = res.data
  647. }
  648. this.form.model_id = this.modelslist[this.modelsid].model_id.toString()
  649. this.form.name = this.modelslist[this.modelsid].name
  650. // this.needCoin = this.modelslist[this.modelsid].coin
  651. this.xzmodels = this.modelslist[this.modelsid].name
  652. // console.log(this.modelslist);
  653. if (this.$Route.query.model_name) {
  654. for (var ty = 0; ty < this.modelslist.length; ty++) {
  655. if (this.$Route.query.model_name == this.modelslist[ty].name) {
  656. // console.log(ty);
  657. this.modelsid = ty
  658. this.form.model_id = this.modelslist[ty].model_id.toString()
  659. // this.needCoin = this.modelslist[ty].coin
  660. this.xzmodels = this.modelslist[ty].name
  661. this.form.name = this.modelslist[ty].name
  662. }
  663. }
  664. }
  665. console.log('模型列表---', this.modelslist);
  666. }
  667. });
  668. },
  669. tapgallery(e) {
  670. // console.log(this.gallerylist[e].guide.slice(0,500));
  671. this.keywords = this.gallerylist[e].guide.slice(0, 500)
  672. this.galleryid = this.gallerylist[e].id
  673. this.cursor = this.keywords.length
  674. },
  675. changepolish() {
  676. // console.log(e);
  677. uni.showLoading({
  678. title: '描述增幅中...'
  679. })
  680. this.$http('gallery.chat', {
  681. prompt: this.keywords
  682. }).then(res => {
  683. if (res.code == 0) {
  684. // this.increaseswitch = e
  685. // this.increase = res.data
  686. this.keywords = res.data
  687. }
  688. });
  689. // if(e){
  690. // if(this.increase){
  691. // this.keywords = this.increase
  692. // return;
  693. // }
  694. // this.increaseswitch = false
  695. // uni.showLoading({
  696. // title:'描述增幅中...'
  697. // })
  698. // this.noincrease = this.keywords
  699. // this.$http('gallery.chat', {prompt:this.keywords}).then(res => {
  700. // if (res.code == 0) {
  701. // this.increaseswitch = e
  702. // this.increase = res.data
  703. // this.keywords = res.data
  704. // }
  705. // });
  706. // return;
  707. // }
  708. // this.keywords = this.noincrease
  709. },
  710. getincrease() {
  711. var that = this;
  712. if (!this.keywords) {
  713. uni.showToast({
  714. title: '请输入描述',
  715. icon: 'none'
  716. })
  717. return;
  718. }
  719. uni.showModal({
  720. confirmText: '立即增幅',
  721. // showCancel:false,
  722. confirmColor: '#207CF7',
  723. content: '如果你正在寻找灵感,或懒得输入描述词,开启描述增幅GTP模型将自动根据你的输入的描述词为你补充描述词',
  724. title: '提示',
  725. success(res) {
  726. if (res.confirm) {
  727. that.changepolish()
  728. }
  729. }
  730. });
  731. },
  732. // loadmores() {
  733. // for (let i = 0; i < 30; i++) {
  734. // this.indexList.push({
  735. // url: this.urls[uni.$u.random(0, this.urls.length - 1)]
  736. // });
  737. // }
  738. // },
  739. getPlan() {
  740. this.$http('conf.getGroupConf', {
  741. group: 'system.plan'
  742. }).then(res => {
  743. if (res.code == 0) {
  744. this.plan = res.data;
  745. uni.setNavigationBarTitle({
  746. title: this.appInfo.site_name
  747. });
  748. // console.log(this.plan);
  749. }
  750. });
  751. },
  752. initWords() {
  753. this.gallerylist = uni.$u.randomArray(this.gallerylist)
  754. },
  755. ratio(e) {
  756. this.ratioIndex = e;
  757. },
  758. onExtend(e) {
  759. if (e == 0) {
  760. this.form.enable_face_enhance = !this.enable_face_enhance;
  761. } else {
  762. this.form.is_last_layer_skip = !this.is_last_layer_skip;
  763. }
  764. },
  765. onWords(e) {
  766. this.keywords = this.keywords ? this.keywords + ',' + e : e;
  767. },
  768. async createClick() {
  769. var that = this;
  770. if (!this.isLogin) {
  771. uni.navigateTo({
  772. url: '/pages/user/signin'
  773. });
  774. uni.setStorageSync('route', '/pages/painting/draw');
  775. return;
  776. }
  777. if (that.appInfo.time_member && that.appInfo.time_member == 1) {
  778. if (that.showmj) {
  779. if (that.userData.vip_info && that.userData.is_validity > 0 && that.userData.vip_info
  780. .mj_used ==
  781. that.userData.vip_info.mj_times && this.userData.coin < this.plan.unlock_mj_aipainting) {
  782. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  783. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的绘画<span>" + alias +
  784. // "</span>不足或会员套餐内剩余绘画次数不足,无法生成绘画</p>"
  785. this.signTitle =
  786. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  787. that.plan.unlock_mj_aipainting + "</span><span>" + alias +
  788. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  789. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  790. this.signShow = true
  791. return;
  792. }
  793. if (that.userData.is_validity == 0 && this.userData.coin < this.plan.unlock_mj_aipainting) {
  794. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  795. this.signTitle =
  796. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  797. that.plan.unlock_mj_aipainting + "</span><span>" + alias +
  798. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  799. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  800. this.signShow = true
  801. return;
  802. }
  803. } else {
  804. if (that.userData.vip_info && that.userData.is_validity > 0 && that.userData.vip_info
  805. .sd_used == that.userData.vip_info
  806. .sd_times && this.userData.coin < (this.plan.unlock_aipainting * this.form.samples)) {
  807. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  808. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的绘画<span>" + alias +
  809. // "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  810. this.signTitle =
  811. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  812. (this.plan.unlock_aipainting * this.form.samples) + "</span><span>" + alias +
  813. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  814. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  815. this.signShow = true
  816. return;
  817. }
  818. if (that.userData.is_validity == 0 && this.userData.coin < (this.plan.unlock_aipainting * this
  819. .form.samples)) {
  820. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  821. this.signTitle =
  822. "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  823. (this.plan.unlock_aipainting * this.form.samples) + "</span><span>" + alias +
  824. "</span></p><p style='padding-top: 10px;'>您的绘画<span>" + alias +
  825. "</span>不足或会员套餐内剩余次数不足,无法生成绘画</p>"
  826. this.signShow = true
  827. return;
  828. }
  829. }
  830. } else {
  831. if (that.showmj && this.userData.coin < this.plan.unlock_mj_aipainting) {
  832. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  833. this.signTitle =
  834. "<p style='font-weight: 550;font-size: 16px;'>mj绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  835. this.plan.unlock_mj_aipainting + "</span><span>" + alias +
  836. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  837. this.userData.coin + "</span><span>" + alias + "</span>,无法生成绘画,快去获取<span>" + alias +
  838. "</span>吧</p>"
  839. this.signShow = true
  840. return;
  841. }
  842. if (!that.showmj && this.userData.coin < (this.plan.unlock_aipainting * this.form.samples)) {
  843. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  844. this.signTitle =
  845. "<p style='font-weight: 550;font-size: 16px;'>sd绘画需要<span style='color: #207CF7;padding: 0 4px;'>" +
  846. this.plan.unlock_aipainting * this.form.samples + "</span><span>" + alias +
  847. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>" +
  848. this.userData.coin + "</span><span>" + alias + "</span>,无法生成绘画,快去获取<span>" + alias +
  849. "</span>吧</p>"
  850. this.signShow = true
  851. return;
  852. }
  853. }
  854. // if(that.showmj){
  855. // if(this.userData.coin < this.plan.unlock_mj_aipainting){
  856. // var alias = this.appInfo.number_alias ? this.appInfo.number_alias : '点数';
  857. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>"+this.plan.unlock_mj_aipainting+"</span><span>"+alias+"</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>"+this.userData.coin+"</span><span>"+alias+"</span>,不支持会员时长,无法生成绘画,快去获取<span>"+alias+"</span>吧</p>"
  858. // this.signShow = true
  859. // return;
  860. // }
  861. // }else{
  862. // if(this.userData.coin < (this.plan.unlock_aipainting*this.form.samples)){
  863. // var alias = this.appInfo.number_alias ? this.appInfo.number_alias : '点数';
  864. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>绘画需要<span style='color: #207CF7;padding: 0 4px;'>"+this.plan.unlock_aipainting*this.form.samples+"</span><span>"+alias+"</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #207CF7;padding: 0 4px;'>"+this.userData.coin+"</span><span>"+alias+"</span>,不支持会员时长,无法生成绘画,快去获取<span>"+alias+"</span>吧</p>"
  865. // this.signShow = true
  866. // return;
  867. // }
  868. // }
  869. if (!this.keywords) {
  870. uni.showToast({
  871. title: '请输入画面描述词',
  872. icon: 'none'
  873. });
  874. return;
  875. }
  876. // console.log(this.form);
  877. if (!this.form.model_id) {
  878. uni.showToast({
  879. title: '请选择绘图模型',
  880. icon: 'none'
  881. });
  882. return;
  883. }
  884. // else if (this.userInfo.coin < 100) {
  885. // var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  886. // uni.showModal({
  887. // confirmText: '立即获取',
  888. // confirmColor: '#207CF7',
  889. // content: '您的' + alias + '不足,当前绘画需要'+ that.plan.lock_aipainting+alias+',暂不支持会员时长。',
  890. // title: '提示',
  891. // success(res) {
  892. // if (res.confirm) {
  893. // uni.navigateTo({
  894. // url: '/pages/user/member/member'
  895. // });
  896. // }
  897. // }
  898. // });
  899. // return;
  900. // this.showcoin = true;
  901. // return;
  902. // }
  903. else {
  904. // this.gallerychat()
  905. uni.showLoading({
  906. title: '内容审核中...'
  907. })
  908. // #ifdef H5
  909. let check = this.appInfo.is_h5_filter && this.appInfo.is_h5_filter == 1 ? await this.getcheckText(
  910. this.keywords) :
  911. 1;
  912. // #endif
  913. // #ifdef MP-WEIXIN
  914. let check = await this.getcheckText(this.keywords);
  915. // #endif
  916. if (check == 1) {
  917. // console.log('this.keywords', this.refer_img + ' ' + this.keywords);
  918. this.aiPlay(this.refer_img + ' ' + this.keywords);
  919. }
  920. }
  921. // uni.navigateTo({
  922. // url:'/pages/painting/generate'
  923. // })
  924. },
  925. getcheckText(e) {
  926. var that = this;
  927. return new Promise((resolve, reject) => {
  928. that.$http('ai.checkText', {
  929. prompt: e
  930. }).then(res => {
  931. if (res.code == 0) {
  932. resolve(1);
  933. }
  934. })
  935. });
  936. },
  937. gallerychat() {
  938. uni.showLoading({
  939. title: '润色中...'
  940. })
  941. this.$http('gallery.chat', {
  942. prompt: this.keywords
  943. }).then(res => {
  944. if (res.code == 0) {
  945. this.aiPlay(res.data);
  946. }
  947. });
  948. },
  949. aiPlay(e) {
  950. let that = this;
  951. that.form.prompt = e;
  952. switch (this.ratioIndex) {
  953. case 0:
  954. that.form.width = '512';
  955. that.form.height = '512';
  956. that.proportion = '';
  957. break;
  958. case 1:
  959. that.form.width = '512';
  960. that.form.height = '768';
  961. that.proportion = ' --ar 3:4';
  962. break;
  963. case 2:
  964. that.form.width = '768';
  965. that.form.height = '512';
  966. that.proportion = ' --ar 4:3';
  967. break;
  968. case 3:
  969. that.form.width = '512';
  970. that.form.height = '1024';
  971. that.proportion = ' --ar 9:16';
  972. break;
  973. case 4:
  974. that.form.width = '1024';
  975. that.form.height = '512';
  976. that.proportion = ' --ar 16:9';
  977. break;
  978. }
  979. if (that.refer_img) {
  980. that.form.init_image = that.refer_img;
  981. that.form.type = 'img2img';
  982. } else {
  983. that.form.type = 'text2img';
  984. }
  985. that.form.keywords = that.keywords
  986. console.log(that.form);
  987. uni.navigateTo({
  988. url: that.showmj ? '/pages/painting/generate?prompt=' + (that.form.prompt + (that.proportion ?
  989. that.proportion : '')) +
  990. '&model_id=' + (that.modelslist.length > 0 ? this.form.model_id : '') + '&version=' + (that
  991. .modelslist.length > 0 ? that.modelslist[this.modelsid].version : '-- v5') +
  992. '&needCoin=' + that.plan.unlock_mj_aipainting +
  993. `&refImg=${that.refer_img?that.refer_img:''}&keywords=${that.keywords}` :
  994. '/pages/painting/details?form=' + JSON
  995. .stringify(this.form)
  996. });
  997. console.log('创作相似url传递的参数:', this.form);
  998. // this.$http('gallery.create', this.form).then(res => {
  999. // if (res.code == 0) {
  1000. // if(res.data.output.length > 0){
  1001. // uni.navigateTo({
  1002. // url: '/pages/painting/details?url=' + res.data.output
  1003. // });
  1004. // }else{
  1005. // uni.showToast({
  1006. // title:'生成失败',
  1007. // icon:'error'
  1008. // })
  1009. // }
  1010. // uni.hideLoading();
  1011. // }
  1012. // });
  1013. },
  1014. close_blur_view() {
  1015. this.showcoin = false;
  1016. },
  1017. toMember() {
  1018. uni.navigateTo({
  1019. url: '/pages/member/member'
  1020. });
  1021. },
  1022. toWelfare() {
  1023. uni.switchTab({
  1024. url: '/pages/welfare/welfare'
  1025. });
  1026. },
  1027. showVideoAd() {
  1028. if (rewardedVideoAd) {
  1029. uni.showToast({
  1030. title: '广告拉取中',
  1031. icon: 'none'
  1032. });
  1033. rewardedVideoAd.show().catch(() => {
  1034. // 失败重试
  1035. rewardedVideoAd
  1036. .load()
  1037. .then(() => rewardedVideoAd.show())
  1038. .catch(err => {
  1039. console.log('激励视频 广告显示失败');
  1040. uni.showToast({
  1041. title: '广告显示失败',
  1042. icon: 'none'
  1043. });
  1044. });
  1045. });
  1046. }
  1047. },
  1048. memberAddCoin() {
  1049. this.$http('member.addCoin', {
  1050. type: 'video'
  1051. }).then(res => {
  1052. if (res.code == 0) {
  1053. uni.showToast({
  1054. title: '获得积分+' + res.data
  1055. });
  1056. // let coin = {coin: this.userData.coin+1}
  1057. // that.$store.commit('userData',coin)
  1058. this.getUserInfo();
  1059. } else {
  1060. uni.showToast({
  1061. title: '获得积分失败',
  1062. icon: 'none'
  1063. });
  1064. }
  1065. });
  1066. },
  1067. uploadImg(engineid) {
  1068. let that = this;
  1069. uni.chooseImage({
  1070. count: 1, //count: 6, //默认9
  1071. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  1072. sourceType: ['album'], //从相册选择
  1073. success: function(res) {
  1074. console.log('上传参考图返回值:', res.tempFiles[0].name, res.tempFiles[0].name.toLowerCase());
  1075. if (!(res.tempFiles[0].name.toLowerCase().endsWith('.png') || res.tempFiles[0].name
  1076. .toLowerCase().endsWith(
  1077. '.jpeg') || res.tempFiles[0].name.toLowerCase().endsWith('.jpg'))) {
  1078. uni.showToast({
  1079. title: '上传失败,请上传png、jpg和jpeg格式的图片',
  1080. icon: 'none',
  1081. duration: 2000
  1082. })
  1083. return
  1084. }
  1085. const path = res.tempFilePaths[0];
  1086. uni.uploadFile({
  1087. url: apiurl('common/upload'),
  1088. filePath: path,
  1089. // name: 'img',
  1090. // formData: {
  1091. // platform: $platform.get(),
  1092. // accept: 'image'
  1093. // },
  1094. name: 'file',
  1095. formData: {
  1096. accept: 'image',
  1097. upload_type: 'ali-oss'
  1098. },
  1099. success: res2 => {
  1100. let a = JSON.parse(res2.data);
  1101. if (a.code == 0) {
  1102. // if (engineid == 0) {
  1103. // that.cos_img = a.data.path;
  1104. // that.cos_id = a.data.id;
  1105. // } else {
  1106. that.refer_img = a.data.path;
  1107. that.refer_id = a.data.id;
  1108. that.form.refer_img = a.data.path
  1109. // }
  1110. } else {
  1111. uni.showToast({
  1112. title: '上传图片失败',
  1113. icon: 'none'
  1114. });
  1115. }
  1116. }
  1117. });
  1118. }
  1119. });
  1120. },
  1121. preViewImg(img) {
  1122. uni.previewImage({
  1123. urls: [img],
  1124. longPressActions: {
  1125. itemList: ['发送给朋友', '保存图片', '收藏'],
  1126. success: function(data) {},
  1127. fail: function(err) {
  1128. console.log(err.errMsg);
  1129. }
  1130. }
  1131. });
  1132. },
  1133. deleteImg() {
  1134. // if (engineid == 0) {
  1135. // this.cos_img = '';
  1136. // this.cos_id = 0;
  1137. // } else {
  1138. this.refer_img = '';
  1139. this.form.refer_img = ''
  1140. this.form.init_image = ''
  1141. // this.refer_id = 0;
  1142. // }
  1143. },
  1144. open() {
  1145. // console.log('open');
  1146. },
  1147. }
  1148. };
  1149. </script>
  1150. <style lang="scss" scoped>
  1151. @import './draw.scss';
  1152. </style>