index.vue 7.4 KB

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