articleDetail.vue 4.2 KB

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