home.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="home">
  3. <view class="search-area">
  4. <u-search
  5. placeholder="搜索设备"
  6. v-model="keyword"
  7. shape="square"
  8. :clearabled="true"
  9. :show-action="true"
  10. action-text="搜索"
  11. :animation="true"
  12. search-icon-color="#000"
  13. color="#000"
  14. placeholder-color="#5c5b5b"
  15. @search="search"
  16. @custom="search"></u-search>
  17. </view>
  18. <view class="rule-area">
  19. <view class="notice-li">通知</view>
  20. <ul v-if="informList.length===0?false:true">
  21. <li v-for="item in informList" :key="item.noticeId" class="notice-li" @click="toNotice(item.noticeId)">
  22. <i class="iconfont icon-yuandian"></i>
  23. {{item.noticeTitle}}
  24. </li>
  25. </ul>
  26. <view class="notice-li" v-else>暂无通知</view>
  27. </view>
  28. <view class="borrow-area" >
  29. <view class="notice-li">
  30. 最新借用设备
  31. </view>
  32. <ul v-if="borList.length===0?false:true">
  33. <li v-for="item in borList" :key="item.id" class="notice-li" @click="toDetail(item.assetBarCode)">
  34. <text>设备编码:{{item.assetBarCode}}</text>
  35. <text>{{handleDate(item.borrowDate)}}</text>
  36. </li>
  37. </ul>
  38. <view v-else>
  39. 暂无最新借用设备
  40. </view>
  41. </view>
  42. <view class="scan-area">
  43. <view class="scan-code" @click="toScan">
  44. <i class="iconfont icon-saoyisao"></i>
  45. <text>扫码设备</text>
  46. </view>
  47. <view class="scan-mine" @click="toMine">
  48. <i class="iconfont icon-wode"></i>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. // import { getInfo } from '@/api/user.js'
  55. // import cache from '@/utils/storage.js'
  56. import { getNewInform } from '@/api/notice.js'
  57. import { getBorrowList } from '@/api/asset.js'
  58. export default {
  59. data() {
  60. return {
  61. keyword:"",
  62. informList:[],
  63. borList:[]
  64. }
  65. },
  66. methods: {
  67. search(){
  68. if(this.keyword===""){
  69. uni.showToast({
  70. title:"请输入查询字段",
  71. icon:'none'
  72. })
  73. }else{
  74. uni.navigateTo({
  75. url:'/pages/search/search?keyword='+this.keyword,
  76. })
  77. }
  78. },
  79. initInfo(){
  80. const that = this
  81. uni.showLoading()
  82. try{
  83. getNewInform(4).then(res=>{
  84. if(res instanceof Array){
  85. that.informList = res
  86. getBorrowList({
  87. pageNum:1,
  88. pageSize:1,
  89. status:0
  90. }).then(res=>{
  91. if(res.data.rows){
  92. that.borList = res.data.rows
  93. }
  94. uni.hideLoading()
  95. })
  96. }else{
  97. uni.hideLoading()
  98. }
  99. })
  100. }catch(err){
  101. uni.hideLoading()
  102. }
  103. },
  104. toMine(){
  105. uni.navigateTo({
  106. url:'/pages/menus/menu/menu',
  107. })
  108. },
  109. toScan(){
  110. uni.scanCode({
  111. scanType:['barCode'],
  112. success (res) {
  113. uni.navigateTo({
  114. url:'/pages/borrow/borrow?number='+res.result
  115. })
  116. }
  117. })
  118. },
  119. toNotice(id){
  120. uni.navigateTo({
  121. url:'/pages/notice/notice?id='+id,
  122. })
  123. },
  124. toDetail(bar){
  125. uni.navigateTo({
  126. url:'/pages/borrow/borrow?number='+bar,
  127. })
  128. },
  129. handleDate(val){
  130. let date = new Date(val)
  131. let year = date.getFullYear()
  132. let month = date.getMonth()+1
  133. let day = date.getDate()
  134. return year+"-"+month+"-"+day;
  135. }
  136. },
  137. onLoad:function(){
  138. this.keyword = ""
  139. },
  140. onShow() {
  141. this.initInfo()
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .home{
  147. padding: 20rpx;
  148. display: flex;
  149. flex-direction: column;
  150. height: 100vh;
  151. box-sizing: border-box;
  152. }
  153. .search-area{
  154. margin-bottom: 20rpx ;
  155. flex-shrink: 0;
  156. position: relative;
  157. input{
  158. height: 76rpx;
  159. border: 2rpx solid #000;
  160. line-height: 76rpx;
  161. padding-left:80rpx ;
  162. }
  163. .iconfont{
  164. position: absolute;
  165. font-size: 40rpx;
  166. top: 20rpx;
  167. left: 16rpx;
  168. }
  169. }
  170. .rule-area{
  171. // margin-bottom: 20rpx ;
  172. flex-shrink: 0;
  173. // height: 270rpx;
  174. // border: 2rpx solid #000;
  175. .notice-li{
  176. display: flex;
  177. flex-direction: row;
  178. line-height: 200%;
  179. }
  180. }
  181. .borrow-area{
  182. flex-shrink: 0;
  183. margin-bottom: 20rpx ;
  184. height: 120rpx;
  185. .notice-li{
  186. line-height: 200%;
  187. display: flex;
  188. flex-direction: row;
  189. justify-content: space-between;
  190. }
  191. // border: 2rpx solid #000;
  192. }
  193. .scan-area{
  194. flex-shrink: 1;
  195. height: 100%;
  196. // max-height: 750rpx;
  197. position: relative;
  198. .scan-code{
  199. width: 280rpx;
  200. height: 280rpx;
  201. background-color: #000;
  202. color: $uni-text-color-inverse;
  203. border-radius: 50%;
  204. position: absolute;
  205. top: 50%;
  206. left: 50%;
  207. transform: translate(-50%,-50%);
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. text-align: center;
  212. flex-direction: column;
  213. font-size: 36rpx;
  214. .iconfont{
  215. font-size: 80rpx;
  216. margin: 20rpx 0;
  217. }
  218. }
  219. .scan-mine{
  220. width: 80rpx;
  221. height: 80rpx;
  222. color: rgba(80, 80, 80, 1);
  223. border-radius: 21px;
  224. // font-size: 14px;
  225. line-height: 150%;
  226. box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.5);
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. text-align: center;
  231. flex-direction: column;
  232. font-size: 36rpx;
  233. position: absolute;
  234. bottom: 20rpx;
  235. left: 20rpx;
  236. }
  237. }
  238. </style>