index.vue 5.9 KB

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