index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <template>
  2. <view class="container">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="status_bar"></view>
  5. <view class="top-bg"></view>
  6. <view class="top-search flex">
  7. <view class="search-box flex" @click="clickSearch()">
  8. <image class="search" src="../../static/icon/search-w.png" mode=""></image>
  9. <view class="search-font">输入关键词搜索</view>
  10. </view>
  11. </view>
  12. <!-- 顶部logo and 搜索 end-->
  13. <view class="jg" style="background-color: #fff;"></view>
  14. <!-- 轮播图 start -->
  15. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" >
  16. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  17. @click="bannerNavToUrl(item)">
  18. <image :src="item.pic" />
  19. </swiper-item>
  20. </swiper>
  21. <!-- 轮播图 end -->
  22. <!-- 分类 start -->
  23. <view class="cate-section flex">
  24. <view class="cate-item flex" v-for="citem in cateList" @click="gogogo(citem)">
  25. <view class="img-wrapper flex">
  26. <image :src="citem.img" mode=""></image>
  27. </view>
  28. <view class="item-title">{{citem.tit}}</view>
  29. </view>
  30. </view>
  31. <!-- 分类 ed -->
  32. <!-- 公告 start -->
  33. <view class="notice" v-if="list.length > 0">
  34. <xzw-notice theme="#ff5050" :list="list" @goItem="goItem" @goMore="goMore" :direction="'row'"/>
  35. </view>
  36. <!-- 公告 end -->
  37. <view class="jg">
  38. </view>
  39. <video src="../../static/video/v1.mp4" controls class="gsjs" ref="inv" id="myVideo" autoplay></video>
  40. <!-- #ifdef APP-PLUS -->
  41. <ad adpid="1108185255" @load="onload" @close="onclose" @error="onerror"></ad>
  42. <!-- #endif -->
  43. <!-- 商品列表 start -->
  44. <!-- <view class="hot-wrap">
  45. <view class="hot-top flex">
  46. <image src="../../static/icon/hhh.png" mode=""></image>
  47. <view class="">
  48. 礼包商品
  49. </view>
  50. </view>
  51. <view class="hot-list">
  52. <view class="good" v-for="item in goodList" @click="navTo('/pages/product/product?id=' + item.id)">
  53. <image :src="item.image" mode="" class="good-img"></image>
  54. <view class="good-tit">
  55. {{item.store_name}}
  56. </view>
  57. <view class="good-cz flex">
  58. <view class="price">
  59. <text class="xy">¥</text> <text>{{item.price}}</text><text class="old-price">¥{{item.ot_price}}</text>
  60. </view>
  61. <view class="cz-btn">
  62. 立即抢购
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view> -->
  68. <!-- 商品列表 ed-->
  69. <uni-popup ref="popupkf" type="center">
  70. <view class="popup-box">
  71. <view class="img">
  72. <image src="../../static/img/img009.png" mode=""></image>
  73. </view>
  74. <view class="mian">
  75. <view class="delivery">
  76. <view class="title">已经为您定制专属客服</view>
  77. <image src="../../static/img/img010.png" mode=""></image>
  78. </view>
  79. <view class="nocancel">客服VX:{{ text }}</view>
  80. <view class="comfirm-box">
  81. <view class="cancel" @click="cancel">取消</view>
  82. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  83. </view>
  84. </view>
  85. </view>
  86. </uni-popup>
  87. </view>
  88. </template>
  89. <script>
  90. import { xzwNotoce} from '@/components/xzw-notice/xzw-notice.vue'
  91. import {
  92. loadIndexs,
  93. getArtList,
  94. groom1
  95. } from '@/api/index.js';
  96. import {
  97. getUserInfo,
  98. spread
  99. } from '@/api/user.js';
  100. import {
  101. getBargainList,
  102. getProducts,
  103. goodsDetail,
  104. poster
  105. } from '@/api/product.js';
  106. import {
  107. saveUrl,
  108. interceptor
  109. } from '@/utils/loginUtils';
  110. import {
  111. mapState,
  112. mapMutations
  113. } from 'vuex';
  114. // #ifdef H5
  115. import {
  116. weixindata,
  117. shareLoad
  118. } from '@/utils/wxAuthorized';
  119. // #endif
  120. export default {
  121. components: {
  122. xzwNotoce
  123. },
  124. data() {
  125. return {
  126. list: [],
  127. muted: false,
  128. cateList: [
  129. {
  130. path: '/pages/index/gift?is_pack=1',
  131. img: '../../static/icon/inx1.png',
  132. tit: 'VIP商品'
  133. },
  134. {
  135. path: '/pages/index/zero',
  136. img: '../../static/icon/inx2.png',
  137. tit: '零创业'
  138. },
  139. {
  140. path: '/pages/index/gift?type=10',
  141. img: '../../static/icon/inx3.png',
  142. tit: '普惠商城'
  143. },
  144. {
  145. path: '/pages/index/three',
  146. img: '../../static/icon/inx4.png',
  147. tit: '第三方商城'
  148. },
  149. {
  150. path: '/pages/index/life',
  151. img: '../../static/icon/inx5.png',
  152. tit: '本地生活'
  153. },
  154. {
  155. path: '/pages/index/gift?is_zero=1',
  156. img: '../../static/icon/inx6.png',
  157. tit: '超级秒杀'
  158. },
  159. {
  160. path: '/pages/index/gift?type=5',
  161. img: '../../static/icon/inx7.png',
  162. tit: '新能源'
  163. },
  164. {
  165. path: '/pages/index/gift?type=14',
  166. img: '../../static/icon/inx8.png',
  167. tit: '健康俱乐部'
  168. }
  169. ],
  170. text: '18248691389', //客服微信
  171. // page: 1,
  172. limitt: 20,
  173. loadingType: 'more',
  174. current: 0,
  175. shareShow: false, //分享海报
  176. titleNViewBackground: '',
  177. swiperCurrent: 0,
  178. swiperLength: 0,
  179. carouselList: [], //轮播列表
  180. page: 1,
  181. limit: 5,
  182. firstList: [],
  183. goodList: [], //商品列表
  184. shopList: [],
  185. period: 1,
  186. shareImage: '',
  187. fgList: '',//复购商品
  188. };
  189. },
  190. computed: {
  191. ...mapState('user', ['hasLogin', 'userInfo'])
  192. },
  193. onShareAppMessage(options) {
  194. // 设置菜单中的转发按钮触发转发事件时的转发内容
  195. let pages = getCurrentPages(); //获取加载的页面
  196. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  197. let url = currentPage.route; //当前页面url
  198. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  199. let shareObj = {}
  200. if (this.userInfo.uid) {
  201. shareObj = {
  202. title: this.userInfo.nickname + '邀请您加入7131', // 默认是小程序的名称(可以写slogan等)
  203. path: url + '?scene=' + this.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
  204. imageUrl: '',
  205. success: function(res) {
  206. // 转发成功之后的回调
  207. if (res.errMsg == 'shareAppMessage:ok') {}
  208. },
  209. fail: function() {
  210. // 转发失败之后的回调
  211. if (res.errMsg == 'shareAppMessage:fail cancel') {
  212. // 用户取消转发
  213. } else if (res.errMsg == 'shareAppMessage:fail') {
  214. // 转发失败,其中 detail message 为详细失败信息
  215. }
  216. }
  217. };
  218. } else {
  219. shareObj = {
  220. title: '7131', // 默认是小程序的名称(可以写slogan等)
  221. path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
  222. imageUrl: '',
  223. success: function(res) {
  224. // 转发成功之后的回调
  225. if (res.errMsg == 'shareAppMessage:ok') {}
  226. },
  227. fail: function() {
  228. // 转发失败之后的回调
  229. if (res.errMsg == 'shareAppMessage:fail cancel') {
  230. // 用户取消转发
  231. } else if (res.errMsg == 'shareAppMessage:fail') {
  232. // 转发失败,其中 detail message 为详细失败信息
  233. }
  234. }
  235. };
  236. }
  237. return shareObj;
  238. },
  239. onReachBottom() {
  240. console.log('到底')
  241. // this.getGoodList()
  242. },
  243. onLoad: function(option) {
  244. // #ifdef MP
  245. if (option.scene) {
  246. // 存储小程序邀请人
  247. uni.setStorage({
  248. key: 'spread_code',
  249. data: option.scene
  250. });
  251. }
  252. // #endif
  253. // #ifdef H5
  254. if (option.spread) {
  255. // 存储小程序邀请人
  256. uni.setStorage({
  257. key: 'spread',
  258. data: option.spread
  259. });
  260. }
  261. // #endif
  262. },
  263. onShow: function() {
  264. this.getGoodList()
  265. this.loadData();
  266. this.getArtList()
  267. },
  268. onHide() {
  269. console.log('滴答滴答滴答滴答滴答滴答的')
  270. let video = uni.createVideoContext('myVideo', this);
  271. console.log(video,'video')
  272. try{
  273. video.pause()
  274. }catch(e){
  275. //TODO handle the exception
  276. console.log('err',e)
  277. }
  278. // this.$refs.inv.pause()
  279. },
  280. methods: {
  281. onload(e) {
  282. console.log("onload--广告加载完成");
  283. },
  284. onclose(e) {
  285. console.log("广告关闭: " + e);
  286. },
  287. onerror(e) {
  288. console.log('广告error:',e);
  289. },
  290. getArtList() {
  291. getArtList({
  292. page: 1,
  293. limit: 100
  294. },2).then(({ data }) => {
  295. this.list = data;
  296. });
  297. },
  298. goItem(e) {
  299. console.log('bbbbbbbbbb',e);
  300. uni.navigateTo({
  301. url: '/pages/index/artDetail?id=' + e.id
  302. })
  303. },
  304. goMore() {
  305. console.log('dddddddddd');
  306. uni.navigateTo({
  307. url: '/pages/index/artList?id=2'
  308. })
  309. },
  310. gogogo(item) {
  311. if(!item.path) {
  312. uni.navigateTo({
  313. url: '/pages/index/dkf'
  314. })
  315. }else {
  316. uni.navigateTo({
  317. url: item.path + '&tit=' + item.tit,
  318. fail() {
  319. uni.navigateTo({
  320. url: item.path
  321. }) }
  322. })
  323. }
  324. },
  325. getGoodList() {
  326. let obj = this
  327. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  328. return
  329. }
  330. obj.loadingType = 'loading'
  331. getProducts({
  332. is_pack: 1,
  333. page: 1,
  334. limit: 50,
  335. }).then(res => {
  336. obj.goodList = res.data
  337. if (obj.limit == res.data.length) {
  338. obj.loadingType = 'more'
  339. } else {
  340. obj.loadingType = 'noMore'
  341. }
  342. })
  343. },
  344. navto(url, type = 0) {
  345. if (type == 1) {
  346. if (!this.hasLogin) {
  347. // 保存地址
  348. saveUrl();
  349. // 登录拦截
  350. interceptor();
  351. } else {
  352. uni.navigateTo({
  353. url,
  354. fail() {
  355. uni.switchTab({
  356. url
  357. })
  358. }
  359. })
  360. }
  361. } else {
  362. uni.navigateTo({
  363. url,
  364. fail() {
  365. uni.switchTab({
  366. url
  367. })
  368. }
  369. })
  370. }
  371. },
  372. navTo(url) {
  373. if (url == '') {
  374. this.$api.msg('暂未开通,敬请期待');
  375. } else {
  376. this.navto(url)
  377. }
  378. },
  379. // 點擊搜索框
  380. clickSearch() {
  381. uni.navigateTo({
  382. url: '/pages/product/search'
  383. });
  384. },
  385. // 监听图片加载完成
  386. onImageError(key, index) {
  387. this[key][index].image = '/static/error/errorImage.jpg';
  388. },
  389. // 请求载入数据
  390. async loadData() {
  391. loadIndexs({})
  392. .then(({
  393. data
  394. }) => {
  395. let goods = data.info;
  396. console.log(goods, '商品信息');
  397. this.carouselList = data.banner;
  398. this.swiperLength = this.carouselList.length;
  399. this.bastList = data.giftInfo; //会员礼包
  400. data.info.firstList.forEach(e => {
  401. e.isVip = e.store_type ? "3" : "0"
  402. })
  403. this.firstList = data.info.firstList //首页商品
  404. uni.stopPullDownRefresh();
  405. })
  406. .catch(e => {
  407. uni.stopPullDownRefresh();
  408. });
  409. },
  410. //轮播图切换修改背景色
  411. swiperChange(e) {
  412. const index = e.detail.current;
  413. this.swiperCurrent = index;
  414. this.titleNViewBackground = this.carouselList[index].background;
  415. },
  416. // 轮播图跳转
  417. bannerNavToUrl(item) {
  418. // #ifdef H5
  419. console.log(item.wap_url.indexOf('http'), 'banner');
  420. if (item.wap_url.indexOf('http') >= 0) {
  421. window.location.href = item.wap_url;
  422. }
  423. // uni.navigateTo({
  424. // url: '/pages/zero/order'
  425. // })
  426. // #endif
  427. //测试数据没有写id,用title代替
  428. uni.navigateTo({
  429. url: item.wap_url
  430. });
  431. },
  432. comfirm(text) {
  433. console.log(text);
  434. const result = this.uniCopy(text);
  435. if (result === false) {
  436. uni.showToast({
  437. title: '不支持'
  438. });
  439. } else {
  440. uni.showToast({
  441. title: '复制成功',
  442. icon: 'none'
  443. });
  444. }
  445. this.$refs.popupkf.close();
  446. },
  447. uniCopy(content) {
  448. /**
  449. * 小程序端 和 app端的复制逻辑
  450. */
  451. //#ifndef H5
  452. uni.setClipboardData({
  453. data: content,
  454. success: function() {
  455. console.log('success');
  456. return true;
  457. }
  458. });
  459. //#endif
  460. /**
  461. * H5端的复制逻辑
  462. */
  463. // #ifdef H5
  464. if (!document.queryCommandSupported('copy')) {
  465. //为了兼容有些浏览器 queryCommandSupported 的判断
  466. // 不支持
  467. return false;
  468. }
  469. let textarea = document.createElement('textarea');
  470. textarea.value = content;
  471. textarea.readOnly = 'readOnly';
  472. document.body.appendChild(textarea);
  473. textarea.select(); // 选择对象
  474. textarea.setSelectionRange(0, content.length); //核心
  475. let result = document.execCommand('copy'); // 执行浏览器复制命令
  476. textarea.remove();
  477. return result;
  478. // #endif
  479. },
  480. // 打开客服
  481. openKf() {
  482. this.$refs.popupkf.open();
  483. },
  484. // 关闭客服
  485. cancel() {
  486. this.$refs.popupkf.close();
  487. },
  488. }
  489. };
  490. </script>
  491. <style lang="scss">
  492. page {
  493. min-height: 100%;
  494. height: auto;
  495. }
  496. // 顶部搜索
  497. .top-search {
  498. height: 80rpx;
  499. padding: 0 20rpx;
  500. position: relative;
  501. .top-logo {
  502. width: 50rpx;
  503. // height: 50rpx;
  504. margin-right: 10rpx;
  505. image {
  506. width: 48rpx;
  507. }
  508. }
  509. .search-box {
  510. justify-content: center;
  511. width: 698rpx;
  512. height: 60rpx;
  513. background: rgba(255,255,255,0.5);
  514. color: #fff;
  515. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  516. border-radius: 30rpx;
  517. .search {
  518. width: 34rpx;
  519. height: 34rpx;
  520. }
  521. .search-font {
  522. margin-left: 14rpx;
  523. font-size: 28rpx;
  524. font-weight: 500;
  525. }
  526. }
  527. }
  528. // 顶部轮播图
  529. .top-swiper {
  530. background-color: #fff;
  531. width: 690rpx;
  532. height: 320rpx;
  533. margin: auto;
  534. .carousel-item {
  535. image {
  536. width: 100%;
  537. height: 100%;
  538. border-radius: 20rpx;
  539. }
  540. }
  541. // margin: 20rpx 0 0;
  542. }
  543. .swiper-btm {
  544. height: 60rpx;
  545. width: 750rpx;
  546. background-color: #fff;
  547. margin-bottom: 20rpx;
  548. font-size: 26rpx;
  549. font-weight: 500;
  550. color: #333333;
  551. .btm-item {
  552. flex-grow: 1;
  553. justify-content: center;
  554. image {
  555. width: 25rpx;
  556. height: 25rpx;
  557. margin-right: 14rpx;
  558. }
  559. }
  560. }
  561. .jg {
  562. height: 20rpx;
  563. background: #F8F8F8;
  564. }
  565. // 分类
  566. .cate-section {
  567. justify-content: flex-start;
  568. background-color: #fff;
  569. padding: 0 0 30rpx;
  570. flex-wrap: wrap;
  571. .cate-item {
  572. padding-top: 30rpx;
  573. flex-grow: 0;
  574. width: 25%;
  575. flex-direction: column;
  576. text-align: center;
  577. align-items: center;
  578. justify-content: center;
  579. .img-wrapper {
  580. width:123rpx;
  581. height: 123rpx;
  582. border-radius: 20rpx;
  583. position: relative;
  584. image {
  585. width: 100%;
  586. height: 100%;
  587. position: absolute;
  588. left: 50%;
  589. top: 50%;
  590. transform: translate(-50%, -50%);
  591. }
  592. }
  593. .item-title {
  594. margin-top: 15rpx;
  595. font-size: 26rpx;
  596. font-weight: 500;
  597. color: #333333;
  598. }
  599. }
  600. }
  601. .hot-wrap {
  602. .hot-top {
  603. width: 750rpx;
  604. height: 174rpx;
  605. background: linear-gradient(#FFFFFF, rgba(255,255,255,0));
  606. padding: 0rpx 22rpx 75rpx;
  607. justify-content: flex-start;
  608. font-size: 32rpx;
  609. font-weight: 800;
  610. color: #000000;
  611. image {
  612. width: 36rpx;
  613. height: 36rpx;
  614. margin-right: 12rpx;
  615. }
  616. }
  617. .hot-list {
  618. margin-top: -70rpx;
  619. .good {
  620. width: 704rpx;
  621. background: #FFFFFF;
  622. border-radius: 20rpx;
  623. margin:0 auto 30rpx;
  624. .good-img {
  625. width: 704rpx;
  626. height: 330rpx;
  627. background: #D4D4E1;
  628. border-radius: 20rpx 20rpx 0rpx 0rpx;
  629. }
  630. .good-tit {
  631. padding:10rpx 20rpx;
  632. font-size: 30rpx;
  633. font-weight: bold;
  634. color: #000000;
  635. }
  636. .good-cz {
  637. padding: 0 20rpx 23rpx 23rpx;
  638. .price {
  639. font-size: 42rpx;
  640. font-weight: bold;
  641. color: $base-color;
  642. .xy {
  643. font-size: 24rpx;
  644. }
  645. .old-price {
  646. font-size: 26rpx;
  647. font-weight: 500;
  648. text-decoration: line-through;
  649. color: #999999;
  650. margin-left: 18rpx;
  651. }
  652. }
  653. .cz-btn {
  654. width: 172rpx;
  655. line-height: 60rpx;
  656. background: $base-color;
  657. border-radius: 10rpx;
  658. font-size: 26rpx;
  659. font-weight: 500;
  660. color: #FFFFFF;
  661. text-align: center;
  662. }
  663. }
  664. }
  665. }
  666. }
  667. .popup-box {
  668. width: 522rpx;
  669. height: 605rpx;
  670. background-color: #ffffff;
  671. border-radius: 20rpx;
  672. position: relative;
  673. .img {
  674. position: relative;
  675. top: -56rpx;
  676. left: 0;
  677. width: 522rpx;
  678. height: 132rpx;
  679. display: flex;
  680. justify-content: center;
  681. image {
  682. border-radius: 20rpx 20rpx 0 0;
  683. width: 450rpx;
  684. height: 132rpx;
  685. }
  686. }
  687. .mian {
  688. margin-top: -44rpx;
  689. display: flex;
  690. flex-direction: column;
  691. align-items: center;
  692. // padding: 32rpx 32rpx;
  693. background-color: #ffffff;
  694. border-radius: 0 0 20rpx 20rpx;
  695. text-align: center;
  696. .delivery {
  697. font-size: 40rpx;
  698. color: #333333;
  699. display: flex;
  700. align-items: center;
  701. flex-direction: column;
  702. image {
  703. margin-top: 48rpx;
  704. width: 172rpx;
  705. height: 160rpx;
  706. }
  707. }
  708. .nocancel {
  709. font-size: 32rpx;
  710. color: #333333;
  711. margin-top: 14rpx;
  712. }
  713. .comfirm-box {
  714. margin-top: 52rpx;
  715. display: flex;
  716. // margin-bottom: 32rpx;
  717. // justify-content: space-around;
  718. .cancel {
  719. display: flex;
  720. align-items: center;
  721. justify-content: center;
  722. width: 197rpx;
  723. height: 74rpx;
  724. border: 1px solid #dcc786;
  725. border-radius: 38rpx;
  726. font-size: 32rpx;
  727. color: #605128;
  728. }
  729. .comfirm {
  730. margin-left: 32rpx;
  731. display: flex;
  732. align-items: center;
  733. justify-content: center;
  734. width: 197rpx;
  735. height: 74rpx;
  736. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  737. border-radius: 38px;
  738. font-size: 32rpx;
  739. color: #605128;
  740. }
  741. }
  742. }
  743. }
  744. .top-bg {
  745. height: 450rpx;
  746. //#f53934
  747. background-image: linear-gradient(to bottom,#f53934,#fff);
  748. position: absolute;
  749. top: 0;
  750. width: 100%;
  751. }
  752. .gsjs {
  753. width: 100%;
  754. }
  755. .status_bar {
  756. height: var(--status-bar-height);
  757. width: 100%;
  758. }
  759. .notice {
  760. padding: 0 30rpx;
  761. background-color: #fff;
  762. }
  763. </style>