index.vue 5.8 KB

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