index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. currentVideoIndex: -1,
  168. centerImg:[],
  169. hotGoods:[],
  170. memberInfo:{},
  171. avatar:'',
  172. iconNavList:[
  173. {name:'品牌导览',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-1.png`,url:''},
  174. {name:'会员权益',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-2.png`,url:''},
  175. {name:'线上商城',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-3.png`,url:'/shopping/producTypetList'},
  176. {name:'积分兑换',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-4.png`,url:'/credits/credits'},
  177. {name:'酒店预定',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-5.png`,url:''},
  178. {name:'月子中心',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-6.png`,url:''},
  179. {name:'限时抢购',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-7.png`,url:''},
  180. {name:'爆款专区',icon:`${this.$commonConfig.staticUrl}/img/index-nav-icon-8.png`,url:'/shopping/productList',param:{typeId:2,typeName:'爆款专区'}},
  181. ],
  182. xsIntro:{},
  183. shopLatitude:'',
  184. shopLongitude:'',
  185. }
  186. },
  187. computed: {
  188. memberInfoBg() {
  189. return { backgroundImage: `url(${this.staticUrl}/img/index-member-info-bg.png)` }
  190. }
  191. },
  192. onShow() {
  193. // this.$refs.cartfixed.getCartList();
  194. this.getHotGoods();
  195. // this.getMemberInfo()
  196. },
  197. onLoad(query) {
  198. const scene = decodeURIComponent(query.scene);
  199. scene&&uni.setStorage({
  200. key:'scene',
  201. data:scene
  202. });
  203. let that = this;
  204. this.swiperList();
  205. setTimeout(()=>{
  206. that.getCenterImg();
  207. },200);
  208. this.getSystemInfo();
  209. this.getIntro();
  210. // console.log('statusBarHeight',this.statusBarHeight);
  211. // console.log('navigationBarHeight',this.navigationBarHeight);
  212. // console.log('windowHeight',this.windowHeight);
  213. // console.log('navHeight',this.navHeight);
  214. console.log('vuex_member_info=======',this.vuex_member_info);
  215. },
  216. methods: {
  217. getIntro(){
  218. this.$u.api.xsGetIntro().then(res=>{
  219. this.xsIntro = res.data;
  220. // this.shopLatitude = res.data.shopLatitude;
  221. // this.shopLongitude = res.data.shopLongitude;
  222. // console.log('res',res);
  223. }).catch(err=>{
  224. console.log('xsGetIntro',err.data);
  225. })
  226. },
  227. goMap(){
  228. uni.openLocation({
  229. latitude:this.xsIntro.shopLatitude, //维度
  230. longitude: this.xsIntro.shopLongitude, //经度
  231. name: "商行地址", //目的地定位名称
  232. scale: 15, //缩放比例
  233. address: this.xsIntro.shopAddress //导航详细地址
  234. })
  235. },
  236. getMemberInfo(){
  237. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  238. this.memberInfo = res.data;
  239. this.avatar = res.data.avatar;
  240. this.$u.vuex('vuex_member_info', res.data);
  241. // console.log('memberInfo',this.memberInfo);
  242. }).catch(err=>{
  243. console.log('memberInfo',err.data);
  244. })
  245. },
  246. swiperList(){
  247. this.$u.api.swiperList({postion:1}).then(res=>{
  248. this.bannerList = res.data.rows;
  249. // console.log('res',res.data.rows);
  250. }).catch(err=>{
  251. console.log('swiperList',err.data);
  252. })
  253. },
  254. getCenterImg(){
  255. this.$u.api.swiperList({postion:2}).then(res=>{
  256. this.centerImg = res.data.rows;
  257. // console.log('res',res.data.rows);
  258. }).catch(err=>{
  259. console.log('swiperList',err.data);
  260. })
  261. },
  262. bannerClick(item){
  263. // console.log('e',e);
  264. // console.log('bannerClick',this.bannerList[e]);
  265. // let item = this.bannerList[e];
  266. uni.$u.route('/xushuo/dynamicdetails', {
  267. type: 'swiperDetail',
  268. id: item.id
  269. });
  270. },
  271. bannerChange(event){
  272. console.log('current',event.detail);
  273. // console.log('bannerCurrent',this.bannerCurrent);
  274. // console.log('bannerChange',this.bannerList[event.detail.current]);
  275. const currentSwiperIndex = event.detail.current;
  276. if (
  277. this.bannerList[currentSwiperIndex].type === 2 &&
  278. currentSwiperIndex !== this.currentVideoIndex
  279. ) {
  280. const previousVideoId = 'videoId' + (this.currentVideoIndex + 1);
  281. const previousVideo = uni.createVideoContext(previousVideoId, this);
  282. previousVideo.stop();
  283. this.currentVideoIndex = currentSwiperIndex;
  284. }
  285. this.previousIndex = currentSwiperIndex;
  286. },
  287. centerImgClick(e){
  288. let item = this.centerImg[e];
  289. uni.$u.route('/xushuo/dynamicdetails', {
  290. type: 'swiperDetail',
  291. id: item.id
  292. });
  293. },
  294. indexNavClick(item){
  295. if(item.url){
  296. uni.$u.route(item.url,item.param );
  297. }else{
  298. uni.$u.toast('开发中,请等待')
  299. }
  300. // if(item.param){
  301. // uni.$u.route(item.url,item.param );
  302. // }
  303. },
  304. getHotGoods(){
  305. this.$u.api.topGoodList({pageNum:1,pageSize:20}).then(res=>{
  306. this.hotGoods = res.data.rows;
  307. console.log('res',res);
  308. }).catch(err=>{
  309. console.log('getHotGoods',err.data);
  310. })
  311. },
  312. activityClick(item){
  313. uni.$u.toast('开发中,请等待')
  314. uni.$u.route('/activity/activitydetails', {
  315. id: item.id
  316. });
  317. },
  318. goLogin(){
  319. uni.$u.route('/pages/login/login')
  320. },
  321. }
  322. }
  323. </script>
  324. <style>
  325. page{
  326. padding-bottom: 40rpx;
  327. }
  328. </style>
  329. <style lang="scss" scoped>
  330. .swiper-wrap{
  331. position: absolute;
  332. left: 0;
  333. top: 0;
  334. width: 100%;
  335. height: 750rpx;
  336. z-index: 10;
  337. .swiper{
  338. height: 100%;
  339. }
  340. }
  341. .page-wrap{
  342. position: relative;
  343. z-index: 20;
  344. background-color: #fff;
  345. }
  346. .member-info{
  347. box-sizing: border-box;
  348. height: 136rpx;
  349. background: linear-gradient(270deg, #EACCA8 0%, #D6986B 100%);
  350. background-size: contain;
  351. background-repeat: no-repeat;
  352. border-radius: 8rpx 8rpx 0rpx 0rpx;
  353. padding: 24rpx;
  354. margin-bottom: 60rpx;
  355. color: #fff;
  356. font-size: 34rpx;
  357. .text{
  358. margin-left: 20rpx;
  359. .name{
  360. font-weight: 600;
  361. color: rgba(255,255,255,0.99);
  362. // line-height: 48rpx;
  363. // margin-bottom: 8rpx;
  364. }
  365. .level-name{
  366. font-size: 22rpx;
  367. font-weight: 400;
  368. // line-height: 30rpx;
  369. }
  370. }
  371. .right{
  372. .credit-text{
  373. font-size: 26rpx;
  374. font-weight: 400;
  375. color: rgba(255,255,255,0.99);
  376. margin-right: 16rpx;
  377. }
  378. .num{
  379. font-weight: 600;
  380. }
  381. }
  382. &.unlogin{
  383. .right{
  384. border-radius: 40rpx;
  385. border: 2rpx solid #FFFFFF;
  386. padding: 14rpx 33rpx;
  387. font-weight: 600;
  388. font-size: 30rpx;
  389. }
  390. }
  391. }
  392. .index-nav{
  393. padding: 0 32rpx;
  394. text-align: center;
  395. margin-bottom: 60rpx;
  396. .nav-item{
  397. width: 25%;
  398. margin-bottom: 30rpx;
  399. .image{
  400. margin-left: auto;
  401. width: 80rpx;
  402. height: 80rpx;
  403. }
  404. .name{
  405. font-size: 26rpx;
  406. font-weight: 400;
  407. color: #666666;
  408. line-height: 37rpx;
  409. }
  410. }
  411. }
  412. .index-img{
  413. margin-bottom: 60rpx;
  414. }
  415. .goMap{
  416. position: absolute;
  417. z-index: 31;
  418. padding: 20rpx;
  419. .image{
  420. width: 34rpx;
  421. height: 35rpx;
  422. }
  423. .text{
  424. font-size: 30rpx;
  425. font-weight: 400;
  426. color: #FFFFFF;
  427. margin-left: 12rpx;
  428. }
  429. }
  430. .activity{
  431. margin-bottom: 60rpx;
  432. }
  433. </style>