index.vue 6.8 KB

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