home.vue 6.0 KB

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