articleDetail.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. "id": "",
  42. "title": "",
  43. "category": "",
  44. "content":"",
  45. "browseNumber": 0,
  46. "thumbnailImage": "",
  47. "createBy": "",
  48. "createTime": "",
  49. "updateBy": "",
  50. "updateTime": "",
  51. "status": "1",
  52. "codeImage": "",
  53. "categoryN": ""
  54. },
  55. }
  56. },
  57. onShareTimeline(){
  58. return {
  59. title: this.newsDetail.title,
  60. path: '/pages/packages/news/articleDetail?shareMP=1&id=' + this.id
  61. }
  62. },
  63. onShareAppMessage(res) {
  64. if (res.from === 'button') { // 来自页面内分享按钮
  65. //.log(res.target)
  66. }
  67. return {
  68. title: this.newsDetail.title,
  69. path: '/pages/packages/news/articleDetail?shareMP=1&id=' + this.id
  70. }
  71. },
  72. onLoad(op) {
  73. if (op.shareMP) {
  74. this.share = op.shareMP
  75. }
  76. this.id =op.id;
  77. this.getNewsDetail();
  78. },
  79. methods: {
  80. customBack(){
  81. uni.redirectTo({
  82. url:"/pages/main/index/index"
  83. })
  84. },
  85. timestart(){
  86. console.log("aaa1")
  87. },
  88. timeend(){
  89. console.log("aaa2")
  90. },
  91. saveImg(){
  92. console.log("aaa3")
  93. },
  94. getNewsDetail() {
  95. uni.showLoading({
  96. title: "加载中",
  97. mask: true,
  98. })
  99. API.newsDetail({
  100. id:this.id
  101. }).then((res) => {
  102. uni.hideLoading()
  103. var newsDetail = res.data.newsInfo;
  104. if(newsDetail.content){
  105. var reg=new RegExp('alt','gi');
  106. newsDetail.content=newsDetail.content.replace(reg,'width="100%" height="100%" /> <p')
  107. }
  108. this.newsDetail=newsDetail
  109. }).catch(error => {
  110. uni.showToast({icon: 'none',
  111. title: error,
  112. icon: "none"
  113. })
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style>
  120. page {
  121. background: #F0F0F2;
  122. padding-bottom: 120px;
  123. }
  124. </style>
  125. <style lang="scss" scoped>
  126. .codeImage{
  127. background-color: #fff;
  128. text-align: center;
  129. .codeImageView{
  130. padding: 20rpx 0px 40rpx;
  131. font-size: 32rpx;
  132. }
  133. image{
  134. border: 1px dashed;
  135. width: 700rpx;
  136. }
  137. }
  138. .main{
  139. padding: 40rpx 32rpx;
  140. background-color: #fff;
  141. .title{
  142. color: rgba(16, 16, 16, 1);
  143. font-size: 40rpx;
  144. text-align: justify;
  145. line-height: 48rpx;
  146. }
  147. .date-views{
  148. margin-top: 64rpx;
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. margin-bottom: 32rpx;
  153. .date{
  154. color: rgba(119, 119, 119, 1);
  155. font-size: 24rpx;
  156. }
  157. .views{
  158. display: flex;
  159. align-items: center;
  160. color: rgba(119, 119, 119, 1);
  161. font-size: 12px;
  162. img{
  163. width: 32rpx;
  164. height: 32rpx;
  165. vertical-align: middle;
  166. margin-right: 8rpx;
  167. }
  168. }
  169. }
  170. .content{
  171. color: rgba(51, 51, 51, 1);
  172. font-size: 32rpx;
  173. line-height: 56rpx;
  174. margin-top: 40rpx;
  175. }
  176. .news-picture{
  177. margin-top: 32rpx;
  178. height: 310rpx;
  179. overflow: hidden;
  180. img{
  181. width: 100%;
  182. height: 100%;
  183. }
  184. }
  185. .picture-title{
  186. color: rgba(119, 119, 119, 1);
  187. font-size: 24rpx;
  188. margin-top: 16rpx;
  189. text-align: center;
  190. }
  191. }
  192. </style>