123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- <template>
- <view class="content">
- <!-- <view>
- <view>点击授权{{hasLogin}}</view>
- <button @click="wxlogion" open-type="getUserInfo">请点击授权</button>
- </view> -->
- <logionDialog @confirmDiaolog="confirmDiaolog" @cancelDiaolog="cancelDiaolog" :showdialog="showdialog"/>
- <scroll-view style="height: 100vh;" class="floor-list"
- :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
- refresher-enabled="true">
- <uniNavBar class="top" :shadow="false" :fixed="false" color="#333333" background-color="#FFFFFF">
- <block style="width: 70%;padding-left: 32upx;" slot="left">
- <view class="city" v-if="!allow">
- <view style="font-size: 35upx;">{{ location }}</view>
- </view>
- <button v-if="allow" @opensetting='handler' open-type="openSetting">定位失败,点击重新获取</button>
- </block>
- <view class="input-view" style="float: right;">
- <uni-icon color="#606266" size="22" @click="scan" type="scan"></uni-icon>
- </view>
- <block slot="right">
- <view @click="goinfor">
- <uni-icon color="#606266" size="22" type="chat"></uni-icon>
- </view>
- </block>
- </uniNavBar>
- <view @click="goSearch" class="searchType" style="background: #fff;">
- <view class="input-view">
- <uni-icon type="search" size="22" color="#666666" />
- <input confirm-type="search" class="input" type="text" placeholder="搜索您入住的酒店" @confirm="confirm" />
- </view>
- </view>
- <view class="scrollswiper">
- <swiper class="swiper"
- :indicator-dots="indicatorDots"
- :autoplay="autoplay"
- :interval="interval"
- :duration="duration"
- >
- <!-- <img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>'); -->
- <swiper-item v-for="(item,index) in backgroundlist" :key="index">
- <view class="swiper-item" @tap="shopDetail(item)" >
- <image style="height: 100%;width: 100%;" :src='pictureUrl +"/uploads/home/adv/"+item.adv_code' />
- </view>
- </swiper-item>
-
- </swiper>
- </view>
- <view class="tips">
- 在附近酒店找到您入住的酒店
- </view>
- <view style="border-bottom: 2upx solid #EEEEEE;width: 100%;margin-bottom: 24upx 0;"></view>
-
- <view v-if="!allow">
- <view class="hotelList" v-for='(item,index) in hotelist' :key="index" @click="openinfo(item)">
- <view class="hotleLeft">
- <image style="width: 214upx;height: 152upx;" :src="pictureUrl+'/uploads/home/adv/'+item.store_logo"/>
- </view>
- <view class="hotelright">
- <view style="font-size: 32upx;color: #303133;font-weight: 550;">{{item.store_name}}
- </view>
- <view style="display: flex;flex-direction: row;justify-content: space-between;align-items: center;padding: 10rpx 0;">
- <view style="font-size: 32upx; color: #303133;font-weight: 550;">{{item.store_servicecredit}}</view>
- <view style="color: #606266;font-size: 24upx;">月访客{{item.store_visitor}}</view>
- <view style="color: #606266;font-size: 24upx;">{{item.distance}}</view>
- </view>
- <view v-if="item.tages.length!=1" class="undertip">
- <view v-for="(items,index) in item.tages" :key="index" class="tipsTop">{{items}}</view>
- </view>
- </view>
- </view>
- </view>
- <view v-if="allow" style="text-align: center;margin: 100upx 0;">
- 定位失败暂时获取不到周边酒店信息哦
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import {
- mapMutations,mapState
- } from 'vuex'
- import uniNavBar from '@/component/uni-nav-bar/uni-nav-bar.vue'
- import uniIcon from '@/component/uni-icon/uni-icon.vue'
- import logionDialog from '@/component/loginDialog.vue'
- import amap from '@/common/amap-wx.js'
- export default {
- components: {
- uniNavBar,
- uniIcon,
- logionDialog
- },
- data() {
- return {
- page: 1,
- ispull: true,
- pagesize: 10,
- store_summary:[], // 标签数组
- pictureUrl: this.pictureUrl,
- amapPlugin: null,
- key: '7277de7a5833626b7da8f2496e9d6bf9',
- showdialog: false, // 点击确定显示弹窗
- backgroundlist: ['color1', 'color2', 'color3'], // 轮播数组
- hotelist:[], // 酒店数组
- indicatorDots: true,
- autoplay: true,
- interval: 2000,
- duration: 500,
- title: 'Hello',
- location:'正在定位...',
- scrollTop: 0,
- old: {
- scrollTop: 0
- },
- allow: false
- }
- },
- computed:{
- ...mapState([
- 'hasLogin',
- 'userInfo'
- ]),
- },
- onLoad() {
- this.getswiper(); // 获取首页轮播
- this.gethotelist(); // 酒店列表
- if(this.allow) {
-
- }else {
- this.gethotelist(); // 酒店列表
- }
- this.isGetLocation(); // 检查是否开启定位权限
- this.isUserInfo(); // 检查是否允许获取用户授权
- // 用户授全
- this.amapPlugin = new amap.AMapWX({
- key: this.key
- });
- },
- methods: {
- ...mapMutations(['login','showDialog']),
- handler() {
- console.log("kkkkk")
- this.getAuthorizeInfo();
- },
- goinfor() {
- if(this.hasLogin) {
- uni.navigateTo({
- url: '../myCenter/information' // 我的收藏
- })
- }else {
- this.showdialog = true;
- }
},
- // 关闭弹窗
- cancelDiaolog() {
- this.showdialog = false;
- },
- // 确定
- confirmDiaolog() {
- this.showdialog = false;
- uni.navigateTo({
- url: '../myCenter/information' // 我的收藏
- })
- },
- goSearch() {
- uni.navigateTo({
- url: './searchresult' // 我的搜索
- })
- },
- // 滚动到顶部
- upper(e) {
-
- console.log("顶部")
- },
-
- // 滚到底部
- lower(e) {
- this.page = this.page + 1;
- if(this.ispull) {
- this.gethotelist();
- }
- },
-
- // 滚动时触发
- scroll(e) {
- this.old.scrollTop = e.detail.scrollTop
- },
- isGetLocation(a="scope.userLocation"){ // 检查当前是否已经授权访问scope属性W
- let _this=this;
- uni.getSetting({
- success(res) {
- // 用户定位接口
- if (!res.authSetting[a]) { // 每次进入程序判断当前是否获得授权,如果没有就去获得授权,如果获得授权,就直接获取当前地理位置
- _this.getAuthorizeInfo()
- }else{
- _this.getRegeo()
- }
-
- }
- });
- },
- // 进入判断是否授权
- isUserInfo(b='scope.userInfo') {
- let _this = this;
- uni.getSetting({
- success(res) {
- if(!res.authSetting[b]) {
- _this.showDialog(false);
- }else {
- _this.showDialog(true);
- }
- }
- })
- },
- getAuthorizeInfo(a="scope.userLocation"){ //uniapp弹窗弹出获取授权弹窗
- let _this=this;
- uni.authorize({
- scope: a,
- success(res) { //允许授权
- console.log("调用位置授权")
- _this.getRegeo();
- },
- fail(){ //拒绝授权
- _this.allow = true;
- _this.$msg("你拒绝了授权,无法获得周边信息")
- }
- })
- },
- getRegeo(){ //获取地理位置
- let _this=this;
- uni.showLoading({
- title: '获取信息中'
- });
- _this.amapPlugin.getRegeo({
- success: (data) => {
- this.location = data[0].name;
- this.allow = false;
- uni.hideLoading();
- },
- fail: (res) => {
- console.log(res);
- uni.hideLoading();
- }
- });
-
- },
-
- // 获取首页轮播
- getswiper() {
-
- this.request({
- url:"/v1/entry/adv",
- method:'get',
- success: (res) => {
- this.backgroundlist = res.data.data;
- }
- })
-
- },
- // 获取酒店列表
- gethotelist() {
- this.request({
- url:"/v2/entry/storeList",
- method:'get',
- data: {
- page: this.page,
- page_size: 10
- },
- success: (res) => {
- let { data,code } = res.data;
- if(code == 1000) {
-
- if(data.store_list.length<10) {
- this.ispull = false;
- }
- if(this.hotelist.length == 0) {
- this.hotelist = data.store_list
- }else {
- this.hotelist = this.hotelist.concat(data.store_list);
- }
- this.hotelist.forEach(item => {
- item.tages = item.store_summary.split(' ');
- })
-
- }else {
- this.$msg("网络错误稍后再试")
- }
- }
- })
- },
- // 点击扫码
- scan(){
- uni.scanCode({
- success: (res) => {
- console.log(res);
- }
- });
- },
-
- // 跳转到新页面 酒店详情
- openinfo(item) {
- let id = item.store_id;
- uni.navigateTo({
- url: `/pages/index/hotel?id=${id}`
- });
- },
-
- // 跳转到商品详情
- shopDetail(item) {
- let id = item.adv_target.goods_id;
- let store_id = item.adv_target.store_id;
- if(item.adv_target.type == 'goods') {
- uni.navigateTo({
- url: `/pages/index/shop?id=${id}&store_id=${store_id}`
- });
- }else if(item.adv_target.type == 'store') {
- let id = item.adv_target.store_id;
- let title = item.adv_target.store_name;
- uni.navigateTo({
- url: `/pages/index/hotel?id=${id}`
- });
- }
-
- }
-
- }
- }
- </script>
- <style>
- .top .uni-navbar__header-btns {
- width: 77%!important;
- }
- .top .uni-navbar__header-container {
- width: 50%!important;
- }
-
- .content {
- background: #fff;
- }
- .city {
- width: 100%;
- height: 100%;
- white-space:nowrap;
- overflow:hidden;
- text-overflow:ellipsis;
- }
- .logo {
- height: 200upx;
- width: 200upx;
- margin-top: 200upx;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 50upx;
- }
- .text-area {
- display: flex;
- justify-content: center;
- }
- .title {
- font-size: 36upx;
- color: #8f8f94;
- }
- .van-cell--borderless {
- background-color: #e7e7e7!important;
- }
- .searchType .input-view {
- width: 85%;
- display: flex;
- background-color: #e7e7e7;
- height: 30px;
- border-radius: 15px;
- padding: 0 4%;
- flex-wrap: nowrap;
- margin: 7px 0;
- line-height: 30px;
- margin: 24upx auto;
- }
-
- .searchType .input-view .uni-icon {
- line-height: 30px !important;
- }
-
- .searchType .input-view .input {
- height: 30px;
- line-height: 30px;
- width: 94%;
- padding: 0 3%;
- }
- .uni-navbar--border::after {
- background: #fff!important;
- }
- .swiper {
- height: 300upx;
- }
- .swiper-item {
- display: block;
- height: 300upx;
- line-height: 300upx;
- text-align: center;
- }
-
- .scrollswiper {
- width: 90%;
- margin: 20upx auto;
- }
-
- .tips {
- color: #303133;
- font-size: 28upx;
- text-align: center;
- margin: 24upx 0;
- }
-
- .hotelList {
- display: flex;
- flex-direction: row;
- padding: 24upx 32upx;
- }
-
- .hotleLeft {
- width: 214upx;
- height: 152upx;
- }
-
- .hotelright {
- padding-left: 16upx;
- display: flex;
- flex-direction: column;
- width: 100%;
- }
-
- .undertip {
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .tipsTop {
- border: 2upx solid #606266;
- margin-right: 12upx;
- color: #606266;
- padding: 4upx;
- font-size: 24upx;
- border-radius: 4rpx;
- padding: 0 10rpx;
- }
- </style>
|