index.vue 4.8 KB

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