home.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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-li">通知</view>
  20. <ul v-if="informList.length===0?false:true">
  21. <li v-for="item in informList" :key="item.noticeId" class="notice-li" @click="toNotice(item.noticeId)">
  22. <i class="iconfont icon-yuandian"></i>
  23. {{item.noticeTitle}}
  24. </li>
  25. </ul>
  26. <view class="notice-li" v-else>暂无通知</view>
  27. </view>
  28. <view class="borrow-area" >
  29. <view class="notice-li">
  30. 最新借用设备
  31. </view>
  32. <ul v-if="borList.length===0?false:true">
  33. <li v-for="item in borList" :key="item.id" class="notice-li">
  34. <text>设备编码:{{item.assetBarCode}}</text>
  35. <text>{{handleDate(item.borrowDate)}}</text>
  36. </li>
  37. </ul>
  38. <view v-else>
  39. 暂无最新借用设备
  40. </view>
  41. </view>
  42. <view class="scan-area">
  43. <view class="scan-code" @click="toScan">
  44. <i class="iconfont icon-saoyisao"></i>
  45. <text>扫码设备</text>
  46. </view>
  47. <view class="scan-mine" @click="toMine">
  48. <i class="iconfont icon-wode"></i>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { getInfo } from '@/api/user.js'
  55. import cache from '@/utils/storage.js'
  56. import { getNewInform } from '@/api/notice.js'
  57. import { borrowList } from '@/api/asset.js'
  58. export default {
  59. data() {
  60. return {
  61. keyword:"",
  62. informList:[],
  63. borList:[]
  64. }
  65. },
  66. methods: {
  67. search(){
  68. if(this.keyword===""){
  69. uni.showToast({
  70. title:"请输入查询字段",
  71. icon:'none'
  72. })
  73. }else{
  74. uni.navigateTo({
  75. url:'/pages/search/search?keyword='+this.keyword,
  76. })
  77. }
  78. },
  79. init(){
  80. getNewInform(4).then(res=>{
  81. this.informList = res
  82. })
  83. borrowList({
  84. pageNum:1,
  85. pageSize:1,
  86. status:0
  87. }).then(res=>{
  88. // console.log(res.data.rows)
  89. this.borList = res.data.rows
  90. })
  91. },
  92. toMine(){
  93. uni.navigateTo({
  94. url:'/pages/menus/menu/menu',
  95. })
  96. },
  97. toScan(){
  98. uni.scanCode({
  99. scanType:['barCode'],
  100. success (res) {
  101. uni.navigateTo({
  102. url:'/pages/fault/fault-report/fault-report?id='+res.result
  103. })
  104. }
  105. })
  106. },
  107. toNotice(id){
  108. // console.log(id)
  109. uni.navigateTo({
  110. url:'/pages/notice/notice?id='+id,
  111. })
  112. },
  113. handleDate(val){
  114. let date = new Date(val)
  115. let year = date.getFullYear()
  116. let month = date.getMonth()+1
  117. let day = date.getDate()
  118. return year+"-"+month+"-"+day;
  119. }
  120. },
  121. onLoad:function(){
  122. this.keyword = "",
  123. getInfo().then(res=>{
  124. if(res.data.code===200){
  125. cache.session.setJSON('role',res.data.roles[0])
  126. cache.session.setJSON('phone',res.data.user.phonenumber)
  127. cache.session.setJSON('email',res.data.user.email)
  128. cache.session.setJSON('nickName',res.data.user.nickName)
  129. cache.session.setJSON('userName',res.data.user.userName)
  130. }
  131. })
  132. if(uni.getStorageSync('Admin-Token')){
  133. this.init()
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .home{
  140. padding: 20rpx;
  141. display: flex;
  142. flex-direction: column;
  143. height: 100vh;
  144. box-sizing: border-box;
  145. }
  146. .search-area{
  147. margin-bottom: 20rpx ;
  148. flex-shrink: 0;
  149. position: relative;
  150. input{
  151. height: 76rpx;
  152. border: 2rpx solid #000;
  153. line-height: 76rpx;
  154. padding-left:80rpx ;
  155. }
  156. .iconfont{
  157. position: absolute;
  158. font-size: 40rpx;
  159. top: 20rpx;
  160. left: 16rpx;
  161. }
  162. }
  163. .rule-area{
  164. margin-bottom: 20rpx ;
  165. flex-shrink: 0;
  166. // height: 270rpx;
  167. // border: 2rpx solid #000;
  168. .notice-li{
  169. display: flex;
  170. flex-direction: row;
  171. line-height: 200%;
  172. }
  173. }
  174. .borrow-area{
  175. flex-shrink: 0;
  176. margin-bottom: 20rpx ;
  177. height: 120rpx;
  178. .notice-li{
  179. line-height: 200%;
  180. display: flex;
  181. flex-direction: row;
  182. justify-content: space-between;
  183. }
  184. // border: 2rpx solid #000;
  185. }
  186. .scan-area{
  187. flex-shrink: 1;
  188. height: 100%;
  189. // max-height: 750rpx;
  190. position: relative;
  191. .scan-code{
  192. width: 280rpx;
  193. height: 280rpx;
  194. background-color: #000;
  195. color: $uni-text-color-inverse;
  196. border-radius: 50%;
  197. position: absolute;
  198. top: 50%;
  199. left: 50%;
  200. transform: translate(-50%,-50%);
  201. display: flex;
  202. align-items: center;
  203. justify-content: center;
  204. text-align: center;
  205. flex-direction: column;
  206. font-size: 36rpx;
  207. .iconfont{
  208. font-size: 80rpx;
  209. margin: 20rpx 0;
  210. }
  211. }
  212. .scan-mine{
  213. width: 80rpx;
  214. height: 80rpx;
  215. color: rgba(80, 80, 80, 1);
  216. border-radius: 21px;
  217. // font-size: 14px;
  218. line-height: 150%;
  219. box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.5);
  220. display: flex;
  221. align-items: center;
  222. justify-content: center;
  223. text-align: center;
  224. flex-direction: column;
  225. font-size: 36rpx;
  226. position: absolute;
  227. bottom: 20rpx;
  228. left: 20rpx;
  229. }
  230. }
  231. </style>