index.vue 13 KB

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