voiceList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="content">
  3. <u-sticky offsetTop="0" customNavHeight="0">
  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. <view>
  10. <mescroll-body bottom="0" ref="mescrollRef" @init="mescrollInit" :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('./voice?id='+item.id)">{{item.voiceTxt}}</view>
  14. <view class="list-cont x-f es-center">
  15. <text class="duration">{{secondsToHoursAndMinutes(item.duration || 0)}}</text>
  16. <view class="btn" v-show="current==0" @click="navTo('./voice?id='+item.id)">录制</view>
  17. <view class="btn" v-show="current==1" @click="navTo('./voice?id='+item.id)">详情</view>
  18. </view>
  19. </view>
  20. </view>
  21. </mescroll-body>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  27. import {querySopVoiceList} from '@/api/companyUser'
  28. export default {
  29. mixins: [MescrollMixin], // 使用mixin
  30. data() {
  31. return {
  32. current: 0,
  33. tabs: [{
  34. id: 0,
  35. name: '未完成'
  36. },
  37. {
  38. id: 1,
  39. name: '已完成'
  40. }
  41. ],
  42. mescroll: null,
  43. downOption: { //下拉刷新
  44. use: true,
  45. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  46. },
  47. upOption: {
  48. onScroll: false,
  49. use: true, // 是否启用上拉加载; 默认true
  50. page: {
  51. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  52. size: 10 // 每页数据的数量,默认10
  53. },
  54. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  55. textNoMore: "已经到底了",
  56. empty: {
  57. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  58. tip: '暂无数据'
  59. }
  60. },
  61. dataList: []
  62. }
  63. },
  64. onLoad() {
  65. uni.$on('refreshVoiceList', () => {
  66. this.mescroll.resetUpScroll()
  67. })
  68. },
  69. onUnload() {
  70. uni.$off('refreshVoiceList')
  71. },
  72. methods: {
  73. secondsToHoursAndMinutes(totalSeconds) {
  74. let hours = Math.floor(totalSeconds / 3600);
  75. let minutes = Math.floor((totalSeconds % 3600) / 60);
  76. let seconds = totalSeconds % 60;
  77. hours = hours.toString().padStart(2, '0');
  78. minutes = minutes.toString().padStart(2, '0');
  79. seconds = seconds.toString().padStart(2, '0');
  80. return hours+':'+minutes+':'+seconds;
  81. },
  82. tabChange(item) {
  83. if(this.current == item.index) return
  84. this.current = item.index
  85. this.mescroll.resetUpScroll()
  86. },
  87. navTo(url) {
  88. uni.navigateTo({
  89. url: url
  90. })
  91. },
  92. mescrollInit(mescroll) {
  93. this.mescroll = mescroll;
  94. },
  95. /*下拉刷新的回调 */
  96. downCallback() {
  97. this.mescroll.resetUpScroll()
  98. },
  99. /*上拉加载的回调*/
  100. upCallback(page) {
  101. //联网加载数据
  102. var that = this;
  103. var data = {
  104. recordType: this.current,
  105. pageNum: page.num,
  106. pageSize: page.size
  107. };
  108. querySopVoiceList(data).then(res => {
  109. if (res.code == 200) {
  110. if (page.num == 1) {
  111. that.dataList = res.rows;
  112. } else {
  113. that.dataList = that.dataList.concat(res.rows);
  114. }
  115. that.mescroll.endBySize(res.rows.length, res.total);
  116. } else {
  117. uni.showToast({
  118. icon: 'none',
  119. title: "请求失败",
  120. });
  121. that.dataList = null;
  122. that.mescroll.endErr();
  123. }
  124. });
  125. },
  126. }
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. @mixin u-flex($flexD, $alignI, $justifyC) {
  131. display: flex;
  132. flex-direction: $flexD;
  133. align-items: $alignI;
  134. justify-content: $justifyC;
  135. }
  136. .content {
  137. .tabs {
  138. background-color: #fff;
  139. }
  140. .list {
  141. width: 100%;
  142. padding: 15rpx;
  143. @include u-flex(column,flex-start,flex-start);
  144. .list-item {
  145. margin-bottom: 15rpx;
  146. width: 100%;
  147. padding: 15rpx;
  148. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  149. background-color: #fff;
  150. border-radius: 15rpx;
  151. @include u-flex(column,flex-start,flex-start);
  152. }
  153. .list-cont {
  154. margin-top: 24rpx;
  155. width: 100%;
  156. }
  157. }
  158. .duration {
  159. box-sizing: border-box;
  160. font-family: PingFang SC, PingFang SC;
  161. font-weight: 400;
  162. font-size: 24rpx;
  163. color: #757575;
  164. }
  165. .btn {
  166. padding: 10rpx 30rpx;
  167. border: 1rpx solid #FF5C03;
  168. color: #FF5C03;
  169. font-size: 28rpx;
  170. border-radius: 30rpx;
  171. }
  172. }
  173. </style>