topic.vue 7.1 KB

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