home.vue 5.6 KB

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