index.vue 5.2 KB

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