多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

440 lines
9.5 KiB

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