演示项目-图书馆
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.

212 lines
6.3 KiB

  1. <template>
  2. <div class="main">
  3. <div class="top-header">
  4. <span class="back" @click="toBack"></span>
  5. <p>我的借阅</p>
  6. </div>
  7. <div class="order-main">
  8. <van-tabs v-model:active="active" swipeable @click-tab="onClickTab">
  9. <van-tab v-for="item in tabTitle" :title="item.name">
  10. <van-list
  11. v-model:loading="loading"
  12. :finished="finished"
  13. finished-text="没有更多了"
  14. @load="onLoad"
  15. >
  16. <div v-for="(item,i) in borrowingList" :key="i">
  17. <div class="order-item">
  18. <div class="list-top">
  19. <div class="top-info">
  20. <p class="active-name">
  21. {{ item.seleceName }}<i></i>
  22. </p>
  23. </div>
  24. <div :class="['order-status', !item.realityTime && 'jy']">{{ !item.realityTime ? '借阅中' : '已归还' }}</div>
  25. </div>
  26. <div class="product-cont lending-cont">
  27. <div class="product-img">
  28. <img :src="$coverUrl+'/demoOnlineSelect/getBookCover.do?id='+item.bookId" alt="" />
  29. </div>
  30. <div class="product-txt">
  31. <div class="product-info">
  32. <h4 class="overflow-txt-only">{{ item.bookName }}</h4>
  33. <div class="author-date">
  34. <p class="author overflow-txt-only">{{ item.author }}</p>
  35. <p class="date overflow-txt-only">{{ item.createdDate }}</p>
  36. </div>
  37. <div class="intro overflow-txt">{{ item.introduce }}</div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="mylending-info">
  42. <p class="lending-date">借阅开始时间{{ item.startTime }}</p>
  43. <p class="lending-date">最后归还时间{{ item.returnTime }}</p>
  44. <p v-if="item.realityTime" class="actual-date">实际归还时间{{ item.realityTime }}</p>
  45. <div :class="['myLending-status', item.returnBook === 1 && 'lq-status', item.returnBook === 2 && 'zs-status', item.returnBook === 3 && 'yq-status']"></div>
  46. </div>
  47. </div>
  48. </div>
  49. </van-list>
  50. </van-tab>
  51. </van-tabs>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. // import { Toast } from 'vant'
  57. import { reactive, computed, onMounted, getCurrentInstance, toRefs } from 'vue'
  58. export default {
  59. name: 'Order',
  60. setup() {
  61. const { proxy } = getCurrentInstance()
  62. let data = reactive({
  63. tabCur: 1,
  64. active: 0,
  65. borrowingList:[],
  66. tabTitle: [
  67. {
  68. value: '0',
  69. name: '全部',
  70. },
  71. {
  72. value: '1',
  73. name: '借阅中',
  74. },
  75. {
  76. value: '2',
  77. name: '已归还',
  78. }
  79. ],
  80. loading: false,
  81. finished: false,
  82. pagetTable: {
  83. current: 1,
  84. size: 10,
  85. total: '',
  86. }
  87. })
  88. onMounted(() => {
  89. data.active = JSON.parse(proxy.$route.query.tabActive)
  90. if(data.active){
  91. onLoad()
  92. }
  93. })
  94. let onClickTab = (item) => {
  95. data.pagetTable.current = 1
  96. data.loading = true
  97. data.finished = false
  98. data.active = item.name
  99. data.borrowingList = []
  100. onLoad()
  101. }
  102. let onLoad = () => {
  103. let timer = setTimeout(() => {
  104. getMyBorrowing()
  105. data.pagetTable.current ++
  106. data.finished && clearTimeout(timer);//清除计时器
  107. }, 1000);
  108. }
  109. let getMyBorrowing = () => {
  110. let param = {
  111. openid: 'ocHu-sysUQ6-xb9knAJ5mATqCOJE',
  112. status: data.active,
  113. pageNo: data.pagetTable.current,
  114. pageSize: data.pagetTable.size,
  115. }
  116. proxy.$http
  117. .get(proxy.$API.MYBORROWING, {
  118. params: param,
  119. })
  120. .then((res) => {
  121. if(res.data !== null && res.data.length !== 0){
  122. // data.borrowingList = res.data
  123. // data.pagetTable.total = res.data.page.totalRows
  124. data.borrowingList.push(...res.data.myBorrowing)
  125. data.loading = false
  126. data.finished = true
  127. // if (data.list.length >= res.data.page.totalRows) {
  128. // data.finished = true
  129. // }
  130. data.borrowingList.forEach(item=>{
  131. if (item.realityTime) {
  132. if (item.realityTime <= item.returnTime) {
  133. item.returnBook = 2
  134. console.log('准时1')
  135. } else {
  136. item.returnBook = 3
  137. console.log('逾期')
  138. }
  139. } else {
  140. const currentDate = new Date();
  141. const remainingDays = Math.ceil((new Date(item.returnTime) - currentDate) / (1000 * 3600 * 24));
  142. console.log(remainingDays)
  143. if (remainingDays <= 3) {
  144. item.returnBook = 1
  145. console.log('临时')
  146. } else {
  147. // item.returnBook = 2
  148. console.log('借阅中,还未到临期时间')
  149. }
  150. }
  151. })
  152. }else{
  153. data.borrowingList = []
  154. data.finished = true;
  155. }
  156. })
  157. .catch((res) => {
  158. console.log(res)
  159. })
  160. }
  161. let toBack = () => {
  162. proxy.$router.go(-1)
  163. }
  164. return {
  165. ...toRefs(data),
  166. toBack,
  167. getMyBorrowing,
  168. onClickTab,
  169. onLoad
  170. }
  171. },
  172. }
  173. </script>
  174. <style scoped lang="scss">
  175. .mylending-info{
  176. position: relative;
  177. margin-top: .32rem;
  178. padding: .25rem;
  179. font-size: .24rem;
  180. line-height: .4rem;
  181. background: rgba(241,241,249,0.4);
  182. border-radius: 0.08rem;
  183. border: 0.02rem solid #C6C6E2;
  184. p.actual-date{
  185. color: #FF3871;
  186. }
  187. .myLending-status{
  188. position: absolute;
  189. right: .3rem;
  190. top: .36rem;
  191. width: 1.22rem;
  192. height: 1.07rem;
  193. &.yq-status{
  194. background: url('@assets/images/mylending-img1.png') no-repeat;
  195. background-size: 100% 100%;
  196. }
  197. &.zs-status{
  198. background: url('@assets/images/mylending-img2.png') no-repeat;
  199. background-size: 100% 100%;
  200. }
  201. &.lq-status{
  202. background: url('@assets/images/mylending-img3.png') no-repeat;
  203. background-size: 100% 100%;
  204. }
  205. }
  206. }
  207. </style>