微信

index.vue 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="libraryListItem flex-h" @click="itemClick(data)">
  3. <div class="img">
  4. <a>
  5. <img :src="data.BookImg" class="centerLabel cover" alt>
  6. </a>
  7. <span v-if="type === 1" :class="data.BorrowStatus=='0'?'active':''">{{myBookStatus}}</span>
  8. </div>
  9. <div class="flex-item">
  10. <div>
  11. <span>{{data.BookName}}</span>
  12. <h5 v-if="!type">{{data.BookDescription}}</h5>
  13. <div v-if="!type" class="flex-h" style="margin-top: .06rem;">
  14. <span class="flex-item">{{data.Author}} 著</span>
  15. <span class="status active" @click="appointmentBook(data.BookId)">{{bookStatus}}</span>
  16. </div>
  17. <div v-if="!type" class="flex-h">
  18. <span class="flex-item">{{data.Publisher}}</span>
  19. <span>
  20. 剩余可借
  21. <em>{{data.LeftNum}}</em>本
  22. </span>
  23. </div>
  24. <div v-if="type === 1" class="flex-h" style="margin-top: .06rem;">
  25. <span class="flex-item">应还时间:{{toolClass.dateFormat(data.EndDate, 'yyyy-MM-dd')}}</span>
  26. </div>
  27. <div v-if="type === 1" class="flex-h">
  28. <span class="flex-item">{{data.CaseName}}</span>
  29. <span v-if="data.BorrowStatus=='3' || data.BorrowStatus=='2'">已归还</span>
  30. <span v-if="data.BorrowStatus == '1'">已借阅
  31. <em>{{borrowDay}}</em>天
  32. </span>
  33. <span v-if="data.BorrowStatus == '0'">已逾期
  34. <em>{{lateDay}}</em>天
  35. </span>
  36. </div>
  37. <div v-if="type === 2" class="flex-h" style="margin-top: .06rem;">
  38. <span class="flex-item">预约时间:{{toolClass.dateFormat(data.ReserveDate)}}</span>
  39. </div>
  40. <div v-if="type === 2" class="flex-h" style="margin-top: 0;">
  41. <span class="flex-item">预约资格将保留至:{{toolClass.dateFormat(data.ReserveEndDate, 'yyyy-MM-dd')}}</span>
  42. </div>
  43. <div v-if="type === 2" class="flex-h" style="margin-top: 0;">
  44. <span class="flex-item">{{data.CaseName}}</span>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import toolClass from '../../util/util'
  52. export default {
  53. name: '',
  54. props: ['data', 'type', 'status'],
  55. data () {
  56. return {
  57. }
  58. },
  59. computed: {
  60. bookStatus() {
  61. let status = '在线预约'
  62. switch(this.status) {
  63. case '4':
  64. status = '已预约'
  65. break
  66. case '1':
  67. status = '借阅中'
  68. break
  69. case '0':
  70. status = '借阅中'
  71. break
  72. }
  73. return status
  74. },
  75. myBookStatus() {
  76. let status = ''
  77. switch(this.data.BorrowStatus) {
  78. case '4':
  79. status = '已预约'
  80. break
  81. case '1':
  82. status = '借阅中'
  83. break
  84. case '0':
  85. status = '预期未还'
  86. break
  87. case '3':
  88. status = '逾期归还'
  89. break
  90. case '2':
  91. status = '已归还'
  92. break
  93. }
  94. return status
  95. },
  96. lateDay() {
  97. const nowdata = new Date()
  98. return toolClass.diffDate(new Date(this.data.EndDate), nowdata)
  99. },
  100. borrowDay() {
  101. const nowdata = new Date()
  102. return toolClass.diffDate(new Date(this.data.BorrowDate), nowdata)
  103. }
  104. },
  105. components: {
  106. },
  107. created () {
  108. },
  109. methods: {
  110. appointmentBook (id) {
  111. if(this.status == '4' || this.status == '1' || this.status == '0'){
  112. return
  113. }
  114. this.$emit('appointmentBook', id)
  115. },
  116. itemClick (target) {
  117. this.$emit('itemClick', target)
  118. }
  119. }
  120. }
  121. </script>
  122. <!-- Add "scoped" attribute to limit CSS to this component only -->
  123. <style lang="scss" scoped>
  124. .libraryListItem {
  125. width: 100%;
  126. position: relative;
  127. overflow: visible;
  128. align-items: center;
  129. .img {
  130. width: 0.78rem;
  131. position: relative;
  132. overflow: visible;
  133. a {
  134. width: 100%;
  135. display: block;
  136. height: 0;
  137. position: relative;
  138. overflow: hidden;
  139. padding-bottom: 143.5%;
  140. background: #eee;
  141. border-radius: 0.03rem;
  142. z-index: 1;
  143. }
  144. > span {
  145. display: inline-block;
  146. position: absolute;
  147. left: -0.1rem;
  148. bottom: 0.2rem;
  149. z-index: 2;
  150. font-size: 0.12rem;
  151. color: #fff;
  152. background: #333;
  153. line-height: 0.25rem;
  154. border-radius: 0.25rem;
  155. padding: 0 0.15rem;
  156. &.active{
  157. background: #fc5534;
  158. }
  159. }
  160. }
  161. > div.flex-item {
  162. margin-left: 0.1rem;
  163. > div {
  164. width: 100%;
  165. position: relative;
  166. overflow: hidden;
  167. > span {
  168. width: 100%;
  169. display: block;
  170. line-height: 0.22rem;
  171. font-size: 0.16rem;
  172. overflow: hidden;
  173. text-overflow: ellipsis;
  174. display: -webkit-box;
  175. -webkit-box-orient: vertical;
  176. -webkit-line-clamp: 2;
  177. max-height: 0.43rem;
  178. }
  179. > h5 {
  180. font-size: 0.11rem;
  181. color: #ccc;
  182. line-height: 0.16rem;
  183. font-weight: normal;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. display: -webkit-box;
  187. -webkit-box-orient: vertical;
  188. -webkit-line-clamp: 2;
  189. max-height: 0.31rem;
  190. }
  191. > div {
  192. margin-top: 0.03rem;
  193. align-items: center;
  194. span {
  195. line-height: 0.25rem;
  196. font-size: 0.12rem;
  197. color: #999;
  198. white-space: nowrap;
  199. em {
  200. color: #fc5534;
  201. font-size: 0.13rem;
  202. }
  203. &.status {
  204. padding: 0 0.15rem;
  205. font-size: 0.12rem;
  206. color: #999;
  207. background: #fff;
  208. border: 1px solid #ccc;
  209. border-radius: 0.25rem;
  210. box-sizing: border-box;
  211. }
  212. &.status.active {
  213. color: #fc674a;
  214. background: #fcf3f3;
  215. border: none;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. </style>