voice.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='音色'></cus-header>
  4. <template v-if="list.length">
  5. <div class="list">
  6. <div class="item adfacjb" :class="{'active':index===idx}" v-for="(item,index) in list" :key="index" @tap="selectVoice(item,index)">
  7. <div class="il">{{item.name}}</div>
  8. <div class="ir" v-if="index===idx">已选择</div>
  9. </div>
  10. </div>
  11. </template>
  12. <template v-else>
  13. <page-empty :height="'calc(100vh - 160rpx)'"></page-empty>
  14. </template>
  15. <div class="zt_btn" @tap="confirm">确认选择</div>
  16. </view>
  17. </template>
  18. <script>
  19. import pageEmpty from '@/components/pageEmpty/index.vue'
  20. export default {
  21. components:{pageEmpty},
  22. data(){
  23. return {
  24. idx:'',
  25. list:[],
  26. voice:null
  27. }
  28. },
  29. onLoad() {
  30. this.getModelVoiceList();
  31. },
  32. methods:{
  33. getModelVoiceList(){
  34. this.$api.get(`/models/${'TTS_EdgeTTS'}/voices`).then(res=>{
  35. if(res.data.code!==0) return this.$showToast(res.data.msg)
  36. this.list = res.data.data;
  37. })
  38. },
  39. selectVoice(item,index){
  40. this.voice = item;
  41. this.idx = index;
  42. },
  43. confirm() {
  44. if(!this.voice) return this.$showToast('请选择音色');
  45. this.getOpenerEventChannel().emit('selectVoice',this.voice)
  46. uni.navigateBack();
  47. }
  48. }
  49. }
  50. </script>
  51. <style scoped lang="less">
  52. .page{
  53. width: 100%;
  54. padding: 0 30rpx 140rpx;
  55. background: #FFFFFF;
  56. box-sizing: border-box;
  57. .list{
  58. margin-top: 35rpx;
  59. .item{
  60. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #E2E2E2;
  61. padding: 41rpx 30rpx 41rpx 0;
  62. width: 100%;
  63. box-sizing: border-box;
  64. &>div{
  65. font-family: PingFang-SC, PingFang-SC;
  66. font-weight: bold;
  67. font-size: 30rpx;
  68. color: #111111;
  69. line-height: 32rpx;
  70. }
  71. &.active{
  72. &>div{
  73. color: #72832B;
  74. }
  75. }
  76. }
  77. }
  78. .zt_btn{
  79. width: calc(100% - 60rpx);
  80. position: fixed;
  81. left: 30rpx;
  82. bottom: 30rpx;
  83. z-index: 999;
  84. }
  85. }
  86. </style>