小说小程序前端代码仓库(小程序)
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.

242 lines
5.3 KiB

  1. <template>
  2. <view class="work-item" @click="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. '0': '连载中',
  60. '1': '已完结'
  61. };
  62. return textMap[this.work.status] || '连载中';
  63. },
  64. toolStatusClass() {
  65. const toolStatusMap = {
  66. '0': 'ongoing',
  67. '1': 'completed',
  68. '2': 'error',
  69. };
  70. return toolStatusMap[this.work.toolStatus] || '';
  71. },
  72. toolStatusText() {
  73. const textMap = {
  74. '0': '设置审核中',
  75. '1': '设置审核通过',
  76. '2': '设置审核不通过'
  77. };
  78. return textMap[this.work.toolStatus] || '连载中';
  79. },
  80. bookStatusClass() {
  81. const bookStatusMap = {
  82. '0': 'ongoing',
  83. '1': 'completed',
  84. '2': 'error',
  85. };
  86. return bookStatusMap[this.work.bookStatus] || '';
  87. },
  88. bookStatusText() {
  89. const textMap = {
  90. '0': '发布审核中',
  91. '1': '发布审核通过',
  92. '2': '发布审核不通过'
  93. };
  94. return textMap[this.work.bookStatus] || '连载中';
  95. },
  96. },
  97. methods: {
  98. handleClick() {
  99. if (this.isManaging) {
  100. this.$emit('click');
  101. return;
  102. }
  103. // 跳转到章节列表页面
  104. uni.navigateTo({
  105. url: '/pages_order/author/chapterList?id=' + this.work.id
  106. });
  107. },
  108. handleDelete() {
  109. this.$emit('delete');
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .work-item {
  116. width: 100%;
  117. display: flex;
  118. padding: 24rpx 0;
  119. border-bottom: 1rpx solid #f0f0f0;
  120. position: relative;
  121. align-items: center;
  122. .cover-wrapper {
  123. position: relative;
  124. width: 170rpx;
  125. height: 230rpx;
  126. margin-right: 20rpx;
  127. border-radius: 6rpx;
  128. overflow: hidden;
  129. flex-shrink: 0;
  130. .cover {
  131. width: 100%;
  132. height: 100%;
  133. }
  134. .tag {
  135. position: absolute;
  136. top: 0;
  137. left: 0;
  138. font-size: 20rpx;
  139. color: #fff;
  140. padding: 2rpx 8rpx;
  141. &.original {
  142. background-color: #ffa502;
  143. }
  144. }
  145. }
  146. .info {
  147. flex: 1;
  148. display: flex;
  149. flex-direction: column;
  150. .title {
  151. font-size: 28rpx;
  152. color: #333;
  153. font-weight: bold;
  154. margin-bottom: 10rpx;
  155. line-height: 1.3;
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. display: -webkit-box;
  159. -webkit-line-clamp: 1;
  160. -webkit-box-orient: vertical;
  161. }
  162. .readers {
  163. margin-top: 20rpx;
  164. .readers-count {
  165. font-size: 24rpx;
  166. color: #999;
  167. }
  168. }
  169. .status-wrapper {
  170. flex-shrink: 0;
  171. display: flex;
  172. align-items: center;
  173. margin-top: 20rpx;
  174. gap: 10rpx;
  175. .status-tag {
  176. font-size: 22rpx;
  177. padding: 4rpx 16rpx;
  178. border-radius: 20rpx;
  179. text-align: center;
  180. width: fit-content;
  181. &.new {
  182. background-color: #e8f3ff;
  183. color: #5cadff;
  184. }
  185. &.ongoing {
  186. background-color: #fff7e6;
  187. color: #ff9900;
  188. }
  189. &.completed {
  190. background-color: #f0f9eb;
  191. color: #67c23a;
  192. }
  193. }
  194. .publish-status {
  195. &.error{
  196. color: #666;
  197. background-color: #f5f5f5;
  198. }
  199. &.completed {
  200. background-color: #67c23a;
  201. color: #fff;
  202. }
  203. font-size: 22rpx;
  204. color: #666;
  205. background-color: #f5f5f5;
  206. padding: 4rpx 16rpx;
  207. border-radius: 20rpx;
  208. white-space: nowrap;
  209. }
  210. }
  211. }
  212. .icon-arrow {
  213. color: #999;
  214. font-size: 16px;
  215. margin-left: 10rpx;
  216. }
  217. }
  218. </style>