| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906 |
- <template>
- <view class="content">
- <!-- 背景图 -->
- <view class="index_bg">
- <view class="welcome">
- <image class="welcome_img" src="../../static/index/welcome.png"></image>
- </view>
- </view>
- <!-- 第一层公寓名称卡片 -->
- <view class="uni-ka" style="margin-top: -40px;margin-bottom:0px;">
- <text class="uni-title">研究生公寓(南昌交通学院)</text>
- <text class="uni-sub-title">2021年装修 | 智能门锁 | 房间wifi | 免费停车</text>
- <text class="uni-extra" @click="navigateToXiangqing">设施/详情></text>
- <text class="uni-body">江西省宜春市靖安县墨轩湖大道1号</text>
- <image class="uni-phone" @click="telphone()" src="../../static/index/index_phone.svg"></image>
- <a href="https://uri.amap.com/marker?position=115.387261,28.788671&name=南昌交通学院智慧公寓">
- <image class="uni-map" @click="mapDaohang('115.387261','28.788671')" src="../../static/index/index_map.svg"></image>
- </a>
- <br><text class="uni-body2">距离我{{distance}}km</text>
- </view>
- <!-- 第二层工具 -->
- <!-- <view class="item-list">
- <view class="item-list-one" @click="navigateToXuzhi">
- <image src="../../static/index/xuzhi.png" class="img-btn" height="100%" width="100%"></image>
- <text class="list-txt">入住须知</text>
- </view>
- <view class="item-list-one" @click="navigateToDairuzhu('warn')">
- <image src="../../static/index/ruzhu.png" class="img-btn"></image>
- <text class="list-txt">办理入住</text>
- </view>
- <view class="item-list-one" @click="navigateToXuzhu">
- <image src="../../static/index/index_xuzhu.svg" class="img-btn"></image>
- <text class="list-txt">办理续住</text>
- </view>
- <view class="item-list-one" @click="navigateToTuifang('warn')">
- <image src="../../static/index/tuifang.png" class="img-btn"></image>
- <text class="list-txt">办理退房</text>
- </view>
- </view> -->
- <!-- 退房失败时弹框 -->
- <!-- <uni-popup ref="popup_tui" type="center" width="300rpx" height="300rpx" background-color="#fff">
- <view class="kuang_txt_tui">
- <text>请先订房</text>
- </view>
- </uni-popup> -->
- <uni-popup ref="popup_tui" type="dialog">
- <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" content="请先订房!" @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
- </uni-popup>
- <!-- 第三层订房 -->
- <view class="room-list">
- <!-- 选择住房日期 -->
- <view class="select-time" @click="openCalendar">
- <view class="select-time-one">
- <text class="select-list">{{startWeek}}入住</text>
- <text class="select-list-time">{{startTime}}</text>
- </view>
- <view class="select-center">
- <view class="select-line1"></view>
- <view class="select-circle">{{ ruzhu_num }} 晚</view>
- <view class="select-line2"></view>
- </view>
- <view class="select-time-one">
- <text class="select-list">{{endWeek}}离店</text>
- <text class="select-list-time">{{endTime}}</text>
- </view>
- </view>
- <uni-popup ref="popup_picker" :mask-click="true">
- <view class=popup_bg_picker>
- <!-- <text class="popup_title">取消</text>
- <text class="popup_error" style="margin-left: 272px;" @click="popup_pickerClose">确定</text> -->
- <uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert"
- :lunar="info.lunar" :startDate="info.startDate" :endDate="info.endDate" :range="info.range" @change="change" />
- </view>
- </uni-popup>
- <!-- 房型列表 -->
- <view class="room-kuang">
- <view class="room-xinxi" v-for="(item, index) in roomType" :key="index">
- <image v-if="item.h_type.indexOf('标准') !== -1" class="room-image" src="../../static/index/std.jpg" @click="inputDialogToggle(item.h_type)">
- </image>
- <image v-else-if="item.h_type.indexOf('高级') !== -1" class="room-image" src="../../static/index/adv1.jpg"
- @click="inputDialogToggle(item.h_type)"></image>
- <image v-else class="room-image" src="../../static/index/lux.jpg" @click="inputDialogToggle(item.h_type)"></image>
- <view class="room-name">{{ item.h_type }}</view>
- <view v-if="item.h_type.indexOf('标准') !== -1" class="room-mark">描述:面积约20平方米,配置1.35米双人床一张,点击左侧图片查看更多。</view>
- <view v-else-if="item.h_type.indexOf('高级') !== -1" class="room-mark">描述:面积约28平方米,配置1.5米双人床一张,点击左侧图片查看更多。</view>
- <view v-else class="room-mark">描述:面积约40平方米,配置1.5米双人床一张,点击左侧图片查看更多。</view>
- <view class="room-icon">
- <image src="../../static/index/index_wifi.svg" style="width: 30rpx;height: 30rpx;"></image>
- <image src="../../static/index/index_kongtiao.svg" style="width: 26rpx;height: 26rpx;margin-left: 10rpx;"></image>
- <image src="../../static/index/index_nosmoking.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
- <image src="../../static/index/index_lock.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
- </view>
- <view class="room-price">¥{{ item.price }}</view>
- <!-- <view class="room-num">今剩{{ item.s_yum }}间</view> -->
- <view class="room-button" :class="{'room-button2': item.s_yum == 0}">
- <text v-if="item.s_yum == 0">已满</text>
- <text v-else @click="navigateToOrderRoom(item.s_yum, item.id, item.h_type, item.price)">订</text>
- </view>
- <view class="room-line" v-if="index < (roomType.length - 1)"></view>
- </view>
- </view>
- </view>
- <!-- 订房时弹框 -->
- <!-- <uni-popup ref="popup_order" type="center" width="300rpx" height="300rpx" background-color="#fff">
- <view class="kuang_txt">
- <text>{{order_txt}}</text>
- </view>
- </uni-popup> -->
- <uni-popup ref="popup_order" type="dialog">
- <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" :content="order_txt" @confirm="dialogConfirm"
- @close="dialogClose"></uni-popup-dialog>
- </uni-popup>
- <!-- 房间样式弹窗页面 -->
- <uni-popup ref="popup" type="dialog" :mask-click="false">
- <view class="popup_bg">
- <text class="popup_title">户型详情</text>
- <text class="popup_error" @click="popupClose"></text>
- <!-- 轮播图 -->
- <swiper class="swiper" circular :indicator-dots="indicatorDots">
- <swiper-item v-for="(item, index) in img" :key="index">
- <view class="swiper-item">
- <image :src="item" class="swiper-img"></image>
- </view>
- </swiper-item>
- </swiper>
- <text class="popup_title2">介绍</text>
- <view class="popup_txt">
- <view class="popup_txt_in">{{ typeText }}</view>
- </view>
- </view>
- </uni-popup>
- <!-- 有一个可续住订单时办理续住弹窗页面 -->
- <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
- <view class="popup_bg_xu">
- <text class="popup_title">办理续住</text>
- <text class="popup_error" @click="popupXuzhuClose"></text>
- <text class="popup_xu_line"></text>
- <!-- 时间选择 -->
- <view class="select-time-xu" @click="openXuCalendar">
- <view class="select-time-one-xu">
- <text class="select-list">周四入住</text>
- <text class="select-list-time">07月21日</text>
- </view>
- <view class="select-center">
- <view class="select-line1"></view>
- <view class="select-circle">1晚</view>
- <view class="select-line2"></view>
- </view>
- <view class="select-time-one-xu">
- <text class="select-list">周五离店</text>
- <text class="select-list-time">07月22日</text>
- </view>
- </view>
- <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
- <!-- 支付框 -->
- <view class="fukuan">
- <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
- <view class="fu-zhifu">立即支付</view>
- </view>
- </view>
- </uni-popup>
- <uni-popup ref="popup_xu" :mask-click="true">
- <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert"
- :lunar="infoXu.lunar" :startDate="infoXu.startDate" :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu" />
- </uni-popup>
- <!-- 无可续住订单时办理续住弹窗页面 -->
- <uni-popup ref="popup_xuzhu_no" type="dialog">
- <uni-popup-dialog cancelText="关闭" confirmText="确定" content="请先订房" @close="dialogClose"></uni-popup-dialog>
- </uni-popup>
- <a :href="'https://chtech.ncjti.edu.cn/hotelReservation/zhotel/appcode.action?card_number=' + cardNumber" id="shouquanId"></a>
- </view>
- </template>
- <script>
- // 导入qq地图图片
- import AMap from "../../lib/qqmap-wx-jssdk.js";
- export default {
- data() {
- return {
- showCalendar: false,
- info: {
- lunar: true,
- range: true,
- insert: true,
- selected: [],
- startDate: '',
- date: '',
- endDate: ''
- },
- msgType: 'warn',
- distance: 0, //"距离"
- startTime: '', //默认到店日期
- endTime: '', //默认离店日期
- startDate: '', //默认到店日期接口数据
- endDate: '', //默认离店日期接口数据
- startWeek: '', // 默认入店日
- endWeek: '', // 默认离店
- payMount: 0, //房间价格
- freeRoom: 0, //房间剩余
- ruzhu_num: 1, //入住夜晚数
- //续住里选择器
- infoXu: {
- lunar: true,
- range: true,
- insert: true,
- selected: [],
- startDate: '',
- date: '',
- endDate: ''
- },
- roomType: [],
- typeText: '', //房型详细描述
- indicatorDots: true, //滚动图片提示条默认出现
- img: [], //轮播图里图片
- phone: '19807957890', //电话
- latitude: '', // 默认当前纬度
- longitude: '',
- scale: 12, // 默认16
- markers: [],
- markerHeight: 30,
- xuzhu_type: [], // 办理续住判断条件
- xuzhu_panduan: [], // 办理续住判断条件赋值
- tui_type: [], // 办理退房判断条件
- tui_panduan: [], // 办理退房判断条件赋值
- dai_type: [], // 办理入住判断条件
- dai_panduan: [], // 办理入住判断条件赋值
- order_txt: '', //订房事故时信息
- cardNumber: '',
- dates: [],
- biaozhun_min: 1000,
- gaoji_min: 1000,
- haohua_min: 1000
- }
- },
- onLoad(options) {
- // 获取当前时间
- const now = new Date()
- // 设置指定日期
- const specifiedDate = new Date('2024-08-15');
- // 将指定日期的时间设置为0时0分0秒
- specifiedDate.setHours(0, 0, 0, 0);
- // 比较当前时间和指定日期
- if (now < specifiedDate) {
- // 如果当前时间早于指定日期的0时0分0秒,执行跳转
- uni.redirectTo({
- url: '/pages/default/default' // 跳转的目标页面路径
- });
-
- return;
- }
- // console.log('index.options:', options.card_number);
- if (!options.hasOwnProperty("card_number")) {
- uni.showLoading({
- title: '加载中...',
- mask: true
- })
- setTimeout(() => {
- uni.hideLoading();
- }, 1500)
- return;
- }
- var cardNumber = options.card_number;
- if (this.$utils.isEmpty(cardNumber)) {
- uni.showToast({
- title: '未获取用户信息',
- duration: 1500
- });
- return;
- }
- var cardNumber_store = this.$utils.getEncryptedData('cardNumber');
- if (!this.$utils.isEmpty(cardNumber) && !this.$utils.isEmpty(cardNumber_store)) {
- if (cardNumber !== cardNumber_store) {
- uni.showToast({
- title: '用户不合法',
- duration: 1500
- })
- return;
- }
- // 存储用户卡号
- this.$utils.storeEncryptedData('cardNumber', cardNumber);
- this.cardNumber = cardNumber;
- }
- },
- mounted() {
- this.startDate = this.$utils.getDate(new Date()).fullDate2
- this.endDate = this.$utils.getDate(new Date(), 1).fullDate2
- },
- onReady() {
- const that = this;
- that.$nextTick(() => {
- that.showCalendar = true
- })
- // TODO 模拟请求异步同步数据
- setTimeout(() => {
- const now = new Date();
- const theEndDate = new Date('2030-09-15');
- // console.log('date:'+getDate(new Date()).fullDate)
- // console.log('startDate:'+getDate(new Date()).fullDate)
- // console.log('startWeek:'+getDate(new Date()).eWeek)
- var arrDate = that.$utils.getDateComponents(now, 'date', 'time', 'weekday_cn', 'monthday_cn');
- var arrDate_1 = that.$utils.getDateComponents(that.$utils.addDaysToDate(now, 1), 'date', 'time', 'weekday_cn', 'monthday_cn');
- var arrDate_6 = that.$utils.getDateComponents(theEndDate, 'date', 'time', 'weekday_cn', 'monthday_cn');
- that.info.date = arrDate.date
- that.info.startDate = arrDate.date
- that.info.endDate = arrDate_6.date
- console.log(that.info.endDate);
- that.infoXu.date = arrDate.date
- that.infoXu.startDate = arrDate.date
- that.infoXu.endDate = arrDate_6.date
- that.startTime = arrDate.monthday_cn
- that.endTime = arrDate_1.monthday_cn
- that.startWeek = arrDate.weekday_cn
- that.endWeek = arrDate_1.weekday_cn
- }, 30)
- // wx请求获取位置权限
- that.getAuthorize()
- .then(() => {
- // 同意后获取
- that.getLocationInfo();
- })
- .catch(() => {
- uni.getLocation({
- type: "gcj02",
- success: function(res) {
- // 暂时
- that.longitude = res.longitude;
- that.latitude = res.latitude;
- var long = 0;
- var lat = 0;
- //小数点保留六位 经度
- if (that.longitude.toString().indexOf('.') > 0) {
- const longlatsplit = that.longitude.toString().split('.');
- if (longlatsplit.length >= 2) {
- long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,
- 6));
- }
- }
- if (that.latitude.toString().indexOf('.') > 0) {
- const longlatsplit1 = that.latitude.toString().split('.');
- if (longlatsplit1.length >= 2) {
- lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,
- 6));
- }
- }
- that.distance = that.getMapDistance(lat, long, '28.788671', '115.387261');
- that.markers = [{
- id: "",
- latitude: res.latitude,
- longitude: res.longitude,
- iconPath: "../../static/img/phone.png",
- width: that.markerHeight, //宽
- height: that.markerHeight, //高
- }, ];
- },
- });
- // 不同意给出弹框,再次确认
- // this.openConfirm()
- // .then(() => {
- // this.getLocationInfo();
- // })
- // .catch(() => {
- // this.rejectGetLocation();
- // });
- });
- // 获取用户信息
- this.getUserInfo()
- },
- onShow() {
- // 获取房型
- this.getRoomType('')
- },
- methods: {
- // 房型接口
- getRoomType(param) {
- let that = this
- let d = ''
- that.roomType = []
- if (param == '') {
- var arrDate = this.$utils.getDateComponents(new Date(), 'date');
- d = arrDate.date
- } else
- d = param
- if (d !== undefined) {
- that.$myRequest({
- url: '/hotelReservation/zhotel/appday_list.action?date=' + d,
- }).then(res => {
- // console.log(res.data);
- if (res.data.code === 200) {
- let data = res.data.data;
- data.forEach(item => {
- let it = {
- date: item.date,
- h_type: item.h_type,
- id: item.id,
- price: item.price,
- y_num: item.y_num,
- z_num: item.z_num,
- s_yum: item.s_yum
- }
- if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
- that.biaozhun_min = item.s_yum
- }
- if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
- that.gaoji_min = item.s_yum
- }
- if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
- that.haohua_min = item.s_yum
- }
- that.roomType.push(it)
- });
- } else {
- uni.showToast({
- title: '未获得房型'
- })
- }
- });
- }
- },
- // 获取用户信息openid,没有则弹出进行授权
- getUserInfo() {
- var that = this;
- that.$myRequest({
- url: '/hotelReservation/zhotel/appuser.action?card_number=' + that.cardNumber,
- }).then(res => {
- if (res.data.code === 200) {
- if (that.$utils.isEmpty(res.data.data.openid)) {
- uni.showModal({
- title: '授权提示',
- content: '获取个人信息',
- success(res) {
- if (res.confirm) {
- // 获取超链接元素
- var link = document.getElementById('shouquanId');
- // 触发点击事件
- link.click();
- } else if (res.cancel) {
- uni.showToast({
- title: '用户取消授权'
- })
- }
- }
- })
- }
- // } else {
- // uni.showToast({
- // title: res.data.message
- // })
- }
- });
- },
- // 房型详情接口
- getRoomTypeInfo(id) {
- let _self = this
- _self.typeText = ''
- _self.img = []
- if (id === 1) {
- _self.typeText = '一室一卫,内有沙发、茶几、空调、电视、衣柜、24小时热水,1.35米双人床一张。'
- _self.img = ['/static/index/std0.jpg', '/static/index/std.jpg']
- } else if (id === 2) {
- _self.typeText = '一室一厅一卫,有标准公寓所有设施,客厅配有空调、3座沙发、书桌。1.5米双人床一张。'
- _self.img = ['/static/index/adv1.jpg', '/static/index/adv.jpg', '/static/index/adv2.jpg']
- } else {
- _self.typeText = '一室一厅一卫,有标准公寓所有设施,大客厅配落地空调、5座沙发、书桌。1.5米双人床一张。'
- _self.img = ['/static/index/lux.jpg', '/static/index/lux1.jpg', '/static/index/lux2.jpg']
- }
- },
- // 订单列表
- getOrderPage() {
- let _self = this
- _self.xuzhu_type = []
- _self.tui_type = []
- _self.dai_type = []
- this.$axios.get("/hotelReservation/zhotel/order/page?curPage=1&pageSize=100", {
- headers: {
- 'user_token': localStorage.getItem('token')
- }
- }).then(res => {
- res = res.data
- if (res.success) {
- res.data.list.forEach(data => {
- if (data.flag !== '-1') {
- _self.xuzhu_type.push(data.orderStatu)
- _self.tui_type.push(data.orderStatu)
- _self.dai_type.push(data.orderStatu)
- // console.log(_self.xuzhu_type)
- }
- })
- } else {
- console.log('获取订单列表失败')
- }
- });
- },
- // // 跳转到入住须知
- // navigateToXuzhi() {
- // uni.navigateTo({
- // url: "/pages/ruzhuxuzhi/ruzhuxuzhi",
- // });
- // },
- // 跳转到公寓详情
- navigateToXiangqing() {
- uni.navigateTo({
- url: "/pages/gongyujieshao/gongyujieshao",
- });
- },
- // 订房间
- navigateToOrderRoom(enableNum, id, typeName, price) {
- // console.log(enableNum, id, typeName, price);
- let _self = this
- _self.roomType = []
- // if (enableNum >= 1) {
- uni.navigateTo({
- url: "/pages/order_room/order_room?roomTypeId=" + id + "&enableStartTime=" + _self.startDate + "&enableEndTime=" + _self.endDate +
- "&startWeek=" + _self.startWeek + "&endWeek=" + _self.endWeek + "&startTime=" + _self.startTime + "&endTime=" + _self.endTime +
- "&ruzhu_num=" + _self.ruzhu_num + "&typeName=" + typeName + "&freeRoom=" + enableNum + "&price=" + price
- });
- // }
- // this.getRoomType()
- },
- //办理入住跳转
- navigateToDairuzhu(type) {
- this.dai_panduan = []
- setTimeout(() => {
- this.getOrderPage()
- }, 1)
- setTimeout(() => {
- for (let i = 0; i < this.dai_type.length; i++) {
- this.dai_type.forEach(val => {
- if (val[i] == 2) {
- this.dai_panduan.push(val)
- }
- })
- }
- if (this.dai_panduan.length >= 1) {
- uni.navigateTo({
- url: "/pages/my_orderlist/my_orderlist?Inv=2"
- })
- } else if (this.dai_panduan.length < 1) {
- this.msgType = type
- this.order_txt = '请先订房!'
- this.$refs.popup_order.open()
- }
- }, 150)
- },
- //办理退房
- navigateToTuifang(type) {
- this.tui_panduan = []
- setTimeout(() => {
- this.getOrderPage()
- }, 1)
- setTimeout(() => {
- for (let i = 0; i < this.tui_type.length; i++) {
- this.tui_type.forEach(val => {
- if (val[i] == 3) {
- this.tui_panduan.push(val)
- }
- })
- }
- if (this.tui_panduan.length >= 1) {
- uni.navigateTo({
- url: "/pages/my_orderlist/my_orderlist?Inv=3"
- })
- } else if (this.tui_panduan.length < 1) {
- this.msgType = type
- this.$refs.popup_tui.open()
- }
- }, 150)
- },
- // 户型详情弹窗
- inputDialogToggle(h_type) {
- this.$refs.popup.open()
- if (h_type.indexOf('标准') !== -1) {
- this.getRoomTypeInfo(1)
- } else if (h_type.indexOf('高级') !== -1) {
- this.getRoomTypeInfo(2)
- } else if (h_type.indexOf('豪华') !== -1) {
- this.getRoomTypeInfo(3)
- } else {
- }
- },
- popupClose() {
- this.$refs.popup.close()
- },
- //办理续住弹窗
- navigateToXuzhu() {
- this.xuzhu_panduan = []
- setTimeout(() => {
- this.getOrderPage()
- }, 1)
- setTimeout(() => {
- for (let i = 0; i < this.xuzhu_type.length; i++) {
- this.xuzhu_type.forEach(val => {
- if (val[i] == 3) {
- this.xuzhu_panduan.push(val)
- }
- })
- }
- // console.log(this.xuzhu_panduan)
- if (this.xuzhu_panduan.length > 1) {
- uni.navigateTo({
- url: "/pages/my_orderlist/my_orderlist?Inv=3"
- })
- } else if (this.xuzhu_panduan.length == 1) {
- this.$refs.popup_xuzhu.open()
- } else if (this.xuzhu_panduan.length == 0) {
- this.$refs.popup_xuzhu_no.open()
- }
- }, 150)
- },
- popupXuzhuClose() {
- this.$refs.popup_xuzhu.close()
- },
- // 不可续住关闭弹窗
- dialogClose() {
- this.$refs.popup_xuzhu_no.close()
- },
- // 日期选择器弹窗开启
- openCalendar() {
- this.$refs.popup_picker.open()
- },
- change(e) {
- var that = this;
- that.biaozhun_min = 1000
- that.gaoji_min = 1000
- that.haohua_min = 1000
- var before = e.range.before;
- var after = e.range.after;
- if (before !== '' && after === '')
- this.getRoomType(before);
- this.dates = this.$utils.generateDates(before, after);
- if (this.dates.length !== 0) {
- let temp = this.roomType;
- this.info.selected = []
- // 创建一个用于存储请求结果的数组
- const results = [];
- // 创建一个包含所有请求的Promise数组
- const requestPromises = this.dates.map(date => {
- return new Promise((resolve, reject) => {
- uni.request({
- url: '/hotelReservation/zhotel/appday_list.action?date=' + date,
- success: res => {
- // 将请求结果存储到结果数组中
- results.push(res);
- resolve();
- },
- fail: err => {
- reject(err);
- }
- });
- });
- });
- // 使用Promise.all()等待所有请求完成
- Promise.all(requestPromises)
- .then(() => {
- // 所有请求完成后的处理
- // 遍历每个元素
- results.forEach(result => {
- // 遍历每个元素中的"data"数组
- result.data.data.forEach(item => {
- // console.log(item);
- var min = 1000;
- // 在这里对每个数据项进行操作
- if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
- temp.forEach((it) => {
- if (it.h_type.indexOf('标准') !== -1) {
- this.$set(it, 's_yum', item.s_yum);
- that.biaozhun_min = item.s_yum;
- }
- })
- } else if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
- temp.forEach((it) => {
- if (it.h_type.indexOf('高级') !== -1) {
- this.$set(it, 's_yum', item.s_yum);
- that.gaoji_min = item.s_yum;
- }
- })
- } else if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
- temp.forEach((it) => {
- if (it.h_type.indexOf('豪华') !== -1) {
- this.$set(it, 's_yum', item.s_yum);
- that.haohua_min = item.s_yum;
- }
- })
- }
- if (min > item.s_yum)
- min = item.s_yum
- that.info.selected.push({
- date: item.date,
- info: min.toString()
- })
- });
- });
- setTimeout(() => {
- this.roomType = []
- this.roomType = temp;
- }, 500)
- })
- .catch(err => {
- // 处理错误
- console.error('异常:', err);
- });
- } else {
- this.info.selected = [{
- date: before,
- info: '到店'
- },
- {
- date: after,
- info: '离店'
- }
- ];
- }
- if (before !== '' && after === '') {
- this.startWeek = '周' + e.lunar.ncWeek.substring(2, 3)
- } else if (before !== '' && after !== '') {
- if ((new Date(after).getTime()) == (new Date(before).getTime())) {
- uni.showToast({
- title: '不能选同一天',
- icon: 'error',
- duration: 1500
- });
- return;
- }
- this.endWeek = '周' + e.lunar.ncWeek.substring(2, 3);
- if ((new Date(after).getTime()) < (new Date(before).getTime())) {
- var temp = before;
- before = after;
- after = temp;
- var tmp = this.startWeek;
- this.startWeek = this.endWeek;
- this.endWeek = tmp;
- }
- this.startTime = before.substring(5, 7) + '月' + before.substring(8, 10) + '日';
- this.endTime = after.substring(5, 7) + '月' + after.substring(8, 10) + '日';
- this.startDate = before + ' 14:00:00';
- this.endDate = after + ' 12:00:00';
- this.ruzhu_num = parseInt(((new Date(after).getTime()) - (new Date(before).getTime())) / 1000 / 60 / 60 / 24);
- if (this.endDate != ' 12:00:00') {
- this.getRoomType();
- }
- }
- },
- // 续住里日期选择器弹窗
- openXuCalendar() {
- this.$refs.popup_xu.open()
- },
- changeXu(e) {
- // console.log('1change 返回:', e)
- // 模拟动态打卡
- if (this.infoXu.selected.length > 5) return
- this.infoXu.selected.push({
- date: e.range.before,
- info: '到店'
- })
- this.infoXu.selected.push({
- date: e.range.after,
- info: '离店'
- })
- },
- //拨打电话
- telphone() {
- var that = this;
- uni.makePhoneCall({
- phoneNumber: that.phone,
- }) // 传参带入号码即可
- },
- // 初次位置授权
- getAuthorize() {
- return new Promise((resolve, reject) => {
- uni.authorize({
- scope: "scope.userLocation",
- success: () => {
- resolve(); // 允许授权
- },
- fail: () => {
- reject(); // 拒绝授权
- },
- });
- });
- },
- // 确认授权后,获取用户位置
- getLocationInfo() {
- const that = this;
- uni.getLocation({
- type: "gcj02",
- success: function(res) {
- // 暂时
- that.longitude = res.longitude; //118.787575;
- that.latitude = res.latitude; //32.05024;
- console.log("获取当前的用户经度", that.longitude);
- console.log("获取当前的用户纬度", that.latitude);
- var long = 0;
- var lat = 0;
- //小数点保留六位 经度
- if (that.longitude.toString().indexOf('.') > 0) {
- const longlatsplit = that.longitude.toString().split('.');
- if (longlatsplit.length >= 2) {
- long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0, 6));
- }
- }
- if (that.latitude.toString().indexOf('.') > 0) {
- const longlatsplit1 = that.latitude.toString().split('.');
- if (longlatsplit1.length >= 2) {
- lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0, 6));
- }
- }
- console.log("纬度", lat);
- that.distance = that.getMapDistance(lat, long, '28.788671', '115.387261');
- console.log(that.distance)
- that.markers = [{
- id: "",
- latitude: res.latitude,
- longitude: res.longitude,
- iconPath: "../../static/img/phone.png",
- width: that.markerHeight, //宽
- height: that.markerHeight, //高
- }, ];
- },
- });
- },
- // 拒绝授权后,弹框提示是否手动打开位置授权
- openConfirm() {
- return new Promise((resolve, reject) => {
- uni.showModal({
- title: "请求授权当前位置",
- content: "我们需要获取地理位置信息,为您推荐路线",
- success: (res) => {
- // if (res.confirm) {
- // uni.openSetting().then((res) => {
- // if (res[1].authSetting["scope.userLocation"] === true) {
- // resolve(); // 打开地图权限设置
- // } else {
- // reject();
- // console.log('reject')
- // }
- // });
- // } else if (res.cancel) {
- // reject();
- // }
- },
- });
- });
- },
- // 彻底拒绝位置获取
- rejectGetLocation() {
- uni.showToast({
- title: "你拒绝了授权,无法获得周边信息",
- icon: "none",
- duration: 2000,
- });
- },
- //打开地图导航
- mapDaohang(lon, lat) {},
- //进行经纬度转换为距离的计算
- Rad(d) {
- return d * Math.PI / 180.0; //经纬度转换成三角函数中度分表形式。
- },
- /*
- 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
- 默认单位km
- */
- getMapDistance(lat1, lng1, lat2, lng2) {
- // console.log(this.Rad(lat1))
- // console.log(this.Rad(lng1))
- // console.log(this.Rad(lat2))
- // console.log(this.Rad(lng2))
- // console.log(this.Rad(28.678651))
- var radLat1 = this.Rad(lat1);
- var radLat2 = this.Rad(lat2);
- var a = radLat1 - radLat2;
- var b = this.Rad(lng1) - this.Rad(lng2);
- var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
- Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
- s = s * 6378.137; // EARTH_RADIUS;
- s = Math.round(s * 10000) / 10000; //输出为公里
- s = s.toFixed(2);
- return s;
- },
- }
- }
- </script>
- <style>
- @import url("./css/index.css");
- </style>
|