history.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="history">
  3. <view
  4. v-for="(item,index) in history"
  5. :key="index"
  6. class="item main-left"
  7. >
  8. <view class="cover-image">
  9. <image :src="item.detail.episode.cover_img" />
  10. </view>
  11. <view class="right-box">
  12. <view class="op-group main-right cross-center">
  13. <view class="delete" @click="handleModal(item.id)">删除</view>
  14. <view class="play" @click="handlePlay(item.detail)">播放</view>
  15. </view>
  16. <view class="name">{{ item.detail.episode.name }}</view>
  17. <view class="status-box">
  18. <text class="status">{{ item.detail.episode.status_text }}</text>
  19. <text>共{{ item.detail.episode.total }}集</text>
  20. </view>
  21. <view class="record">
  22. 上次看至 <text>第{{ item.detail.sort }}集</text>
  23. </view>
  24. </view>
  25. </view>
  26. <u-modal
  27. title="确定删除"
  28. :show="modal.show"
  29. :show-cancel-button="true"
  30. @confirm="handleDelete"
  31. @cancel="modal.show = false"
  32. />
  33. </view>
  34. </template>
  35. <script>
  36. import UModal from '../../uni_modules/uview-ui/components/u-modal/u-modal'
  37. export default {
  38. components: { UModal },
  39. data() {
  40. return {
  41. limit: 10,
  42. page: 1,
  43. isMore: true,
  44. history: [],
  45. modal: {
  46. show: false,
  47. id: null
  48. }
  49. }
  50. },
  51. computed: {},
  52. methods: {
  53. handlePlay(detail) {
  54. this.$u.route({
  55. url: '/pages/episode/play',
  56. params: {
  57. id: detail.episode.id,
  58. list_id: detail.id
  59. }
  60. })
  61. },
  62. handleModal(id) {
  63. this.modal.id = id
  64. this.modal.show = true
  65. },
  66. handleDelete() {
  67. this.$loading('删除中...')
  68. this.$api.user.episode.deleteRecord(this.modal.id).then(res => {
  69. this.$hideLoading()
  70. this.page = 1
  71. this.isMore = true
  72. this.history = []
  73. this.getHistory()
  74. this.modal.show = false
  75. }).catch(err => {
  76. this.$hideLoading()
  77. })
  78. },
  79. getHistory() {
  80. this.$loading()
  81. this.$api.user.episode.record({ limit: this.limit, page: this.page }).then(res => {
  82. this.$hideLoading()
  83. if (res.data.length) {
  84. this.history = this.history.concat(res.data)
  85. } else {
  86. this.isMore = false
  87. }
  88. }).catch(err => {
  89. this.$hideLoading()
  90. console.error('-->error', err)
  91. })
  92. }
  93. },
  94. onLoad() {
  95. this.getHistory()
  96. },
  97. onReachBottom(e) {
  98. if (!this.isMore) return
  99. this.page += 1
  100. this.getHistory()
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .history{
  106. padding: 20rpx;
  107. color: $default-color ;
  108. font-size: 30rpx;
  109. .item{
  110. padding: 30rpx;
  111. border: 1rpx solid $primary-color;
  112. border-radius: 30rpx;
  113. margin-top: 30rpx;
  114. .cover-image{
  115. image{
  116. width: 200rpx;
  117. height: 280rpx;
  118. border-radius: 16rpx;
  119. }
  120. }
  121. .right-box{
  122. flex: 1;
  123. margin-left: 20rpx;
  124. .op-group{
  125. .delete{
  126. border: 1rpx solid #FB3651;
  127. color: #FB3651;
  128. border-radius: 30rpx;
  129. width: 140rpx;
  130. padding: 10rpx;
  131. text-align: center;
  132. margin-right: 30rpx;
  133. }
  134. .play{
  135. background: linear-gradient(90deg, #FF74B9,#6EEBE8);
  136. color: $default-color;
  137. border-radius: 30rpx;
  138. width: 140rpx;
  139. padding: 10rpx;
  140. text-align: center;
  141. }
  142. }
  143. .name{
  144. font-size: 38rpx;
  145. font-weight: 600;
  146. margin-bottom: 10rpx;
  147. margin-top: 50rpx;
  148. }
  149. .status-box{
  150. font-size: 28rpx;
  151. margin-bottom: 10rpx;
  152. color: $info-color;
  153. .status{
  154. color: $primary-color;
  155. margin-right: 14rpx;
  156. }
  157. }
  158. .record{
  159. text{
  160. color: #FB3651;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. </style>