dynamicdetails.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="详情"
  5. :autoBack="true"
  6. :safeAreaInsetTop="true"
  7. >
  8. </u-navbar>
  9. <view class="page-wrap">
  10. <view class="title">{{pageData.title}}</view>
  11. <view class="info u-flex u-row-between">
  12. <view class="time">{{pageData.createTime}}</view>
  13. <view class="view-count">{{pageData.viewCount}}</view>
  14. </view>
  15. <view class="content-wrap">
  16. <u--image :src="pageData.mainImg" :showLoading="true" width="100%" mode="aspectFill"></u--image>
  17. <view class="content">
  18. {{pageData.content}}
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default{
  26. data(){
  27. return{
  28. id:null,
  29. pageData:{
  30. title:'',
  31. content:''
  32. },
  33. }
  34. },
  35. onLoad(page) {
  36. this.id = page.id;
  37. this.getDetails(this.id);
  38. this.addViewCount(this.id);
  39. },
  40. methods:{
  41. getDetails(id){
  42. this.$u.api.shopNews({id:id}).then(res=>{
  43. this.pageData = res.data;
  44. // console.log('res',res);
  45. }).catch(err=>{
  46. console.log('shopNews',err.data);
  47. })
  48. },
  49. addViewCount(id){
  50. this.$u.api.addViewCount({id:id}).then(res=>{
  51. // console.log('res',res);
  52. }).catch(err=>{
  53. console.log('addViewCount',err.data);
  54. })
  55. }
  56. }
  57. }
  58. </script>
  59. <style>
  60. page{background-color: #F5F5F5;}
  61. </style>
  62. <style lang="scss" scoped>
  63. .title{
  64. font-size: 36rpx;
  65. font-weight: 600;
  66. color: #333333;
  67. line-height: 50rpx;
  68. margin-bottom: 20rpx;
  69. }
  70. .info{
  71. margin-bottom: 50rpx;
  72. font-size: 24rpx;
  73. font-weight: 400;
  74. color: #999999;
  75. line-height: 33rpx;
  76. }
  77. .content{
  78. font-size: 26rpx;
  79. font-weight: 400;
  80. color: #666666;
  81. line-height: 44rpx;
  82. margin: 20rpx 0;
  83. }
  84. .u-image{
  85. max-width: 100%;
  86. }
  87. </style>