You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

297 lines
6.6 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <view class='newsDetail' :style="{backgroundColor:bgColor}">
  4. <view class='title'>{{articleInfo.title}}</view>
  5. <view class='list acea-row row-middle'>
  6. <view class='label'>{{articleInfo.author}}</view>
  7. <view class='item'></text>{{articleInfo.createTime}}</view>
  8. <view class='item'><text class='iconfont icon-liulan'></text>{{articleInfo.visit}}</view>
  9. </view>
  10. <view class='conter'>
  11. <jyf-parser :html="content" ref="article" :tag-style="tagStyle"></jyf-parser>
  12. </view>
  13. <view class="picTxt acea-row row-between-wrapper" v-if="store_info.id">
  14. <view class="pictrue">
  15. <image :src="store_info.image"></image>
  16. </view>
  17. <view class="text">
  18. <view class="name line1">{{store_info.storeName}}</view>
  19. <view class="money price_color">
  20. <text class="num">{{store_info.price}}</text>
  21. </view>
  22. <view class="y_money">{{store_info.otPrice}}</view>
  23. </view>
  24. <navigator :url="'/pages/goods/goods_details/index?id='+store_info.id" hover-class="none" class="label"><text
  25. class="span">查看商品</text></navigator>
  26. </view>
  27. <!-- #ifdef H5 -->
  28. <button class="bnt bg_color" hover-class='none' @click="listenerActionSheet"
  29. v-if="this.$wechat.isWeixin()">和好友一起分享</button>
  30. <!-- #endif -->
  31. <!-- #ifdef MP -->
  32. <button class="bnt bg_color" open-type="share" hover-class='none'>和好友一起分享</button>
  33. <!-- #endif -->
  34. </view>
  35. <shareInfo @setShareInfoStatus="setShareInfoStatus" :shareInfoStatus="shareInfoStatus"></shareInfo>
  36. <view class="article_theme">
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. getArticleDetails
  43. } from '@/api/api.js';
  44. import {
  45. getProductDetail
  46. } from '@/api/store.js';
  47. import shareInfo from '@/components/shareInfo';
  48. import parser from "@/components/jyf-parser/jyf-parser";
  49. let app = getApp();
  50. export default {
  51. components: {
  52. shareInfo,
  53. "jyf-parser": parser
  54. },
  55. data() {
  56. return {
  57. id: 0,
  58. articleInfo: [],
  59. store_info: {},
  60. content: '',
  61. shareInfoStatus: false,
  62. tagStyle: {
  63. img: 'width:100%;display:block;',
  64. table: 'width:100%',
  65. video: 'width:100%'
  66. },
  67. productId: 0,
  68. theme: app.globalData.theme,
  69. bgColor:'#ffffff'
  70. };
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad: function(options) {
  76. if (options.hasOwnProperty('id')) {
  77. this.id = options.id;
  78. } else {
  79. // #ifndef H5
  80. uni.navigateBack({
  81. delta: 1
  82. });
  83. // #endif
  84. // #ifdef H5
  85. history.back();
  86. // #endif
  87. }
  88. },
  89. onShow: function() {
  90. this.getArticleOne();
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. // #ifdef MP
  96. onShareAppMessage: function() {
  97. return {
  98. title: this.articleInfo.title,
  99. imageUrl: this.articleInfo.imageInput.length ? this.articleInfo.imageInput : "",
  100. desc: this.articleInfo.synopsis,
  101. path: '/pages/news/news_details/index?id=' + this.id
  102. };
  103. },
  104. // #endif
  105. methods: {
  106. getArticleOne: function() {
  107. let that = this;
  108. getArticleDetails({
  109. id: that.id
  110. }).then(res => {
  111. uni.setNavigationBarTitle({
  112. title: res.data.title.substring(0, 7) + "..."
  113. });
  114. that.$set(that, 'articleInfo', res.data);
  115. that.$set(that, 'productId', res.data.productId);
  116. if (res.data.productId) {
  117. that.goodInfo(res.data.productId);
  118. }
  119. that.content = res.data.content;
  120. // #ifdef H5
  121. if (this.$wechat.isWeixin()) {
  122. this.setShareInfo();
  123. }
  124. // #endif
  125. });
  126. },
  127. goodInfo(id) {
  128. getProductDetail(id).then(res => {
  129. this.$set(this, 'store_info', res.data.storeInfo ? res.data.storeInfo : {});
  130. })
  131. },
  132. listenerActionSheet() {
  133. this.shareInfoStatus = true
  134. },
  135. setShareInfoStatus() {
  136. this.shareInfoStatus = false
  137. },
  138. setShareInfo: function() {
  139. let href = location.href;
  140. let configAppMessage = {
  141. desc: this.articleInfo.synopsis,
  142. title: this.articleInfo.title,
  143. link: href,
  144. imgUrl: this.articleInfo.imageInput.length ? this.articleInfo.imageInput[0] : ""
  145. };
  146. this.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage);
  147. },
  148. bgTheme(value){
  149. this.bgColor = value;
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. // page {
  156. // background-color: #fff !important;
  157. // }
  158. .newsDetail {
  159. // background-color: #fff;
  160. // background-color: #D8EFD2;
  161. // background-color: #F9F2E2;
  162. // background-color: #D9EBED;
  163. // background-color: #131313;
  164. // color: #fff !important;
  165. padding: 30rpx 0;
  166. }
  167. .newsDetail .title {
  168. padding: 0 30rpx;
  169. font-size: 34rpx;
  170. color: #282828;
  171. font-weight: bold;
  172. line-height: 1.5;
  173. }
  174. .newsDetail .list {
  175. margin: 28rpx 30rpx 0 30rpx;
  176. padding-bottom: 25rpx;
  177. }
  178. .newsDetail .list .label {
  179. font-size: 30rpx;
  180. color: #B1B2B3;
  181. }
  182. .newsDetail .list .item {
  183. margin-left: 27rpx;
  184. font-size: 30rpx;
  185. color: #B1B2B3;
  186. }
  187. .newsDetail .list .item .iconfont {
  188. font-size: 28rpx;
  189. margin-right: 10rpx;
  190. }
  191. .newsDetail .list .item .iconfont.icon-shenhezhong {
  192. font-size: 26rpx;
  193. }
  194. .newsDetail .picTxt {
  195. width: 690rpx;
  196. height: 200rpx;
  197. border-radius: 20rpx;
  198. border: 1px solid #e1e1e1;
  199. position: relative;
  200. margin: 30rpx auto 0 auto;
  201. }
  202. .newsDetail .picTxt .pictrue {
  203. width: 200rpx;
  204. height: 200rpx;
  205. }
  206. .newsDetail .picTxt .pictrue image {
  207. width: 100%;
  208. height: 100%;
  209. border-radius: 20rpx 0 0 20rpx;
  210. display: block;
  211. }
  212. .newsDetail .picTxt .text {
  213. width: 460rpx;
  214. }
  215. .newsDetail .picTxt .text .name {
  216. font-size: 30rpx;
  217. color: #282828;
  218. }
  219. .newsDetail .picTxt .text .money {
  220. font-size: 24rpx;
  221. margin-top: 40rpx;
  222. font-weight: bold;
  223. }
  224. .price_color {
  225. @include price_color(theme);
  226. }
  227. .newsDetail .picTxt .text .money .num {
  228. font-size: 36rpx;
  229. }
  230. .newsDetail .picTxt .text .y_money {
  231. font-size: 26rpx;
  232. color: #999;
  233. text-decoration: line-through;
  234. }
  235. .newsDetail .picTxt .label {
  236. position: absolute;
  237. background-color: #303131;
  238. width: 160rpx;
  239. height: 50rpx;
  240. right: -7rpx;
  241. border-radius: 25rpx 0 6rpx 25rpx;
  242. text-align: center;
  243. line-height: 50rpx;
  244. bottom: 24rpx;
  245. }
  246. .newsDetail .picTxt .label .span {
  247. background-image: linear-gradient(to right, #fff71e 0%, #f9b513 100%);
  248. -webkit-background-clip: text;
  249. -webkit-text-fill-color: transparent;
  250. }
  251. .newsDetail .picTxt .label:after {
  252. content: " ";
  253. position: absolute;
  254. width: 0;
  255. height: 0;
  256. border-bottom: 8rpx solid #303131;
  257. border-right: 8rpx solid transparent;
  258. top: -7rpx;
  259. right: 0;
  260. }
  261. .newsDetail .bnt {
  262. color: #fff;
  263. font-size: 30rpx;
  264. width: 690rpx;
  265. height: 90rpx;
  266. border-radius: 45rpx;
  267. margin: 48rpx auto;
  268. text-align: center;
  269. line-height: 90rpx;
  270. }
  271. .bg_color {
  272. @include main-bg_color(theme);
  273. }
  274. </style>