index.vue 6.8 KB

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