template.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view>
  3. <wike-skeleton :count="4" v-if="list.length === 0"></wike-skeleton>
  4. <view class="directask">
  5. <block v-for="(item, index) in list" :key="index">
  6. <!-- #ifdef MP-WEIXIN -->
  7. <view v-if="index == 0">
  8. <view class="wxad" v-if="appInfo.wxad_template && appInfo.wxad_template >= 1">
  9. <view style="width: 100%">
  10. <wike-flow-main :flowtype="appInfo.wxad_template" :banner_id="appInfo.banner_id"
  11. :video_banner_id="appInfo.video_banner_id"
  12. :native_id="appInfo.native_id"></wike-flow-main>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- #endif -->
  17. <view class="askaquestion u-flex align-center justify-between">
  18. <u--text :text="item.title" iconStyle="font-size: 21px;color: #26B3A0" size="15" prefixIcon="tags"
  19. :lines="1" bold block lineHeight="20"></u--text>
  20. </view>
  21. <view class="u-flex flex-wrap justify-between align-center">
  22. <navigator class="helpme" :url="'/pages/template/detail?id=' + row.id"
  23. v-for="(row, index2) in item.children" :key="index2">
  24. <view class="title">{{ row.title }}</view>
  25. <view class="sub_title">{{ row.sub_title }}</view>
  26. </navigator>
  27. </view>
  28. </block>
  29. <wike-ad></wike-ad>
  30. </view>
  31. <wike-tabbar :onTabbar="true" :isShowAnimate="true"></wike-tabbar>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapMutations,
  37. mapActions,
  38. mapState,
  39. mapGetters
  40. } from 'vuex';
  41. let interstitialAd = null,
  42. timer,
  43. time2;
  44. export default {
  45. data() {
  46. return {
  47. tobheight: 45,
  48. platform: this.$platform.get(),
  49. list: []
  50. };
  51. },
  52. computed: {
  53. ...mapGetters(['appInfo', 'userInfo', 'userData'])
  54. },
  55. onLoad() {
  56. var that = this;
  57. this.getList();
  58. },
  59. onReady() {
  60. let that = this;
  61. // #ifdef MP-WEIXIN
  62. clearTimeout(timer);
  63. // 在适合的场景显示插屏广告
  64. timer = setTimeout(function() {
  65. // 在页面onLoad回调事件中创建插屏广告实例
  66. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  67. interstitialAd = wx.createInterstitialAd({
  68. adUnitId: that.appInfo.interstitial_id
  69. });
  70. interstitialAd.onLoad(() => {});
  71. interstitialAd.onError(err => {});
  72. interstitialAd.onClose(() => {
  73. if (that.appInfo.interstitial_infinite_status == 1) {
  74. that.showInterstitial();
  75. }
  76. });
  77. interstitialAd.show().catch(err => {
  78. // console.error(err);
  79. });
  80. }
  81. }, 4000);
  82. // #endif
  83. },
  84. onUnload() {
  85. clearInterval(time2);
  86. },
  87. methods: {
  88. getList() {
  89. this.$http('template.list').then(res => {
  90. if (res.code == 0) {
  91. this.list = res.data;
  92. uni.setNavigationBarTitle({
  93. title: this.appInfo.site_name
  94. });
  95. }
  96. });
  97. },
  98. ondetails(id) {
  99. uni.navigateTo({
  100. url: '/pages/template/detail?id=' + id
  101. });
  102. },
  103. showInterstitial() {
  104. time2 = setInterval(
  105. function() {
  106. interstitialAd.show().catch(err => {
  107. // console.error(err);
  108. });
  109. },
  110. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  111. );
  112. }
  113. }
  114. };
  115. </script>
  116. <style lang="scss">
  117. .directask {
  118. padding: 30rpx 30rpx 200rpx;
  119. border-top: 1px solid #ededed;
  120. .askaquestion {
  121. font-size: 32rpx;
  122. margin-bottom: 30rpx;
  123. }
  124. .helpme {
  125. background: #f5f8f7;
  126. border-radius: 20rpx;
  127. padding: 30rpx;
  128. width: 48%;
  129. margin-bottom: 30rpx;
  130. height: 92px;
  131. .title {
  132. font-size: 30rpx;
  133. font-weight: bold;
  134. margin-bottom: 18rpx;
  135. color: #000;
  136. overflow:hidden; text-overflow:ellipsis; white-space:nowrap
  137. }
  138. .sub_title {
  139. color: #8f9ca2;
  140. font-size: 24rpx;
  141. overflow: hidden;
  142. text-overflow: ellipsis;
  143. display: -webkit-box;
  144. -webkit-box-orient: vertical;
  145. -webkit-line-clamp: 2;
  146. }
  147. }
  148. }
  149. .wxad {
  150. margin-bottom: 30rpx;
  151. border-radius: 20rpx;
  152. overflow: hidden;
  153. }
  154. </style>