voiceList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="content">
  3. <u-sticky>
  4. <view class="tabs">
  5. <u-tabs :scrollable="false" :list="tabs" :current="current" lineColor="#FF5C03" @change="tabChange">
  6. </u-tabs>
  7. </view>
  8. </u-sticky>
  9. <mescroll-body :bottom="bottom+'px'" ref="mescrollRef" :height="height+'px'" @init="mescrollInit"
  10. :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  11. <view class="list">
  12. <view class="list-item" v-for="item in dataList" :key="item.id">
  13. <view class="list-top ellipsis2" @click="navTo('./voiceItem?id='+item.id)">{{item.voiceTxt}}</view>
  14. <view class="list-cont x-bc">
  15. <text class="duration">{{secondsToHoursAndMinutes(item.duration || 0)}}</text>
  16. <view class="btns" v-show="current==0" @click="navTo('./voiceItem?type=2&id='+item.id)">录制</view>
  17. <view class="btns" v-show="current==1" @click="navTo('./voiceItem?id='+item.id)">录制</view>
  18. <view class="btns" v-show="current==2" @click="navTo('./voiceItem?id='+item.id)">详情</view>
  19. </view>
  20. </view>
  21. </view>
  22. </mescroll-body>
  23. <view class="footer" id="footer-btn" v-show="current==1&&dataList&&dataList.length>0">
  24. <button class="footer-btn" @click="handleAllVoice">一键生成所有录制</button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  30. import {
  31. querySopVoiceList,
  32. createUserAllVoice
  33. } from '@/api/manageCompany'
  34. export default {
  35. mixins: [MescrollMixin], // 使用mixin
  36. data() {
  37. return {
  38. current: 0,
  39. tabs: [
  40. {
  41. id: 2,
  42. name: '声音录制'
  43. }, {
  44. id: 0,
  45. name: '未完成'
  46. },
  47. {
  48. id: 1,
  49. name: '已完成'
  50. }
  51. ],
  52. mescroll: null,
  53. downOption: { //下拉刷新
  54. use: true,
  55. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  56. },
  57. upOption: {
  58. onScroll: false,
  59. use: true, // 是否启用上拉加载; 默认true
  60. page: {
  61. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  62. size: 10 // 每页数据的数量,默认10
  63. },
  64. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  65. textNoMore: "已经到底了",
  66. empty: {
  67. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  68. tip: '暂无数据'
  69. }
  70. },
  71. dataList: [],
  72. height: 0,
  73. bottom: 0
  74. }
  75. },
  76. onLoad() {
  77. uni.$on('refreshVoiceList', () => {
  78. this.mescroll.resetUpScroll()
  79. })
  80. },
  81. onUnload() {
  82. uni.$off('refreshVoiceList')
  83. },
  84. methods: {
  85. getHeight() {
  86. this.$nextTick(() => {
  87. const query = uni.createSelectorQuery().in(this);
  88. query
  89. .select("#footer-btn")
  90. .boundingClientRect((data) => {
  91. if (data) {
  92. this.height = uni.getSystemInfoSync().windowHeight - data.height - 44
  93. this.bottom = data.height
  94. }
  95. })
  96. .exec();
  97. })
  98. },
  99. secondsToHoursAndMinutes(totalSeconds) {
  100. let hours = Math.floor(totalSeconds / 3600);
  101. let minutes = Math.floor((totalSeconds % 3600) / 60);
  102. let seconds = totalSeconds % 60;
  103. hours = hours.toString().padStart(2, '0');
  104. minutes = minutes.toString().padStart(2, '0');
  105. seconds = seconds.toString().padStart(2, '0');
  106. return hours + ':' + minutes + ':' + seconds;
  107. },
  108. tabChange(item) {
  109. if (this.current == item.index) return
  110. this.current = item.index
  111. this.mescroll.resetUpScroll()
  112. },
  113. navTo(url) {
  114. uni.navigateTo({
  115. url: url
  116. })
  117. },
  118. mescrollInit(mescroll) {
  119. this.mescroll = mescroll;
  120. },
  121. /*下拉刷新的回调 */
  122. downCallback() {
  123. this.mescroll.resetUpScroll()
  124. },
  125. /*上拉加载的回调*/
  126. upCallback(page) {
  127. //联网加载数据
  128. var that = this;
  129. var data = {
  130. recordType: this.tabs[this.current].id,
  131. pageNum: page.num,
  132. pageSize: page.size
  133. };
  134. querySopVoiceList(data).then(res => {
  135. if (res.code == 200) {
  136. if (page.num == 1) {
  137. that.dataList = res.rows;
  138. that.getHeight()
  139. } else {
  140. that.dataList = that.dataList.concat(res.rows);
  141. }
  142. that.mescroll.endBySize(res.rows.length, res.total);
  143. } else {
  144. uni.showToast({
  145. icon: 'none',
  146. title: "请求失败",
  147. });
  148. that.dataList = null;
  149. that.mescroll.endErr();
  150. }
  151. });
  152. },
  153. handleAllVoice() {
  154. createUserAllVoice().then(res => {
  155. uni.showToast({
  156. icon: 'none',
  157. title: res.msg,
  158. duration: 2000
  159. });
  160. })
  161. }
  162. }
  163. }
  164. </script>
  165. <style scoped lang="scss">
  166. @mixin u-flex($flexD, $alignI, $justifyC) {
  167. display: flex;
  168. flex-direction: $flexD;
  169. align-items: $alignI;
  170. justify-content: $justifyC;
  171. }
  172. .content {
  173. .tabs {
  174. background-color: #fff;
  175. }
  176. .list {
  177. width:100%;
  178. padding: 15rpx;
  179. @include u-flex(column, flex-start, flex-start);
  180. .list-item {
  181. margin-bottom: 15rpx;
  182. width:100%;
  183. padding: 15rpx;
  184. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  185. background-color: #fff;
  186. border-radius: 15rpx;
  187. @include u-flex(column, flex-start, flex-start);
  188. }
  189. .list-cont {
  190. margin-top: 24rpx;
  191. width: 100%;
  192. }
  193. }
  194. .duration {
  195. box-sizing: border-box;
  196. font-family: PingFang SC, PingFang SC;
  197. font-weight: 400;
  198. font-size: 24rpx;
  199. color: #757575;
  200. }
  201. .btns {
  202. padding: 10rpx 30rpx;
  203. border: 1rpx solid #FF5C03;
  204. color: #FF5C03;
  205. font-size: 28rpx;
  206. border-radius: 30rpx;
  207. }
  208. }
  209. .footer {
  210. width: 100%;
  211. height: 152rpx;
  212. padding: 20rpx 24rpx;
  213. box-sizing: border-box;
  214. position: fixed;
  215. bottom: var(--window-bottom);
  216. left: 0;
  217. &-btn {
  218. height: 112rpx;
  219. background: #FF5C03;
  220. border-radius: 112rpx;
  221. font-weight: 600;
  222. font-size: 34rpx;
  223. color: #FFFFFF;
  224. line-height: 112rpx;
  225. text-align: center;
  226. &::after {
  227. border: none;
  228. }
  229. }
  230. }
  231. </style>