index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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+'&mt=0'" hover-class="none" class="label">
  25. <text 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. // +----------------------------------------------------------------------
  42. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  43. // +----------------------------------------------------------------------
  44. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  45. // +----------------------------------------------------------------------
  46. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  47. // +----------------------------------------------------------------------
  48. // | Author: CRMEB Team <admin@crmeb.com>
  49. // +----------------------------------------------------------------------
  50. import {
  51. getArticleDetails
  52. } from '@/api/api.js';
  53. import {
  54. getProductDetail
  55. } from '@/api/product.js';
  56. import shareInfo from '../components/shareInfo';
  57. import parser from "../components/jyf-parser/jyf-parser";
  58. let app = getApp();
  59. export default {
  60. components: {
  61. shareInfo,
  62. "jyf-parser": parser
  63. },
  64. data() {
  65. return {
  66. id: 0,
  67. articleInfo: [],
  68. store_info: {},
  69. content: '',
  70. shareInfoStatus: false,
  71. tagStyle: {
  72. img: 'width:100%;display:block;',
  73. table: 'width:100%',
  74. video: 'width:100%'
  75. },
  76. productId: 0,
  77. theme: app.globalData.theme,
  78. bgColor: '#ffffff'
  79. };
  80. },
  81. /**
  82. * 生命周期函数--监听页面加载
  83. */
  84. onLoad: function(options) {
  85. if (options.hasOwnProperty('id')) {
  86. this.id = options.id;
  87. } else {
  88. // #ifndef H5
  89. uni.navigateBack({
  90. delta: 1
  91. });
  92. // #endif
  93. // #ifdef H5
  94. history.back();
  95. // #endif
  96. }
  97. },
  98. onShow: function() {
  99. this.getArticleOne();
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. // #ifdef MP
  105. onShareAppMessage: function() {
  106. return {
  107. title: this.articleInfo.title,
  108. imageUrl: this.articleInfo.imageInput.length ? this.articleInfo.imageInput : "",
  109. desc: this.articleInfo.synopsis,
  110. path: '/pages/news_details/index?id=' + this.id
  111. };
  112. },
  113. // #endif
  114. methods: {
  115. getArticleOne: function() {
  116. let that = this;
  117. getArticleDetails(that.id).then(res => {
  118. uni.setNavigationBarTitle({
  119. title: res.data.title.substring(0, 7) + "..."
  120. });
  121. that.$set(that, 'articleInfo', res.data);
  122. that.$set(that, 'productId', res.data.productId);
  123. if (res.data.productId) {
  124. that.goodInfo(res.data.productId);
  125. }
  126. that.content = res.data.content;
  127. // #ifdef H5
  128. if (this.$wechat.isWeixin()) {
  129. this.setShareInfo();
  130. }
  131. // #endif
  132. });
  133. },
  134. goodInfo(id) {
  135. getProductDetail(id).then(res => {
  136. this.$set(this, 'store_info', res.data.storeInfo ? res.data.storeInfo : {});
  137. })
  138. },
  139. listenerActionSheet() {
  140. this.shareInfoStatus = true
  141. },
  142. setShareInfoStatus() {
  143. this.shareInfoStatus = false
  144. },
  145. setShareInfo: function() {
  146. let href = location.href;
  147. let configAppMessage = {
  148. desc: this.articleInfo.synopsis,
  149. title: this.articleInfo.title,
  150. link: href,
  151. imgUrl: this.articleInfo.imageInput.length ? this.articleInfo.imageInput[0] : ""
  152. };
  153. this.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage);
  154. },
  155. bgTheme(value) {
  156. this.bgColor = value;
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .newsDetail {
  163. padding: 30rpx 0;
  164. }
  165. .newsDetail .title {
  166. padding: 0 30rpx;
  167. font-size: 34rpx;
  168. color: #282828;
  169. font-weight: bold;
  170. line-height: 1.5;
  171. }
  172. .newsDetail .list {
  173. margin: 28rpx 30rpx 0 30rpx;
  174. padding-bottom: 25rpx;
  175. }
  176. .newsDetail .list .label {
  177. font-size: 30rpx;
  178. color: #B1B2B3;
  179. }
  180. .newsDetail .list .item {
  181. margin-left: 27rpx;
  182. font-size: 30rpx;
  183. color: #B1B2B3;
  184. }
  185. .newsDetail .list .item .iconfont {
  186. font-size: 28rpx;
  187. margin-right: 10rpx;
  188. }
  189. .newsDetail .list .item .iconfont.icon-shenhezhong {
  190. font-size: 26rpx;
  191. }
  192. .newsDetail .picTxt {
  193. width: 690rpx;
  194. height: 200rpx;
  195. border-radius: 20rpx;
  196. border: 1px solid #e1e1e1;
  197. position: relative;
  198. margin: 30rpx auto 0 auto;
  199. }
  200. .newsDetail .picTxt .pictrue {
  201. width: 200rpx;
  202. height: 200rpx;
  203. }
  204. .newsDetail .picTxt .pictrue image {
  205. width: 100%;
  206. height: 100%;
  207. border-radius: 20rpx 0 0 20rpx;
  208. display: block;
  209. }
  210. .newsDetail .picTxt .text {
  211. width: 460rpx;
  212. }
  213. .newsDetail .picTxt .text .name {
  214. font-size: 30rpx;
  215. color: #282828;
  216. }
  217. .newsDetail .picTxt .text .money {
  218. font-size: 24rpx;
  219. margin-top: 40rpx;
  220. font-weight: bold;
  221. }
  222. .price_color {
  223. @include price_color(theme);
  224. }
  225. .newsDetail .picTxt .text .money .num {
  226. font-size: 36rpx;
  227. }
  228. .newsDetail .picTxt .text .y_money {
  229. font-size: 26rpx;
  230. color: #999;
  231. text-decoration: line-through;
  232. }
  233. .newsDetail .picTxt .label {
  234. position: absolute;
  235. background-color: #303131;
  236. width: 160rpx;
  237. height: 50rpx;
  238. right: -7rpx;
  239. border-radius: 25rpx 0 6rpx 25rpx;
  240. text-align: center;
  241. line-height: 50rpx;
  242. bottom: 24rpx;
  243. }
  244. .newsDetail .picTxt .label .span {
  245. background-image: linear-gradient(to right, #fff71e 0%, #f9b513 100%);
  246. -webkit-background-clip: text;
  247. -webkit-text-fill-color: transparent;
  248. }
  249. .newsDetail .picTxt .label:after {
  250. content: " ";
  251. position: absolute;
  252. width: 0;
  253. height: 0;
  254. border-bottom: 8rpx solid #303131;
  255. border-right: 8rpx solid transparent;
  256. top: -7rpx;
  257. right: 0;
  258. }
  259. .newsDetail .bnt {
  260. color: #fff;
  261. font-size: 30rpx;
  262. width: 690rpx;
  263. height: 90rpx;
  264. border-radius: 45rpx;
  265. margin: 48rpx auto;
  266. text-align: center;
  267. line-height: 90rpx;
  268. }
  269. .bg_color {
  270. @include main-bg_color(theme);
  271. }
  272. </style>