index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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'></text>{{articleInfo.createTime}}</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. <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 font-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_details/index?id='+store_info.id" hover-class="none" class="label"><text class="span">查看商品</text></navigator>
  25. </view>
  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 {
  42. getProductDetail
  43. } from '@/api/store.js';
  44. import shareInfo from '@/components/shareInfo';
  45. import home from '@/components/home';
  46. import parser from "@/components/jyf-parser/jyf-parser";
  47. export default {
  48. components: {
  49. shareInfo,
  50. home,
  51. "jyf-parser": parser
  52. },
  53. data() {
  54. return {
  55. id: 0,
  56. articleInfo: [],
  57. store_info: {},
  58. content:'',
  59. shareInfoStatus:false,
  60. tagStyle: {
  61. img: 'width:100%;'
  62. },
  63. productId: 0
  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. /**
  85. * 用户点击右上角分享
  86. */
  87. // #ifdef MP
  88. onShareAppMessage: function() {
  89. return {
  90. title: this.articleInfo.title,
  91. imageUrl: this.articleInfo.imageInput.length ? this.articleInfo.imageInput[0] : "",
  92. desc: this.articleInfo.synopsis,
  93. path: '/pages/news_details/index?id=' + this.id
  94. };
  95. },
  96. // #endif
  97. methods: {
  98. getArticleOne:function(){
  99. let that = this;
  100. getArticleDetails({id:that.id}).then(res=>{
  101. uni.setNavigationBarTitle({
  102. title:res.data.title.substring(0,7) + "..."
  103. });
  104. that.$set(that,'articleInfo',res.data);
  105. that.$set(that,'productId',res.data.productId);
  106. if(res.data.productId){
  107. that.goodInfo(res.data.productId);
  108. }
  109. that.content = res.data.content;
  110. // #ifdef H5
  111. if(this.$wechat.isWeixin()){
  112. this.setShareInfo();
  113. }
  114. // #endif
  115. });
  116. },
  117. goodInfo(id){
  118. getProductDetail(id).then(res=>{
  119. this.$set(this,'store_info',res.data.storeInfo?res.data.storeInfo:{});
  120. })
  121. },
  122. listenerActionSheet(){
  123. this.shareInfoStatus = true
  124. },
  125. setShareInfoStatus(){
  126. this.shareInfoStatus = false
  127. },
  128. setShareInfo: function() {
  129. let href = location.href;
  130. let configAppMessage = {
  131. desc: this.articleInfo.synopsis,
  132. title: this.articleInfo.title,
  133. link: href,
  134. imgUrl: this.articleInfo.imageInput.length ? this.articleInfo.imageInput[0] : ""
  135. };
  136. this.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage);
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. page {
  143. background-color: #fff !important;
  144. }
  145. .newsDetail{
  146. padding: 30rpx 0;
  147. }
  148. .newsDetail .title {
  149. padding: 0 30rpx;
  150. font-size: 34rpx;
  151. color: #282828;
  152. font-weight: bold;
  153. line-height: 1.5;
  154. }
  155. .newsDetail .list {
  156. margin: 28rpx 30rpx 0 30rpx;
  157. padding-bottom: 25rpx;
  158. }
  159. .newsDetail .list .label {
  160. font-size: 30rpx;
  161. color: #B1B2B3;
  162. }
  163. .newsDetail .list .item {
  164. margin-left: 27rpx;
  165. font-size: 30rpx;
  166. color: #B1B2B3;
  167. }
  168. .newsDetail .list .item .iconfont {
  169. font-size: 28rpx;
  170. margin-right: 10rpx;
  171. }
  172. .newsDetail .list .item .iconfont.icon-shenhezhong {
  173. font-size: 26rpx;
  174. }
  175. .newsDetail .conters {
  176. padding: 0 30rpx;
  177. font-size: 32rpx;
  178. color: #8A8B8C;
  179. line-height: 1.7;
  180. }
  181. .newsDetail .picTxt {
  182. width: 690rpx;
  183. height: 200rpx;
  184. border-radius: 20rpx;
  185. border: 1px solid #e1e1e1;
  186. position: relative;
  187. margin: 30rpx auto 0 auto;
  188. }
  189. .newsDetail .picTxt .pictrue {
  190. width: 200rpx;
  191. height: 200rpx;
  192. }
  193. .newsDetail .picTxt .pictrue image {
  194. width: 100%;
  195. height: 100%;
  196. border-radius: 20rpx 0 0 20rpx;
  197. display: block;
  198. }
  199. .newsDetail .picTxt .text {
  200. width: 460rpx;
  201. }
  202. .newsDetail .picTxt .text .name {
  203. font-size: 30rpx;
  204. color: #282828;
  205. }
  206. .newsDetail .picTxt .text .money {
  207. font-size: 24rpx;
  208. margin-top: 40rpx;
  209. font-weight: bold;
  210. }
  211. .newsDetail .picTxt .text .money .num {
  212. font-size: 36rpx;
  213. }
  214. .newsDetail .picTxt .text .y_money {
  215. font-size: 26rpx;
  216. color: #999;
  217. text-decoration: line-through;
  218. }
  219. .newsDetail .picTxt .label {
  220. position: absolute;
  221. background-color: #303131;
  222. width: 160rpx;
  223. height: 50rpx;
  224. right: -7rpx;
  225. border-radius: 25rpx 0 6rpx 25rpx;
  226. text-align: center;
  227. line-height: 50rpx;
  228. bottom: 24rpx;
  229. }
  230. .newsDetail .picTxt .label .span {
  231. background-image: linear-gradient(to right, #fff71e 0%, #f9b513 100%);
  232. -webkit-background-clip: text;
  233. -webkit-text-fill-color: transparent;
  234. }
  235. .newsDetail .picTxt .label:after {
  236. content: " ";
  237. position: absolute;
  238. width: 0;
  239. height: 0;
  240. border-bottom: 8rpx solid #303131;
  241. border-right: 8rpx solid transparent;
  242. top: -7rpx;
  243. right: 0;
  244. }
  245. .newsDetail .bnt {
  246. color: #fff;
  247. font-size: 30rpx;
  248. width: 690rpx;
  249. height: 90rpx;
  250. border-radius: 45rpx;
  251. margin: 48rpx auto;
  252. text-align: center;
  253. line-height: 90rpx;
  254. }
  255. </style>