home.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. title:"正在加载中",
  83. icon:'none',
  84. mask:true
  85. })
  86. try{
  87. getNewInform(4).then(res=>{
  88. if(res instanceof Array){
  89. that.informList = res
  90. getBorrowList({
  91. pageNum:1,
  92. pageSize:1,
  93. status:0
  94. }).then(res=>{
  95. if(res.data.rows){
  96. that.borList = res.data.rows
  97. }
  98. uni.hideLoading()
  99. })
  100. }else{
  101. uni.hideLoading()
  102. }
  103. })
  104. }catch(err){
  105. uni.hideLoading()
  106. }
  107. },
  108. toMine(){
  109. uni.navigateTo({
  110. url:'/pages/menus/menu/menu',
  111. })
  112. },
  113. toScan(){
  114. uni.scanCode({
  115. scanType:['barCode'],
  116. success (res) {
  117. uni.navigateTo({
  118. url:'/pages/borrow/borrow?number='+res.result
  119. })
  120. }
  121. })
  122. },
  123. toNotice(id){
  124. uni.navigateTo({
  125. url:'/pages/notice/notice?id='+id,
  126. })
  127. },
  128. toDetail(bar){
  129. uni.navigateTo({
  130. url:'/pages/borrow/borrow?number='+bar,
  131. })
  132. },
  133. handleDate(val){
  134. let date = new Date(val)
  135. let year = date.getFullYear()
  136. let month = date.getMonth()+1
  137. let day = date.getDate()
  138. return year+"-"+month+"-"+day;
  139. }
  140. },
  141. onLoad:function(){
  142. this.keyword = ""
  143. },
  144. onShow() {
  145. this.initInfo()
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .home{
  151. padding: 20rpx;
  152. display: flex;
  153. flex-direction: column;
  154. height: 100vh;
  155. box-sizing: border-box;
  156. }
  157. .search-area{
  158. margin-bottom: 20rpx ;
  159. flex-shrink: 0;
  160. position: relative;
  161. input{
  162. height: 76rpx;
  163. border: 2rpx solid #000;
  164. line-height: 76rpx;
  165. padding-left:80rpx ;
  166. }
  167. .iconfont{
  168. position: absolute;
  169. font-size: 40rpx;
  170. top: 20rpx;
  171. left: 16rpx;
  172. }
  173. }
  174. .rule-area{
  175. flex-shrink: 0;
  176. .notice-li{
  177. display: flex;
  178. flex-direction: row;
  179. line-height: 200%;
  180. }
  181. }
  182. .borrow-area{
  183. flex-shrink: 0;
  184. margin-bottom: 20rpx ;
  185. height: 120rpx;
  186. .notice-li{
  187. line-height: 200%;
  188. display: flex;
  189. flex-direction: row;
  190. justify-content: space-between;
  191. }
  192. // border: 2rpx solid #000;
  193. }
  194. .scan-area{
  195. flex-shrink: 1;
  196. height: 100%;
  197. // max-height: 750rpx;
  198. position: relative;
  199. .scan-code{
  200. width: 280rpx;
  201. height: 280rpx;
  202. background-color: #000;
  203. color: $uni-text-color-inverse;
  204. border-radius: 50%;
  205. position: absolute;
  206. top: 50%;
  207. left: 50%;
  208. transform: translate(-50%,-50%);
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. text-align: center;
  213. flex-direction: column;
  214. font-size: 36rpx;
  215. .iconfont{
  216. font-size: 80rpx;
  217. margin: 20rpx 0;
  218. }
  219. }
  220. .scan-mine{
  221. width: 80rpx;
  222. height: 80rpx;
  223. color: rgba(80, 80, 80, 1);
  224. border-radius: 21px;
  225. // font-size: 14px;
  226. line-height: 150%;
  227. box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.5);
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. text-align: center;
  232. flex-direction: column;
  233. font-size: 36rpx;
  234. position: absolute;
  235. bottom: 20rpx;
  236. left: 20rpx;
  237. }
  238. }
  239. </style>