index.vue 11 KB

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