index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="swiper-wrap">
  5. <!-- <u-swiper
  6. :list="bannerList"
  7. indicator
  8. height="750rpx"
  9. keyName="sliderImg"
  10. indicatorMode="dot"
  11. radius="0"
  12. :circular="true"
  13. imgMode="aspectFit"
  14. @click="bannerClick()"
  15. ></u-swiper> -->
  16. <swiper
  17. class="swiper"
  18. indicator-color="rgba(255,255,255,0.3)"
  19. indicator-active-color="#fff"
  20. circular
  21. @change="bannerChange"
  22. :current="bannerCurrent"
  23. :indicator-dots="true"
  24. :autoplay="false"
  25. :interval="5000"
  26. :duration="500">
  27. <swiper-item @click="bannerClick(item)" v-for="(item,index) in bannerList" :key="index">
  28. <u--image
  29. v-if="item.type==1"
  30. :showLoading="true"
  31. :src="item.sliderImg"
  32. width="100%"
  33. height="750rpx"
  34. >
  35. </u--image>
  36. <!-- object-fit== contain:包含,fill:填充,cover:覆盖 -->
  37. <video
  38. style="width: 100%;height: 100%"
  39. v-if="item.type==2"
  40. object-fit="fill"
  41. loop
  42. :id="`videoId${ index + 1}`"
  43. :autoplay="false"
  44. :src="item.sliderImg"
  45. @error="videoErrorCallback"
  46. :controls="false">
  47. </video>
  48. </swiper-item>
  49. </swiper>
  50. </view>
  51. <view class="swiper-block" :style="{height: ( 375 - navHeight )+'px' }"></view>
  52. <view class="page-wrap">
  53. <view class="member-info u-flex u-row-between" :style="[memberInfoBg]" v-if="vuex_member_info.name">
  54. <view class="left u-flex">
  55. <u-avatar :src="avatar||staticUrl+'/img/avatar-white.png'" size="88rpx"></u-avatar>
  56. <view class="text">
  57. <view class="name">{{vuex_member_info.name}}</view>
  58. <text class="level-name">{{vuex_member_info.levelName}}</text>
  59. </view>
  60. </view>
  61. <view class="right u-flex">
  62. <text class="credit-text">积分</text>
  63. <text class="num">{{memberInfo.credit||0}}</text>
  64. </view>
  65. </view>
  66. <view class="member-info u-flex u-row-between unlogin" :style="[memberInfoBg]" v-else>
  67. <view class="left u-flex">
  68. <u-avatar :src="staticUrl+'/img/avatar-white.png'" size="88rpx"></u-avatar>
  69. <view class="text">
  70. <view class="name">欢迎登录</view>
  71. </view>
  72. </view>
  73. <view class="right" @click="goLogin">
  74. 登录 / 注册
  75. </view>
  76. </view>
  77. <view class="index-nav u-flex u-row-between u-flex-wrap">
  78. <view class="nav-item" v-for="(item,index) in iconNavList" @click="indexNavClick(item)" :key="index">
  79. <!-- <u--image class="image" :src="item.icon" width="101rpx" height="101rpx"></u--image> -->
  80. <img class="image" :src="item.icon" alt="">
  81. <view class="name">{{item.name}}</view>
  82. </view>
  83. </view>
  84. <view class="index-img">
  85. <u-swiper
  86. :list="centerImg"
  87. :indicator="centerImg.length>1"
  88. radius="0"
  89. keyName="sliderImg"
  90. indicatorMode="dot"
  91. imgMode="aspectFit"
  92. height="240rpx"
  93. @click="centerImgClick()"
  94. ></u-swiper>
  95. </view>
  96. <view class="activity">
  97. <view class="single-til u-flex u-row-between">
  98. <view class="text u-flex">
  99. 活动专区
  100. <text class="sub-title">Activity Zone</text>
  101. </view>
  102. <!-- <view class="u-flex" @click="$u.route('/shopping/producTypetList')">
  103. <text class="more-text">更多</text>
  104. <u-icon name="arrow-right" color="#676767" size="24rpx"></u-icon>
  105. </view> -->
  106. </view>
  107. <view class="activity-list">
  108. <view class="activity-item" v-for="item in centerImg" :key="item.id" @click="activityClick(item)">
  109. <u--image :showLoading="true" :src="item.sliderImg" mode="aspectFit" width="100%" height="240rpx"></u--image>
  110. <view class="title ellipsis-1">{{item.name}}</view>
  111. <view class="time">{{item.createTime}}</view>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="product-list-v2">
  116. <view class="single-til u-flex u-row-between">
  117. <view class="text u-flex">
  118. 全部产品
  119. <text class="sub-title">All Products</text>
  120. </view>
  121. <view class="u-flex" @click="$u.route('/shopping/producTypetList')">
  122. <text class="more-text">更多</text>
  123. <u-icon name="arrow-right" color="#676767" size="24rpx"></u-icon>
  124. </view>
  125. </view>
  126. <view class="product-wrap u-flex u-flex-wrap u-row-between">
  127. <view class="product-v2" @click="$u.route('/shopping/productdetails',{id:item.id})" v-for="item in hotGoods" :key="item.id">
  128. <u--image :showLoading="true" :src="item.mainImg" width="100%" height="280rpx"></u--image>
  129. <view class="name ellipsis-2">{{item.goodsName}}</view>
  130. <view class="price">
  131. <view class="myprice u-flex">
  132. ¥ <text class="price-num">{{item.vipPrice}}</text>
  133. <text class="price-type">会员价</text>
  134. </view>
  135. <view class="salePrice">
  136. <text class="gray line-through">{{item.salePrice}}</text>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. <u-empty mode="list" text="暂无产品" v-if="hotGoods.length<1"></u-empty>
  142. </view>
  143. </view>
  144. <view class="goMap u-flex" @click="goMap" :style="{top:`${statusBarHeight}px`}">
  145. <img class="image" :src="staticUrl+'/img/go-map-icon.png'" alt="">
  146. <text class="text">去商场</text>
  147. </view>
  148. <tabbar :tabbarIndexProps='0' />
  149. <!-- <cartfixed ref="cartfixed" @getCartList="getCartList" /> -->
  150. </view>
  151. </template>
  152. <script>
  153. import { systemInfo } from "@/mixin.js";
  154. import tabbar from "../../components/tabbar.vue";
  155. import cartfixed from "../../components/cartfixed.vue"
  156. export default {
  157. components:{
  158. tabbar,
  159. // cartfixed
  160. },
  161. mixins:[systemInfo],
  162. data() {
  163. return {
  164. staticUrl:this.$commonConfig.staticUrl,
  165. bannerList: [],
  166. bannerCurrent: 0,
  167. previousIndex: 0,
  168. previousVideoId: '',
  169. currentVideoIndex: -1,
  170. centerImg:[],
  171. hotGoods:[],
  172. memberInfo:{},
  173. avatar:'',
  174. iconNavList:[
  175. {name:'品牌导览',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-1.png`,url:'brand/brand'},
  176. {name:'会员权益',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-2.png`,url:'center/privilege'},
  177. {name:'线上商城',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-3.png`,url:'/shopping/producTypetList'},
  178. {name:'积分兑换',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-4.png`,url:'/credits/credits'},
  179. {name:'酒店预定',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-5.png`,url:''},
  180. {name:'月子中心',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-6.png`,url:''},
  181. {name:'限时抢购',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-7.png`,url:''},
  182. {name:'爆款专区',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-8.png`,url:'/shopping/productList',param:{typeId:2,typeName:'爆款专区'}},
  183. ],
  184. xsIntro:{},
  185. shopLatitude:'',
  186. shopLongitude:'',
  187. }
  188. },
  189. computed: {
  190. memberInfoBg() {
  191. return { backgroundImage: `url(${this.staticUrl}/img/index-member-info-bg.png)` }
  192. }
  193. },
  194. onShow() {
  195. // this.$refs.cartfixed.getCartList();
  196. this.getHotGoods();
  197. // this.getMemberInfo()
  198. },
  199. onLoad(query) {
  200. const scene = decodeURIComponent(query.scene);
  201. scene&&uni.setStorage({
  202. key:'scene',
  203. data:scene
  204. });
  205. let that = this;
  206. this.swiperList();
  207. setTimeout(()=>{
  208. that.getCenterImg();
  209. },200);
  210. this.getSystemInfo();
  211. this.getIntro();
  212. // console.log('statusBarHeight',this.statusBarHeight);
  213. // console.log('navigationBarHeight',this.navigationBarHeight);
  214. // console.log('windowHeight',this.windowHeight);
  215. // console.log('navHeight',this.navHeight);
  216. console.log('vuex_member_info=======',this.vuex_member_info);
  217. },
  218. methods: {
  219. getIntro(){
  220. this.$u.api.xsGetIntro().then(res=>{
  221. this.xsIntro = res.data;
  222. // this.shopLatitude = res.data.shopLatitude;
  223. // this.shopLongitude = res.data.shopLongitude;
  224. // console.log('res',res);
  225. }).catch(err=>{
  226. console.log('xsGetIntro',err.data);
  227. })
  228. },
  229. goMap(){
  230. uni.openLocation({
  231. latitude:this.xsIntro.shopLatitude, //维度
  232. longitude: this.xsIntro.shopLongitude, //经度
  233. name: "商行地址", //目的地定位名称
  234. scale: 15, //缩放比例
  235. address: this.xsIntro.shopAddress //导航详细地址
  236. })
  237. },
  238. getMemberInfo(){
  239. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  240. this.memberInfo = res.data;
  241. this.avatar = res.data.avatar;
  242. this.$u.vuex('vuex_member_info', res.data);
  243. // console.log('memberInfo',this.memberInfo);
  244. }).catch(err=>{
  245. console.log('memberInfo',err.data);
  246. })
  247. },
  248. swiperList(){
  249. this.$u.api.swiperList({postion:1}).then(res=>{
  250. this.bannerList = res.data.rows;
  251. if(this.bannerList[0].type==2){
  252. this.currentVideoIndex = 0;
  253. const videoId = 'videoId' + (this.currentVideoIndex + 1);
  254. const video = uni.createVideoContext(videoId, this);
  255. video.play();
  256. this.previousVideoId = videoId;
  257. }
  258. // console.log('res',res.data.rows);
  259. }).catch(err=>{
  260. console.log('swiperList',err.data);
  261. })
  262. },
  263. getCenterImg(){
  264. this.$u.api.swiperList({postion:2}).then(res=>{
  265. this.centerImg = res.data.rows;
  266. // console.log('res',res.data.rows);
  267. }).catch(err=>{
  268. console.log('swiperList',err.data);
  269. })
  270. },
  271. bannerClick(item){
  272. // console.log('e',e);
  273. // console.log('bannerClick',this.bannerList[e]);
  274. // let item = this.bannerList[e];
  275. uni.$u.route('/xushuo/dynamicdetails', {
  276. type: 'swiperDetail',
  277. id: item.id
  278. });
  279. },
  280. bannerChange(event){
  281. console.log('current', event.detail);
  282. const currentSwiperIndex = event.detail.current;
  283. // console.log('currentSwiperIndex', currentSwiperIndex);
  284. console.log('previousVideoId',this.previousVideoId);
  285. if (this.previousVideoId !== '') {
  286. // 停止上一个视频的播放
  287. const previousVideo = uni.createVideoContext(this.previousVideoId);
  288. previousVideo.stop();
  289. console.log('stop video');
  290. }
  291. if (this.bannerList[currentSwiperIndex].type === 2) {
  292. // console.log('Play video')
  293. // 播放当前视频
  294. const currentVideoId = 'videoId' + (currentSwiperIndex + 1);
  295. const currentVideo = uni.createVideoContext(currentVideoId, this);
  296. currentVideo.play();
  297. // console.log('Play video');
  298. // 更新上一个视频的ID
  299. this.previousVideoId = currentVideoId;
  300. }
  301. this.previousIndex = currentSwiperIndex;
  302. },
  303. centerImgClick(e){
  304. let item = this.centerImg[e];
  305. uni.$u.route('/xushuo/dynamicdetails', {
  306. type: 'swiperDetail',
  307. id: item.id
  308. });
  309. },
  310. indexNavClick(item){
  311. if(item.url){
  312. uni.$u.route(item.url,item.param );
  313. }else{
  314. uni.$u.toast('开发中,请等待')
  315. }
  316. // if(item.param){
  317. // uni.$u.route(item.url,item.param );
  318. // }
  319. },
  320. getHotGoods(){
  321. this.$u.api.topGoodList({pageNum:1,pageSize:20}).then(res=>{
  322. this.hotGoods = res.data.rows;
  323. console.log('res',res);
  324. }).catch(err=>{
  325. console.log('getHotGoods',err.data);
  326. })
  327. },
  328. activityClick(item){
  329. uni.$u.toast('开发中,请等待')
  330. uni.$u.route('/activity/activitydetails', {
  331. id: item.id
  332. });
  333. },
  334. goLogin(){
  335. uni.$u.route('/pages/login/login')
  336. },
  337. }
  338. }
  339. </script>
  340. <style>
  341. page{
  342. padding-bottom: 40rpx;
  343. }
  344. </style>
  345. <style lang="scss" scoped>
  346. .swiper-wrap{
  347. position: absolute;
  348. left: 0;
  349. top: 0;
  350. width: 100%;
  351. height: 750rpx;
  352. z-index: 10;
  353. .swiper{
  354. height: 100%;
  355. }
  356. }
  357. .page-wrap{
  358. position: relative;
  359. z-index: 20;
  360. background-color: #fff;
  361. }
  362. .member-info{
  363. box-sizing: border-box;
  364. height: 136rpx;
  365. background: linear-gradient(270deg, #EACCA8 0%, #D6986B 100%);
  366. background-size: contain;
  367. background-repeat: no-repeat;
  368. border-radius: 8rpx 8rpx 0rpx 0rpx;
  369. padding: 24rpx;
  370. margin-bottom: 60rpx;
  371. color: #fff;
  372. font-size: 34rpx;
  373. .text{
  374. margin-left: 20rpx;
  375. .name{
  376. font-weight: 600;
  377. color: rgba(255,255,255,0.99);
  378. // line-height: 48rpx;
  379. // margin-bottom: 8rpx;
  380. }
  381. .level-name{
  382. font-size: 22rpx;
  383. font-weight: 400;
  384. // line-height: 30rpx;
  385. }
  386. }
  387. .right{
  388. .credit-text{
  389. font-size: 26rpx;
  390. font-weight: 400;
  391. color: rgba(255,255,255,0.99);
  392. margin-right: 16rpx;
  393. }
  394. .num{
  395. font-weight: 600;
  396. }
  397. }
  398. &.unlogin{
  399. .right{
  400. border-radius: 40rpx;
  401. border: 2rpx solid #FFFFFF;
  402. padding: 14rpx 33rpx;
  403. font-weight: 600;
  404. font-size: 30rpx;
  405. }
  406. }
  407. }
  408. .index-nav{
  409. padding: 0 32rpx;
  410. text-align: center;
  411. margin-bottom: 60rpx;
  412. .nav-item{
  413. width: 25%;
  414. margin-bottom: 30rpx;
  415. .image{
  416. margin-left: auto;
  417. width: 80rpx;
  418. height: 80rpx;
  419. }
  420. .name{
  421. font-size: 26rpx;
  422. font-weight: 400;
  423. color: #666666;
  424. line-height: 37rpx;
  425. }
  426. }
  427. }
  428. .index-img{
  429. margin-bottom: 60rpx;
  430. }
  431. .goMap{
  432. position: absolute;
  433. z-index: 31;
  434. padding: 20rpx;
  435. .image{
  436. width: 34rpx;
  437. height: 35rpx;
  438. }
  439. .text{
  440. font-size: 30rpx;
  441. font-weight: 400;
  442. color: #FFFFFF;
  443. margin-left: 12rpx;
  444. }
  445. }
  446. .activity{
  447. margin-bottom: 60rpx;
  448. }
  449. </style>