index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div class="hom-page" :style="{'padding-top': height + 'px'}">
  3. <global-loading />
  4. <!--&lt;!&ndash; #ifdef MP-WEIXIN &ndash;&gt;-->
  5. <!--<view class="header weiXinBox"-->
  6. <!--:style="{'padding-top': topHeight + 'px'}">-->
  7. <!--<view class="topBox"-->
  8. <!--:style="{'height': height + 'px'}">-->
  9. <!--<image class="logo"-->
  10. <!--src="https://ceres.zkthink.com/static/assets/img/logo.png"-->
  11. <!--mode="widthFix"></image>-->
  12. <!--</view>-->
  13. <!--</view>-->
  14. <!--<view class="wxBtnBg"-->
  15. <!--:style="{'padding-top': (topHeight + height + 10) + 'px'}">-->
  16. <!--<view class="weiXinBoxBtn"-->
  17. <!--@click="searchPro">-->
  18. <!--<image class="search-icon"-->
  19. <!--src="https://ceres.zkthink.com/static/images/searchImg.png"-->
  20. <!--mode="widthFix">-->
  21. <!--</image>-->
  22. <!--<text>请输入您想要的宝贝</text>-->
  23. <!--</view>-->
  24. <!--</view>-->
  25. <!--&lt;!&ndash; #endif &ndash;&gt;-->
  26. <!--&lt;!&ndash; #ifdef H5 || APP-PLUS &ndash;&gt;-->
  27. <!--<view class="header">-->
  28. <!--<view class="topBox topWap">-->
  29. <!--<image class="logo"-->
  30. <!--src="https://ceres.zkthink.com/static/assets/img/logo.png"-->
  31. <!--mode="widthFix"></image>-->
  32. <!--<view class="search-btn"-->
  33. <!--@click="searchPro">-->
  34. <!--<image class="search-icon"-->
  35. <!--src="https://ceres.zkthink.com/static/img/search.png"-->
  36. <!--mode="widthFix">-->
  37. <!--</image>-->
  38. <!--</view>-->
  39. <!--</view>-->
  40. <!--</view>-->
  41. <!--&lt;!&ndash; #endif &ndash;&gt;-->
  42. <!--<category-list @tabChange='tabChange'></category-list>-->
  43. <com-header v-if="componentsData.length > 1 && componentsData[0].type==='header'"
  44. :componentContent="componentsData[0].componentContent"
  45. :terminal="terminal"
  46. :typeId="1"
  47. @tabChange="tabChange"></com-header>
  48. <canvas-page ref="canvasPage"
  49. :componentsData="componentsData"
  50. v-if="activeTab==0"
  51. :terminal="terminal"
  52. :typeId="1"
  53. ></canvas-page>
  54. <category-show ref="categoryShow"
  55. v-else
  56. :categoryid="categoryid"></category-show>
  57. <ad-window ref="adWindow"
  58. :triggerCondition="1"></ad-window>
  59. <view class="reachBottom"
  60. v-if="topLeft > 400">
  61. <image class="reach-icon"
  62. src="https://ceres.zkthink.com/static/img/reachBottom.png"
  63. mode="widthFix">
  64. </image>
  65. <text class="reach-text">这里到底了哦~~</text>
  66. </view>
  67. <tui-modal :show="privacyShow"
  68. :custom="true"
  69. :fadein="true">
  70. <view class="Put-box1">
  71. <view class="text-align fs34 fs-bold">
  72. 协议与隐私政策
  73. </view>
  74. <p class="mar-top-20">欢迎来到cereshop!我们根据最新的法律、法规、监管政策要求,更新了cereshop隐私政策。</p>
  75. <view class="flex-display flex-sp-between">
  76. <view class="btn submit"
  77. @click="privacyShow = false">
  78. 同意
  79. </view>
  80. </view>
  81. </view>
  82. </tui-modal>
  83. </div>
  84. </template>
  85. <script>
  86. import tuiModal from "@/components/modal/modal";
  87. import AdWindow from "@/components/adWindow";
  88. const NET = require('@/utils/request')
  89. const API = require('../../../config/api')
  90. import api from '@/components/canvasShow/config/api'
  91. import CategoryList from "@/components/basics/categoryList.vue"
  92. import CategoryShow from "@/components/basics/categoryShow.vue"
  93. import comHeader from '@/components/canvasShow/basics/header/app'
  94. import canvasPage from '@/components/canvasShow/canvasShowPage.vue'
  95. import GlobalLoading from "../../../components/GlobalLoading";
  96. export default {
  97. components: {
  98. GlobalLoading,
  99. comHeader,
  100. AdWindow,
  101. CategoryList,
  102. CategoryShow,
  103. canvasPage,
  104. tuiModal
  105. },
  106. data() {
  107. return {
  108. terminal: API.terminal,
  109. activeTab: 0,
  110. categoryid: 0,
  111. topHeight: 0,
  112. height: 0,
  113. topLeft: 0,
  114. privacyShow: false,
  115. componentsData: [],
  116. typeId: 1
  117. }
  118. },
  119. onReachBottom() {
  120. this.HandleLoadMoreProduct()
  121. },
  122. onLoad() {
  123. if (!uni.getStorageSync('storage_key')) {
  124. // #ifdef APP-PLUS
  125. this.privacyShow = true
  126. // #endif
  127. }
  128. this.$nextTick(() => {
  129. this.canvasGet()
  130. this.$refs.adWindow.getAd()
  131. })
  132. },
  133. onShow() {
  134. // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
  135. let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  136. this.topHeight = menuButtonInfo.top
  137. this.height = menuButtonInfo.height
  138. // #endif
  139. },
  140. onPageScroll(e) {
  141. this.topLeft = e.scrollTop
  142. },
  143. methods: {
  144. // 读取画布
  145. canvasGet() {
  146. var _this = this
  147. var apiUrl = api.getCanvas + '?terminal=' + this.terminal + '&type=' + this.typeId
  148. if (this.shopId) {
  149. apiUrl += '&shopId=' + this.shopId
  150. }
  151. let params = {
  152. url: apiUrl,
  153. method: 'GET'
  154. }
  155. // uni.showLoading({
  156. // mask: true,
  157. // title: '加载中...',
  158. // })
  159. NET.request(apiUrl, {}, 'GET').then(res => {
  160. if (JSON.stringify(res.data) !== '{}') {
  161. var componentsData = JSON.parse(res.data.json)
  162. this.componentsData = componentsData
  163. }
  164. uni.hideLoading()
  165. }).catch(res => {
  166. uni.hideLoading()
  167. })
  168. },
  169. // 分享到朋友圈
  170. onShareTimeline: function() {
  171. return {
  172. title: this.miniHomeRemark,
  173. imageUrl: this.miniHomeImg,
  174. path: 'pages/tabbar/index/index',
  175. }
  176. },
  177. // 分享好友
  178. onShareAppMessage: function() {
  179. return {
  180. title: this.miniHomeRemark,
  181. imageUrl: this.miniHomeImg,
  182. path: 'pages/tabbar/index/index',
  183. }
  184. },
  185. /**
  186. * 请求非首页的子组件的下一页
  187. * */
  188. HandleLoadMoreProduct(){
  189. if (this.activeTab != 0) {
  190. let pitchOnPage = this.$refs.categoryShow
  191. if (pitchOnPage.total !== 0 && pitchOnPage.productList.length < pitchOnPage.total) {
  192. pitchOnPage.page++
  193. pitchOnPage.getData()
  194. }
  195. }
  196. },
  197. /**
  198. * 清空非首页的子组件商品数据
  199. * 回滚请求参数到起始页
  200. * */
  201. HandleCleanActiveTabProduct(){
  202. if(this.$refs.categoryShow){
  203. let pitchOnPage = this.$refs.categoryShow
  204. pitchOnPage.total = 0
  205. pitchOnPage.page=1
  206. pitchOnPage.productList=[]
  207. }
  208. },
  209. tabChange(index, id) {
  210. this.HandleCleanActiveTabProduct()
  211. this.activeTab = index
  212. this.categoryid = id
  213. },
  214. }
  215. };
  216. </script>
  217. <style lang="scss" scoped>
  218. .hom-page{
  219. margin-top: calc(20rpx + var(--status-bar-height));
  220. }
  221. .header {
  222. .toLive {
  223. height: 40px;
  224. color: #FFF;
  225. background-color: #333;
  226. }
  227. .topBox {
  228. display: flex;
  229. align-items: center;
  230. justify-content: space-between;
  231. width: 100%;
  232. }
  233. .logo {
  234. width: 280rpx;
  235. height: 42rpx;
  236. margin-top: -40rpx;
  237. // margin-left: 30rpx;
  238. }
  239. .search-btn {
  240. height: 66rpx;
  241. background: rgba(255, 255, 255, 1);
  242. border-radius: 33rpx;
  243. display: flex;
  244. flex-direction: row;
  245. align-items: center;
  246. margin-right: 30rpx;
  247. .search-icon {
  248. width: 60rpx;
  249. height: 60rpx;
  250. // margin-left: 33rpx;
  251. }
  252. .search-word {
  253. font-size: 26rpx;
  254. font-weight: 400;
  255. color: rgba(153, 153, 153, 1);
  256. margin-left: 10rpx;
  257. }
  258. }
  259. .tabs-nav-warp {
  260. margin-top: 20rpx;
  261. padding: 0 30rpx;
  262. }
  263. .tabs-nav {
  264. .ul {
  265. display: flex;
  266. .li {
  267. flex: 1 0 auto;
  268. margin-left: 36rpx;
  269. font-size: 30rpx;
  270. color: #999999;
  271. position: relative;
  272. padding-bottom: 18rpx;
  273. &:first-child {
  274. margin-left: 0;
  275. }
  276. &.on {
  277. &:after {
  278. content: '';
  279. width: 100%;
  280. height: 4rpx;
  281. background: #C5AA7B;
  282. position: absolute;
  283. left: 0;
  284. bottom: 0;
  285. }
  286. font-weight: bold;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. .weiXinBox {
  293. width: 100%;
  294. position: fixed;
  295. background: #FFFFFF;
  296. z-index: 99;
  297. }
  298. .wxBtnBg {
  299. padding: 0 20rpx;
  300. .weiXinBoxBtn {
  301. display: flex;
  302. align-items: center;
  303. padding: 10rpx 0 10rpx 15rpx;
  304. width: 100%;
  305. background: #F3F4F5;
  306. opacity: 1;
  307. .search-icon {
  308. width: 50rpx;
  309. height: 50rpx;
  310. margin-right: 20rpx;
  311. }
  312. text {
  313. color: #999999;
  314. }
  315. }
  316. }
  317. .terminal1 {
  318. .header {
  319. .topBox {
  320. // justify-content: left;
  321. .search-btn {
  322. .search-icon {
  323. margin-left: 0rpx;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .topTitle {
  330. display: flex;
  331. justify-content: center;
  332. align-items: center;
  333. height: 100rpx;
  334. width: 100%;
  335. .topText {
  336. text-align: center;
  337. color: #000000;
  338. font-size: 38rpx;
  339. font-weight: bold;
  340. }
  341. }
  342. .topWap {
  343. padding-top: 60rpx;
  344. .logo {
  345. margin-top: 0 !important;
  346. }
  347. }
  348. .terminal2 {
  349. }
  350. .terminal3 {
  351. }
  352. // 触底样式
  353. .reachBottom {
  354. margin-top: 30rpx;
  355. display: flex;
  356. flex-direction: column;
  357. align-items: center;
  358. .reach-icon {
  359. width: 150rpx;
  360. height: 150rpx;
  361. }
  362. .reach-text {
  363. margin: 20rpx 0;
  364. color: #CCCCCC;
  365. }
  366. }
  367. .Put-box1 {
  368. .btn {
  369. text-align: center;
  370. margin-top: 40rpx;
  371. border: 1px solid #333333;
  372. height: 80upx;
  373. line-height: 80upx;
  374. width: 100%;
  375. color: #333333;
  376. }
  377. .submit {
  378. background-color: #333333;
  379. color: #FFEBC4;
  380. }
  381. }
  382. </style>