index.vue 5.9 KB

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