index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. <template>
  2. <view class="content">
  3. <!-- 背景图 -->
  4. <view class="index_bg">
  5. <view class="welcome"><image class="welcome_img" src="../../static/index/welcome.png"></image></view>
  6. </view>
  7. <!-- 第一层公寓名称卡片 -->
  8. <view class="uni-ka" style="margin-top: -40px;margin-bottom:0px;">
  9. <text class="uni-title">墨轩湖姬子公寓(南昌交通学院)</text>
  10. <text class="uni-sub-title">2021年装修 | 智能门锁 | 房间wifi | 免费停车</text>
  11. <text class="uni-extra" @click="navigateToXiangqing">设施/详情></text>
  12. <text class="uni-body">江西省宜春市靖安县墨轩湖大道1号</text>
  13. <image class="uni-phone" @click="telphone(phone)" src="../../static/index/index_phone.svg"></image>
  14. <a href="https://uri.amap.com/marker?position=115.387261,28.788671&name=南昌交通学院智慧公寓">
  15. <image class="uni-map" @click="mapDaohang('115.387261','28.788671')" src="../../static/index/index_map.svg"></image>
  16. </a>
  17. <br><text class="uni-body2">距离我{{distance}}km</text>
  18. </view>
  19. <!-- 第二层工具 -->
  20. <!-- <view class="item-list">
  21. <view class="item-list-one" @click="navigateToXuzhi">
  22. <image src="../../static/index/xuzhi.png" class="img-btn" height="100%" width="100%"></image>
  23. <text class="list-txt">入住须知</text>
  24. </view>
  25. <view class="item-list-one" @click="navigateToDairuzhu('warn')">
  26. <image src="../../static/index/ruzhu.png" class="img-btn"></image>
  27. <text class="list-txt">办理入住</text>
  28. </view> -->
  29. <!-- <view class="item-list-one" @click="navigateToXuzhu">
  30. <image src="../../static/index/index_xuzhu.svg" class="img-btn"></image>
  31. <text class="list-txt">办理续住</text>
  32. </view> -->
  33. <!-- <view class="item-list-one" @click="navigateToTuifang('warn')">
  34. <image src="../../static/index/tuifang.png" class="img-btn"></image>
  35. <text class="list-txt">办理退房</text>
  36. </view>
  37. </view> -->
  38. <!-- 退房失败时弹框 -->
  39. <!-- <uni-popup ref="popup_tui" type="center" width="300rpx" height="300rpx" background-color="#fff">
  40. <view class="kuang_txt_tui">
  41. <text>请先订房</text>
  42. </view>
  43. </uni-popup> -->
  44. <uni-popup ref="popup_tui" type="dialog">
  45. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" content="请先订房!" @confirm="dialogConfirm"
  46. @close="dialogClose"></uni-popup-dialog>
  47. </uni-popup>
  48. <!-- 切换全日房和钟点房 -->
  49. <view class="select-type" v-if="roomtype" @click="changeType">
  50. <view class="allday">全日房</view>
  51. <view class="hourday_no">钟点房</view>
  52. </view>
  53. <view class="select-type" v-else @click="changeType">
  54. <view class="allday2">全日房</view>
  55. <view class="hourday_no2">钟点房</view>
  56. </view>
  57. <!-- 第三层订房 -->
  58. <view class="room-list">
  59. <!-- 选择住房日期 -->
  60. <!-- 全日房 -->
  61. <view class="select-time" @click="openCalendar" v-if="roomtype">
  62. <view class="select-time-one">
  63. <text class="select-list">{{startWeek}}入住</text>
  64. <text class="select-list-time">{{startTime}}</text>
  65. </view>
  66. <view class="select-center">
  67. <view class="select-line1"></view>
  68. <view class="select-circle">{{ruzhu_num}}晚</view>
  69. <view class="select-line2"></view>
  70. </view>
  71. <view class="select-time-one">
  72. <text class="select-list">{{endWeek}}离店</text>
  73. <text class="select-list-time">{{endTime}}</text>
  74. </view>
  75. </view>
  76. <!-- 钟点房 -->
  77. <view class="select-time" v-else>
  78. <view class="hourtime">
  79. <uni-datetime-picker type="date" v-model="hourruzhu" @maskClick="maskClick">
  80. 入住时段
  81. <text class="select-list-time" style="margin-left: 26rpx;">{{hourruzhu}}</text>
  82. <image class="hour_right" src="../../static/index/hour_right.png"></image>
  83. </uni-datetime-picker>
  84. <view class="hour_line"></view>
  85. </view>
  86. </view>
  87. <!-- 全日房选择时间 -->
  88. <uni-popup ref="popup_picker" :mask-click="true">
  89. <view class=popup_bg_picker>
  90. <!-- <text class="popup_title">取消</text>
  91. <text class="popup_error" style="margin-left: 272px;" @click="popup_pickerClose">确定</text> -->
  92. <uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert" :lunar="info.lunar" :startDate="info.startDate"
  93. :endDate="info.endDate" :range="info.range" @change="change"/>
  94. </view>
  95. </uni-popup>
  96. <!-- 房型列表 -->
  97. <view class="room-kuang">
  98. <view class="room-xinxi" v-for="(item,index) in roomType" :key="index">
  99. <image class="room-image" :src="item.masterImage" @click="inputDialogToggle(item.id)"></image>
  100. <view class="room-name">{{item.typeName}}</view>
  101. <view class="room-mark">{{item.typeShortDesc}}</view>
  102. <view class="room-icon">
  103. <image src="../../static/index/index_wifi.svg" style="width: 30rpx;height: 30rpx;"></image>
  104. <image src="../../static/index/index_kongtiao.svg" style="width: 26rpx;height: 26rpx;margin-left: 10rpx;"></image>
  105. <image src="../../static/index/index_nosmoking.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  106. <image src="../../static/index/index_lock.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  107. </view>
  108. <view class="before-price"><strike>¥{{item.usualPrice}}</strike></view>
  109. <view class="room-price">¥{{item.depositPrice}}</view>
  110. <view class="room-button" :class="{'room-button2': item.enableNum == 0}">
  111. <text v-if="item.enableNum==0">已满</text>
  112. <text v-else @click="navigateToOrderRoom(item.enableNum,item.id,item.typeName)">订</text>
  113. </view>
  114. <view class="room-line" v-if="index<(roomType.length-1)"></view>
  115. </view>
  116. </view>
  117. </view>
  118. <!-- 订房时弹框 -->
  119. <!-- <uni-popup ref="popup_order" type="center" width="300rpx" height="300rpx" background-color="#fff">
  120. <view class="kuang_txt">
  121. <text>{{order_txt}}</text>
  122. </view>
  123. </uni-popup> -->
  124. <uni-popup ref="popup_order" type="dialog">
  125. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" :content="order_txt" @confirm="dialogConfirm"
  126. @close="dialogClose"></uni-popup-dialog>
  127. </uni-popup>
  128. <!-- 房间样式弹窗页面 -->
  129. <uni-popup ref="popup" type="dialog" :mask-click="false">
  130. <view class="popup_bg">
  131. <text class="popup_title">户型详情</text>
  132. <text class="popup_error" @click="popupClose"></text>
  133. <!-- 轮播图 -->
  134. <swiper class="swiper" circular :indicator-dots="indicatorDots">
  135. <swiper-item v-for="(item, index) in img" :key="index">
  136. <view class="swiper-item">
  137. <image :src="item" class="swiper-img"></image>
  138. </view>
  139. </swiper-item>
  140. </swiper>
  141. <text class="popup_title2">便利设施</text>
  142. <view class="popup_txt"><view class="popup_txt_in">{{typeText}}</view></view>
  143. </view>
  144. </uni-popup>
  145. <!-- 有一个可续住订单时办理续住弹窗页面 -->
  146. <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
  147. <view class="popup_bg_xu">
  148. <text class="popup_title">办理续住</text>
  149. <text class="popup_error" @click="popupXuzhuClose"></text>
  150. <text class="popup_xu_line"></text>
  151. <!-- 时间选择 -->
  152. <view class="select-time-xu" @click="openXuCalendar">
  153. <view class="select-time-one-xu">
  154. <text class="select-list">周四入住</text>
  155. <text class="select-list-time">07月21日</text>
  156. </view>
  157. <view class="select-center">
  158. <view class="select-line1"></view>
  159. <view class="select-circle">1晚</view>
  160. <view class="select-line2"></view>
  161. </view>
  162. <view class="select-time-one-xu">
  163. <text class="select-list">周五离店</text>
  164. <text class="select-list-time">07月22日</text>
  165. </view>
  166. </view>
  167. <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
  168. <!-- 支付框 -->
  169. <view class="fukuan">
  170. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
  171. <view class="fu-zhifu">立即支付</view>
  172. </view>
  173. </view>
  174. </uni-popup>
  175. <uni-popup ref="popup_xu" :mask-click="true">
  176. <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert" :lunar="infoXu.lunar" :startDate="infoXu.startDate"
  177. :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu"/>
  178. </uni-popup>
  179. <!-- 无可续住订单时办理续住弹窗页面 -->
  180. <uni-popup ref="popup_xuzhu_no" type="dialog">
  181. <uni-popup-dialog cancelText="关闭" confirmText="确定" content="请先订房"
  182. @close="dialogClose"></uni-popup-dialog>
  183. </uni-popup>
  184. </view>
  185. </template>
  186. <script>
  187. /**
  188. * 获取任意时间
  189. */
  190. function getDate(date, AddDayCount = 0) {
  191. if (!date) {
  192. date = new Date()
  193. }
  194. if (typeof date !== 'object') {
  195. date = date.replace(/-/g, '/')
  196. }
  197. const dd = new Date(date)
  198. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  199. var a = new Array("日", "一", "二", "三", "四", "五", "六");
  200. var week = new Date().getDay();
  201. var week2 = new Date().getDay()+1;
  202. const y = dd.getFullYear()
  203. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  204. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  205. const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  206. const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  207. const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  208. return {
  209. fullDate: y + '-' + m + '-' + d,
  210. fullDate2: y + '-' + m + '-' + d+' '+h+':'+f+':'+s,
  211. fullTime: m + '月' + d + '日',
  212. year: y,
  213. month: m,
  214. date: d,
  215. day: dd.getDay(),
  216. sWeek:"周"+ a[week],
  217. eWeek:"周"+ a[week2]
  218. }
  219. }
  220. import {
  221. getroomtype,
  222. getroomtypeinfo,
  223. getorderpage
  224. } from '../../utils/api_hotel.js'
  225. // 导入图片
  226. import AMap from "../../lib/qqmap-wx-jssdk.js"
  227. export default {
  228. data() {
  229. return {
  230. showCalendar: false,
  231. info: {
  232. lunar: true,
  233. range: true,
  234. insert: true,
  235. selected: [],
  236. startDate:'',
  237. date:'',
  238. endDate:''
  239. },
  240. msgType: 'warn',
  241. distance: 0, //"距离"
  242. startTime:'',//默认到店日期
  243. endTime:'',//默认离店日期
  244. startDate:'',//默认到店日期接口数据
  245. endDate:'',//默认离店日期接口数据
  246. startWeek:'',// 默认入店日
  247. endWeek:'',// 默认离店
  248. payMount:0,//房间价格
  249. freeRoom:0,//房间剩余
  250. ruzhu_num:1,//入住夜晚数
  251. //续住里选择器
  252. infoXu: {
  253. lunar: true,
  254. range: true,
  255. insert: true,
  256. selected: [],
  257. startDate:'',
  258. date:'',
  259. endDate:''
  260. },
  261. roomType:[],
  262. typeText:'',//房型详细描述
  263. indicatorDots: true,//滚动图片提示条默认出现
  264. img:[],//轮播图里图片
  265. phone:'0791-82293574',//电话
  266. latitude: '', // 默认当前纬度
  267. longitude:'',
  268. scale: 12, // 默认16
  269. markers: [],
  270. markerHeight: 30,
  271. xuzhu_type:[],// 办理续住判断条件
  272. xuzhu_panduan:[],// 办理续住判断条件赋值
  273. tui_type:[],// 办理退房判断条件
  274. tui_panduan:[],// 办理退房判断条件赋值
  275. dai_type:[],// 办理入住判断条件
  276. dai_panduan:[],// 办理入住判断条件赋值
  277. order_txt:'',//订房事故时信息
  278. roomtype:true,//区分房型,ture全日房 ;false钟点房
  279. hourruzhu:'',//钟点房入住时间
  280. }
  281. },
  282. onLoad() {
  283. this.startDate = getDate(new Date()).fullDate2
  284. this.endDate = getDate(new Date(),1).fullDate2
  285. this.getRoomType()
  286. // uni.showToast({
  287. // title: 'openId'+localStorage.getItem('openId')
  288. // })
  289. },
  290. mounted() {
  291. },
  292. onReady() {
  293. this.$nextTick(() => {
  294. this.showCalendar = true
  295. })
  296. // TODO 模拟请求异步同步数据
  297. setTimeout(() => {
  298. // console.log('date:'+getDate(new Date()).fullDate)
  299. // console.log('startDate:'+getDate(new Date()).fullDate)
  300. // console.log('endDate:'+getDate(new Date(),6).fullDate)
  301. this.info.date = getDate(new Date()).fullDate
  302. this.info.startDate = getDate(new Date()).fullDate
  303. this.info.endDate = getDate(new Date(),6).fullDate
  304. this.infoXu.date = getDate(new Date()).fullDate
  305. this.infoXu.startDate = getDate(new Date()).fullDate
  306. this.infoXu.endDate = getDate(new Date(),6).fullDate
  307. this.startTime = getDate(new Date()).fullTime
  308. this.endTime = getDate(new Date(),1).fullTime
  309. this.hourruzhu= getDate(new Date(),1).fullDate
  310. this.startWeek = getDate(new Date()).sWeek
  311. this.endWeek = getDate(new Date(),1).eWeek
  312. }, 1)
  313. // wx请求获取位置权限
  314. this.getAuthorize()
  315. .then(() => {
  316. // 同意后获取
  317. this.getLocationInfo();
  318. })
  319. .catch(() => {
  320. const that = this;
  321. uni.getLocation({
  322. type: "gcj02",
  323. success: function(res) {
  324. // 暂时
  325. that.longitude = res.longitude;
  326. that.latitude = res.latitude;
  327. var long = 0;
  328. var lat = 0;
  329. //小数点保留六位 经度
  330. if (that.longitude.toString().indexOf('.') > 0) {
  331. const longlatsplit = that.longitude.toString().split('.');
  332. if (longlatsplit.length >= 2) {
  333. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  334. }
  335. }
  336. if (that.latitude.toString().indexOf('.') > 0) {
  337. const longlatsplit1 = that.latitude.toString().split('.');
  338. if (longlatsplit1.length >= 2) {
  339. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  340. }
  341. }
  342. that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
  343. that.markers = [{
  344. id: "",
  345. latitude: res.latitude,
  346. longitude: res.longitude,
  347. iconPath: "../../static/img/phone.png",
  348. width: that.markerHeight, //宽
  349. height: that.markerHeight, //高
  350. }, ];
  351. },
  352. });
  353. // 不同意给出弹框,再次确认
  354. // this.openConfirm()
  355. // .then(() => {
  356. // this.getLocationInfo();
  357. // })
  358. // .catch(() => {
  359. // this.rejectGetLocation();
  360. // });
  361. });
  362. },
  363. methods: {
  364. //切换房型
  365. changeType(){
  366. this.roomtype=!this.roomtype
  367. },
  368. // 房型接口
  369. getRoomType() {
  370. let _self = this
  371. _self.roomType = []
  372. var data="?startDate="+this.startDate.substring(0,10)+"&endDate="+this.endDate.substring(0,10)
  373. getroomtype(data).then((res) => {
  374. if (res.success) {
  375. res.data.forEach(data => {
  376. if (data.flag !== '-1') {
  377. _self.roomType.push(data)
  378. }
  379. })
  380. return;
  381. } else {
  382. this.$message.warning('没有符合条件的数据!')
  383. }
  384. }).catch((err) => {
  385. this.$message.error(err.message)
  386. });
  387. },
  388. // 房型详情接口
  389. getRoomTypeInfo(id) {
  390. let _self = this
  391. _self.typeText=''
  392. _self.img=[]
  393. var data=id
  394. getroomtypeinfo(data).then((res) => {
  395. if (res.success) {
  396. _self.typeText=res.data.typeDesc
  397. _self.img=res.data.typeImage.split(',')
  398. return;
  399. } else {
  400. this.$message.warning('没有符合条件的数据!')
  401. }
  402. }).catch((err) => {
  403. this.$message.error(err.message)
  404. });
  405. },
  406. // 订单列表
  407. getOrderPage() {
  408. let _self = this
  409. _self.xuzhu_type=[]
  410. _self.tui_type=[]
  411. _self.dai_type=[]
  412. var data='?curPage=1&pageSize=100'
  413. getorderpage(data).then((res) => {
  414. if (res.success) {
  415. console.log(res)
  416. res.data.list.forEach(data => {
  417. if (data.flag !== '-1') {
  418. _self.xuzhu_type.push(data.orderStatu)
  419. _self.tui_type.push(data.orderStatu)
  420. _self.dai_type.push(data.orderStatu)
  421. // console.log(_self.xuzhu_type)
  422. }
  423. })
  424. return;
  425. } else {
  426. this.$message.warning('没有符合条件的数据!')
  427. }
  428. }).catch((err) => {
  429. this.$message.error(err.message)
  430. });
  431. // this.$axios.get("/hotel/ihotel-api/ihotel/hotelOrder/user/order/page?curPage=1&pageSize=100",
  432. // {
  433. // headers:{
  434. // 'user_token':localStorage.getItem('token')
  435. // }
  436. // }).then(res => {
  437. // res = res.data
  438. // if (res.success) {
  439. // res.data.list.forEach(data => {
  440. // if (data.flag !== '-1') {
  441. // _self.xuzhu_type.push(data.orderStatu)
  442. // _self.tui_type.push(data.orderStatu)
  443. // _self.dai_type.push(data.orderStatu)
  444. // // console.log(_self.xuzhu_type)
  445. // }
  446. // })
  447. // } else {
  448. // console.log('获取订单列表失败')
  449. // }
  450. // });
  451. },
  452. // 跳转到入住须知
  453. navigateToXuzhi(){
  454. uni.navigateTo({
  455. url: "../ruzhuxuzhi/ruzhuxuzhi",
  456. });
  457. },
  458. // 跳转到公寓详情
  459. navigateToXiangqing(){
  460. uni.navigateTo({
  461. url: "../gongyuxiangqing/gongyuxiangqing",
  462. });
  463. },
  464. // 订房间
  465. navigateToOrderRoom(enableNum,id,typeName) {
  466. let _self = this
  467. _self.roomType = []
  468. if (enableNum>=1){
  469. uni.navigateTo({
  470. url: "../order_room/order_room?roomTypeId="+id +"&enableStartTime="+this.startDate+"&enableEndTime="+this.endDate+"&startTime="+this.startTime+"&endTime="+this.endTime+"&typeName="+typeName,
  471. });
  472. }
  473. this.getRoomType()
  474. },
  475. //办理入住跳转
  476. navigateToDairuzhu(type){
  477. this.dai_panduan=[]
  478. setTimeout(() => {
  479. this.getOrderPage()
  480. },1)
  481. setTimeout(() => {
  482. for (let i=0;i<this.dai_type.length;i++){
  483. this.dai_type.forEach(val => {
  484. if(val[i]==2) {
  485. this.dai_panduan.push(val)
  486. }
  487. })
  488. }
  489. if(this.dai_panduan.length>=1) {
  490. uni.navigateTo({
  491. url:"../my_orderlist/my_orderlist?Inv=2"
  492. })
  493. }else if(this.dai_panduan.length<1) {
  494. this.msgType = type
  495. this.order_txt='请先订房!'
  496. this.$refs.popup_order.open()
  497. }
  498. },150)
  499. },
  500. //办理退房
  501. navigateToTuifang(type){
  502. this.tui_panduan=[]
  503. setTimeout(() => {
  504. this.getOrderPage()
  505. },1)
  506. setTimeout(() => {
  507. for (let i=0;i<this.tui_type.length;i++){
  508. this.tui_type.forEach(val => {
  509. if(val[i]==3) {
  510. this.tui_panduan.push(val)
  511. }
  512. })
  513. }
  514. if(this.tui_panduan.length>=1) {
  515. uni.navigateTo({
  516. url:"../my_orderlist/my_orderlist?Inv=3"
  517. })
  518. }else if(this.tui_panduan.length<1) {
  519. this.msgType = type
  520. this.$refs.popup_tui.open()
  521. }
  522. },150)
  523. },
  524. //户型详情弹窗
  525. inputDialogToggle(id) {
  526. this.$refs.popup.open()
  527. this.getRoomTypeInfo(id)
  528. },
  529. popupClose() {
  530. this.$refs.popup.close()
  531. },
  532. //办理续住弹窗
  533. navigateToXuzhu(){
  534. this.xuzhu_panduan=[]
  535. setTimeout(() => {
  536. this.getOrderPage()
  537. },1)
  538. setTimeout(() => {
  539. for (let i=0;i<this.xuzhu_type.length;i++){
  540. this.xuzhu_type.forEach(val => {
  541. if(val[i]==3) {
  542. this.xuzhu_panduan.push(val)
  543. }
  544. })
  545. }
  546. console.log(this.xuzhu_panduan)
  547. if(this.xuzhu_panduan.length>1) {
  548. uni.navigateTo({
  549. url:"../my_orderlist/my_orderlist?Inv=3"
  550. })
  551. }else if(this.xuzhu_panduan.length==1) {
  552. this.$refs.popup_xuzhu.open()
  553. }else if(this.xuzhu_panduan.length==0) {
  554. this.$refs.popup_xuzhu_no.open()
  555. }
  556. },150)
  557. },
  558. popupXuzhuClose() {
  559. this.$refs.popup_xuzhu.close()
  560. },
  561. // 不可续住关闭弹窗
  562. dialogClose(){
  563. this.$refs.popup_xuzhu_no.close()
  564. },
  565. // 日期选择器弹窗开启
  566. openCalendar() {
  567. this.$refs.popup_picker.open()
  568. },
  569. change(e) {
  570. this.info.selected=[
  571. {
  572. date: e.range.before,
  573. info: '到店'
  574. },
  575. {
  576. date: e.range.after,
  577. info: '离店'
  578. }
  579. ]
  580. if(e.range.before!=''&&e.range.after=='') {
  581. this.startWeek='周'+e.lunar.ncWeek.substring(2,3)
  582. } else if(e.range.before!=''&&e.range.after!=''){
  583. if((new Date(e.range.after).getTime())<(new Date(e.range.before).getTime())) {
  584. this.order_txt='离店日期不能小于到店日期'
  585. this.$refs.popup_order.open()
  586. }else{
  587. this.endWeek='周'+e.lunar.ncWeek.substring(2,3)
  588. this.startTime=e.range.before.substring(5,7)+'月'+e.range.before.substring(8,10)+'日'
  589. this.endTime=e.range.after.substring(5,7)+'月'+e.range.after.substring(8,10)+'日'
  590. this.startDate = e.range.before +' 14:00:00'
  591. this.endDate = e.range.after +' 12:00:00'
  592. this.ruzhu_num=parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)
  593. if(this.endDate !=' 12:00:00') {
  594. this.getRoomType()
  595. }
  596. }
  597. }
  598. },
  599. // 续住里日期选择器弹窗
  600. openXuCalendar() {
  601. this.$refs.popup_xu.open()
  602. },
  603. changeXu(e) {
  604. console.log('1change 返回:', e)
  605. // 模拟动态打卡
  606. if (this.infoXu.selected.length > 5) return
  607. this.infoXu.selected.push({
  608. date: e.range.before,
  609. info: '到店'
  610. })
  611. this.infoXu.selected.push({
  612. date: e.range.after,
  613. info: '离店'
  614. })
  615. },
  616. //拨打电话
  617. telphone(phone){
  618. uni.makePhoneCall({
  619. phoneNumber: phone ,
  620. }) // 传参带入号码即可
  621. },
  622. // 初次位置授权
  623. getAuthorize() {
  624. return new Promise((resolve, reject) => {
  625. uni.authorize({
  626. scope: "scope.userLocation",
  627. success: () => {
  628. resolve(); // 允许授权
  629. },
  630. fail: () => {
  631. reject(); // 拒绝授权
  632. },
  633. });
  634. });
  635. },
  636. // 确认授权后,获取用户位置
  637. getLocationInfo() {
  638. const that = this;
  639. uni.getLocation({
  640. type: "gcj02",
  641. success: function(res) {
  642. // 暂时
  643. that.longitude = res.longitude; //118.787575;
  644. that.latitude = res.latitude; //32.05024;
  645. console.log("获取当前的用户经度", that.longitude);
  646. console.log("获取当前的用户纬度", that.latitude);
  647. var long = 0;
  648. var lat = 0;
  649. //小数点保留六位 经度
  650. if (that.longitude.toString().indexOf('.') > 0) {
  651. const longlatsplit = that.longitude.toString().split('.');
  652. if (longlatsplit.length >= 2) {
  653. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  654. }
  655. }
  656. if (that.latitude.toString().indexOf('.') > 0) {
  657. const longlatsplit1 = that.latitude.toString().split('.');
  658. if (longlatsplit1.length >= 2) {
  659. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  660. }
  661. }
  662. console.log("纬度", lat);
  663. that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
  664. console.log(that.distance)
  665. that.markers = [{
  666. id: "",
  667. latitude: res.latitude,
  668. longitude: res.longitude,
  669. iconPath: "../../static/img/phone.png",
  670. width: that.markerHeight, //宽
  671. height: that.markerHeight, //高
  672. }, ];
  673. },
  674. });
  675. },
  676. // 拒绝授权后,弹框提示是否手动打开位置授权
  677. openConfirm() {
  678. return new Promise((resolve, reject) => {
  679. uni.showModal({
  680. title: "请求授权当前位置",
  681. content: "我们需要获取地理位置信息,为您推荐路线",
  682. success: (res) => {
  683. // if (res.confirm) {
  684. // uni.openSetting().then((res) => {
  685. // if (res[1].authSetting["scope.userLocation"] === true) {
  686. // resolve(); // 打开地图权限设置
  687. // } else {
  688. // reject();
  689. // console.log('reject')
  690. // }
  691. // });
  692. // } else if (res.cancel) {
  693. // reject();
  694. // }
  695. },
  696. });
  697. });
  698. },
  699. // 彻底拒绝位置获取
  700. rejectGetLocation() {
  701. uni.showToast({
  702. title: "你拒绝了授权,无法获得周边信息",
  703. icon: "none",
  704. duration: 2000,
  705. });
  706. },
  707. //打开地图导航
  708. mapDaohang(lon,lat){
  709. },
  710. //进行经纬度转换为距离的计算
  711. Rad(d) {
  712. return d * Math.PI / 180.0; //经纬度转换成三角函数中度分表形式。
  713. },
  714. /*
  715. 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  716. 默认单位km
  717. */
  718. getMapDistance(lat1, lng1, lat2, lng2) {
  719. // console.log(this.Rad(lat1))
  720. // console.log(this.Rad(lng1))
  721. // console.log(this.Rad(lat2))
  722. // console.log(this.Rad(lng2))
  723. // console.log(this.Rad(28.678651))
  724. var radLat1 = this.Rad(lat1);
  725. var radLat2 = this.Rad(lat2);
  726. var a = radLat1 - radLat2;
  727. var b = this.Rad(lng1) - this.Rad(lng2);
  728. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  729. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  730. s = s * 6378.137; // EARTH_RADIUS;
  731. s = Math.round(s * 10000) / 10000; //输出为公里
  732. s=s.toFixed(2);
  733. return s;
  734. },
  735. }
  736. }
  737. </script>
  738. <style>
  739. @import url("./css/index.css");
  740. </style>