articleDetail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view>
  3. <u-navbar :share="share" :back-text="newsDetail.title" back-icon-size="28" back-icon-color="#ffffff"
  4. :background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
  5. <view class="main">
  6. <view class="title">
  7. {{newsDetail.title}}
  8. </view>
  9. <view class="date-views">
  10. <view class="date">
  11. {{newsDetail.createTime}}
  12. </view>
  13. <view class="views">
  14. <view class="icon">
  15. <img src="@/assets/img/riLine-eye-line Copy@1x.png" alt="">
  16. </view>
  17. <view class="number">
  18. {{newsDetail.browseNumber}}
  19. </view>
  20. </view>
  21. </view>
  22. <u-line color="#e6e6e6"/>
  23. <view class="content news-content" v-html="newsDetail.content" >
  24. </view>
  25. </view>
  26. <view v-if="newsDetail.codeImage" class="codeImage">
  27. <image mode="aspectFit"
  28. v-if="newsDetail.codeImage" :src="newsDetail.codeImage" :show-menu-by-longpress="true" ></image>
  29. <view class="codeImageView" ><u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon> 长按图片<u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon></view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import * as API from '@/apis/pagejs/packages.js'
  35. export default {
  36. data() {
  37. return {
  38. id: '',
  39. share: 0,
  40. newsDetail: {},
  41. }
  42. },
  43. onShareTimeline(){
  44. return {
  45. title: "荆州经开区共享用工平台",
  46. }
  47. },
  48. onShareAppMessage(res) {
  49. if (res.from === 'button') { // 来自页面内分享按钮
  50. //.log(res.target)
  51. }
  52. return {
  53. title: this.newsDetail.title,
  54. path: '/pages/packages/news/articleDetail?shareMP=1&id=' + this.id
  55. }
  56. },
  57. onLoad(op) {
  58. if (op.shareMP) {
  59. this.share = op.shareMP
  60. }
  61. this.id =op.id;
  62. this.getNewsDetail();
  63. },
  64. methods: {
  65. customBack(){
  66. uni.redirectTo({
  67. url:"/pages/main/index/index"
  68. })
  69. },
  70. timestart(){
  71. console.log("aaa1")
  72. },
  73. timeend(){
  74. console.log("aaa2")
  75. },
  76. saveImg(){
  77. console.log("aaa3")
  78. },
  79. getNewsDetail() {
  80. uni.showLoading({
  81. title: "加载中",
  82. mask: true,
  83. })
  84. API.newsDetail({
  85. id:this.id
  86. }).then((res) => {
  87. uni.hideLoading()
  88. var newsDetail = res.data.newsInfo;
  89. if(newsDetail.content){
  90. var reg=new RegExp('alt','gi');
  91. newsDetail.content=newsDetail.content.replace(reg,'width="100%" height="100%" /> <p')
  92. }
  93. this.newsDetail=newsDetail
  94. }).catch(error => {
  95. uni.showToast({icon: 'none',
  96. title: error,
  97. icon: "none"
  98. })
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style>
  105. page {
  106. background: #F0F0F2;
  107. padding-bottom: 120px;
  108. }
  109. </style>
  110. <style lang="scss" scoped>
  111. .codeImage{
  112. background-color: #fff;
  113. text-align: center;
  114. .codeImageView{
  115. padding: 20rpx 0px 40rpx;
  116. font-size: 32rpx;
  117. }
  118. image{
  119. border: 1px dashed;
  120. width: 600rpx;
  121. }
  122. }
  123. .main{
  124. padding: 40rpx 32rpx;
  125. background-color: #fff;
  126. .title{
  127. color: rgba(16, 16, 16, 1);
  128. font-size: 40rpx;
  129. text-align: justify;
  130. line-height: 48rpx;
  131. }
  132. .date-views{
  133. margin-top: 64rpx;
  134. display: flex;
  135. justify-content: space-between;
  136. align-items: center;
  137. margin-bottom: 32rpx;
  138. .date{
  139. color: rgba(119, 119, 119, 1);
  140. font-size: 24rpx;
  141. }
  142. .views{
  143. display: flex;
  144. align-items: center;
  145. color: rgba(119, 119, 119, 1);
  146. font-size: 12px;
  147. img{
  148. width: 32rpx;
  149. height: 32rpx;
  150. vertical-align: middle;
  151. margin-right: 8rpx;
  152. }
  153. }
  154. }
  155. .content{
  156. color: rgba(51, 51, 51, 1);
  157. font-size: 32rpx;
  158. line-height: 56rpx;
  159. margin-top: 40rpx;
  160. }
  161. .news-picture{
  162. margin-top: 32rpx;
  163. height: 310rpx;
  164. overflow: hidden;
  165. img{
  166. width: 100%;
  167. height: 100%;
  168. }
  169. }
  170. .picture-title{
  171. color: rgba(119, 119, 119, 1);
  172. font-size: 24rpx;
  173. margin-top: 16rpx;
  174. text-align: center;
  175. }
  176. }
  177. </style>