index.vue 18 KB

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