微信

index.vue 6.9KB

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