home.vue 6.1 KB

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