index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <template>
  2. <view class="container">
  3. <tn-nav-bar :isBack="true" backgroundColor="#fff" :bottomShadow="false">数字人创建</tn-nav-bar>
  4. <view class="pos">
  5. </view>
  6. <view class="context">
  7. <view class="top" @click="show4=true">
  8. <view class="videoBox1" v-if="bgItem.scale==1&&selBgPic">
  9. <image class="img16" :src="selBgPic" mode=""></image>
  10. </view>
  11. <view class="videoBox2" v-if="bgItem.scale==2&&selBgPic" :style="{}">
  12. <image class="img16" :src="selBgPic" mode=""></image>
  13. </view>
  14. <view class="videoBox" v-if="!bgItem.scale&&!selBgPic" :style="{minHeight:!selBgPic?'465rpx':''}">
  15. <view class="emptyVideo" style="background: #ccc;height: 100%;"></view>
  16. </view>
  17. </view>
  18. <view class="selCon">
  19. <view class="item" @click="show=true">
  20. <view class="label">
  21. 语速:
  22. </view>
  23. <view class="con">
  24. {{roundRate}}X
  25. </view>
  26. </view>
  27. <view class="item" @click="show1=true">
  28. <view class="label">
  29. 声音:{{selVoiceItem.name}}
  30. </view>
  31. <image class="conImg" :src="selVoiceItem.url">
  32. </image>
  33. </view>
  34. <view class="item" @click="show3=true">
  35. <view class="label">
  36. 角色:{{selRoleItem.name}}
  37. </view>
  38. <image class="conImg" :src="selRoleItem.url">
  39. </image>
  40. </view>
  41. </view>
  42. <view class="centerMenuBar">
  43. <view class="barItem" v-for="(item,index) in menuList" @click="handleSetBox(item)">
  44. <view class="left" style="display: flex;justify-content: flex-end;align-items: center;">
  45. <!-- <text class="iconfont " :class="[item.icon]" style="color: #26b3a0;font-weight: 600;"></text> -->
  46. <image :src="item.icon" mode=""></image>
  47. </view>
  48. <view class="right">
  49. {{item.name}}
  50. </view>
  51. </view>
  52. </view>
  53. <view class="robotNameBox">
  54. <!-- <view class="name">
  55. 播报标题:
  56. </view> -->
  57. <uni-easyinput :inputBorder="true" :clearable="false" v-model="robotName"
  58. placeholder="请输入播报标题"></uni-easyinput>
  59. </view>
  60. <u--textarea height="" border="none" :autoHeight="true" maxlength="9999" v-model="textAreaValue"
  61. placeholder="请输入播报内容"></u--textarea>
  62. <view class="btnBox">
  63. <view class="btn draft" @click="saveDraft">
  64. 存草稿
  65. </view>
  66. <view class="btn" @click="genRobot" style="background: linear-gradient(to right,#06C68E,#02BCCD);">
  67. 合成
  68. </view>
  69. </view>
  70. </view>
  71. <u-picker :showIcon="true" :show="showMoreMenu" :columns="columns" title="更多" confirmColor=""
  72. @cancel="showMoreMenu=false" @confirm="handleConfirm"></u-picker>
  73. <u-popup :show="show" @close="close" @open="open">
  74. <view class="contentBox">
  75. <view class="toolBar">
  76. <view class="cancel" @click="show=false">
  77. <image src="/static/images/closeBtn.png" mode=""></image>
  78. </view>
  79. <view class="center">
  80. 全局语速
  81. </view>
  82. <view class="confirm" @click="handleBtnConfirm">
  83. <image src="/static/images/selected.png" mode=""></image>
  84. </view>
  85. </view>
  86. <view class="content" style="min-height: 300rpx;">
  87. <u-slider height="50" min="0.7" max="1.3" step="0.1" class="slider" :showValue='false'
  88. @change="handleChange" activeColor="#26b3a0" v-model="voiceRate"></u-slider>
  89. <view class="sliderValue">
  90. {{roundRate}}X
  91. </view>
  92. </view>
  93. </view>
  94. </u-popup>
  95. <!-- 声音 -->
  96. <u-popup :show="show1" @close="close1" @open="open">
  97. <view class="contentBox">
  98. <view class="toolBar">
  99. <view class="cancel" @click="show1=false">
  100. <image src="/static/images/closeBtn.png" mode=""></image>
  101. </view>
  102. <view class="center">
  103. 声音
  104. </view>
  105. <view class="confirm" @click="handleBtnConfirm1">
  106. <image src="/static/images/selected.png" mode=""></image>
  107. </view>
  108. </view>
  109. <view class="content">
  110. <!-- <view class="filterBox">
  111. <view class="tabList">
  112. <view class="item1" v-for="(item,index) in voiceList"
  113. :class="[currTabIndex==index?'tabActive':'']" @click="currTabIndex=index">
  114. {{item}}
  115. </view>
  116. </view>
  117. <view class="filterBtn" @click="handleFilter">
  118. <text class="iconfont icon-shaixuanguolv" style="font-size: 44rpx; color: #26b3a0;"></text>
  119. </view>
  120. </view> -->
  121. <view class="filterConList" style="max-height: 500rpx;min-height: 500rpx;overflow-y: scroll;">
  122. <view class="item" v-for="(item,index) in allList" @click="handleVoiceSel(item,index)">
  123. <view class="imgBox">
  124. <image :class="[currTabIndexAll==index?'sel':'']" :src="item.url" mode="">
  125. </view>
  126. </image>
  127. <view class="nameDes">
  128. {{item.title}}
  129. </view>
  130. <view class="name" :class="[currTabIndexAll==index?'selTxt':'']">
  131. {{item.name}}
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </u-popup>
  138. <!-- 模型 -->
  139. <u-popup :show="show3" @close="close3" @open="open">
  140. <view class="contentBox2">
  141. <view class="toolBar">
  142. <view class="cancel" @click="show3=false">
  143. <image src="/static/images/closeBtn.png" mode=""></image>
  144. </view>
  145. <view class="center">
  146. 角色
  147. </view>
  148. <view class="confirm" @click="handleBtnConfirm2">
  149. <image src="/static/images/selected.png" mode=""></image>
  150. </view>
  151. </view>
  152. <view class="content">
  153. <!-- <view class="filterBox">
  154. <view class="tabList">
  155. <view class="item1" style="padding-left: 40rpx;padding-right: 40rpx;"
  156. v-for="(item,index) in viewList" :class="[currTabIndex1==index?'tabActive':'']"
  157. @click="currTabIndex1=index">
  158. {{item}}
  159. </view>
  160. </view>
  161. </view> -->
  162. <view class="filterConList">
  163. <view class="item" v-for="(item,index) in roleList" @click="handleRoleSel(item,index)">
  164. <image :class="[currTabIndexModal==index?'sel':'']" :src="item.url" mode="">
  165. </image>
  166. <view class="name" :class="[currTabIndexModal==index?'selTxt':'']">
  167. {{item.name}}
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. </view>
  173. </u-popup>
  174. <!-- 背景 -->
  175. <u-popup :show="show4" @close="close4" @open="open">
  176. <view class="contentBox2">
  177. <view class="toolBar">
  178. <view class="cancel" @click="show4=false">
  179. <image src="/static/images/closeBtn.png" mode=""></image>
  180. </view>
  181. <view class="center">
  182. 背景
  183. </view>
  184. <view class="confirm" @click="handleBtnConfirm3">
  185. <image src="/static/images/selected.png" mode=""></image>
  186. </view>
  187. </view>
  188. <view class="content">
  189. <!-- <view class="filterBox">
  190. <view class="tabList">
  191. <view class="item1" style="padding-left: 40rpx;padding-right: 40rpx;"
  192. v-for="(item,index) in bgList" :class="[currTabIndex2==index?'tabActive':'']"
  193. @click="currTabIndex2=index">
  194. {{item}}
  195. </view>
  196. </view>
  197. </view> -->
  198. <view class="filterConList2" style="max-height: 500rpx;min-height: 500rpx;overflow-y: scroll;">
  199. <view class="pictureBox" v-if="currTabIndex2==0">
  200. <image :class="[currTabIndexBg==index?'sel':'']" :src="item.url" mode=""
  201. v-for="(item,index) in bgPicList" @click="handleSelBg(item,index)"></image>
  202. </view>
  203. <view class="pictureBox" v-if="currTabIndex2==1">
  204. <view class="color" :style="{background:item}" :class="[currTabIndexBgc==index?'sel':'']"
  205. v-for="(item,index) in bgColorList" @click="currTabIndexBgc=index"></view>
  206. </view>
  207. </view>
  208. </view>
  209. </view>
  210. </u-popup>
  211. <!-- 声音筛选弹框 -->
  212. <u-popup :show="show2" @close="close" @open="open">
  213. <view class="contentBox">
  214. <view class="toolBar2">
  215. <view class="closeBtn" @click="show2=false">
  216. <!-- <image src="/static/images/selected.png" mode=""></image> -->
  217. X
  218. </view>
  219. </view>
  220. <view class="content">
  221. <!-- 场景 -->
  222. <view class="scenList">
  223. <view class="item " v-for="(item, index) in scenList"
  224. :class="[currScenIndex==index?'active':'']" @click="currScenIndex=index">
  225. {{item}}
  226. </view>
  227. </view>
  228. <!-- 性别-->
  229. <view class="sexList">
  230. <view class="item " v-for="(item, index) in sexList" :class="[currSexIndex==index?'active':'']"
  231. @click="currSexIndex=index">
  232. {{item}}
  233. </view>
  234. </view>
  235. <!-- 年龄-->
  236. <view class="ageList">
  237. <view class="item " v-for="(item, index) in ageList" :class="[currAgeIndex==index?'active':'']"
  238. @click="currAgeIndex=index">
  239. {{item}}
  240. </view>
  241. </view>
  242. <view class="filterBtn2" @click="filter">
  243. 确认
  244. </view>
  245. </view>
  246. </view>
  247. </u-popup>
  248. <!-- 备用-视频尺寸 -->
  249. <u-popup :show="show5" @close="close" @open="open">
  250. <view class="contentBox">
  251. <!-- <view class="toolBar2">
  252. <view class="closeBtn" @click="show5=false">
  253. X
  254. </view>
  255. </view> -->
  256. <view class="toolBar toolBar2">
  257. <view class="cancel">
  258. </view>
  259. <view class="center">
  260. 视频尺寸
  261. </view>
  262. <view class="confirm" @click="handleBtnConfirm2">
  263. <!-- <image src="/static/images/selected.png" mode=""></image> -->
  264. <view class="closeBtn" @click="show5=false">
  265. X
  266. </view>
  267. </view>
  268. </view>
  269. <view class="content">
  270. <view class="videoRatioBox">
  271. <view class="item">
  272. <view class="top">
  273. 竖版视频
  274. </view>
  275. <view class="bottom">
  276. 9:16
  277. </view>
  278. </view>
  279. <view class="item">
  280. <view class="top">
  281. 横版视频
  282. </view>
  283. <view class="bottom">
  284. 16:9
  285. </view>
  286. </view>
  287. </view>
  288. <view class="filterBtn2" @click="show5=false">
  289. 确认
  290. </view>
  291. </view>
  292. </view>
  293. </u-popup>
  294. <!-- <wike-tabbar :onTabbar="true" :isShowAnimate="true"></wike-tabbar> -->
  295. </view>
  296. </view>
  297. </template>
  298. <script>
  299. import {
  300. generateWork,
  301. roleList,
  302. voiceList,
  303. backList
  304. } from '@/api/robot/index.js'
  305. import indexVue from './index.vue';
  306. export default {
  307. data() {
  308. return {
  309. bgItem: {
  310. },
  311. show5: false,
  312. show4: false,
  313. bgList: ['图片', '颜色'],
  314. currTabIndex2: 0,
  315. currTabIndexBg: -1,
  316. currTabIndexBgc: -1,
  317. bgPicList: [],
  318. bgColorList: ['red', 'green', 'blue', 'orange', 'green', 'blue', 'orange'],
  319. show3: false,
  320. viewList: ['2D', '3D'],
  321. currTabIndex1: 0,
  322. currTabIndexModal: -1,
  323. modalList: [{
  324. img: '',
  325. name: '模型名称'
  326. },
  327. {
  328. img: '',
  329. name: '模型名称'
  330. },
  331. {
  332. img: '',
  333. name: '模型名称'
  334. },
  335. {
  336. img: '',
  337. name: '模型名称'
  338. },
  339. {
  340. img: '',
  341. name: '模型名称'
  342. },
  343. {
  344. img: '',
  345. name: '模型名称'
  346. },
  347. {
  348. img: '',
  349. name: '模型名称'
  350. },
  351. ],
  352. show2: false,
  353. currTabIndexAll: -1,
  354. scenList: ['全部场景', '热门', '新闻咨询', '影视咨询', '热门', '新闻咨询', '影视咨询'],
  355. currScenIndex: 0,
  356. sexList: ['全部性别', '男声', '女声'],
  357. currSexIndex: 0,
  358. ageList: ['全部年龄', '儿童', '少年', '青年', '中年', '老年'],
  359. currAgeIndex: 0,
  360. allList: [],
  361. // voiceList: ['全部', '热门', '新闻咨询', '影视综艺', '其他'],
  362. show1: false,
  363. currTabIndex: 0,
  364. robotName: '',
  365. textAreaValue: '',
  366. voiceRate: 1,
  367. selRoleId: -1,
  368. selVoiceId: -1,
  369. selBgId: -1,
  370. selBgPic: '',
  371. roleList: [],
  372. value: 1,
  373. show: false,
  374. menuList: [{
  375. icon: require('@/static/images/yusu.png'),
  376. name: '全局语速'
  377. },
  378. {
  379. icon: require('@/static/images/audio.png'),
  380. name: '声音'
  381. },
  382. {
  383. icon: require('@/static/images/role.png'),
  384. name: '角色'
  385. },
  386. {
  387. icon: require('@/static/images/bg.png'),
  388. name: '背景'
  389. },
  390. ],
  391. videoSrc: '',
  392. showMoreMenu: false,
  393. columns: [
  394. []
  395. ],
  396. selVoiceItem: {
  397. name: '',
  398. url: ''
  399. },
  400. selRoleItem: {
  401. name: '',
  402. url: ''
  403. },
  404. detail: {},
  405. roundRate: 1,
  406. isGenerate: false,
  407. isCreate: false
  408. };
  409. },
  410. computed: {
  411. },
  412. onReady() {
  413. },
  414. onUnload() {
  415. },
  416. onLoad(o) {
  417. if (o.type == 'create') {
  418. this.isCreate = true
  419. this.selRoleId = 5
  420. this.selBgId = 0
  421. this.selVoiceId = 9
  422. this.roundRate = 1
  423. this.voiceRate = 1
  424. return
  425. console.log('create')
  426. }
  427. this.detail = getApp().draftDetail
  428. this.robotName = getApp().draftDetail.name
  429. this.textAreaValue = getApp().draftDetail.content
  430. this.selRoleId = getApp().draftDetail.role - 1
  431. this.selBgId = getApp().draftDetail.back - 1
  432. this.selVoiceId = getApp().draftDetail.audio - 1
  433. this.voiceRate = getApp().draftDetail.stage
  434. this.selBgPic = getApp().draftDetail.backs.url
  435. this.bgItem = getApp().draftDetail.backs
  436. this.roundRate = getApp().draftDetail.stage
  437. this.selVoiceItem = getApp().draftDetail.audios
  438. this.selRoleItem = getApp().draftDetail.roles
  439. console.log('传过来的草稿项:', this.detail, this.selBgPic);
  440. },
  441. async onShow() {
  442. let res = await roleList({})
  443. if (res.code == 0) {
  444. this.roleList = res.msg
  445. console.log('数字人角色列表返回值:', res);
  446. this.currTabIndexModal = res.msg.findIndex((item, index) => {
  447. return item.id == this.selRoleId + 1
  448. })
  449. if (this.isCreate) {
  450. this.selRoleItem = this.roleList[5]
  451. }
  452. } else {
  453. uni.showToast({
  454. title: res.msg,
  455. icon: 'none'
  456. })
  457. }
  458. let res1 = await voiceList({})
  459. if (res1.code == 0) {
  460. // this.roleList = res.data
  461. this.allList = res1.msg
  462. console.log('数字人声音列表返回值:', res1);
  463. this.currTabIndexAll = res1.msg.findIndex((item, index) => {
  464. return item.id == this.selVoiceId + 1
  465. })
  466. if (this.isCreate) {
  467. this.selVoiceItem = this.allList[9]
  468. }
  469. } else {
  470. uni.showToast({
  471. title: res1.msg,
  472. icon: 'none'
  473. })
  474. }
  475. let res3 = await backList({})
  476. if (res3.code == 0) {
  477. // this.roleList = res.data
  478. this.bgPicList = res3.msg
  479. console.log('数字人背景列表返回值:', res3);
  480. this.currTabIndexBg = res3.msg.findIndex((item, index) => {
  481. return item.id == this.selBgId + 1
  482. })
  483. if (this.isCreate) {
  484. this.selBgPic = this.bgPicList[0].url
  485. this.bgItem = this.bgPicList[0]
  486. }
  487. console.log('index3', this.currTabIndexBgc);
  488. } else {
  489. uni.showToast({
  490. title: res3.msg,
  491. icon: 'none'
  492. })
  493. }
  494. },
  495. onShareAppMessage: function(res) {
  496. },
  497. methods: {
  498. close() {
  499. this.show = false
  500. },
  501. close1() {
  502. this.show1 = false
  503. },
  504. close3() {
  505. this.show3 = false
  506. },
  507. close4() {
  508. this.show4 = false
  509. },
  510. handleSelBg(item, index) {
  511. this.bgItem = item
  512. this.selBgPic = item.url
  513. this.selBgId = item.id - 1
  514. this.currTabIndexBg = index
  515. },
  516. handleVoiceSel(item, index) {
  517. this.selVoiceItem = item
  518. this.selVoiceId = item.id - 1
  519. this.currTabIndexAll = index
  520. },
  521. handleRoleSel(item, index) {
  522. this.selRoleItem = item
  523. this.selRoleId = item.id - 1
  524. this.currTabIndexModal = index
  525. },
  526. async saveDraft() {
  527. let parmas = {
  528. name: this.robotName,
  529. content: this.textAreaValue,
  530. // role: this.selRoleId,
  531. // back: this.selBgId,
  532. // audio: this.selVoiceId,
  533. stage: this.roundRate,
  534. is_draft: 1
  535. }
  536. if (this.selRoleId != -1) {
  537. parmas['role'] = this.selRoleId
  538. }
  539. if (this.selBgId != -1) {
  540. parmas['back'] = this.selBgId
  541. }
  542. if (this.selVoiceId != -1) {
  543. parmas['audio'] = this.selVoiceId
  544. }
  545. console.log('保存数字人草稿参数:', parmas);
  546. let res = await generateWork(parmas)
  547. if (res.code == 0) {
  548. uni.showToast({
  549. title: '保存成功!',
  550. icon: 'success'
  551. })
  552. setTimeout(() => {
  553. uni.navigateBack()
  554. }, 1500)
  555. } else {
  556. uni.showToast({
  557. title: res.msg,
  558. icon: 'none'
  559. })
  560. }
  561. console.log('保存数字人草稿返回值:', res);
  562. },
  563. async genRobot() {
  564. if (this.isGenerate) {
  565. uni.showToast({
  566. title: '请等待上一次生成完成后提交!',
  567. icon: 'none'
  568. })
  569. return
  570. }
  571. let parmas = {
  572. name: this.robotName,
  573. content: this.textAreaValue,
  574. role: this.selRoleId,
  575. back: this.selBgId,
  576. audio: this.selVoiceId,
  577. stage: this.roundRate
  578. }
  579. console.log('创建数字人参数:', parmas);
  580. // return
  581. let res = await generateWork(parmas)
  582. if (res.code == 0) {
  583. this.isGenerate = true
  584. uni.showToast({
  585. title: '创建数字人成功!',
  586. icon: 'success'
  587. })
  588. getApp().from = 'create'
  589. setTimeout(() => {
  590. uni.navigateBack()
  591. }, 1500)
  592. } else {
  593. uni.showToast({
  594. title: res.msg,
  595. icon: 'none'
  596. })
  597. }
  598. console.log('生成数字人返回值:', res);
  599. },
  600. filter() {
  601. this.show2 = false
  602. },
  603. handleFilter() {
  604. // this.show1 = false
  605. this.show2 = true
  606. },
  607. handleBtnConfirm1() {
  608. this.show1 = false
  609. },
  610. handleBtnConfirm2() {
  611. this.show3 = false
  612. },
  613. handleBtnConfirm3() {
  614. this.show4 = false
  615. },
  616. handleSetBox(item) {
  617. if (item.name == '全局语速') {
  618. this.show = true
  619. } else if (item.name == '声音') {
  620. this.show1 = true
  621. } else if (item.name == '角色') {
  622. this.show3 = true
  623. } else if (item.name == '背景') {
  624. this.show4 = true
  625. }
  626. },
  627. handleChange(e) {
  628. console.log(e);
  629. this.roundRate = e.toFixed(1)
  630. },
  631. handleBtnConfirm() {
  632. this.show = false
  633. },
  634. handleCreatePro() {
  635. uni.navigateTo({
  636. url: ''
  637. })
  638. },
  639. handleShowMoreMenu() {
  640. this.showMoreMenu = true
  641. },
  642. handleConfirm(e) {
  643. this.showMoreMenu = false
  644. },
  645. open() {
  646. // console.log('open() ');
  647. }
  648. }
  649. };
  650. </script>
  651. <style lang="scss" scoped>
  652. @import './index.scss';
  653. </style>