金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
5.8 KiB

  1. <template>
  2. <view id="detail">
  3. <!--<wxparser rich-text="{{richText}}" bind:tapLink="jumpDetail" />-->
  4. <u-parse :content="richText" v-if="richText" @navigate="navigate" />
  5. <!-- #ifdef MP-WEIXIN -->
  6. <button class="share-box" open-type="share">
  7. <span class="iconfont icon--fenxiang"></span>
  8. 分享好友
  9. </button>
  10. <!-- #endif -->
  11. <!-- #ifdef APP-PLUS -->
  12. <button class="share-box" @click="shareapp">
  13. <span class="iconfont icon--fenxiang"></span>
  14. 分享好友
  15. </button>
  16. <!-- #endif -->
  17. <!-- #ifdef H5 -->
  18. <view >
  19. <uni-popup :show="type === 'middle-img'" position="top" mode="fixed" @hidePopup="togglePopup('')">
  20. <view class="uni-center center-box">
  21. <image style="position: absolute; top: 0;right:0" @tap="togglePopup('')" class="image" src="/static/ico-share-wechat.png" />
  22. </view>
  23. </uni-popup>
  24. </view>
  25. <!-- #endif -->
  26. </view>
  27. </template>
  28. <script>
  29. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  30. import uParse from '@/components/gaoyia-parse/parse.vue';
  31. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  32. export default {
  33. data() {
  34. return {
  35. richText: '',
  36. id: '',
  37. title: ''
  38. };
  39. },
  40. components:{
  41. uParse
  42. },
  43. //监听用户点击页面内转发按钮
  44. onShareAppMessage(res) {
  45. return {
  46. title: this.title,
  47. path: '/pages/article/detail/detail?id=' + this.id
  48. };
  49. },
  50. onLoad(e) {
  51. if (e.id) {
  52. this.queryVipList(e.id);
  53. this.setData({
  54. id: e.id
  55. });
  56. }
  57. },
  58. methods: {
  59. togglePopup(type) {
  60. this.type = type;
  61. },
  62. ShearUser(){
  63. this.togglePopup('middle-img')
  64. },
  65. // 获取文章页详情 getArticleDetail
  66. queryVipList(id) {
  67. wx.showLoading({
  68. title: "加载中",
  69. mask: true
  70. });
  71. this.$http.get({
  72. api: 'api/article/detail/' + id
  73. }).then(res => {
  74. if (res.statusCode == 200) {
  75. res = res.data;
  76. if (res.status) {
  77. var goods = res.data.goods_list;
  78. for (var i in goods) {
  79. // var str = `<a href="/pages/store/detail/detail?id=${goods[i].id}" style="display:block;overflow:visible">
  80. // <div style="width: 100%; background: url('${goods[i].img}');
  81. // padding-top: 100%; background-size: cover; position: relative">
  82. // <div style="position: absolute; top: 15px; right: 15px; width: 40px; height: 40px;
  83. // background: url('https://cdn.ibrand.cc/%20%E5%B0%8F%E7%A8%8B%E5%BA%8Fii7.png');
  84. // background-size: cover"></div></div><div style="color: #000000; display: flex;
  85. // align-items: center; justify-content: flex-end; margin-top: 10px">
  86. // <div style="width: 20px; height: 20px;margin-right: 10px;
  87. // background: url('https://cdn.ibrand.cc/%E7%AE%AD%E5%A4%B4434.png') no-repeat; background-size: 100%; "></div>点击图片立即购买</div></a>`;
  88. //
  89. var str = `<div style="position: relative"><div style="width: 100%; background: url('${goods[i].img}');
  90. padding-top: 100%; background-size: cover; position: relative"><div style="position: absolute; top: 15px;
  91. right: 15px; width: 40px; height: 40px;background: url('https://cdn.ibrand.cc/%20%E5%B0%8F%E7%A8%8B%E5%BA%8Fii7.png');
  92. background-size: cover"></div></div><div style="color: #000000; display: flex;align-items: center;
  93. justify-content: flex-end; margin-top: 10px"><div style="width: 20px; height: 20px;margin-right: 10px;
  94. background: url('https://cdn.ibrand.cc/%E7%AE%AD%E5%A4%B4434.png') no-repeat; background-size: 100%; "></div>
  95. <a href="/pages/store/detail/detail?id=${goods[i].id}">点击图片立即购买</a></div><a href="/pages/store/detail/detail?id=${goods[i].id}" style="display:block;overflow:visible; position: absolute; top: 0; left: 0; right: 0; bottom: 0"></a></div>`;
  96. res.data.article.article_detail = res.data.article.article_detail.replace("goods_" + goods[i].id, str);
  97. }
  98. this.setData({
  99. richText: res.data.article.article_detail,
  100. title: res.data.article.title
  101. });
  102. wx.setNavigationBarTitle({
  103. title: res.data.article.title
  104. });
  105. // #ifdef H5
  106. if (this.$wechat && this.$wechat.isWechat()) {
  107. var title=this.title;
  108. this.$wechat.share({
  109. title: title,
  110. img:'https://cdn.guojiang.club/h5_share_logo.png',
  111. dec:'果酱小店'
  112. });
  113. }
  114. // #endif
  115. } else {
  116. wx.showModal({
  117. content: res.message || '请求失败',
  118. showCancel: false
  119. });
  120. }
  121. } else {
  122. wx.showModal({
  123. content: res.message || '请求失败',
  124. showCancel: false
  125. });
  126. }
  127. wx.hideLoading();
  128. }).catch(rej => {
  129. wx.hideLoading();
  130. wx.showModal({
  131. content: rej.message || '请求失败',
  132. showCancel: false
  133. });
  134. });
  135. },
  136. jumpDetail(e) {
  137. console.log(e);
  138. wx.navigateTo({
  139. url: e.detail.href
  140. });
  141. },
  142. navigate(href, e) {
  143. console.log(href,e);
  144. wx.navigateTo({
  145. url: href
  146. });
  147. },
  148. setData: function (obj) {
  149. let that = this;
  150. let keys = [];
  151. let val, data;
  152. Object.keys(obj).forEach(function (key) {
  153. keys = key.split('.');
  154. val = obj[key];
  155. data = that.$data;
  156. keys.forEach(function (key2, index) {
  157. if (index + 1 == keys.length) {
  158. that.$set(data, key2, val);
  159. } else {
  160. if (!data[key2]) {
  161. that.$set(data, key2, {});
  162. }
  163. }
  164. data = data[key2];
  165. });
  166. });
  167. }
  168. },
  169. computed: {},
  170. watch: {}
  171. };
  172. </script>
  173. <style rel="stylesheet/less" lang="less">
  174. @import "detail";
  175. </style>