index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="container">
  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="study-box">
  21. <view class="title">
  22. 研究成果栏
  23. </view>
  24. <view class="list">
  25. <view class="study" v-for="study in studyList" :key="study.id">
  26. <view class="title">
  27. {{study.noticeTitle}}
  28. </view>
  29. <view class="content">
  30. <rich-text :nodes="study.noticeContent" style="text-indent: 2em;"></rich-text>
  31. </view>
  32. </view>
  33. <view class="study" v-if="!studyList.length">
  34. <view class="title" style="text-align: center;">
  35. 暂无数据
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="asset-box">
  41. <view class="title">
  42. 公开设备
  43. </view>
  44. <view class="list">
  45. <view class="asset" v-for="asset in assetList" @click="toDetail(asset)">
  46. <view class="left">
  47. <image class="image" :src="imgSrc(asset.img)" mode="aspectFit" @error="imgError"></image>
  48. </view>
  49. <view class="right">
  50. <view class="name">
  51. {{asset.name}}
  52. </view>
  53. <view class="introduce">
  54. <text>{{asset.introduce}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import { assetList, studyNew, getImage } from '@/api/visitor.js'
  64. export default {
  65. name: 'Visitor-Index',
  66. data() {
  67. return {
  68. assetList: [],
  69. studyList: []
  70. }
  71. },
  72. methods: {
  73. getAssetList() {
  74. assetList().then(res => {
  75. this.assetList = res
  76. })
  77. },
  78. getNewStudy() {
  79. studyNew(5).then(res => {
  80. this.studyList = res
  81. console.log('研究成果数据', res);
  82. })
  83. },
  84. imgSrc(src) {
  85. return getImage(src)
  86. },
  87. imgError(err) {
  88. console.log('图片异常', err.detail.errMsg);
  89. },
  90. /** 搜索框 */
  91. search() {},
  92. toDetail(asset) {
  93. console.log('资产信息', asset);
  94. uni.navigateTo({
  95. url: '/pages/visitor/assetDetail/assetDetail?barCode=' + asset.barCode
  96. });
  97. }
  98. },
  99. onLoad() {
  100. this.getNewStudy()
  101. this.getAssetList()
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. page{
  107. background-color: #f5f6fa;
  108. }
  109. .container{
  110. padding: 20rpx 24rpx;
  111. .study-box{
  112. margin-top: 20rpx;
  113. // min-height: 400rpx;
  114. background-color: #fff;
  115. border-radius: 20rpx;
  116. padding: 10rpx 20rpx;
  117. box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  118. .title{
  119. width: 100%;
  120. text-align: center;
  121. font-weight: bold;
  122. font-size: 36rpx;
  123. margin-bottom: 20rpx;
  124. }
  125. .study {
  126. line-height: 50rpx;
  127. margin-bottom: 10rpx;
  128. padding-bottom: 20rpx;
  129. border-bottom: 1rpx solid #dddddd;
  130. .title {
  131. font-size: 36rpx;
  132. width: 100%;
  133. text-align: left;
  134. font-weight: 500;
  135. margin-bottom: 5rpx;
  136. overflow: hidden; /*超出部分隐藏*/
  137. white-space: nowrap; /*禁止换行*/
  138. text-overflow: ellipsis; /*省略号*/
  139. }
  140. .content {
  141. font-size: 24rpx;
  142. line-height: 40rpx;
  143. display: -webkit-box;
  144. -webkit-box-orient: vertical;
  145. -webkit-line-clamp: 3;
  146. overflow: hidden;
  147. }
  148. }
  149. }
  150. .asset-box{
  151. margin-top: 40rpx;
  152. .title{
  153. font-weight: bold;
  154. font-size: 36rpx;
  155. margin-bottom: 20rpx;
  156. }
  157. .list{
  158. .asset {
  159. display: flex;
  160. background-color: #fff;
  161. align-items: center;
  162. height: 260rpx;
  163. border-radius: 20rpx;
  164. box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  165. padding: 30rpx;
  166. margin-bottom: 45rpx;
  167. .left {
  168. flex: 1;
  169. .image {
  170. width: 200rpx;
  171. }
  172. margin-right: 20rpx;
  173. }
  174. .right {
  175. flex: 4;
  176. .name {
  177. font-size: 42rpx;
  178. margin-bottom: 20rpx;
  179. overflow: hidden; /*超出部分隐藏*/
  180. white-space: nowrap; /*禁止换行*/
  181. text-overflow: ellipsis; /*省略号*/
  182. }
  183. .introduce {
  184. line-height: 50rpx;
  185. display: -webkit-box;
  186. -webkit-box-orient: vertical;
  187. -webkit-line-clamp: 4;
  188. overflow: hidden;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>