makeImgDetail.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="makedetail-container">
  3. <view class="status-bar"></view>
  4. <!-- 顶部导航 -->
  5. <view class="nav-bar">
  6. <view class="left">
  7. <view class="uni-btn-icon" @click="goBack">&#xe601;</view>
  8. <view class="create">灵感创作</view>
  9. <image src="@/static/makedetail/cz_icon_lingganchuangzuo.png" class="edit"></image>
  10. </view>
  11. <view class="right">
  12. <view class="coinM">
  13. <image src="/static/icon/coin_m.png" mode="aspectFit"></image>
  14. <text>{{ myinfo.num_gmm }}</text>
  15. </view>
  16. <view class="coinC">
  17. <image src="/static/icon/coin_cd.png" mode="aspectFit"></image>
  18. <text>{{ myinfo.num_gmd }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 排队预览区域 -->
  23. <view class="preview-section lineUp-section" v-if="queuing">
  24. <view class="section-title">
  25. <text>创作预览</text>
  26. <view class="member-box">
  27. <image src="@/static/makedetail/wd_icon_vip(1).png" mode="aspectFit"></image>
  28. 升级会员插队加速
  29. </view>
  30. </view>
  31. <view class="preview-card">
  32. <image src="@/static/makedetail/cz_icon_jiazai.png" mode="aspectFit"></image>
  33. <view class="text1">排队中1/262</view>
  34. <view class="text2">退出不影响继续生成</view>
  35. </view>
  36. </view>
  37. <!-- 创作预览区域 -->
  38. <view class="preview-section" v-if="inQueue">
  39. <view class="section-title">创作预览</view>
  40. <view class="preview-card">
  41. <image src="@/static/makedetail/cz_icon_shengcheng.png" mode="aspectFit"></image>
  42. <view class="text1">生成中0%</view>
  43. <view class="text2">退出不影响继续生成</view>
  44. </view>
  45. </view>
  46. <!-- 以下区域在非排队状态下显示 -->
  47. <view>
  48. <!-- 创作描述输入区 -->
  49. <view class="description-section">
  50. <view class="section-header">
  51. <text class="section-title">创作描述<text style="display: none;" class="required">*</text></text>
  52. <view class="clear-text" @click="clearDescription">
  53. <image src="/static/clear.png" mode="aspectFit"></image>
  54. <view class="clear-box">
  55. <image src="@/static/makedetail/cz_icon_qingkongwenben.png" class="edit"></image>
  56. <text>清空文本</text>
  57. </view>
  58. </view>
  59. </view>
  60. <textarea auto-height class="input-area" v-model="description" placeholder="请输入描述语,例如:穿着白色运动服,外表俊朗..."
  61. maxlength="1000" @input="onDescriptionInput" disabled="doYouWantToEdit"></textarea>
  62. <view class="word-count">{{ descriptionLength }}/1000</view>
  63. </view>
  64. <!-- 行为动作选择区 -->
  65. <view class="action-section">
  66. <view class="section-title">行为动作</view>
  67. <input class="input-box" v-model="action" placeholder="可输入也可点击推荐词" />
  68. <view class="tag-group">
  69. <text class="tag" v-for="(item, index) in actionTags" :key="index" @click="selectAction(item)"
  70. :class="{ active: action == item }">{{ item }}</text>
  71. </view>
  72. </view>
  73. <!-- 主体环境选择区 -->
  74. <view class="environment-section">
  75. <view class="section-title">主体环境</view>
  76. <input class="input-box" v-model="environment" placeholder="可输入也可点击推荐词" />
  77. <view class="tag-group">
  78. <text class="tag" v-for="(item, index) in environmentTags" :key="index"
  79. @click="selectEnvironment(item)" :class="{ active: environment == item }">{{ item }}</text>
  80. </view>
  81. </view>
  82. <!-- 主体形象选择区 -->
  83. <view class="image-section">
  84. <view class="section-title">主体形象</view>
  85. <input class="input-box" v-model="image" placeholder="可输入也可点击推荐词" />
  86. <view class="tag-group">
  87. <text class="tag" v-for="(item, index) in imageTags" :key="index" @click="selectImage(item)"
  88. :class="{ active: image == item }">{{ item
  89. }}</text>
  90. </view>
  91. </view>
  92. <!-- 参考风格选择区 -->
  93. <view class="style-section">
  94. <view class="section-title">选择参考风格<text style="display: none;" class="required">*</text></view>
  95. <scroll-view class="style-scroll" scroll-x>
  96. <view class="style-item" v-for="(item, index) in styleList" :key="index"
  97. :class="{ 'active': selectedStyle === index }" @click="selectStyle(index)">
  98. <image :src="item.image" mode="aspectFill"></image>
  99. <text>{{ item.name }}</text>
  100. </view>
  101. </scroll-view>
  102. </view>
  103. <!-- 底部按钮 -->
  104. <view class="bottom-button">
  105. <button v-if="!doYouWantToEdit" class="generate-btn" @click="generateImage">立即生成
  106. <image src="/static/icon/coin_cd.png" mode="aspectFit"></image>
  107. 10
  108. </button>
  109. <view v-else class="generate-btn prohibit" >生成中
  110. </view>
  111. <view class="promotion-link">
  112. <image class="vip" src="/static/makedetail/wd_icon_vip(1).png" mode="aspectFit"></image>
  113. <text> 即刻开通订阅,获取各种福利! </text>
  114. <image class="jiantou" src="/static/makedetail/cz_icon_jiantou.png" mode="aspectFit"></image>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. export default {
  122. data() {
  123. return {
  124. description: '',
  125. descriptionLength: 0,
  126. action: '',
  127. environment: '',
  128. image: '',
  129. selectedStyle: -1,
  130. actionTags: ['跳舞', '开枪', '喝咖啡', '看书', '运动'],
  131. environmentTags: ['都市大道', '大树底下', '办公室', '厨房'],
  132. imageTags: ['戴着墨镜', '戴着耳机', '戴着帽子', '手持冲浪板'],
  133. styleList: [{
  134. name: '自然共生',
  135. image: '../../static/dome/fenge.png'
  136. },
  137. {
  138. name: '国风新锋',
  139. image: '../../static/dome/fenge.png'
  140. },
  141. {
  142. name: '萌系治愈',
  143. image: '../../static/dome/fenge.png'
  144. }
  145. ],
  146. inQueue: false,//是否创作中
  147. queuing: false,//是否排队中
  148. queueMessage: '',
  149. myinfo: {}
  150. }
  151. },
  152. onLoad(e) {
  153. // this.checkQueueStatus()
  154. this.getMyInfo();
  155. },
  156. methods: {
  157. doYouWantToEdit() {
  158. return this.inQueue || this.queuing
  159. },
  160. goBack() {
  161. uni.navigateBack()
  162. },
  163. getMyInfo() {
  164. uni.request({
  165. url: this.$apiHost + '/My/getnum',
  166. method: 'GET',
  167. header: {
  168. 'content-type': 'application/json',
  169. 'sign': getApp().globalData.headerSign
  170. },
  171. data: {
  172. uuid: getApp().globalData.uuid
  173. },
  174. success: (res) => {
  175. console.log("获取用户信息:", res.data);
  176. this.myinfo = res.data
  177. }
  178. })
  179. },
  180. checkQueueStatus() {
  181. uni.request({
  182. url: this.$apiHost + '/WorkAI/queueStatus',
  183. method: 'GET',
  184. header: {
  185. 'Content-Type': 'application/x-www-form-urlencoded',
  186. 'sign': getApp().globalData.headerSign
  187. },
  188. data: {
  189. uuid: getApp().globalData.uuid,
  190. task_type: 1
  191. },
  192. success: (res) => {
  193. console.log("队列状态:", res.data);
  194. if (res.data.success === "yes") {
  195. this.inQueue = res.data.in_queue
  196. if (this.inQueue) {
  197. this.queueMessage = res.data.str
  198. }
  199. }
  200. },
  201. fail: (err) => {
  202. console.log('获取队列状态失败:', err);
  203. uni.showToast({
  204. title: '获取状态失败',
  205. icon: 'none'
  206. });
  207. }
  208. })
  209. },
  210. clearDescription() {
  211. this.description = ''
  212. this.descriptionLength = 0
  213. },
  214. onDescriptionInput(e) {
  215. this.descriptionLength = e.detail.value.length
  216. },
  217. selectAction(tag) {
  218. this.action = tag
  219. },
  220. selectEnvironment(tag) {
  221. this.environment = tag
  222. },
  223. selectImage(tag) {
  224. this.image = tag
  225. },
  226. selectStyle(index) {
  227. this.selectedStyle = index
  228. },
  229. generateImage() {
  230. if (!this.description) {
  231. uni.showToast({
  232. title: '请输入创作描述',
  233. icon: 'none'
  234. })
  235. return
  236. }
  237. // if (this.selectedStyle === -1) {
  238. // uni.showToast({
  239. // title: '请选择参考风格',
  240. // icon: 'none'
  241. // })
  242. // return
  243. // }
  244. let style = '';
  245. if (this.selectedStyle !== -1) {
  246. style = this.styleList[this.selectedStyle].name
  247. }
  248. let that = this
  249. uni.request({
  250. url: this.$apiHost + '/WorkAI/creatorLG',
  251. data: {
  252. uuid: getApp().globalData.uuid,
  253. description: this.description,
  254. action: this.action,
  255. environment: this.environment,
  256. subject: this.image,
  257. style: style
  258. },
  259. method: 'POST',
  260. header: {
  261. 'Content-Type': 'application/x-www-form-urlencoded',
  262. 'sign': getApp().globalData.headerSign
  263. },
  264. dataType: 'json',
  265. success: (res) => {
  266. console.log("生成结果:", res.data);
  267. uni.showToast({
  268. title: res.data.str || '请求成功',
  269. icon: 'none'
  270. });
  271. if (res.data.success == "yes") {
  272. // TODO: 处理生成成功后的逻辑
  273. setTimeout(function () {
  274. // that.checkQueueStatus()
  275. uni.navigateBack()
  276. }, 500);
  277. }
  278. },
  279. fail: (err) => {
  280. console.log('生成失败:', err);
  281. uni.showToast({
  282. title: '生成请求失败',
  283. icon: 'none'
  284. });
  285. }
  286. })
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="scss">
  292. @import './makeImgDetail.scss';
  293. </style>