index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <div class="hom-page home_page_content">
  3. <!-- 头部 -->
  4. <FixedHead>
  5. <CategoryList @tabChange="tabChange"></CategoryList>
  6. </FixedHead>
  7. <!-- 首页画布骨架屏 -->
  8. <Skeleton v-if="isFirst" :loading="loading" :is-first="isFirst" />
  9. <template v-if="!isFirst">
  10. <!-- 首页画布 -->
  11. <view v-if="activeTab === 0" id="home_canvas_page">
  12. <CanvasPage ref="canvasPage" :components-data="componentsData" :terminal="terminal" :type-id="1" />
  13. </view>
  14. <!-- 其他分类 -->
  15. <CategoryShow v-else ref="categoryShow" :classify-id="classifyId" />
  16. <ListBottomTips v-if="activeTab === 0 && scrollTop > 400" :loading="false" />
  17. <Agreement />
  18. <global-loading />
  19. <AdWindow ref="adWindow" :trigger-condition="1" />
  20. </template>
  21. </div>
  22. </template>
  23. <script>
  24. import AdWindow from '@/components/adWindow'
  25. import api from '@/components/canvasShow/config/api'
  26. import CategoryList from '@/components/basics/categoryList.vue'
  27. import CategoryShow from '@/components/basics/categoryShow.vue'
  28. import canvasPage from '@/components/canvasShow/canvasShowPage.vue'
  29. import FixedHead from './component/FixedHead'
  30. import ListBottomTips from '@/components/ListBottomTips'
  31. import Agreement from './component/Agreement'
  32. import Skeleton from './component/Skeleton'
  33. const NET = require('@/utils/request')
  34. const API = require('../../../config/api')
  35. export default {
  36. components: {
  37. AdWindow,
  38. CategoryList,
  39. CategoryShow,
  40. CanvasPage: canvasPage,
  41. FixedHead,
  42. ListBottomTips,
  43. Agreement,
  44. Skeleton
  45. },
  46. data() {
  47. return {
  48. loading: true,
  49. isFirst: true,
  50. classifyId: 0, // 分类ID
  51. terminal: API.terminal,
  52. activeTab: 0,
  53. componentsData: [],
  54. typeId: 1,
  55. scrollTop: 0
  56. }
  57. },
  58. onReachBottom() {
  59. this.HandleLoadMoreProduct()
  60. },
  61. onLoad() {
  62. this.$nextTick(async () => {
  63. await this.handleGetCanvas()
  64. this.$refs.adWindow.getAd()
  65. })
  66. },
  67. onPageScroll(e) {
  68. this.scrollTop = e.scrollTop
  69. },
  70. methods: {
  71. // 读取画布
  72. async handleGetCanvas() {
  73. this.loading = true
  74. const apiUrl = api.getCanvas + '?terminal=' + this.terminal + '&type=' + this.typeId
  75. const { data } = await NET.request(apiUrl, {}, 'GET')
  76. if (JSON.stringify(data) !== '{}') {
  77. this.componentsData = JSON.parse(data.json)
  78. this.isFirst = false
  79. this.loading = false
  80. }
  81. },
  82. // 分享到朋友圈
  83. onShareTimeline() {
  84. return {
  85. title: this.miniHomeRemark,
  86. imageUrl: this.miniHomeImg,
  87. path: 'pages/tabbar/index/index'
  88. }
  89. },
  90. // 分享好友
  91. onShareAppMessage() {
  92. return {
  93. title: this.miniHomeRemark,
  94. imageUrl: this.miniHomeImg,
  95. path: 'pages/tabbar/index/index'
  96. }
  97. },
  98. /**
  99. * 请求非首页的子组件的下一页
  100. * */
  101. HandleLoadMoreProduct() {
  102. if (this.activeTab !== 0) {
  103. const pitchOnPage = this.$refs.categoryShow
  104. if (pitchOnPage.total !== 0 && pitchOnPage.productList.length < pitchOnPage.total) {
  105. pitchOnPage.page++
  106. pitchOnPage.handleGetProductData()
  107. }
  108. }
  109. },
  110. tabChange(index, id) {
  111. this.activeTab = index
  112. this.classifyId = id
  113. }
  114. }
  115. }
  116. </script>
  117. <style
  118. lang="scss"
  119. scoped
  120. >
  121. .header {
  122. background: #fff;
  123. .toLive {
  124. height: 40px;
  125. color: #FFF;
  126. background-color: #333;
  127. }
  128. .topBox {
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. width: 100%;
  133. height: 100%;
  134. }
  135. .logo {
  136. width: 280rpx;
  137. height: 100%;
  138. //margin-top: -40rpx;
  139. // margin-left: 30rpx;
  140. }
  141. .search-btn {
  142. height: 66rpx;
  143. background: rgba(255, 255, 255, 1);
  144. border-radius: 33rpx;
  145. display: flex;
  146. flex-direction: row;
  147. align-items: center;
  148. margin-right: 30rpx;
  149. .search-icon {
  150. width: 60rpx;
  151. height: 60rpx;
  152. // margin-left: 33rpx;
  153. }
  154. .search-word {
  155. font-size: 26rpx;
  156. font-weight: 400;
  157. color: rgba(153, 153, 153, 1);
  158. margin-left: 10rpx;
  159. }
  160. }
  161. .tabs-nav-warp {
  162. margin-top: 20rpx;
  163. padding: 0 30rpx;
  164. }
  165. .tabs-nav {
  166. .ul {
  167. display: flex;
  168. .li {
  169. flex: 1 0 auto;
  170. margin-left: 36rpx;
  171. font-size: 30rpx;
  172. color: #999999;
  173. position: relative;
  174. padding-bottom: 18rpx;
  175. &:first-child {
  176. margin-left: 0;
  177. }
  178. &.on {
  179. &:after {
  180. content: '';
  181. width: 100%;
  182. height: 4rpx;
  183. background: #C5AA7B;
  184. position: absolute;
  185. left: 0;
  186. bottom: 0;
  187. }
  188. font-weight: bold;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. .weiXinBox {
  195. width: 100%;
  196. //position: fixed;
  197. background: #FFFFFF;
  198. //z-index: 99;
  199. }
  200. .wxBtnBg {
  201. padding: 0 20rpx;
  202. .weiXinBoxBtn {
  203. display: flex;
  204. align-items: center;
  205. padding: 10rpx 0 10rpx 15rpx;
  206. width: 100%;
  207. background: #F3F4F5;
  208. opacity: 1;
  209. .search-icon {
  210. width: 50rpx;
  211. height: 50rpx;
  212. margin-right: 20rpx;
  213. }
  214. text {
  215. color: #999999;
  216. }
  217. }
  218. }
  219. .terminal1 {
  220. .header {
  221. .topBox {
  222. // justify-content: left;
  223. .search-btn {
  224. .search-icon {
  225. margin-left: 0rpx;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. .topTitle {
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. height: 100rpx;
  236. width: 100%;
  237. .topText {
  238. text-align: center;
  239. color: #000000;
  240. font-size: 38rpx;
  241. font-weight: bold;
  242. }
  243. }
  244. .topWap {
  245. padding-top: 30rpx;
  246. .logo {
  247. margin-top: 0 !important;
  248. }
  249. }
  250. .terminal2 {}
  251. .terminal3 {}
  252. // 触底样式
  253. .reachBottom {
  254. margin-top: 30rpx;
  255. display: flex;
  256. flex-direction: column;
  257. align-items: center;
  258. .reach-icon {
  259. width: 150rpx;
  260. height: 150rpx;
  261. }
  262. .reach-text {
  263. margin: 20rpx 0;
  264. color: #CCCCCC;
  265. }
  266. }
  267. // 优化兼容UI
  268. .home_page_content {
  269. #home_canvas_page {
  270. width: 100%;
  271. position: relative;
  272. }
  273. }
  274. </style>