index.vue 9.5 KB

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