detail.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view>
  3. <swiper class="carousel" indicator-dots=true circular=true interval="3000" duration="700">
  4. <swiper-item v-for="(item,index) in data.imgList" :key="index">
  5. <view class="image-wrapper">
  6. <image
  7. :src="item.src"
  8. :class="item.loaded"
  9. mode="aspectFill"
  10. @load="imageOnLoad('imgList', index)"
  11. ></image>
  12. </view>
  13. </swiper-item>
  14. </swiper>
  15. <view class="scroll-view-wrapper">
  16. <scroll-view class="episode-panel" :class="{Skeleton:!loaded}" scroll-x>
  17. <view v-for="(item, index) in data.episodeList" :key="index"
  18. :class="{current: currentEpd===item}"
  19. @click="changeEpd(index)"
  20. >
  21. {{item}}
  22. </view>
  23. </scroll-view>
  24. </view>
  25. <view class="info">
  26. <view class="title">
  27. <text :class="{Skeleton:!loaded}">{{data.title}}</text>
  28. <text :class="{Skeleton:!loaded}">{{data.title2}}</text>
  29. </view>
  30. <text class="yticon icon-xia"></text>
  31. </view>
  32. <view class="actions">
  33. <text class="yticon icon-fenxiang2" @click="share"></text>
  34. <text class="yticon icon-Group-"></text>
  35. <text class="yticon icon-shoucang" :class="{active: data.favorite}" @click="favorite"></text>
  36. </view>
  37. <!-- 猜你喜欢 -->
  38. <view class="guess">
  39. <view class="section-tit">猜你喜欢</view>
  40. <view class="guess-list">
  41. <view
  42. v-for="(item, index) in data.guessList" :key="index"
  43. class="guess-item"
  44. >
  45. <view class="image-wrapper">
  46. <image
  47. :src="item.src"
  48. :class="item.loaded"
  49. mode="aspectFill"
  50. @load="imageOnLoad('guessList', index)"
  51. ></image>
  52. </view>
  53. <text class='title clamp' :class="{Skeleton:!loaded}">{{item.title}}</text>
  54. <text class="clamp" :class="{Skeleton:!loaded}">{{item.title2}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 评论 -->
  59. <view class="evalution">
  60. <view class="section-tit">评论</view>
  61. <view class="eva-list" :class="{Skeleton:!loaded}">
  62. <view v-for="(item, index) in data.evaList" :key="index"
  63. class="eva-item"
  64. >
  65. <image :src="item.src" mode="aspectFill"></image>
  66. <view class="eva-right">
  67. <text>{{item.nickname}}</text>
  68. <text>{{item.time}}</text>
  69. <view class="zan-box">
  70. <text>{{item.zan}}</text>
  71. <text class="yticon icon-shoucang"></text>
  72. </view>
  73. <text class="content">{{item.content}}</text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 分享 -->
  79. <share
  80. ref="share"
  81. :contentHeight="580"
  82. :shareList="shareList"
  83. ></share>
  84. </view>
  85. </template>
  86. <script>
  87. import share from '@/components/share';
  88. export default {
  89. components: {
  90. share
  91. },
  92. data() {
  93. return {
  94. loaded: false,
  95. currentEpd: 1,
  96. data: {
  97. guessList: [{},{},{},{}]
  98. },
  99. shareList: []
  100. };
  101. },
  102. async onLoad(){
  103. let detailData = await this.$api.json('detailData');
  104. let shareList = await this.$api.json('shareList');
  105. this.loaded = true;
  106. this.data = detailData;
  107. this.shareList = shareList;
  108. uni.setNavigationBarTitle({
  109. title: detailData.title
  110. })
  111. },
  112. methods:{
  113. imageOnLoad(key,index){
  114. this.$set(this.data[key][index], 'loaded', 'loaded');
  115. },
  116. changeEpd(index){
  117. let list = this.data.episodeList;
  118. let epd = list[index];
  119. this.$api.msg(`切换到第${epd}项`);
  120. this.currentEpd = epd;
  121. },
  122. //分享
  123. share(){
  124. this.$refs.share.toggleMask();
  125. },
  126. //收藏
  127. favorite(){
  128. this.data.favorite = !this.data.favorite;
  129. }
  130. },
  131. //处理遮罩层物理返回键
  132. onBackPress(){
  133. if(this.$refs.share.show){
  134. this.$refs.share.toggleMask();
  135. return true;
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. page{
  142. background: $page-color-base;
  143. }
  144. .carousel {
  145. height: 200px;
  146. .image-wrapper{
  147. display: flex;
  148. justify-content: center;
  149. align-content: center;
  150. width: 100%;
  151. height: 100%;
  152. overflow: hidden;
  153. image {
  154. width: 100%;
  155. height: 100%;
  156. }
  157. }
  158. }
  159. .scroll-view-wrapper{
  160. display:flex;
  161. align-items:center;
  162. height: 90rpx;
  163. padding: 20rpx 0 20rpx 40rpx;
  164. background: #fff;
  165. }
  166. .episode-panel {
  167. white-space: nowrap;
  168. width: 100%;
  169. view {
  170. display: inline-block;
  171. margin-right: 30rpx;
  172. width: 56rpx;
  173. font-size: $font-lg;
  174. color: $font-color-base;
  175. &.current{
  176. color: #07a7a7;
  177. }
  178. }
  179. }
  180. .info {
  181. display: flex;
  182. align-items: center;
  183. padding: 10rpx 40rpx;
  184. background: #fff;
  185. .title {
  186. flex: 1;
  187. display: flex;
  188. flex-direction: column;
  189. font-size: $font-lg + 4rpx;
  190. color: $font-color-dark;
  191. text:last-child {
  192. font-size: $font-sm;
  193. color: $font-color-light;
  194. margin-top: 4rpx;
  195. &.Skeleton{
  196. width:220rpx;
  197. }
  198. }
  199. }
  200. .yticon {
  201. font-size: 44rpx;
  202. color: $font-color-base;
  203. margin: 0 10rpx 0 30rpx;
  204. }
  205. }
  206. .actions {
  207. padding: 10rpx 28rpx;
  208. background: #fff;
  209. .yticon {
  210. font-size: 46rpx;
  211. color: $font-color-base;
  212. padding: 10rpx 12rpx;
  213. &.active{
  214. color: #ff4443;
  215. }
  216. &:nth-child(2) {
  217. font-size: 50rpx;
  218. }
  219. }
  220. }
  221. .section-tit {
  222. font-size: $font-base+2rpx;
  223. color: $font-color-dark;
  224. margin-bottom: 30rpx;
  225. text-align:center;
  226. }
  227. .guess {
  228. display: flex;
  229. flex-direction: column;
  230. justify-content: center;
  231. align-items: center;
  232. padding: 30rpx 40rpx 10rpx;
  233. margin-top: 16rpx;
  234. background: #fff;
  235. }
  236. .guess-list {
  237. display: flex;
  238. flex-wrap: wrap;
  239. width: 100%;
  240. }
  241. .guess-item {
  242. display: flex;
  243. flex-direction: column;
  244. flex: 1;
  245. overflow: hidden;
  246. min-width: 40%;
  247. margin-right: 26rpx;
  248. padding-bottom: 40rpx;
  249. &:nth-child(2n) {
  250. margin-right: 0;
  251. }
  252. image {
  253. width: 100%;
  254. height: 200rpx;
  255. border-radius: 10rpx;
  256. }
  257. text {
  258. font-size: $font-sm;
  259. color: $font-color-light;
  260. &.Skeleton{
  261. width: 180rpx;
  262. &.title{
  263. width: 140rpx;
  264. }
  265. }
  266. &.title{
  267. font-size: $font-base+2rpx;
  268. color: $font-color-dark;
  269. margin-top:16rpx;
  270. margin-bottom: 8rpx;
  271. }
  272. }
  273. }
  274. .evalution{
  275. display:flex;
  276. flex-direction:column;
  277. background: #fff;
  278. margin-top: 16rpx;
  279. padding: 40rpx 0;
  280. }
  281. .eva-item{
  282. display:flex;
  283. padding: 20rpx 40rpx;
  284. image{
  285. width: 60rpx;
  286. height: 60rpx;
  287. border-radius: 50px;
  288. flex-shrink: 0;
  289. margin-right: 24rpx;
  290. }
  291. }
  292. .eva-right{
  293. display:flex;
  294. flex-direction:column;
  295. flex: 1;
  296. font-size: $font-sm + 2rpx;
  297. color: $font-color-light;
  298. position:relative;
  299. .zan-box{
  300. display:flex;
  301. align-items:base-line;
  302. position:absolute;
  303. top: 10rpx;
  304. right: 10rpx;
  305. .yticon{
  306. margin-left: 8rpx;
  307. }
  308. }
  309. .content{
  310. font-size: $font-base;
  311. color: #333;
  312. padding-top:20rpx;
  313. }
  314. }
  315. </style>