template.vue 5.7 KB

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