小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
5.4 KiB

  1. <template>
  2. <view class="work-item" @click.stop="handleClick">
  3. <view class="cover-wrapper">
  4. <image class="cover" :src="work.image && work.image.split(',')[0]" mode="aspectFill"></image>
  5. <view class="tag original" v-if="work.isOriginal">原创</view>
  6. </view>
  7. <view class="info">
  8. <text class="title">{{work.name}}</text>
  9. <view class="readers">
  10. <text class="readers-count">达成成就人{{work.readers || 0}}</text>
  11. </view>
  12. <!-- 状态标签 -->
  13. <view class="status-wrapper">
  14. <view class="status-tag" :class="statusClass">
  15. {{statusText}}
  16. </view>
  17. <!-- 发布状态标签 -->
  18. <view class="publish-status"
  19. :class="bookStatusClass"
  20. >
  21. <text>{{bookStatusText}}</text>
  22. </view>
  23. <!-- 设置状态标签 -->
  24. <view class="publish-status"
  25. :class="toolStatusClass"
  26. >
  27. <text>{{toolStatusText}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 添加右箭头图标 -->
  32. <!-- <text class="iconfont icon-arrow">&#xe65f;</text> -->
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. props: {
  38. work: {
  39. type: Object,
  40. default: {},
  41. },
  42. isManaging: {
  43. type: Boolean,
  44. default: false
  45. },
  46. },
  47. computed: {
  48. statusClass() {
  49. const statusMap = {
  50. 'draft': 'new',
  51. '0': 'ongoing',
  52. '1': 'completed'
  53. };
  54. return statusMap[this.work.status] || 'ongoing';
  55. },
  56. statusText() {
  57. const textMap = {
  58. '0': '连载中',
  59. '1': '已完结'
  60. };
  61. return textMap[this.work.status] || '连载中';
  62. },
  63. toolStatusClass() {
  64. const toolStatusMap = {
  65. '0': 'ongoing',
  66. '1': 'completed',
  67. '2': 'error',
  68. };
  69. return toolStatusMap[this.work.toolStatus] || '';
  70. },
  71. toolStatusText() {
  72. const textMap = {
  73. '0': '设置审核中',
  74. '1': '设置审核通过',
  75. '2': '设置审核不通过'
  76. };
  77. return textMap[this.work.toolStatus] || '连载中';
  78. },
  79. bookStatusClass() {
  80. const bookStatusMap = {
  81. '0': 'ongoing',
  82. '1': 'completed',
  83. '2': 'error',
  84. };
  85. return bookStatusMap[this.work.bookStatus] || '';
  86. },
  87. bookStatusText() {
  88. const textMap = {
  89. '0': '发布审核中',
  90. '1': '发布审核通过',
  91. '2': '发布审核不通过'
  92. };
  93. return textMap[this.work.bookStatus] || '连载中';
  94. },
  95. },
  96. methods: {
  97. handleClick() {
  98. console.log('handleClick called, isManaging:', this.isManaging);
  99. // 在编辑模式下,只触发选中事件
  100. if (this.isManaging) {
  101. this.$emit('click');
  102. return;
  103. }
  104. // 非编辑模式下,跳转到章节列表页面
  105. uni.navigateTo({
  106. url: '/pages_order/author/chapterList?id=' + this.work.id
  107. });
  108. },
  109. handleDelete() {
  110. this.$emit('delete');
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .work-item {
  117. width: 100%;
  118. display: flex;
  119. padding: 24rpx 0;
  120. border-bottom: 1rpx solid #f0f0f0;
  121. position: relative;
  122. align-items: center;
  123. .cover-wrapper {
  124. position: relative;
  125. width: 170rpx;
  126. height: 230rpx;
  127. margin-right: 20rpx;
  128. border-radius: 6rpx;
  129. overflow: hidden;
  130. flex-shrink: 0;
  131. .cover {
  132. width: 100%;
  133. height: 100%;
  134. }
  135. .tag {
  136. position: absolute;
  137. top: 0;
  138. left: 0;
  139. font-size: 20rpx;
  140. color: #fff;
  141. padding: 2rpx 8rpx;
  142. &.original {
  143. background-color: #ffa502;
  144. }
  145. }
  146. }
  147. .info {
  148. flex: 1;
  149. display: flex;
  150. flex-direction: column;
  151. .title {
  152. font-size: 28rpx;
  153. color: #333;
  154. font-weight: bold;
  155. margin-bottom: 10rpx;
  156. line-height: 1.3;
  157. overflow: hidden;
  158. text-overflow: ellipsis;
  159. display: -webkit-box;
  160. -webkit-line-clamp: 1;
  161. -webkit-box-orient: vertical;
  162. }
  163. .readers {
  164. margin-top: 20rpx;
  165. .readers-count {
  166. font-size: 24rpx;
  167. color: #999;
  168. }
  169. }
  170. .status-wrapper {
  171. flex-shrink: 0;
  172. display: flex;
  173. align-items: center;
  174. margin-top: 20rpx;
  175. gap: 10rpx;
  176. .status-tag {
  177. font-size: 22rpx;
  178. padding: 4rpx 16rpx;
  179. border-radius: 20rpx;
  180. text-align: center;
  181. width: fit-content;
  182. &.new {
  183. background-color: #e8f3ff;
  184. color: #5cadff;
  185. }
  186. &.ongoing {
  187. background-color: #fff7e6;
  188. color: #ff9900;
  189. }
  190. &.completed {
  191. background-color: #f0f9eb;
  192. color: #67c23a;
  193. }
  194. }
  195. .publish-status {
  196. &.error{
  197. color: #666;
  198. background-color: #f5f5f5;
  199. }
  200. &.completed {
  201. background-color: #67c23a;
  202. color: #fff;
  203. }
  204. font-size: 22rpx;
  205. color: #666;
  206. background-color: #f5f5f5;
  207. padding: 4rpx 16rpx;
  208. border-radius: 20rpx;
  209. white-space: nowrap;
  210. }
  211. }
  212. }
  213. .icon-arrow {
  214. color: #999;
  215. font-size: 16px;
  216. margin-left: 10rpx;
  217. }
  218. }
  219. </style>