detail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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">{{$L('猜你喜欢')}}</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">{{$L('评论')}}</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: 90upx;
  163. padding: 20upx 0 20upx 40upx;
  164. background: #fff;
  165. }
  166. .episode-panel {
  167. white-space: nowrap;
  168. width: 100%;
  169. view {
  170. display: inline-block;
  171. margin-right: 30upx;
  172. width: 56upx;
  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: 10upx 40upx;
  184. background: #fff;
  185. .title {
  186. flex: 1;
  187. display: flex;
  188. flex-direction: column;
  189. font-size: $font-lg + 4upx;
  190. color: $font-color-dark;
  191. text:last-child {
  192. font-size: $font-sm;
  193. color: $font-color-light;
  194. margin-top: 4upx;
  195. &.Skeleton{
  196. width:220upx;
  197. }
  198. }
  199. }
  200. .yticon {
  201. font-size: 44upx;
  202. color: $font-color-base;
  203. margin: 0 10upx 0 30upx;
  204. }
  205. }
  206. .actions {
  207. padding: 10upx 28upx;
  208. background: #fff;
  209. .yticon {
  210. font-size: 46upx;
  211. color: $font-color-base;
  212. padding: 10upx 12upx;
  213. &.active{
  214. color: #ff4443;
  215. }
  216. &:nth-child(2) {
  217. font-size: 50upx;
  218. }
  219. }
  220. }
  221. .section-tit {
  222. font-size: $font-base+2upx;
  223. color: $font-color-dark;
  224. margin-bottom: 30upx;
  225. text-align:center;
  226. }
  227. .guess {
  228. display: flex;
  229. flex-direction: column;
  230. justify-content: center;
  231. align-items: center;
  232. padding: 30upx 40upx 10upx;
  233. margin-top: 16upx;
  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: 26upx;
  248. padding-bottom: 40upx;
  249. &:nth-child(2n) {
  250. margin-right: 0;
  251. }
  252. image {
  253. width: 100%;
  254. height: 200upx;
  255. border-radius: 10upx;
  256. }
  257. text {
  258. font-size: $font-sm;
  259. color: $font-color-light;
  260. &.Skeleton{
  261. width: 180upx;
  262. &.title{
  263. width: 140upx;
  264. }
  265. }
  266. &.title{
  267. font-size: $font-base+2upx;
  268. color: $font-color-dark;
  269. margin-top:16upx;
  270. margin-bottom: 8upx;
  271. }
  272. }
  273. }
  274. .evalution{
  275. display:flex;
  276. flex-direction:column;
  277. background: #fff;
  278. margin-top: 16upx;
  279. padding: 40upx 0;
  280. }
  281. .eva-item{
  282. display:flex;
  283. padding: 20upx 40upx;
  284. image{
  285. width: 60upx;
  286. height: 60upx;
  287. border-radius: 50px;
  288. flex-shrink: 0;
  289. margin-right: 24upx;
  290. }
  291. }
  292. .eva-right{
  293. display:flex;
  294. flex-direction:column;
  295. flex: 1;
  296. font-size: $font-sm + 2upx;
  297. color: $font-color-light;
  298. position:relative;
  299. .zan-box{
  300. display:flex;
  301. align-items:base-line;
  302. position:absolute;
  303. top: 10upx;
  304. right: 10upx;
  305. .yticon{
  306. margin-left: 8upx;
  307. }
  308. }
  309. .content{
  310. font-size: $font-base;
  311. color: #333;
  312. padding-top:20upx;
  313. }
  314. }
  315. </style>