template.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view>
  3. <div class="addFix" v-if="showInitLead">
  4. <div class="leadBg">
  5. <div class="leadBox1" v-if="showLead1" :style="{'background-image': `url(${leadBaseUrl}yy_lead.png)`}">
  6. <div class="nextBtn" @click="nextLead">
  7. </div>
  8. </div>
  9. <div class="leadBox2" v-if="showLead2">
  10. <div class="nextBtn" @click="finishLead">
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <wike-skeleton :count="4" v-if="list.length === 0"></wike-skeleton>
  16. <!-- 新增顶部搜索框 -->
  17. <view class="searchBox">
  18. <uni-search-bar @confirm="searchConfirm" @input="handleInput" v-model="searchKey" placeholder="请输入关键词"
  19. radius="50" cancelButton="none" bgColor="#F3F4F6"></uni-search-bar>
  20. </view>
  21. <view class=" " v-if="searchKey">
  22. <view class="searchResList" v-if="searchList.length">
  23. <navigator class="item" v-for="(item,index) in searchList"
  24. :url="'/pages/template/detail?id=' + item.id">
  25. <view class="title">{{item.title}} </view>
  26. <view class="sub_title"> {{item.sub_title}}</view>
  27. </navigator>
  28. </view>
  29. <view class="" style="padding-top:162rpx ;" v-else>
  30. <u-empty mode="search" icon="/static/empty.png">
  31. </u-empty>
  32. </view>
  33. </view>
  34. <view class="" v-else style=" padding-top: 130rpx;">
  35. <view v-if="appInfo.page_template == 1 ||appInfo.page_template == 2 || !appInfo.page_template">
  36. <view v-if="appInfo.template_style&&appInfo.template_style == 1" class="directask">
  37. <block v-for="(item, index) in list" :key="index">
  38. <!-- #ifdef MP-WEIXIN -->
  39. <view v-if="index == 0">
  40. <view class="wxad" v-if="appInfo.wxad_template && appInfo.wxad_template >= 1">
  41. <view style="width: 100%">
  42. <wike-flow-main :flowtype="appInfo.wxad_template" :banner_id="appInfo.banner_id"
  43. :video_banner_id="appInfo.video_banner_id"
  44. :native_id="appInfo.native_id"></wike-flow-main>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- #endif -->
  49. <view class="askaquestion u-flex align-center justify-between" style="">
  50. <u--text style="position:relative;z-index:0" class="tagColor" :text="item.title"
  51. iconStyle="font-size: 21px;color:#207CF7;" size="15" prefixIcon="tags" :lines="1" bold
  52. block lineHeight="20"></u--text>
  53. </view>
  54. <!-- <view class="u-flex flex-wrap justify-between align-center"> -->
  55. <view class="" style="display: flex;flex-wrap: wrap;justify-content:space-between;">
  56. <navigator class="helpme" :url="'/pages/template/detail?id=' + row.id"
  57. v-for="(row, index2) in item.children" :key="index2">
  58. <view class="title">{{ row.title }}</view>
  59. <view class="sub_title">{{ row.sub_title }}</view>
  60. </navigator>
  61. </view>
  62. </block>
  63. <wike-ad></wike-ad>
  64. </view>
  65. <block v-else>
  66. <wike-scrollview v-if="list.length > 0" :viewList="list" :scrollHeight="pageheight"
  67. @leftClick="leftClick" @rightClick="rightClick"></wike-scrollview>
  68. </block>
  69. </view>
  70. <view v-else>
  71. <u-sticky bgColor="#fff"><u-tabs :list="list" @click="tabsClick" keyName="title"></u-tabs></u-sticky>
  72. <view class="directask">
  73. <view class="askaquestion u-flex align-center justify-between">
  74. <u--text :text="itemInfo.title" iconStyle="font-size: 21px;color: #26B3A0" size="15"
  75. prefixIcon="tags" :lines="1" bold block lineHeight="20"></u--text>
  76. </view>
  77. <view class="u-flex flex-wrap justify-between align-center">
  78. <navigator class="helpme" :url="'/pages/template/detail?id=' + row.id"
  79. v-for="(row, index2) in itemInfo.children" :key="index2">
  80. <view class="title">{{ row.title }}</view>
  81. <view class="sub_title">{{ row.sub_title }}</view>
  82. </navigator>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <wike-tabbar2 :currTabIndex='1' v-if="appInfo.page_template == 3" :is_aipainting="appInfo.is_aipainting"
  88. :onTabbar="true" :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar2>
  89. <wike-tabbar :currTabIndex='1' v-else :onTabbar="true" :is_aipainting="appInfo.is_aipainting"
  90. :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar>
  91. <u-modal @cancel="handleCancel" @confirm="handleConfirm" cancelText='退出登录' showCancelButton :show="showFixInfo"
  92. confirmColor="#26b3a0" confirmText="完善信息" title="请完善个人手机号信息后使用本应用"
  93. content='您已充值,但未绑定手机号,请完善信息以方便为您提供进一步的服务'></u-modal>
  94. </view>
  95. </template>
  96. <script>
  97. import BaseUrl from '@/common/config.js';
  98. import {
  99. mapMutations,
  100. mapActions,
  101. mapState,
  102. mapGetters
  103. } from 'vuex';
  104. let interstitialAd = null,
  105. timer,
  106. time2;
  107. export default {
  108. data() {
  109. return {
  110. leadBaseUrl: BaseUrl.leadBaseUrl,
  111. showInitLead: false,
  112. showLead2: false,
  113. showLead1: true,
  114. searchKey: '',
  115. searchList: [],
  116. tobheight: 45,
  117. pageheight: 0,
  118. platform: this.$platform.get(),
  119. list: [],
  120. itemInfo: {},
  121. is_aipainting: '',
  122. showFixInfo: false,
  123. };
  124. },
  125. computed: {
  126. ...mapGetters(['appInfo', 'userInfo', 'userData'])
  127. },
  128. watch: {
  129. searchKey(n, o) {
  130. if (n) {
  131. // uni.showLoading()
  132. setTimeout(() => {
  133. this.getSearchList(n)
  134. }, 1000)
  135. }
  136. }
  137. },
  138. onLoad() {
  139. this.showInitLead = !uni.getStorageSync('showInitLead_yy')
  140. console.log("uni.getStorageSync('showInitLead')", uni.getStorageSync('showInitLead_yy'));
  141. var that = this;
  142. this.getList();
  143. },
  144. onShow() {
  145. if (getApp().lastPage == 'templateDes') {
  146. getApp().lastPage = null
  147. } else {
  148. this.searchKey = ''
  149. this.searchList = []
  150. }
  151. this.$http('user.info').then(res => {
  152. if (res.code == 0) {
  153. console.log('用户是否是首次支付成功,但未填写手机号', res.data.is_new);
  154. this.showFixInfo = res.data.is_new;
  155. // this.showFixInfo = true;
  156. }
  157. })
  158. // #ifdef H5
  159. this.pageheight = uni.$u.sys().windowHeight - 70
  160. // #endif
  161. // #ifdef MP-WEIXIN
  162. this.pageheight = uni.$u.sys().windowHeight
  163. // #endif
  164. },
  165. onReady() {
  166. let that = this;
  167. // #ifdef MP-WEIXIN
  168. clearTimeout(timer);
  169. // 在适合的场景显示插屏广告
  170. timer = setTimeout(function() {
  171. // 在页面onLoad回调事件中创建插屏广告实例
  172. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  173. interstitialAd = wx.createInterstitialAd({
  174. adUnitId: that.appInfo.interstitial_id
  175. });
  176. interstitialAd.onLoad(() => {});
  177. interstitialAd.onError(err => {});
  178. interstitialAd.onClose(() => {
  179. if (that.appInfo.interstitial_infinite_status && that.appInfo
  180. .interstitial_infinite_status == 1) {
  181. that.showInterstitial();
  182. } else {
  183. interstitialAd.show().catch(err => {
  184. console.error(err);
  185. });
  186. }
  187. });
  188. interstitialAd.show().catch(err => {
  189. // console.error(err);
  190. });
  191. }
  192. }, 4000);
  193. // #endif
  194. },
  195. onUnload() {
  196. clearInterval(time2);
  197. },
  198. methods: {
  199. nextLead() {
  200. // this.showLead1 = false
  201. // this.showLead2 = true
  202. this.showInitLead = false
  203. this.showLead1 = false
  204. uni.setStorageSync('showInitLead_yy', true)
  205. },
  206. finishLead() {
  207. this.showInitLead = false
  208. this.showLead2 = false
  209. uni.setStorageSync('showInitLead_yy', true)
  210. },
  211. async getSearchList(search) {
  212. this.$http('template.list', {
  213. search
  214. }).then(res => {
  215. if (res.code == 0) {
  216. this.searchList = res.data;
  217. console.log('getSearchList返回值:', res);
  218. }
  219. });
  220. },
  221. handleInput() {
  222. },
  223. searchConfirm() {
  224. },
  225. ...mapActions(['getUserInfo', 'showAuthModal', 'getUserData', 'logout']),
  226. handleCancel() {
  227. this.showFixInfo = false
  228. this.logout()
  229. // uni.clearStorage()
  230. uni.reLaunch({
  231. url: '/pages/user/signin'
  232. })
  233. },
  234. handleConfirm() {
  235. uni.navigateTo({
  236. url: '/pages/user/userinfo?isNewUser=true'
  237. })
  238. },
  239. leftClick(e) {
  240. },
  241. getList() {
  242. this.$http('template.list').then(res => {
  243. if (res.code == 0) {
  244. this.list = res.data;
  245. // this.list = [];
  246. console.log('应用数据返回值------:', this.list);
  247. this.itemInfo = res.data[0]
  248. uni.setNavigationBarTitle({
  249. title: this.appInfo.site_name
  250. });
  251. }
  252. });
  253. },
  254. tabsClick(e) {
  255. // console.log(e);
  256. this.itemInfo = e
  257. },
  258. ondetails(id) {
  259. uni.navigateTo({
  260. url: '/pages/template/detail?id=' + id
  261. });
  262. },
  263. showInterstitial() {
  264. time2 = setInterval(
  265. function() {
  266. interstitialAd.show().catch(err => {
  267. // console.error(err);
  268. });
  269. },
  270. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  271. );
  272. }
  273. }
  274. };
  275. </script>
  276. <style lang="scss" scoped>
  277. @import '@/pages/template/template.scss';
  278. .tagColor {
  279. color: $tc;
  280. }
  281. .directask {
  282. padding: 30rpx 30rpx 200rpx;
  283. // border-top: 1px solid #ededed;
  284. .askaquestion {
  285. font-size: 32rpx;
  286. margin-bottom: 30rpx;
  287. }
  288. .helpme {
  289. // background: #f5f8f7;
  290. background: rgba(0, 53, 95, 0.06);
  291. border-radius: 20rpx;
  292. padding: 30rpx;
  293. width: 48%;
  294. margin-bottom: 30rpx;
  295. // height: 92px;
  296. .title {
  297. font-size: 30rpx;
  298. font-weight: bold;
  299. margin-bottom: 18rpx;
  300. color: #000;
  301. overflow: hidden;
  302. text-overflow: ellipsis;
  303. white-space: nowrap
  304. }
  305. .sub_title {
  306. color: #8f9ca2;
  307. font-size: 24rpx;
  308. overflow: hidden;
  309. text-overflow: ellipsis;
  310. display: -webkit-box;
  311. -webkit-box-orient: vertical;
  312. -webkit-line-clamp: 2;
  313. }
  314. }
  315. }
  316. .wxad {
  317. margin-bottom: 30rpx;
  318. border-radius: 20rpx;
  319. overflow: hidden;
  320. }
  321. </style>