index.vue 17 KB

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