voiceList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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/companyUser'
  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. companyUserId:null
  75. }
  76. },
  77. onLoad(option) {
  78. this.companyUserId=option.companyUserId
  79. uni.$on('refreshVoiceList', () => {
  80. this.mescroll.resetUpScroll()
  81. })
  82. },
  83. onUnload() {
  84. uni.$off('refreshVoiceList')
  85. },
  86. methods: {
  87. getHeight() {
  88. this.$nextTick(() => {
  89. const query = uni.createSelectorQuery().in(this);
  90. query
  91. .select("#footer-btn")
  92. .boundingClientRect((data) => {
  93. if (data) {
  94. this.height = uni.getSystemInfoSync().windowHeight - data.height - 44
  95. this.bottom = data.height
  96. }
  97. })
  98. .exec();
  99. })
  100. },
  101. secondsToHoursAndMinutes(totalSeconds) {
  102. let hours = Math.floor(totalSeconds / 3600);
  103. let minutes = Math.floor((totalSeconds % 3600) / 60);
  104. let seconds = totalSeconds % 60;
  105. hours = hours.toString().padStart(2, '0');
  106. minutes = minutes.toString().padStart(2, '0');
  107. seconds = seconds.toString().padStart(2, '0');
  108. return hours + ':' + minutes + ':' + seconds;
  109. },
  110. tabChange(item) {
  111. if (this.current == item.index) return
  112. this.current = item.index
  113. this.mescroll.resetUpScroll()
  114. },
  115. navTo(url) {
  116. uni.navigateTo({
  117. url: url
  118. })
  119. },
  120. mescrollInit(mescroll) {
  121. this.mescroll = mescroll;
  122. },
  123. /*下拉刷新的回调 */
  124. downCallback() {
  125. this.mescroll.resetUpScroll()
  126. },
  127. /*上拉加载的回调*/
  128. upCallback(page) {
  129. //联网加载数据
  130. var that = this;
  131. var data = {
  132. recordType: this.tabs[this.current].id,
  133. pageNum: page.num,
  134. pageSize: page.size,
  135. companyUserId:this.companyUserId,
  136. };
  137. querySopVoiceList(data).then(res => {
  138. if (res.code == 200) {
  139. if (page.num == 1) {
  140. that.dataList = res.rows;
  141. that.getHeight()
  142. } else {
  143. that.dataList = that.dataList.concat(res.rows);
  144. }
  145. that.mescroll.endBySize(res.rows.length, res.total);
  146. } else {
  147. uni.showToast({
  148. icon: 'none',
  149. title: "请求失败",
  150. });
  151. that.dataList = null;
  152. that.mescroll.endErr();
  153. }
  154. });
  155. },
  156. handleAllVoice() {
  157. createUserAllVoice().then(res => {
  158. uni.showToast({
  159. icon: 'none',
  160. title: res.msg,
  161. duration: 2000
  162. });
  163. })
  164. }
  165. }
  166. }
  167. </script>
  168. <style scoped lang="scss">
  169. @mixin u-flex($flexD, $alignI, $justifyC) {
  170. display: flex;
  171. flex-direction: $flexD;
  172. align-items: $alignI;
  173. justify-content: $justifyC;
  174. }
  175. .content {
  176. .tabs {
  177. background-color: #fff;
  178. }
  179. .list {
  180. width:100%;
  181. padding: 15rpx;
  182. @include u-flex(column, flex-start, flex-start);
  183. .list-item {
  184. margin-bottom: 15rpx;
  185. width:100%;
  186. padding: 15rpx;
  187. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  188. background-color: #fff;
  189. border-radius: 15rpx;
  190. @include u-flex(column, flex-start, flex-start);
  191. }
  192. .list-cont {
  193. margin-top: 24rpx;
  194. width: 100%;
  195. }
  196. }
  197. .duration {
  198. box-sizing: border-box;
  199. font-family: PingFang SC, PingFang SC;
  200. font-weight: 400;
  201. font-size: 24rpx;
  202. color: #757575;
  203. }
  204. .btns {
  205. padding: 10rpx 30rpx;
  206. border: 1rpx solid #FF5C03;
  207. color: #FF5C03;
  208. font-size: 28rpx;
  209. border-radius: 30rpx;
  210. }
  211. }
  212. .footer {
  213. width: 100%;
  214. height: 152rpx;
  215. padding: 20rpx 24rpx;
  216. box-sizing: border-box;
  217. position: fixed;
  218. bottom: var(--window-bottom);
  219. left: 0;
  220. &-btn {
  221. height: 112rpx;
  222. background: #FF5C03;
  223. border-radius: 112rpx;
  224. font-weight: 600;
  225. font-size: 34rpx;
  226. color: #FFFFFF;
  227. line-height: 112rpx;
  228. text-align: center;
  229. &::after {
  230. border: none;
  231. }
  232. }
  233. }
  234. </style>