index.vue 12 KB

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