index_mall.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. <template>
  2. <view>
  3. <!-- <headerSerch :dataConfig="headItem"></headerSerch> -->
  4. <view class="nav-bar_2 flex-row justify-between">
  5. <text class="text_3">中意购</text>
  6. </view>
  7. <view class="block_2 flex-row justify-between">
  8. <view class="image-text_9 flex-row justify-between">
  9. <image class="icon_1" referrerpolicy="no-referrer"
  10. src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng64f8d7838848f656c98b8047aa0940b03a63be81a880f5a9920d8242f6be887d" />
  11. <text class="text-group_1">上海市浦东新区秀浦路29号三层303室</text>
  12. </view>
  13. <view class="image-text_10 flex-row justify-between">
  14. <text class="text-group_2" @click="getCurrentLocation()">切换地点</text>
  15. <image class="icon_2" referrerpolicy="no-referrer"
  16. src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng91356afb3fca819201cc9be0df3b1c18cca66d523b364042bcf5fbdf766a8902" />
  17. </view>
  18. </view>
  19. <!-- 轮播 -->
  20. <view class="swiper-group">
  21. <u-swiper
  22. :list="swiperTabList"
  23. @change="e => current = e.current"
  24. :autoplay="false"
  25. >
  26. <view
  27. slot="indicator"
  28. class="indicator"
  29. >
  30. <view
  31. class="indicator__dot"
  32. v-for="(item, index) in swiperTabList"
  33. :key="index"
  34. :class="[index === current && 'indicator__dot--active']"
  35. >
  36. </view>
  37. </view>
  38. </u-swiper>
  39. </view>
  40. <view class="header-group">
  41. <view class="tabs">
  42. <u-tabs class="defalt-utabs" :is-scroll="false" :list="navigationList" @click="clickNav" lineColor="#B22338" :inactiveStyle="{ color: '#999999' }"
  43. :activeStyle="{ color: '#B22338', fontWeight: 'bold' }" keyName="title"></u-tabs>
  44. </view>
  45. </view>
  46. <view class="good-list">
  47. <latestGroupBuying @changeTab="changeTab" :iSshowH="true" @detail="goDetail" :currentId="currentId"
  48. - :isSortType="false" :positionInfo="positionInfo" ref="latestGroupBuying"></latestGroupBuying>
  49. </view>
  50. <view v-if="!isLogin">
  51. <u-skeleton :loading="true" rows="20" :animate="true"></u-skeleton>
  52. </view>
  53. <view v-else>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import headerSerch from './components/headerSerch';
  59. import latestGroupBuying from './components/latestGroupBuying';
  60. import {
  61. toLogin
  62. } from '@/libs/login.js';
  63. import {
  64. mapGetters
  65. } from "vuex";
  66. import {getAdsList, getNoticeList, getCategoryOne,getGoodsPage, getIndexData, getGoodsInfo} from '../../../api/home.js'
  67. import {latestGroupon, historyGroupon, detailGroupon, goodsDetail} from '../../../api/groupon.js'
  68. import {
  69. goShopDetail
  70. } from '@/libs/order.js';
  71. export default {
  72. components: {
  73. headerSerch,
  74. latestGroupBuying
  75. },
  76. data () {
  77. return {
  78. currentId: 0,
  79. noticeShow: false,
  80. noticeContent: '',
  81. tempArr: [],
  82. where: {
  83. zoneType: 8,
  84. current: 1,
  85. size: 20,
  86. },
  87. isSortType: 0,
  88. current: 0,
  89. noticeList: [],
  90. notice: [
  91. '寒雨连江夜入吴',
  92. '平明送客楚山孤',
  93. '洛阳亲友如相问',
  94. '一片冰心在玉壶'
  95. ],
  96. swiperTabList: [
  97. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  98. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  99. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  100. ],
  101. swiperList: [
  102. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  103. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  104. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  105. ],
  106. navigationList: [{
  107. title: '最新团购',
  108. id: '0'
  109. }, {
  110. title: '历史团购',
  111. id: '1'
  112. }],
  113. positionInfo: {
  114. address: '',
  115. longitude: '106.62502', //经度
  116. latitude: '26.65214', //纬度
  117. },
  118. user_latitude: '',
  119. user_longitude: ''
  120. }
  121. },
  122. computed: mapGetters(['isLogin']),
  123. created () {
  124. this.getAdsList();
  125. this.getLatestGroupon();
  126. this.getCurrentLocation()
  127. },
  128. onMounted (options) {
  129. },
  130. onLoad (options) {
  131. },
  132. onShow () {
  133. },
  134. updated () {
  135. },
  136. watch: {
  137. isLogin: {
  138. deep: true, //深度监听设置为 true
  139. handler: function (newV, oldV) {
  140. this.getAdsList()
  141. this.getLatestGroupon()
  142. }
  143. }
  144. },
  145. methods: {
  146. // 通过自带的方法获取到当前的经纬度,调用方法获取到地址获取到地址的中文信息
  147. getCurrentLocation () {
  148. let that = this //在uniapp中药定义一下this才能使用
  149. uni.getLocation({
  150. type: 'wgs84',
  151. success: function (res) {
  152. console.log("dizhixinxi -> ", res)
  153. that.positionInfo.longitude = res.longitude;
  154. that.positionInfo.latitude = res.latitude;
  155. // that.loAcquire(that.positionInfo.longitude, that.positionInfo.latitude)
  156. }
  157. });
  158. },
  159. // 获取当前地址
  160. loAcquire (longitude, latitude) {
  161. let that = this;
  162. // uni.showLoading({
  163. // title: '加载中',
  164. // mask: true
  165. // });
  166. let str = `output=jsonp&key='此处输入你申请的密钥'=${latitude},${longitude}` //记得在这里要输入密钥哦!
  167. console.log(this.$jsonp);
  168. this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/?', {}).then(res => {
  169. console.log(res);
  170. uni.hideLoading();
  171. if (res.status == 0) {
  172. that.positionInfo.address = '当前位置是:' + res.result.address_component.street_number; //当前定位
  173. }
  174. })
  175. },
  176. pullResh () {
  177. if (this.current == 0) {
  178. uni.showLoading({ title: '刷新中' });
  179. this.getAdsList()
  180. this.getLatestGroupon()
  181. } else {
  182. this.$refs.latestGroupBuying.getGoodsPage()
  183. }
  184. },
  185. getLatestGroupon() {
  186. // let that = this;
  187. // latestGroupon({
  188. // current: 1,
  189. // size: 1,
  190. // longitude: that.positionInfo.longitude,
  191. // latitude: that.positionInfo.latitude
  192. // }).then(res => {
  193. // console.log(res)
  194. // })
  195. },
  196. getGoodsInfo () {
  197. getGoodsInfo({
  198. current: 1,
  199. size: 50,
  200. isRecom: 1
  201. }).then(res => {
  202. this.tempArr = res.data
  203. uni.stopPullDownRefresh()
  204. uni.hideLoading();
  205. })
  206. },
  207. getBroGoodsInfo () {
  208. getGoodsInfo({
  209. current: 1,
  210. size: 50,
  211. zoneType: 6
  212. }).then(res => {
  213. this.tempArrBao = res.data
  214. })
  215. },
  216. getCategoryOne () {
  217. getCategoryOne().then(res => {
  218. this.navigationList = []
  219. let tuiJian = {
  220. title: '推荐',
  221. id: '0'
  222. }
  223. this.navigationList = res.data
  224. this.navigationList.unshift(tuiJian)
  225. })
  226. },
  227. menusTap (url, zoneType) {
  228. let that = this
  229. // #ifdef H5
  230. location.href = url
  231. // #endif
  232. // #ifdef MP || APP-PLUS
  233. if (zoneType == 8) {
  234. //共富取消中间过渡界面
  235. getGoodsInfo(that.where).then(res => {
  236. let list = res.data;
  237. if (that.where.zoneType == 8 && list.length == 1) {
  238. // 自动跳转共富1580商品详情
  239. that.godDetail(list[0])
  240. }
  241. })
  242. } else {
  243. uni.navigateTo({
  244. url: "/pages/goods/goods_list_mall/index?zoneType=" + zoneType + "&title=" + url
  245. });
  246. }
  247. // #endif
  248. },
  249. // 去详情页
  250. godDetail (item) {
  251. goShopDetail(item, this.uid).then(res => {
  252. uni.navigateTo({
  253. url: `/pages/goods_details/index?id=${item.id}`
  254. + "&zoneType=" + item.zoneType
  255. })
  256. })
  257. },
  258. noticeClose () {
  259. this.noticeShow = false
  260. },
  261. goNoticeDetail (value) {
  262. this.noticeContent = this.noticeList[value].content
  263. this.noticeShow = true
  264. },
  265. getNoticeList () {
  266. getNoticeList().then(res => {
  267. this.notice = []
  268. this.noticeList = res.data
  269. res.data.forEach(element => {
  270. this.notice.push(element.title)
  271. });
  272. })
  273. },
  274. getAdsList () {
  275. getAdsList({
  276. type: 2
  277. }).then(res => {
  278. if (res.data.length > 0) {
  279. this.swiperList = []
  280. res.data.forEach(element => {
  281. this.swiperList.push(element.imageUrl)
  282. });
  283. }
  284. });
  285. },
  286. // 促销列表的点击事件;
  287. changeTab (type) {
  288. this.goodType = type;
  289. this.tempArr = [];
  290. this.page = 1;
  291. this.loadend = false;
  292. let onloadH = true;
  293. this.getGroomList(onloadH);
  294. },
  295. // 精品推荐
  296. getGroomList (onloadH) {
  297. let that = this;
  298. let type = that.goodType;
  299. if (that.loadend) return false;
  300. if (that.loading) return false;
  301. if (onloadH) {
  302. that.$set(that, 'iSshowH', true);
  303. }
  304. uni.request({
  305. url: 'api/groom/list',
  306. success: res => {
  307. that.$set(that, 'iSshowH', false);
  308. let maxPage = Math.ceil(this.numConfig / this.limit);
  309. let list = res.data.list,
  310. loadend = list.length < that.limit || that.page >= maxPage;
  311. let tempArr = that.$util.SplitArray(list, that.tempArr);
  312. that.$set(that, 'tempArr', tempArr.slice(0, this.numConfig));
  313. that.loadend = loadend;
  314. that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  315. that.page = that.page + 1;
  316. that.loading = false;
  317. }
  318. })
  319. // getGroomList(type, {
  320. // page: that.page,
  321. // limit: this.numConfig
  322. // })
  323. // .then(({
  324. // data
  325. // }) => {
  326. // that.$set(that, 'iSshowH', false);
  327. // let maxPage = Math.ceil(this.numConfig / this.limit);
  328. // let list = data.list,
  329. // loadend = list.length < that.limit || that.page >= maxPage;
  330. // let tempArr = that.$util.SplitArray(list, that.tempArr);
  331. // that.$set(that, 'tempArr', tempArr.slice(0, this.numConfig));
  332. // that.loadend = loadend;
  333. // that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  334. // that.page = that.page + 1;
  335. // that.loading = false;
  336. // })
  337. // .catch(res => {
  338. // that.loading = false;
  339. // that.loadTitle = that.$t(`加载更多`);
  340. // });
  341. },
  342. goDetail (item) {
  343. goShopDetail(item, this.$store.state.app.uid).then(res => {
  344. uni.navigateTo({
  345. url: `/pages/goods_details/index?id=${item.id}`
  346. });
  347. });
  348. },
  349. // 去商品详情
  350. goGoodsDetail (item) {
  351. goShopDetail(item, this.uid).then(res => {
  352. uni.navigateTo({
  353. url: `/pages/goods_details/index?id=${item.id}`
  354. });
  355. });
  356. },
  357. clickNav (e) {
  358. this.current = e.index
  359. // if (e.index > 0) {
  360. this.currentId = e.id
  361. // }
  362. // console.log("currentId ->", this.currentId)
  363. }
  364. }
  365. }
  366. </script>
  367. <style lang="scss" scoped>
  368. page {
  369. background-color: #ee4040;
  370. }
  371. .header-group {
  372. background-color: #F9F9F9;
  373. .search-group {
  374. display: flex;
  375. align-items: center;
  376. justify-content: space-between;
  377. padding: 30rpx 30rpx 10rpx 30rpx;
  378. .logo {
  379. width: 138rpx;
  380. height: 46rpx;
  381. }
  382. .message {
  383. line-height: 1;
  384. image {
  385. width: 48rpx;
  386. height: 48rpx;
  387. }
  388. }
  389. .search {
  390. flex: 1;
  391. padding: 0 30rpx;
  392. .searchBox {
  393. padding: 0 30rpx;
  394. display: flex;
  395. align-items: center;
  396. background-color: #FFF;
  397. border-radius: 100rpx;
  398. height: 60rpx;
  399. image {
  400. width: 28rpx;
  401. height: 28rpx;
  402. padding-right: 20rpx;
  403. }
  404. text {
  405. font-size: 24rpx;
  406. color: #999;
  407. }
  408. }
  409. }
  410. }
  411. .tabs {
  412. padding: 0 20rpx;
  413. }
  414. }
  415. .tab-content {
  416. .swiper-group {
  417. padding: 20rpx 30rpx 10rpx 30rpx;
  418. background-image: linear-gradient(to bottom, #EB4C63, #F9F9F9);
  419. }
  420. .grid-box {
  421. padding: 10rpx 30rpx 20rpx 30rpx;
  422. .grid-group {
  423. padding: 20rpx 0;
  424. border-radius: 20rpx;
  425. background-color: #FFF;
  426. display: flex;
  427. align-items: center;
  428. flex-wrap: wrap;
  429. .grid-item {
  430. width: 33.333%;
  431. display: flex;
  432. flex-direction: column;
  433. align-items: center;
  434. margin: 10rpx 0;
  435. image {
  436. width: 98rpx;
  437. height: 98rpx;
  438. }
  439. text {
  440. font-size: 24rpx;
  441. color: #666;
  442. margin-top: 10rpx;
  443. }
  444. }
  445. }
  446. }
  447. .notice {
  448. padding: 0 30rpx;
  449. }
  450. .sale-group {
  451. padding: 20rpx 30rpx;
  452. .sale-content {
  453. border-radius: 20rpx;
  454. background-image: linear-gradient(45deg, #EB4C63, #FFA470);
  455. padding: 20rpx 0;
  456. .title {
  457. display: flex;
  458. align-items: center;
  459. justify-content: space-between;
  460. color: #FFF;
  461. font-weight: bold;
  462. padding: 0 30rpx;
  463. .more {
  464. display: flex;
  465. align-items: center;
  466. font-size: 24rpx;
  467. font-weight: normal;
  468. image {
  469. width: 24rpx;
  470. height: 24rpx;
  471. }
  472. }
  473. }
  474. .goods-scroll {
  475. white-space: nowrap;
  476. padding: 20rpx 15rpx 0 15rpx;
  477. .goods-item {
  478. display: inline-block;
  479. width: 240rpx;
  480. padding: 15rpx;
  481. margin: 0 10rpx;
  482. background-color: #FFF;
  483. border-radius: 10rpx;
  484. image {
  485. width: 210rpx;
  486. height: 210rpx;
  487. }
  488. .goods-name {
  489. font-size: 26rpx;
  490. color: #333;
  491. width: 240rpx;
  492. margin: 6rpx 0;
  493. word-break: break-all;
  494. white-space: pre-wrap;
  495. text-overflow: ellipsis;
  496. display: -webkit-box;
  497. line-height: 1.2;
  498. -webkit-box-orient: vertical;
  499. -webkit-line-clamp: 2;
  500. overflow: hidden;
  501. }
  502. .tags {
  503. display: inline-block;
  504. font-size: 20rpx;
  505. padding: 6rpx;
  506. background-color: #FCE9EC;
  507. color: #EB4C63;
  508. margin: 6rpx 0;
  509. }
  510. .price {
  511. font-size: 32rpx;
  512. font-weight: bold;
  513. color: #EB4C63;
  514. }
  515. }
  516. }
  517. }
  518. }
  519. .goods-list {
  520. .title {
  521. text-align: center;
  522. color: #333;
  523. display: flex;
  524. align-items: center;
  525. justify-content: center;
  526. font-size: 32rpx;
  527. font-weight: bold;
  528. .line {
  529. display: inline-block;
  530. width: 200rpx;
  531. height: 2rpx;
  532. margin: 0 30rpx;
  533. background-color: #FFA470;
  534. }
  535. }
  536. .list-group {
  537. display: flex;
  538. align-items: center;
  539. flex-wrap: wrap;
  540. padding: 15rpx;
  541. box-sizing: border-box;
  542. .list-item-content {
  543. width: 50%;
  544. padding: 15rpx;
  545. box-sizing: border-box;
  546. .list-item {
  547. padding: 15rpx;
  548. background-color: #FFF;
  549. border-radius: 10rpx;
  550. image {
  551. width: 100%;
  552. }
  553. .goods-name {
  554. font-size: 28rpx;
  555. color: #333;
  556. margin: 6rpx 0;
  557. word-break: break-all;
  558. white-space: pre-wrap;
  559. text-overflow: ellipsis;
  560. display: -webkit-box;
  561. line-height: 1.4;
  562. -webkit-box-orient: vertical;
  563. -webkit-line-clamp: 2;
  564. overflow: hidden;
  565. }
  566. .tags {
  567. display: inline-block;
  568. font-size: 20rpx;
  569. padding: 6rpx;
  570. background-color: #FCE9EC;
  571. color: #EB4C63;
  572. margin: 6rpx 0;
  573. }
  574. .price {
  575. font-size: 32rpx;
  576. font-weight: bold;
  577. color: #EB4C63;
  578. }
  579. }
  580. }
  581. }
  582. }
  583. }
  584. .nav-bar_2 {
  585. width: 374px;
  586. margin-top: 6px;
  587. padding: 10px 9px 7px 16px;
  588. }
  589. .text_3 {
  590. overflow-wrap: break-word;
  591. color: rgba(51, 51, 51, 1);
  592. font-size: 18px;
  593. letter-spacing: 2px;
  594. font-family: STYuanti-SC-Regular;
  595. font-weight: NaN;
  596. text-align: left;
  597. white-space: nowrap;
  598. line-height: 24px;
  599. margin-top: 3px;
  600. }
  601. .applet-top-bar_1 {
  602. width: 90px;
  603. height: 30px;
  604. }
  605. .block_2 {
  606. display: flex;
  607. justify-content: space-around;
  608. box-shadow: 0px 2px 4px 0px rgba(178, 35, 56, 0.05);
  609. background-image: url(https://lanhu-dds-backend.oss-cn-beijing.aliyuncs.com/merge_image/imgs/7ac954eaf57b4d42b263ef296c3fa351_mergeImage.png);
  610. align-self: center;
  611. margin: 20rpx;
  612. margin-top: 4px;
  613. padding: 15px 8px 15px 8px;
  614. }
  615. .image-text_9 {
  616. width: 228px;
  617. }
  618. .icon_1 {
  619. width: 16px;
  620. height: 16px;
  621. margin: 2px 0 2px 0;
  622. }
  623. .text-group_1 {
  624. overflow-wrap: break-word;
  625. color: rgba(51, 51, 51, 1);
  626. font-size: 12px;
  627. text-align: left;
  628. white-space: nowrap;
  629. line-height: 20px;
  630. max-width: 190px;
  631. display: block;
  632. white-space: pre-line;
  633. }
  634. .flex-row {
  635. display: flex;
  636. }
  637. .image-text_10 {
  638. width: 56px;
  639. }
  640. .text-group_2 {
  641. overflow-wrap: break-word;
  642. color: rgba(153, 153, 153, 1);
  643. font-size: 10px;
  644. font-weight: NaN;
  645. text-align: right;
  646. line-height: 20px;
  647. }
  648. .icon_2 {
  649. width: 12px;
  650. height: 12px;
  651. margin: 4px 0 4px 0;
  652. }
  653. .indicator {
  654. @include flex(row);
  655. justify-content: center;
  656. &__dot {
  657. height: 6px;
  658. width: 6px;
  659. border-radius: 100px;
  660. background-color: rgba(255, 255, 255, 0.35);
  661. margin: 0 5px;
  662. transition: background-color 0.3s;
  663. &--active {
  664. background-color: #ffffff;
  665. }
  666. }
  667. }
  668. .indicator-num {
  669. padding: 2px 0;
  670. background-color: rgba(0, 0, 0, 0.35);
  671. border-radius: 100px;
  672. width: 35px;
  673. @include flex;
  674. justify-content: center;
  675. &__text {
  676. color: #FFFFFF;
  677. font-size: 12px;
  678. }
  679. }
  680. </style>