home.vue 7.0 KB

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