index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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" v-show="assetList.length > 0">
  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 === null ? '暂无' : asset.introduce}}</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="asset-box" v-show="videoList.length > 0">
  64. <view class="title">
  65. 公开视频
  66. <view class="right" @click="toMoreVideo">更多&gt;&gt;&gt;</view>
  67. </view>
  68. <view class="list">
  69. <view class="video" v-for="(video, index) in videoList" :key="video.id">
  70. <video :src="playerURL(video.url)" controls :id="video.id" :data-id="video.id" :title="video.name" @play="videoPlay" :type="video.type"></video>
  71. <view class="info">{{video.name}}</view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import { assetList, studyNew, getImage, demoVideo, playerVideo } from '@/api/visitor.js'
  79. export default {
  80. name: 'Visitor-Index',
  81. data() {
  82. return {
  83. studyNumber: 3,
  84. assetList: [],
  85. studyList: [],
  86. videoList: []
  87. }
  88. },
  89. methods: {
  90. getAssetList() {
  91. assetList().then(res => {
  92. this.assetList = res
  93. })
  94. },
  95. getNewStudy() {
  96. studyNew(this.studyNumber).then(res => {
  97. this.studyList = res
  98. })
  99. },
  100. getDemoVideo() {
  101. demoVideo(1, 3).then(res => {
  102. this.videoList = res.data.rows
  103. })
  104. },
  105. playerURL(url) {
  106. return playerVideo(url)
  107. },
  108. videoPlay(e) {
  109. // 获取当前视频id
  110. let currentId = e.currentTarget.dataset.id;
  111. // uni.createVideoContext获取视频上下文对象
  112. this.videoContent = uni.createVideoContext(currentId);
  113. // 获取json对象并遍历, 停止非当前视频
  114. let videoList = this.videoList;
  115. for (let i = 0; i < videoList.length; i++) {
  116. let temp = videoList[i].id;
  117. if (temp !== currentId) {
  118. uni.createVideoContext(temp).pause();
  119. }
  120. }
  121. },
  122. imgSrc(src) {
  123. return getImage(src)
  124. },
  125. imgError(err) {
  126. console.log('图片异常', err.detail.errMsg);
  127. },
  128. /** 搜索框 */
  129. search() {},
  130. toList() {
  131. uni.navigateTo({
  132. url: '/pages/visitor/noticeList'
  133. });
  134. },
  135. toDetail(asset) {
  136. uni.navigateTo({
  137. url: '/pages/visitor/assetDetail/assetDetail?barCode=' + asset.barCode
  138. });
  139. },
  140. toNotice(id){
  141. uni.navigateTo({
  142. url:'/pages/notice/notice?id='+id,
  143. })
  144. },
  145. toMoreVideo() {
  146. uni.navigateTo({
  147. url: '/pages/visitor/modeVideo/modeVideo'
  148. });
  149. }
  150. },
  151. onLoad() {
  152. this.getNewStudy()
  153. this.getAssetList()
  154. this.getDemoVideo()
  155. }
  156. }
  157. </script>
  158. <style lang="scss">
  159. page{
  160. background-color: #f5f6fa;
  161. }
  162. .container{
  163. padding: 20rpx 24rpx;
  164. .study-box{
  165. margin-top: 20rpx;
  166. // min-height: 400rpx;
  167. background-color: #fff;
  168. border-radius: 20rpx;
  169. padding: 10rpx 20rpx;
  170. // box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  171. .title{
  172. width: 100%;
  173. text-align: center;
  174. // font-weight: bold;
  175. font-size: $uni-title-font-size;
  176. margin-bottom: 40rpx;
  177. }
  178. .study {
  179. line-height: $uni-line-height;
  180. margin-bottom: 10rpx;
  181. padding-bottom: 20rpx;
  182. border-bottom: 1rpx solid #dddddd;
  183. .title {
  184. font-size: $uni-title-font-size;
  185. width: 100%;
  186. text-align: left;
  187. font-weight: 500;
  188. margin-bottom: 5rpx;
  189. overflow: hidden; /*超出部分隐藏*/
  190. white-space: nowrap; /*禁止换行*/
  191. text-overflow: ellipsis; /*省略号*/
  192. }
  193. .content {
  194. font-size: $uni-font-size;
  195. line-height: $uni-line-height;
  196. display: -webkit-box;
  197. -webkit-box-orient: vertical;
  198. -webkit-line-clamp: 3;
  199. overflow: hidden;
  200. }
  201. }
  202. .more {
  203. text-align: right;
  204. padding-top: 10rpx;
  205. }
  206. }
  207. .asset-box{
  208. margin-top: 40rpx;
  209. .title{
  210. font-weight: 500;
  211. font-size: $uni-title-font-size;
  212. margin-bottom: 20rpx;
  213. position: relative;
  214. .right{
  215. position: absolute;
  216. font-size: 28rpx;
  217. font-weight: 400;
  218. right: 20rpx;
  219. top: 25%;
  220. }
  221. }
  222. .list{
  223. .asset {
  224. display: flex;
  225. background-color: #fff;
  226. align-items: center;
  227. height: 260rpx;
  228. border-radius: 20rpx;
  229. // box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  230. padding: 60rpx 30rpx;
  231. margin-bottom: 45rpx;
  232. .left {
  233. flex: 1;
  234. .image {
  235. width: 200rpx;
  236. }
  237. margin-right: 20rpx;
  238. }
  239. .right {
  240. flex: 4;
  241. .name {
  242. font-size: $uni-title-font-size;
  243. margin-bottom: 20rpx;
  244. overflow: hidden; /*超出部分隐藏*/
  245. white-space: nowrap; /*禁止换行*/
  246. text-overflow: ellipsis; /*省略号*/
  247. }
  248. .introduce {
  249. line-height: $uni-line-height;
  250. font-size: $uni-font-size;
  251. display: -webkit-box;
  252. -webkit-box-orient: vertical;
  253. -webkit-line-clamp: 3;
  254. overflow: hidden;
  255. }
  256. }
  257. }
  258. .video {
  259. text-align: center;
  260. // box-shadow: rgba(17, 17, 26, 0.1) 0px 1px 0px;
  261. margin-bottom: 50rpx;
  262. &:last-child {
  263. margin-bottom: 20rpx;
  264. }
  265. .info {
  266. padding: 10rpx;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. </style>