assetDetail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="container">
  3. <view class="assetBox" v-if="assetInfo">
  4. <view class="imageBox">
  5. <image class="image" :src="imgSrc(assetInfo.img)" mode="aspectFit"></image>
  6. </view>
  7. <view class="infoBox">
  8. <view class="name">{{assetInfo.name}}</view>
  9. <scroll-view class="content" scroll-y="true">
  10. <view class="introduce">
  11. 简介:<br/><text selectable="true">{{assetInfo.introduce}}</text>
  12. </view>
  13. </scroll-view>
  14. <!-- <view class="name2">设备详情</view>
  15. <scroll-view class="content1" scroll-y="true">
  16. <view v-if="assetInfo.specificationsModel">规格:<text selectable="true">{{assetInfo.specificationsModel}}</text></view>
  17. <view v-if="assetInfo.purpose">用途:<text selectable="true">{{assetInfo.purpose}}</text></view>
  18. <view v-if="assetInfo.kind">种类:<text selectable="true">{{assetInfo.kind}}</text></view>
  19. <view v-if="assetInfo.placeName">位置:<text selectable="true">{{assetInfo.placeName}}</text></view>
  20. <view v-if="assetInfo.amount">原值:<text selectable="true">{{assetInfo.amount}}</text></view>
  21. <view v-if="assetInfo.brand">品牌:<text selectable="true">{{assetInfo.brand}}</text></view>
  22. <view v-if="assetInfo.manufacturer">厂商:<text selectable="true">{{assetInfo.manufacturer}}</text></view>
  23. <view>编号:<text selectable="true">{{assetInfo.number}}</text></view>
  24. <view>条形码:<text selectable="true">{{assetInfo.barCode}}</text></view>
  25. </scroll-view> -->
  26. </view>
  27. </view>
  28. <view class="videoBox" v-if="videoList">
  29. <view class="title">演示视频</view>
  30. <view class="video" v-for="(video, index) in videoList" :key="video.id">
  31. <video :src="playerURL(video.url)" controls :id="video.id" :data-id="video.id" :title="video.name" @play="videoPlay" :type="video.type"></video>
  32. <view class="info">{{video.name}}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { assetDetail, getImage, playerVideo } from '@/api/visitor.js'
  39. export default {
  40. name: 'Asset-Detail',
  41. data() {
  42. return {
  43. barCode: null,
  44. assetInfo: null,
  45. videoList: [],
  46. videoOptions: null
  47. };
  48. },
  49. methods: {
  50. initData() {
  51. assetDetail(this.barCode).then(res => {
  52. console.log('详情页数据', res);
  53. this.assetInfo = res.tbAsset
  54. this.videoList = res.demoVideos
  55. })
  56. },
  57. imgSrc(src) {
  58. return getImage(src)
  59. },
  60. playerURL(url) {
  61. return playerVideo(url)
  62. },
  63. videoPlay(e) {
  64. // 获取当前视频id
  65. let currentId = e.currentTarget.dataset.id;
  66. // uni.createVideoContext获取视频上下文对象
  67. this.videoContent = uni.createVideoContext(currentId);
  68. // 获取json对象并遍历, 停止非当前视频
  69. let videoList = this.videoList;
  70. for (let i = 0; i < videoList.length; i++) {
  71. let temp = videoList[i].id;
  72. if (temp !== currentId) {
  73. uni.createVideoContext(temp).pause();
  74. }
  75. }
  76. }
  77. },
  78. onLoad(option) {
  79. this.barCode = option.barCode
  80. this.initData()
  81. }
  82. }
  83. </script>
  84. <style lang="less">
  85. page{
  86. background-color: #f5f6fa;
  87. }
  88. .container{
  89. padding: 20rpx 24rpx;
  90. .assetBox {
  91. background-color: #fff;
  92. border-radius: 20rpx;
  93. box-shadow: rgba(0, 0, 0, 0.05) 0px 0px 0px 1px;
  94. .imageBox{
  95. border-radius: 20rpx;
  96. box-shadow: rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgb(209, 213, 219) 0px 0px 0px 1px inset;
  97. .image{
  98. height: 350rpx;
  99. }
  100. }
  101. .infoBox {
  102. padding: 30rpx 20rpx;
  103. .name{
  104. font-size: 40rpx;
  105. margin-bottom: 10rpx;
  106. }
  107. .content{
  108. height: 350rpx;
  109. line-height: 68rpx;
  110. // width: 100%;
  111. // overflow: auto;
  112. .introduce{
  113. color: #696969;
  114. }
  115. /* 设置滚动条样式 */
  116. ::-webkit-scrollbar {
  117. width: 80rpx; /* 滚动条宽度 */
  118. }
  119. /* 设置滚动条轨道背景颜色 */
  120. ::-webkit-scrollbar-track {
  121. background-color: #f1f1f1;
  122. }
  123. /* 设置滚动条滑块颜色 */
  124. ::-webkit-scrollbar-thumb {
  125. background-color: #888;
  126. border-radius: 4rpx; /* 可选,设置滑块的圆角 */
  127. }
  128. }
  129. .name2{
  130. margin-top: 20rpx;
  131. font-size: 40rpx;
  132. margin-bottom: 10rpx;
  133. }
  134. .content1{
  135. color: #696969;
  136. height: 205rpx;
  137. line-height: 68rpx;
  138. width: 100%;
  139. overflow-y: auto;
  140. }
  141. }
  142. }
  143. .videoBox {
  144. margin-top: 20rpx;
  145. background-color: #fff;
  146. border-radius: 20rpx;
  147. box-shadow: rgba(0, 0, 0, 0.05) 0px 0px 0px 1px;
  148. padding: 10rpx 20rpx;
  149. .title{
  150. font-size: 40rpx;
  151. margin-bottom: 20rpx;
  152. }
  153. .video {
  154. text-align: center;
  155. box-shadow: rgba(0, 0, 0, 0.45) 0px 25px 20px -20px;
  156. margin-bottom: 50rpx;
  157. &:last-child {
  158. margin-bottom: 20rpx;
  159. }
  160. .info {
  161. padding: 10rpx;
  162. }
  163. }
  164. }
  165. }
  166. </style>