index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="container">
  3. <!-- 头部轮播 -->
  4. <view class="carousel-section">
  5. <!-- 背景色区域 -->
  6. <view class="bg"><image src="../../static/img/index.png" mode=""></image></view>
  7. <!-- 标题栏和状态栏占位符 -->
  8. <!-- <view class="titleNview-placing"></view> -->
  9. <!-- 搜素栏 -->
  10. <view class="search flex">
  11. <image src="../../static/icon/address.png" class="address"></image>
  12. <view class="shop-name clamp">满园春台州店11111111</view>
  13. <view class="input-box flex" @click="clickSearch">
  14. <view class=" input-content flex">
  15. <view class="iconfont iconsearch"></view>
  16. <view class="input"><input type="text" disabled value="输入关键字搜索" /></view>
  17. </view>
  18. </view>
  19. </view>
  20. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange" :indicator-dots="true" indicator-active-color="#FFFFFF">
  21. <!-- <swiper class="carousel" autoplay="true" duration="400" interval="5000"> -->
  22. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item">
  23. <image :src="item.pic" mode="aspectFill" @click="bannerNavToUrl(item)"></image>
  24. </swiper-item>
  25. </swiper>
  26. </view>
  27. <!-- 分类 -->
  28. <view class="cate-section">
  29. <navigator url="/pages/shoping/list">
  30. <view class="cate-item">
  31. <image class="Uimg" src="/static/icon/in2.png"></image>
  32. <text>全部分类</text>
  33. </view>
  34. </navigator>
  35. <navigator url="/pages/prefecture/integral">
  36. <view class="cate-item">
  37. <image src="/static/icon/in1.png"></image>
  38. <text>附近门店</text>
  39. </view>
  40. </navigator>
  41. <navigator url="/pages/prefecture/consumer">
  42. <view class="cate-item">
  43. <image src="/static/icon/in3.png"></image>
  44. <text>邀请有礼</text>
  45. </view>
  46. </navigator>
  47. <navigator url="/pages/received/index?state=0">
  48. <view class="cate-item">
  49. <image src="/static/icon/in4.png"></image>
  50. <text>收付款</text>
  51. </view>
  52. </navigator>
  53. </view>
  54. <!-- 积分兑换 -->
  55. <view class="main-box">
  56. <view class="main-top">
  57. <image src="../../static/icon/indexI.png" mode="" class="main-icon"></image>
  58. <view class="main-title">积分兑换</view>
  59. <view class="main-synopsis">超值体验</view>
  60. </view>
  61. <view class="main-content">
  62. <view class="content-top flex">
  63. <view class="content-font">
  64. <view class="content-title">积分兑换热门好物</view>
  65. <view class="content-synopsis">买到就是赚到</view>
  66. </view>
  67. <image src="../../static/icon/fanhui.png" class="go" mode=""></image>
  68. </view>
  69. </view>
  70. <view class="commodity">
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import seckill from './seckill';
  77. import { loadIndexs } from '@/api/index.js';
  78. import { interceptor } from '@/utils/loginUtils';
  79. import { userinfo } from '@/api/user.js';
  80. import { mapState } from 'vuex';
  81. export default {
  82. components: {
  83. seckill
  84. },
  85. filters: {
  86. moneyNum: function(value) {
  87. return +value;
  88. }
  89. },
  90. data() {
  91. return {
  92. titleNViewBackground: '',
  93. swiperCurrent: 0,
  94. swiperLength: 0,
  95. carouselList: [], //轮播列表
  96. goodsList: [], //最新商品列表
  97. bastList: [], //精品推荐列表
  98. bastBanner: [], //促销商品列表
  99. menusList: [], //头部菜单
  100. userServant: [
  101. {
  102. image: ''
  103. }
  104. ] //用户推广服务
  105. };
  106. },
  107. computed: {
  108. ...mapState(['loginInterceptor']),
  109. ...mapState('user', ['hasLogin', 'userInfo'])
  110. },
  111. onLoad(option) {
  112. let agree = uni.getStorageSync('agree') || false;
  113. // 判断是否已经同意协议
  114. if (!agree) {
  115. uni.redirectTo({ url: '/pages/contract/start' });
  116. }
  117. if (option.spread) {
  118. // 存储邀请人
  119. uni.setStorage({
  120. key: 'spread',
  121. data: option.spread
  122. });
  123. }
  124. },
  125. onShow() {
  126. // 判断是否强制登录
  127. if (this.loginInterceptor && !this.hasLogin) {
  128. // 登录拦截
  129. userinfo()
  130. .then(e => {})
  131. .catch(e => {
  132. console.log(e);
  133. });
  134. }
  135. this.loadData();
  136. },
  137. // #ifndef MP
  138. // 监听导航栏输入框点击事件
  139. onNavigationBarSearchInputClicked(e) {
  140. //跳转到搜索页面
  141. this.clickSearch();
  142. },
  143. //点击导航栏 buttons 时触发
  144. onNavigationBarButtonTap(e) {
  145. const index = e.index;
  146. if (index === 0) {
  147. this.$api.msg('点击了扫描');
  148. } else if (index === 1) {
  149. // #ifdef APP-PLUS
  150. const pages = getCurrentPages();
  151. const page = pages[pages.length - 1];
  152. const currentWebview = page.$getAppWebview();
  153. currentWebview.hideTitleNViewButtonRedDot({
  154. index
  155. });
  156. // #endif
  157. uni.navigateTo({
  158. url: '/pages/notice/notice'
  159. });
  160. }
  161. },
  162. // #endif
  163. methods: {
  164. // 點擊搜索框
  165. clickSearch() {
  166. uni.navigateTo({
  167. url: '/pages/product/search'
  168. });
  169. },
  170. // 监听图片加载完成
  171. onImageError(key, index) {
  172. this[key][index].image = '/static/error/errorImage.jpg';
  173. },
  174. // 请求载入数据
  175. async loadData() {
  176. loadIndexs({}).then(({ data }) => {
  177. let goods = data.info;
  178. this.carouselList = data.banner;
  179. this.swiperLength = this.carouselList.length;
  180. this.menusList = data.menus;
  181. this.goodsList = goods.firstList; //最新商品
  182. this.bastList = goods.bastList; //精品推荐
  183. this.bastBanner = goods.bastBanner; //促销单品
  184. this.userServant = goods.platoonList; //服务商品
  185. });
  186. },
  187. //轮播图切换修改背景色
  188. swiperChange(e) {
  189. const index = e.detail.current;
  190. this.swiperCurrent = index;
  191. // this.titleNViewBackground = this.carouselList[index].background;
  192. },
  193. //详情页
  194. navToDetailPage(item) {
  195. uni.navigateTo({
  196. url: '/pages/product/product?id=' + item.id
  197. });
  198. },
  199. // 轮播图跳转
  200. bannerNavToUrl(item) {
  201. // #ifdef H5
  202. if (item.wap_url.indexOf('http') > 0) {
  203. window.location.href = item.wap_url;
  204. }
  205. // #endif
  206. //测试数据没有写id,用title代替
  207. uni.navigateTo({
  208. url: item.wap_url
  209. });
  210. }
  211. }
  212. };
  213. </script>
  214. <style lang="scss">
  215. page {
  216. background: #f5f5f5;
  217. }
  218. .m-t {
  219. margin-top: 16rpx;
  220. }
  221. /* 头部 轮播图 */
  222. .carousel-section {
  223. position: relative;
  224. padding-top: 10px;
  225. overflow: hidden;
  226. .bg {
  227. position: absolute;
  228. top: 0;
  229. left: 0;
  230. width: 750rpx;
  231. height: 346rpx;
  232. image {
  233. width: 100%;
  234. height: 100%;
  235. }
  236. }
  237. .titleNview-placing {
  238. height: var(--status-bar-height);
  239. padding-top: 44px;
  240. box-sizing: content-box;
  241. }
  242. .search {
  243. justify-content: flex-start;
  244. padding: 10rpx 24rpx 20rpx;
  245. align-items: center;
  246. .address {
  247. width: 32rpx;
  248. height: 38rpx;
  249. }
  250. .shop-name {
  251. position: relative;
  252. z-index: 10;
  253. width: 206rpx;
  254. font-size: 30rpx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #ffffff;
  258. padding-left: 10rpx;
  259. }
  260. .input-box {
  261. position: relative;
  262. z-index: 999;
  263. width: 427rpx;
  264. height: 60rpx;
  265. background: rgba(39, 170, 116, 0.4);
  266. box-shadow: 0px 9rpx 21rpx 0px rgba(4, 114, 69, 0.22);
  267. border-radius: 30px;
  268. margin-left: 25rpx;
  269. .input-content {
  270. position: relative;
  271. z-index: 11;
  272. border-radius: 99rpx;
  273. flex-grow: 1;
  274. padding: 5rpx 30rpx;
  275. background: #a2e0c7;
  276. .iconsearch {
  277. font-size: 50rpx;
  278. color: #ffffff;
  279. }
  280. .input {
  281. margin-left: 19rpx;
  282. flex-grow: 1;
  283. color: #ffffff;
  284. input {
  285. font-size: 26rpx;
  286. color: #ffffff;
  287. }
  288. }
  289. }
  290. .input-button {
  291. padding-left: 20rpx;
  292. font-size: $font-base;
  293. height: 100%;
  294. }
  295. }
  296. }
  297. }
  298. .carousel {
  299. width: 100%;
  300. height: 300rpx;
  301. background-color: #fff;
  302. .carousel-item {
  303. width: 100%;
  304. height: 100%;
  305. padding: 0 28rpx;
  306. overflow: hidden;
  307. }
  308. image {
  309. width: 100%;
  310. height: 100%;
  311. border-radius: $border-radius-sm;
  312. }
  313. }
  314. .swiper-dots {
  315. display: flex;
  316. position: absolute;
  317. left: 60rpx;
  318. bottom: 15rpx;
  319. width: 72rpx;
  320. height: 36rpx;
  321. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAYAAADDhn8LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTMyIDc5LjE1OTI4NCwgMjAxNi8wNC8xOS0xMzoxMzo0MCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9i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7x+ABQEEAggEEAggEEAggEAAgQACASAQQCCAQACBAAIBBAIIBBAIIBBAIABe4e9iAe/xd7EAJxYgEGDeO4j3EODp/cOCAE4sYMyJ5cwCHs4rCwI4sYBxJ5YzC84rCwKcXxArAuthQYDzC2JF0H49LAhwYUGsCFqvx5EF2T07dMaJBetx4cRyaqFtHJ8EIhK0i8OJBQxcECuCVutxJhCRoE0cZwMRyRcFefa/ffZBVPogePihhyCnbBhcfMFFEFM+DD4m+ghSlgmDkwlOgpAl4+BkkJMgZdk4+EgaSCcpVX7bmY9kgXQQU+1TgE0c+QJZUUz1b2T4SBbIKmJW+3iMj2SBVBWz+leVfCQLpIqYbp8b85EskIxyfIOfK5Sf+wiCRJEsllQ+oqEkQfBxmD8BBgA5hVjXyrBNUQAAAABJRU5ErkJggg==);
  322. background-size: 100% 100%;
  323. .num {
  324. width: 36rpx;
  325. height: 36rpx;
  326. border-radius: 50px;
  327. font-size: 24rpx;
  328. color: #fff;
  329. text-align: center;
  330. line-height: 36rpx;
  331. }
  332. .sign {
  333. position: absolute;
  334. top: 0;
  335. left: 50%;
  336. line-height: 36rpx;
  337. font-size: 12rpx;
  338. color: #fff;
  339. transform: translateX(-50%);
  340. }
  341. }
  342. /* 分类 */
  343. .cate-section {
  344. display: flex;
  345. justify-content: space-around;
  346. align-items: center;
  347. flex-wrap: wrap;
  348. padding: 30rpx 22rpx;
  349. background: #fff;
  350. .cate-item {
  351. display: flex;
  352. flex-direction: column;
  353. align-items: center;
  354. font-size: 24rpx;
  355. font-family: PingFang SC;
  356. font-weight: bold;
  357. color: #333333;
  358. .none-font-color {
  359. color: $page-color-base;
  360. }
  361. .Uimg {
  362. border-radius: 999px;
  363. }
  364. }
  365. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  366. image {
  367. width: 88rpx;
  368. height: 88rpx;
  369. margin-bottom: 14rpx;
  370. border-radius: 50%;
  371. opacity: 0.7;
  372. }
  373. }
  374. .ad-1 {
  375. width: 100%;
  376. height: 210upx;
  377. padding: 10upx 0;
  378. background: #fff;
  379. image {
  380. width: 100%;
  381. height: 100%;
  382. }
  383. }
  384. /*公用边框样式*/
  385. %icon {
  386. margin-right: 10rpx;
  387. display: inline-block;
  388. padding: 2rpx 10rpx;
  389. border: 1rpx solid $color-yellow;
  390. color: $color-yellow;
  391. line-height: 1;
  392. font-size: $font-base;
  393. border-radius: 10rpx;
  394. }
  395. // 积分兑换,消费券
  396. .main-box {
  397. background-color: #ffffff;
  398. margin-top: 20rpx;
  399. padding: 22rpx 30rpx;
  400. .main-top {
  401. display: flex;
  402. justify-content: flex-start;
  403. align-items: center;
  404. .main-icon {
  405. width: 36rpx;
  406. height: 36rpx;
  407. }
  408. .main-title {
  409. margin-left: 8rpx;
  410. font-size: 32rpx;
  411. font-family: Source Han Sans CN;
  412. font-weight: 500;
  413. color: #333333;
  414. }
  415. .main-synopsis {
  416. margin-left: 16rpx;
  417. font-size: 20rpx;
  418. font-family: PingFang SC;
  419. font-weight: bold;
  420. color: #95a0b1;
  421. }
  422. }
  423. .main-content {
  424. width: 690rpx;
  425. background: #f4f4f4;
  426. border-radius: 12rpx;
  427. margin: 20rpx auto 0;
  428. .content-top {
  429. width: 690rpx;
  430. background: linear-gradient(43deg, #73deb2, #52c696);
  431. border-radius: 12rpx 12rpx 0px 0px;
  432. padding: 24rpx 22rpx 68rpx 27rpx;
  433. .content-font {
  434. .content-title {
  435. font-size: 32rpx;
  436. font-family: Source Han Sans CN;
  437. font-weight: 500;
  438. color: #ffffff;
  439. }
  440. .content-synopsis {
  441. margin-top: 10rpx;
  442. font-size: 24rpx;
  443. font-family: Source Han Sans CN;
  444. font-weight: 400;
  445. color: #ffffff;
  446. }
  447. }
  448. .go {
  449. width: 30rpx;
  450. height: 35rpx;
  451. transform: rotate(180deg);
  452. -ms-transform: rotate(180deg); /* Internet Explorer */
  453. -moz-transform: rotate(180deg); /* Firefox */
  454. -webkit-transform: rotate(180deg); /* Safari 和 Chrome */
  455. -o-transform: rotate(180deg); /* Opera */
  456. }
  457. }
  458. }
  459. }
  460. </style>