index.vue 6.8 KB

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