topic.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <app-layout>
  3. <view class="u-topic">
  4. <view class="topic" v-if="topic">
  5. <view class="title">{{topic.title}}</view>
  6. <view class="time plr-24">{{topic.read_count}}</view>
  7. <template v-if="topic.detail.length > 0">
  8. <block v-for="(temp, index) in topic.detail" :key="index">
  9. <template v-if="temp.id === 'image-text'">
  10. <view class="plr-24">
  11. <app-rich-text :content="temp.data.content"></app-rich-text>
  12. </view>
  13. </template>
  14. <template v-else-if="temp.id === 'rubik'">
  15. <view style="position: relative">
  16. <app-image-ad :image-style="temp.data.style" :list="temp.data.list"
  17. :height="temp.data.height"></app-image-ad>
  18. <block v-for="(hotspot, hotspot_index) in temp.data.hotspot" :key="hotspot_index">
  19. <view>
  20. <app-hotspot :hotspot="rubikHotspot(hotspot)"></app-hotspot>
  21. </view>
  22. </block>
  23. </view>
  24. </template>
  25. <template v-else-if="temp.id === 'video'">
  26. <view>
  27. <app-video :pic-url="temp.data.pic_url"
  28. :url="temp.data.url"
  29. ></app-video>
  30. </view>
  31. </template>
  32. </block>
  33. </template>
  34. </view>
  35. <view>
  36. <app-empty-bottom :height="Number(96)"></app-empty-bottom>
  37. </view>
  38. <view>
  39. <app-iphone-x>
  40. <view class="bar dir-left-nowrap cross-center" slot="empty-area">
  41. <view class="box-grow-1 dir-top-wrap cross-center" v-if="topic.is_favorite === 'love'" @click="favorite">
  42. <image src="../../static/image/icon/icon-favorite-active.png"></image>
  43. <view>已收藏</view>
  44. </view>
  45. <view class="box-grow-1 dir-top-wrap cross-center" v-else @click="favorite">
  46. <image src="../../static/image/icon/icon-favorite.png"></image>
  47. <view>收藏</view>
  48. </view>
  49. <view class="box-grow-1 dir-top-wrap cross-center" @click="shareClick">
  50. <image src="../../static/image/icon/icon-share.png"></image>
  51. <view>分享</view>
  52. </view>
  53. <app-share-qr-code-poster :theme="getTheme" v-model="shareShow" :url="poster" title="生成海报"></app-share-qr-code-poster>
  54. </view>
  55. </app-iphone-x>
  56. </view>
  57. </view>
  58. </app-layout>
  59. </template>
  60. <script>
  61. import {mapGetters, mapState} from "vuex";
  62. import appRichText from "../../components/basic-component/app-rich/parse";
  63. import appShareQrCodePoster from "../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue";
  64. import appIphoneX from '../../components/basic-component/app-iphone-x/app-iphone-x.vue';
  65. import appEmptyBottom from'../../components/basic-component/app-empty-bottom/app-empty-bottom.vue';
  66. import appVideo from "../../components/page-component/app-video/app-video.vue";
  67. import appImageAd from "../../components/page-component/app-image-ad/app-image-ad.vue";
  68. import appHotspot from "../../components/basic-component/app-hotspot/app-hotspot.vue";
  69. export default {
  70. name: "topic",
  71. components: {
  72. 'app-rich-text': appRichText,
  73. 'app-share-qr-code-poster': appShareQrCodePoster,
  74. appIphoneX,
  75. appEmptyBottom,
  76. 'app-video': appVideo,
  77. 'app-image-ad': appImageAd,
  78. 'app-hotspot': appHotspot,
  79. },
  80. computed: {
  81. ...mapState({
  82. gConfig: state => state.gConfig,
  83. }),
  84. ...mapGetters('mallConfig', {
  85. getTheme: 'getTheme',
  86. }),
  87. },
  88. data() {
  89. return {
  90. topic: null,
  91. is_loading: false,
  92. shareShow: false,
  93. poster: null,
  94. };
  95. },
  96. onLoad(options) {
  97. this.loadData(options.id);
  98. this.poster = this.$api.poster.topic + '&id=' + options.id
  99. },
  100. onShareAppMessage(object) {
  101. return this.$shareAppMessage({
  102. title: this.topic.app_share_title ? this.topic.app_share_title : this.topic.title,
  103. imageUrl: this.topic.qrcode_pic ? this.topic.qrcode_pic : '',
  104. path: '/pages/topic/topic',
  105. params: {
  106. id: this.topic.id
  107. }
  108. });
  109. },
  110. methods: {
  111. loadData(id) {
  112. this.$showLoading();
  113. this.$request({
  114. url: this.$api.topic.detail,
  115. data: {
  116. id: id
  117. }
  118. }).then(response => {
  119. this.$hideLoading();
  120. if (response.code === 0) {
  121. this.topic = response.data.list
  122. }
  123. }).catch(e => {
  124. this.$hideLoading();
  125. });
  126. },
  127. favorite() {
  128. if (this.is_loading) {
  129. return;
  130. }
  131. uni.showLoading({
  132. mark: true,
  133. title: '正在请求'
  134. });
  135. this.is_loading = true;
  136. let is_favorite = this.topic.is_favorite === 'no_love' ? 'love' : 'no_love';
  137. this.$request({
  138. url: this.$api.topic.favorite,
  139. data: {
  140. id: this.topic.id,
  141. is_favorite: is_favorite
  142. },
  143. method: 'post'
  144. }).then(response => {
  145. uni.hideLoading();
  146. this.is_loading = false;
  147. if (response.code === 0) {
  148. this.topic.is_favorite = is_favorite;
  149. uni.showToast({
  150. title: response.msg,
  151. mask: false
  152. })
  153. } else {
  154. uni.showModal({
  155. title: '提示',
  156. content: response.msg,
  157. showCancel: false,
  158. });
  159. }
  160. }).catch(e => {
  161. uni.hideLoading();
  162. this.is_loading = false;
  163. });
  164. },
  165. shareClick() {
  166. this.shareShow = true;
  167. },
  168. rubikHotspot(hotspot) {
  169. if (hotspot && hotspot.link) {
  170. hotspot.link.url = hotspot.link.new_link_url;
  171. hotspot.link.openType = hotspot.link.open_type;
  172. }
  173. return hotspot;
  174. },
  175. }
  176. }
  177. </script>
  178. <style scoped lang="scss">
  179. .topic {
  180. background-color: #ffffff;
  181. .title {
  182. padding: #{28rpx} #{24rpx} #{44rpx} #{24rpx};
  183. font-size: #{42rpx};
  184. }
  185. .time {
  186. margin-bottom: #{32rpx};
  187. font-size: $uni-font-size-general-two;
  188. color: $uni-general-color-two;
  189. }
  190. }
  191. .plr-24 {
  192. padding: 0 #{24rpx};
  193. }
  194. .bar {
  195. background-color: #ffffff;
  196. height: #{96rpx};
  197. width: 100%;
  198. border-top: #{1rpx} solid #e2e2e2;
  199. font-size: $uni-font-size-weak-one;
  200. color: $uni-general-color-two;
  201. image {
  202. width: #{40rpx};
  203. height: #{40rpx};
  204. }
  205. &>view {
  206. width: 50%;
  207. }
  208. }
  209. .u-topic {
  210. min-height: 100vh;
  211. background-color: #ffffff;
  212. }
  213. </style>