微信

index.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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" :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. }
  63. },
  64. computed: {
  65. ...mapState({
  66. user: item => item.userCenter.userInfo.customer
  67. }),
  68. bookStatus () {
  69. let status = '在线预约'
  70. switch (this.status) {
  71. case '4':
  72. status = '已预约'
  73. break
  74. case '1':
  75. status = '借阅中'
  76. break
  77. case '0':
  78. status = '借阅中'
  79. break
  80. }
  81. return status
  82. },
  83. myBookStatus () {
  84. let status = ''
  85. switch (this.data.BorrowStatus) {
  86. case '4':
  87. status = '已预约'
  88. break
  89. case '1':
  90. status = '借阅中'
  91. break
  92. case '0':
  93. status = '逾期未还'
  94. break
  95. case '3':
  96. status = '逾期归还'
  97. break
  98. case '2':
  99. status = '已归还'
  100. break
  101. }
  102. return status
  103. },
  104. lateDay () {
  105. const nowdata = new Date()
  106. return toolClass.diffDate(new Date(this.data.EndDate), nowdata)
  107. },
  108. borrowDay () {
  109. const nowdata = new Date()
  110. return toolClass.diffDate(new Date(this.data.BorrowDate), nowdata)
  111. }
  112. },
  113. components: {
  114. },
  115. created () {
  116. },
  117. methods: {
  118. appointmentBook (id) {
  119. if (this.status == '4' || this.status == '1' || this.status == '0') {
  120. return
  121. }
  122. if (!this.user.Phone) {
  123. this.$router.push({ name: 'bindMobile' })
  124. return
  125. }
  126. this.$emit('appointmentBook', id)
  127. },
  128. itemClick (target) {
  129. this.$emit('itemClick', target)
  130. }
  131. }
  132. }
  133. </script>
  134. <!-- Add "scoped" attribute to limit CSS to this component only -->
  135. <style lang="scss" scoped>
  136. .libraryListItem {
  137. width: 100%;
  138. position: relative;
  139. overflow: visible;
  140. align-items: center;
  141. .img {
  142. width: 0.78rem;
  143. position: relative;
  144. overflow: visible;
  145. a {
  146. width: 100%;
  147. display: block;
  148. height: 0;
  149. position: relative;
  150. overflow: hidden;
  151. padding-bottom: 143.5%;
  152. background: #eee;
  153. border-radius: 0.03rem;
  154. z-index: 1;
  155. }
  156. > span {
  157. display: inline-block;
  158. position: absolute;
  159. left: -0.1rem;
  160. bottom: 0.2rem;
  161. z-index: 2;
  162. font-size: 0.12rem;
  163. color: #fff;
  164. background: #333;
  165. line-height: 0.25rem;
  166. border-radius: 0.25rem;
  167. padding: 0 0.15rem;
  168. &.active {
  169. background: #fc5534;
  170. }
  171. }
  172. }
  173. > div.flex-item {
  174. margin-left: 0.1rem;
  175. > div {
  176. width: 100%;
  177. position: relative;
  178. overflow: hidden;
  179. > span {
  180. width: 100%;
  181. display: block;
  182. line-height: 0.22rem;
  183. font-size: 0.16rem;
  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.43rem;
  190. }
  191. > h5 {
  192. font-size: 0.11rem;
  193. color: #ccc;
  194. line-height: 0.16rem;
  195. font-weight: normal;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. display: -webkit-box;
  199. -webkit-box-orient: vertical;
  200. -webkit-line-clamp: 2;
  201. max-height: 0.31rem;
  202. }
  203. > div {
  204. margin-top: 0.03rem;
  205. align-items: center;
  206. span {
  207. line-height: 0.25rem;
  208. font-size: 0.12rem;
  209. color: #999;
  210. white-space: nowrap;
  211. em {
  212. color: #fc5534;
  213. font-size: 0.13rem;
  214. }
  215. &.status {
  216. padding: 0 0.15rem;
  217. font-size: 0.12rem;
  218. color: #999;
  219. background: #fff;
  220. border: 1px solid #ccc;
  221. border-radius: 0.25rem;
  222. box-sizing: border-box;
  223. }
  224. &.status.active {
  225. color: #fc674a;
  226. background: #fcf3f3;
  227. border: none;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. </style>