home.vue 6.1 KB

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