index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <app-layout :haveBackground="haveBackground">
  3. <app-my-app></app-my-app>
  4. <view v-if="type === 'mall'">
  5. <app-index v-if="destroy"
  6. :page-hide="pageHide"
  7. :home-pages="homePages"
  8. :scrollTop="scrollTop"
  9. :is_storage="is_storage"
  10. ></app-index>
  11. </view>
  12. <view v-else-if="type === 'diy'">
  13. <app-diy-page v-if="destroy"
  14. :page-hide="pageHide"
  15. :home-pages="homePages"
  16. :scrollTop="scrollTop"
  17. :is_storage="is_storage"
  18. ></app-diy-page>
  19. </view>
  20. <!-- <view class="course">
  21. <view class="custom-header-container">
  22. <view class="header-bg" :style="{height:headerBgHeight}">
  23. <image src="../../static/image/course/bg.png"/>
  24. </view>
  25. <view class="custom-header-status-bar" :style="{height:getStausBarHeight}"></view>
  26. <view class="custom-header-top-container">
  27. <view class="custom-header-title">课程报名</view>
  28. </view>
  29. </view>
  30. <view class="banner">
  31. <swiper class="swipe" indicator-dots="true" autoplay="true" interval="5000" duration="1500">
  32. <swiper-item :url="item.url" v-for="(item, index) in bannerImg" :key="index">
  33. <image :src="item.img" mode="aspectFill" :title="item.title" class="banner-img"/>
  34. </swiper-item>
  35. </swiper>
  36. </view>
  37. <view class="course-list-icon">
  38. <view class="img">
  39. <image src="../../static/image/course/creation.png" mode=""></image>
  40. </view>
  41. <text>课程报名</text>
  42. </view>
  43. <view class="course-list">
  44. <view class="course-list-item" v-for="(item, index) in courseListData" :key="index">
  45. <view class="course-item-left">
  46. <image :src="item.img" mode=""></image>
  47. </view>
  48. <view class="course-item-right">
  49. <view class="course-item-title">
  50. {{item.title}}
  51. </view>
  52. <view class="course-item-content">
  53. {{item.content}}
  54. </view>
  55. <view class="course-item-moneyAndBtn">
  56. <view class="moneyAndBtn-money">
  57. <text>¥</text> 30.00
  58. </view>
  59. <view class="moneyAndBtn-btn" @click="navTo">
  60. 立即报名
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="placeholder-view">
  66. </view>
  67. </view>
  68. </view> -->
  69. <app-buy-prompt v-if="config.is_purchase_frame === `1`"></app-buy-prompt>
  70. </app-layout>
  71. </template>
  72. <script>
  73. import appIndex from '../../components/page-component/index/app-index.vue';
  74. import appDiyPage from '../../components/page-component/index/app-diy-page.vue';
  75. import appBuyPrompt from '../../components/page-component/app-buy-prompt/app-buy-prompt.vue';
  76. import {getStorageSync, setStorageSync} from '../../core/cache.js';
  77. import {mapGetters, mapState} from 'vuex';
  78. import appMyApp from '../../components/page-component/app-my-app/app-my-app.vue';
  79. let page_id = 0;
  80. export default {
  81. name: 'index',
  82. components: {
  83. 'app-index': appIndex,
  84. 'app-diy-page': appDiyPage,
  85. appBuyPrompt,
  86. appMyApp
  87. },
  88. data() {
  89. return {
  90. scrollTop: 0,
  91. homePages: [],
  92. type: '',
  93. is_storage: false,
  94. haveBackground: true,
  95. // newHomePages: [],
  96. destroy: true,
  97. // page_id: 152,
  98. pageHide: false,
  99. courseListData:[
  100. {
  101. img:'../../static/image/course/img1.png',
  102. title: '4-6岁幼儿兴趣班',
  103. content: '适合4岁至6岁的小朋友学习开发运动潜力',
  104. },
  105. {
  106. img:'../../static/image/course/img2.png',
  107. title: '7-9岁幼儿兴趣班',
  108. content: '适合4岁至6岁的小朋友学习开发运动潜力',
  109. },
  110. {
  111. img:'../../static/image/course/img3.png',
  112. title: '9-12岁幼儿兴趣班',
  113. content: '适合4岁至6岁的小朋友学习开发运动潜力',
  114. },
  115. {
  116. img:'../../static/image/course/img4.png',
  117. title: '12-15岁幼儿兴趣班',
  118. content: '适合4岁至6岁的小朋友学习开发运动潜力',
  119. },
  120. ],
  121. bannerImg:[
  122. {img:'../../static/image/course/banner.png'}
  123. ]
  124. }
  125. },
  126. onShow(e) {
  127. console.log('page onShow--->'); // 公众号文章进小程序无底部导航调试,请勿删除
  128. console.log(e); // 公众号文章进小程序无底部导航调试,请勿删除
  129. console.log('<---page onShow'); // 公众号文章进小程序无底部导航调试,请勿删除
  130. uni.hideNavigationBarLoading();
  131. // #ifdef MP-TOUTIAO
  132. this.destroy = true;
  133. // #endif
  134. this.pageHide = false;
  135. },
  136. onHide() {
  137. // #ifdef MP-TOUTIAO
  138. this.destroy = false;
  139. // #endif
  140. this.pageHide = true;
  141. },
  142. onLoad(options) {
  143. console.log('page onLoad--->'); // 公众号文章进小程序无底部导航调试,请勿删除
  144. console.log(options); // 公众号文章进小程序无底部导航调试,请勿删除
  145. console.log('<---page onLoad'); // 公众号文章进小程序无底部导航调试,请勿删除
  146. if (typeof options.scene !== 'undefined') {
  147. if (options.scene === 'share') {
  148. this.share(options);
  149. } else {
  150. this.qrcode(options);
  151. }
  152. } else {
  153. this.$showLoading();
  154. }
  155. // #ifdef MP-ALIPAY
  156. let query = this.$store.state.page.query;
  157. if (query && typeof query.scene !== 'undefined') this.qrcode(query);
  158. // #endif
  159. if (typeof options.user_id !== 'undefined') {
  160. this.$store.dispatch('user/setTempParentId', options.user_id)
  161. }
  162. page_id = typeof options.page_id !== 'undefined' ? options.page_id : 0;
  163. // let index_data = getStorageSync('__index_data');
  164. //
  165. // if (index_data && page_id == 0) {
  166. // this.is_storage = true;
  167. // this.type = index_data.type;
  168. // this.homePages = index_data.home_pages;
  169. // }
  170. this.loadData();
  171. },
  172. /* #ifdef MP_WEIXIN || MP_BAIDU */
  173. onPageScroll(e) {
  174. this.$store.dispatch('page/actionSetScrollTop', e.scrollTop);
  175. },
  176. /* #endif */
  177. methods: {
  178. navTo(){
  179. uni.navigateTo({
  180. url: '/pages/goods/goods'
  181. })
  182. },
  183. loadData() {
  184. let that = this;
  185. uni.showNavigationBarLoading();
  186. that.$request({
  187. url: that.$api.index.index,
  188. method: 'get',
  189. data: {
  190. page_id: page_id,
  191. longitude: '',
  192. latitude: '',
  193. }
  194. }).then(response => {
  195. uni.hideNavigationBarLoading();
  196. this.$hideLoading();
  197. let {code, data} = response;
  198. if (code === 0) {
  199. that.is_storage = false;
  200. that.$popupAd.show = null;
  201. that.homePages = data.home_pages;
  202. if(that.homePages.navs && that.homePages.navs.length > 0) {
  203. that.homePages.navs.forEach(function(row,inedx){
  204. row.template.data.forEach(function(v,idx){
  205. if(v.id == 'background') {
  206. that.haveBackground = false;
  207. return false;
  208. }
  209. })
  210. })
  211. }
  212. that.type = data.type;
  213. // if (page_id == 0) setStorageSync('__index_data', data);
  214. } else {
  215. }
  216. })
  217. },
  218. share(options) {
  219. if (typeof options.params !== 'undefined') {
  220. let params = JSON.parse(options.params);
  221. this.$jump({
  222. url: params.path + '?' + this.$utils.objectToUrlParams(params),
  223. open_type: 'navigate'
  224. });
  225. }
  226. },
  227. qrcode(options) {
  228. this.$request({
  229. url: this.$api.default.qrcode_parameter,
  230. data: {
  231. token: options.scene
  232. }
  233. }).then(response => {
  234. if (response.code === 0) {
  235. this.$store.dispatch('page/actionSetQeury', null);
  236. let {data, path} = response.data.detail;
  237. let url = `/${path}`;
  238. if (data) {
  239. url += '?' + this.$utils.objectToUrlParams(data);
  240. if (typeof data.user_id !== 'undefined') {
  241. this.$store.dispatch('user/setTempParentId', data.user_id)
  242. }
  243. }
  244. if (`/${path}` != '/pages/index/index') {
  245. this.$jump({
  246. url: url,
  247. open_type: 'navigate'
  248. });
  249. }
  250. }
  251. }).catch(() => {
  252. });
  253. }
  254. },
  255. onShareAppMessage() {
  256. let args = {
  257. path: '/pages/index/index',
  258. params: {}
  259. };
  260. if (page_id == 0) {
  261. args.title = this.mall.setting.share_title ? this.mall.setting.share_title : this.mall.name;
  262. args.imageUrl = this.mall.setting.share_pic
  263. } else {
  264. args.title = this.homePages.title;
  265. args.params.page_id = page_id;
  266. }
  267. return this.$shareAppMessage(args);
  268. },
  269. computed: {
  270. ...mapGetters('mallConfig', {
  271. tabBarNavs: 'getNavBar',
  272. }),
  273. ...mapState('mallConfig', {
  274. config: state => state.mall.setting,
  275. mall: state => state.mall,
  276. }),
  277. getStausBarHeight(){
  278. try {
  279. const res = uni.getSystemInfoSync();
  280. return res.statusBarHeight + 'px';
  281. } catch (err) {
  282. console.log(err)
  283. }
  284. },
  285. headerBgHeight(){
  286. try {
  287. const res = uni.getSystemInfoSync();
  288. return 120+44+res.statusBarHeight + 'px';
  289. } catch (err) {
  290. console.log(err)
  291. }
  292. }
  293. },
  294. };
  295. </script>
  296. <style lang="scss">
  297. .custom-header-container{
  298. width: 100%;
  299. top: 0;
  300. z-index: 0;
  301. display: flex;
  302. flex-direction: column;
  303. align-items: center;
  304. background: #fff;
  305. font-size: 26upx;
  306. background: transparent;
  307. .header-bg{
  308. width: 100%;
  309. position: absolute;
  310. overflow: hidden;
  311. z-index: 0;
  312. image{
  313. width: 100%;
  314. height: 230px;
  315. }
  316. }
  317. .custom-header-status-bar{
  318. width: 100%;
  319. top: 0;
  320. position: sticky;
  321. z-index: 100;
  322. }
  323. .custom-header-top-container{
  324. width: 100%;
  325. display: flex;
  326. justify-content: center;
  327. align-items: center;
  328. padding: 0 15upx;
  329. .custom-header-title{
  330. height: 44px;
  331. line-height: 44px;
  332. font-size: 36upx;
  333. font-weight:400;
  334. font-family:Source Han Sans CN;
  335. color: #FBF9F9;
  336. z-index: 1;
  337. }
  338. }
  339. .cu-bar{
  340. width: 100%;
  341. height: 55px;
  342. }
  343. .head-search{
  344. width: 100%;
  345. height: 60upx;
  346. .head-search-item{
  347. width: 690upx;
  348. height: 65upx;
  349. background: #fff;
  350. border-radius: 50%;
  351. }
  352. }
  353. }
  354. .banner{
  355. width: 94vw;
  356. height: auto;
  357. margin: 0 3vw;
  358. padding: 5vw 0;
  359. z-index: 1;
  360. .swipe {
  361. width: 100%;
  362. height: 42vw;
  363. /* background: #eee; */
  364. border-radius: 10px;
  365. overflow: hidden;
  366. z-index: 1;
  367. .banner-img{
  368. width: 100%;
  369. height: 100%;
  370. }
  371. }
  372. }
  373. .course-list-icon{
  374. width: 100%;
  375. height: 60upx;
  376. padding-left: 20upx;
  377. display: flex;
  378. align-items: center;
  379. justify-content: flex-start;
  380. margin: 30upx 0;
  381. overflow: hidden;
  382. text-overflow: ellipsis;
  383. white-space: nowrap;
  384. .img{
  385. width: 29upx;
  386. height: 31upx;
  387. margin-right: 10upx;
  388. image{
  389. width: 100%;
  390. height: 100%;
  391. }
  392. }
  393. text{
  394. font-size:34upx;
  395. font-family:Source Han Sans CN;
  396. font-weight:500;
  397. color:rgba(61,61,61,1);
  398. }
  399. }
  400. .placeholder-view{
  401. width: 100%;
  402. height: 100upx;
  403. }
  404. .course-list-item{
  405. width: 100%;
  406. height: 242upx;
  407. padding: 15upx;
  408. border-bottom: 1rpx solid #E5E5E5;
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. }
  413. .course-item-left{
  414. width: 251upx;
  415. height: 200upx;
  416. margin-right: 20upx;
  417. image{
  418. width: 100%;
  419. height: 100%;
  420. }
  421. }
  422. .course-item-right{
  423. .course-item-title{
  424. width: 430upx;
  425. font-size:34upx;
  426. font-family:Source Han Sans CN;
  427. font-weight:500;
  428. color:rgba(61,61,61,1);
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. white-space: nowrap;
  432. }
  433. .course-item-content{
  434. width: 430upx;
  435. height: 35upx;
  436. margin: 15upx 0 20upx 0;
  437. font-size:26upx;
  438. font-family:Source Han Sans CN;
  439. font-weight:400;
  440. color:rgba(112,112,112,1);
  441. overflow: hidden;
  442. text-overflow: ellipsis;
  443. white-space: nowrap;
  444. }
  445. .course-item-moneyAndBtn{
  446. display: flex;
  447. align-items: center;
  448. justify-content: space-between;
  449. .moneyAndBtn-money{
  450. font-size:34upx;
  451. font-family:Source Han Sans CN;
  452. font-weight:500;
  453. color: #FF4800;
  454. text{
  455. font-size:34upx;
  456. font-family:Source Han Sans CN;
  457. font-weight:500;
  458. color: #FF4800;
  459. margin: 0 8upx;
  460. }
  461. }
  462. .moneyAndBtn-btn{
  463. font-size:34upx;
  464. font-family:Source Han Sans CN;
  465. font-weight:500;
  466. color: #fff;
  467. background: #F09A21;
  468. padding: 10upx 22upx;
  469. text-align: center;
  470. box-shadow: 0 4px 10px #999;
  471. border-radius: 8upx;
  472. }
  473. }
  474. }
  475. </style>