index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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">宜春市靖安县北高速路口什么路899号</text>
  13. <image class="uni-phone" @click="telphone(phone)" src="../../static/index/index_phone.svg"></image>
  14. <image class="uni-map" @click="mapDaohang('115.387261','28.788671')" src="../../static/index/index_map.svg"></image>
  15. <br><text class="uni-body2">距离我520km</text>
  16. </view>
  17. <!-- 第二层工具 -->
  18. <view class="item-list">
  19. <view class="item-list-one" @click="navigateToXuzhi">
  20. <image src="../../static/index/index_xuzhi.svg" class="img-btn" height="100%" width="100%"></image>
  21. <text class="list-txt">入住须知</text>
  22. </view>
  23. <view class="item-list-one" @click="navigateToDairuzhu">
  24. <image src="../../static/index/index_ruzhu.svg" class="img-btn"></image>
  25. <text class="list-txt">办理入住</text>
  26. </view>
  27. <view class="item-list-one" @click="navigateToXuzhu">
  28. <image src="../../static/index/index_xuzhu.svg" class="img-btn"></image>
  29. <text class="list-txt">办理续住</text>
  30. </view>
  31. <view class="item-list-one" @click="navigateToTuifang">
  32. <image src="../../static/index/index_tuifang.svg" class="img-btn"></image>
  33. <text class="list-txt">办理退房</text>
  34. </view>
  35. </view>
  36. <!-- 第三层订房 -->
  37. <view class="room-list">
  38. <!-- 选择住房日期 -->
  39. <view class="select-time" @click="openCalendar">
  40. <view class="select-time-one">
  41. <text class="select-list">{{startWeek}}入住</text>
  42. <text class="select-list-time">{{startTime}}</text>
  43. </view>
  44. <view class="select-center">
  45. <view class="select-line1"></view>
  46. <view class="select-circle">1晚</view>
  47. <view class="select-line2"></view>
  48. </view>
  49. <view class="select-time-one">
  50. <text class="select-list">{{endWeek}}离店</text>
  51. <text class="select-list-time">{{endTime}}</text>
  52. </view>
  53. </view>
  54. <uni-popup ref="popup_picker" :mask-click="true">
  55. <view class=popup_bg_picker>
  56. <!-- <text class="popup_title">取消</text>
  57. <text class="popup_error" style="margin-left: 272px;" @click="popup_pickerClose">确定</text> -->
  58. <uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert" :lunar="info.lunar" :startDate="info.startDate"
  59. :endDate="info.endDate" :range="info.range" @change="change"/>
  60. </view>
  61. </uni-popup>
  62. <!-- 房型列表 -->
  63. <view class="room-kuang">
  64. <view class="room-xinxi" v-for="(item,index) in roomType" :key="index">
  65. <image class="room-image" src="item.masterImage" @click="inputDialogToggle(item.id)"></image>
  66. <view class="room-name">{{item.typeName}}</view>
  67. <view class="room-mark">{{item.typeShortDesc}}</view>
  68. <view class="room-icon">
  69. <image src="../../static/index/index_wifi.svg" style="width: 30rpx;height: 30rpx;"></image>
  70. <image src="../../static/index/index_kongtiao.svg" style="width: 26rpx;height: 26rpx;margin-left: 10rpx;"></image>
  71. <image src="../../static/index/index_nosmoking.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  72. <image src="../../static/index/index_lock.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  73. </view>
  74. <view class="before-price"><strike>¥{{item.usualPrice}}</strike></view>
  75. <view class="room-price">¥{{item.discountPrice}}</view>
  76. <view class="room-button" :class="{'room-button2': item.enableNum == 0}" @click="navigateToOrderRoom(item.enableNum,item.id,item.typeName)">
  77. <text v-if="item.enableNum==0">已满</text>
  78. <text v-else>订</text>
  79. </view>
  80. <view class="room-line" v-if="index<(roomType.length-1)"></view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 房间样式弹窗页面 -->
  85. <uni-popup ref="popup" type="dialog" :mask-click="false">
  86. <view class="popup_bg">
  87. <text class="popup_title">户型详情</text>
  88. <text class="popup_error" @click="popupClose"></text>
  89. <!-- 轮播图 -->
  90. <swiper class="swiper" circular :indicator-dots="indicatorDots">
  91. <swiper-item v-for="(item, index) in img" :key="index">
  92. <view class="swiper-item">
  93. <image :src="item" class="swiper-img"></image>
  94. </view>
  95. </swiper-item>
  96. </swiper>
  97. <text class="popup_title2">便利设施</text>
  98. <view class="popup_txt">{{typeText}}</view>
  99. </view>
  100. </uni-popup>
  101. <!-- 有一个可续住订单时办理续住弹窗页面 -->
  102. <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
  103. <view class="popup_bg_xu">
  104. <text class="popup_title">办理续住</text>
  105. <text class="popup_error" @click="popupXuzhuClose"></text>
  106. <text class="popup_xu_line"></text>
  107. <!-- 时间选择 -->
  108. <view class="select-time-xu" @click="openXuCalendar">
  109. <view class="select-time-one-xu">
  110. <text class="select-list">周四入住</text>
  111. <text class="select-list-time">07月21日</text>
  112. </view>
  113. <view class="select-center">
  114. <view class="select-line1"></view>
  115. <view class="select-circle">1晚</view>
  116. <view class="select-line2"></view>
  117. </view>
  118. <view class="select-time-one-xu">
  119. <text class="select-list">周五离店</text>
  120. <text class="select-list-time">07月22日</text>
  121. </view>
  122. </view>
  123. <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
  124. <!-- 支付框 -->
  125. <view class="fukuan">
  126. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
  127. <view class="fu-zhifu">立即支付</view>
  128. </view>
  129. </view>
  130. </uni-popup>
  131. <uni-popup ref="popup_xu" :mask-click="true">
  132. <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert" :lunar="infoXu.lunar" :startDate="infoXu.startDate"
  133. :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu"/>
  134. </uni-popup>
  135. <!-- 无可续住订单时办理续住弹窗页面 -->
  136. <uni-popup ref="popup_xuzhu_no" type="dialog">
  137. <uni-popup-dialog cancelText="关闭" confirmText="确定" content="请先订房"
  138. @close="dialogClose"></uni-popup-dialog>
  139. </uni-popup>
  140. </view>
  141. </template>
  142. <script>
  143. /**
  144. * 获取任意时间
  145. */
  146. function getDate(date, AddDayCount = 0) {
  147. if (!date) {
  148. date = new Date()
  149. }
  150. if (typeof date !== 'object') {
  151. date = date.replace(/-/g, '/')
  152. }
  153. const dd = new Date(date)
  154. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  155. var a = new Array("日", "一", "二", "三", "四", "五", "六");
  156. var week = new Date().getDay();
  157. var week2 = new Date().getDay()+1;
  158. const y = dd.getFullYear()
  159. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  160. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  161. const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  162. const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  163. const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  164. return {
  165. fullDate: y + '-' + m + '-' + d,
  166. fullDate2: y + '-' + m + '-' + d+' '+h+':'+f+':'+s,
  167. fullTime: m + '月' + d + '日',
  168. year: y,
  169. month: m,
  170. date: d,
  171. day: dd.getDay(),
  172. sWeek:"周"+ a[week],
  173. eWeek:"周"+ a[week2]
  174. }
  175. }
  176. // 导入图片
  177. import room1 from '../../static/index/swiper_img1.svg'
  178. import room2 from '../../static/index/swiper_img1.svg'
  179. import AMap from "../../lib/qqmap-wx-jssdk.js"
  180. export default {
  181. data() {
  182. return {
  183. showCalendar: false,
  184. info: {
  185. lunar: true,
  186. range: true,
  187. insert: true,
  188. selected: [],
  189. startDate:'',
  190. date:'',
  191. endDate:''
  192. },
  193. startTime:'',//默认到店日期
  194. endTime:'',//默认离店日期
  195. startDate:'',//默认到店日期接口数据
  196. endDate:'',//默认离店日期接口数据
  197. startWeek:'',// 默认入店日
  198. endWeek:'',// 默认离店
  199. //续住里选择器
  200. infoXu: {
  201. lunar: true,
  202. range: true,
  203. insert: true,
  204. selected: [],
  205. startDate:'',
  206. date:'',
  207. endDate:''
  208. },
  209. roomType:[],
  210. typeText:'',//房型详细描述
  211. indicatorDots: true,//滚动图片提示条默认出现
  212. img:[
  213. {
  214. value: '1',
  215. srcUrl:room1,
  216. name: '图1'
  217. },
  218. {
  219. value: '2',
  220. srcUrl:room2,
  221. name: '图2'
  222. },
  223. ],
  224. phone:'15079248859',//电话
  225. latitude: '', // 默认定在首都
  226. longitude:'',
  227. scale: 12, // 默认16
  228. markers: [],
  229. markerHeight: 30,
  230. xuzhu_type:[],// 办理续住判断条件
  231. xuzhu_panduan:[]// 办理续住判断条件赋值
  232. }
  233. },
  234. onLoad() {
  235. this.startDate = getDate(new Date()).fullDate2
  236. this.endDate = getDate(new Date(),1).fullDate2
  237. this.getRoomType()
  238. },
  239. onReady() {
  240. this.$nextTick(() => {
  241. this.showCalendar = true
  242. })
  243. // TODO 模拟请求异步同步数据
  244. setTimeout(() => {
  245. // console.log('date:'+getDate(new Date()).fullDate)
  246. // console.log('startDate:'+getDate(new Date()).fullDate)
  247. // console.log('startWeek:'+getDate(new Date()).eWeek)
  248. this.info.date = getDate(new Date()).fullDate
  249. this.info.startDate = getDate(new Date()).fullDate
  250. this.info.endDate = getDate(new Date(),6).fullDate
  251. this.infoXu.date = getDate(new Date()).fullDate
  252. this.infoXu.startDate = getDate(new Date()).fullDate
  253. this.infoXu.endDate = getDate(new Date(),6).fullDate
  254. this.startTime = getDate(new Date()).fullTime
  255. this.endTime = getDate(new Date(),1).fullTime
  256. this.startWeek = getDate(new Date()).sWeek
  257. this.endWeek = getDate(new Date(),1).eWeek
  258. }, 1)
  259. // wx请求获取位置权限
  260. this.getAuthorize()
  261. .then(() => {
  262. // 同意后获取
  263. this.getLocationInfo();
  264. })
  265. .catch(() => {
  266. // 不同意给出弹框,再次确认
  267. this.openConfirm()
  268. .then(() => {
  269. this.getLocationInfo();
  270. })
  271. .catch(() => {
  272. this.rejectGetLocation();
  273. });
  274. });
  275. },
  276. methods: {
  277. // 房型接口
  278. getRoomType() {
  279. let _self = this
  280. _self.roomType = []
  281. this.$axios.get("/ihotel/roomType/list?startTime="+this.startDate+"&endTime="+this.endDate).then(res => {
  282. res = res.data
  283. if (res.success) {
  284. // console.log(res)
  285. res.data.forEach(data => {
  286. if (data.flag !== '-1') {
  287. _self.roomType.push(data)
  288. }
  289. })
  290. } else {
  291. console.log('获取房型失败')
  292. }
  293. });
  294. },
  295. // 房型详情接口
  296. getRoomTypeInfo(id) {
  297. let _self = this
  298. _self.typeText=''
  299. _self.img=[]
  300. this.$axios.get(`/ihotel/roomType/info/${id}`).then(res => {
  301. res = res.data
  302. if (res.success) {
  303. // console.log(res)
  304. _self.typeText=res.data.typeDesc
  305. _self.img=res.data.typeImage.split(',')
  306. // console.log(_self.img)
  307. } else {
  308. console.log('获取房型详情失败')
  309. }
  310. });
  311. },
  312. // 订单列表
  313. getOrderPage() {
  314. let _self = this
  315. _self.xuzhu_type=[]
  316. this.$axios.get("/ihotel/hotelOrder/user/order/page?curPage=1&pageSize=100",
  317. {
  318. headers:{
  319. 'user_token':localStorage.getItem('user_token')
  320. }
  321. }).then(res => {
  322. res = res.data
  323. if (res.success) {
  324. // console.log(res)
  325. res.data.list.forEach(data => {
  326. if (data.flag !== '-1') {
  327. _self.xuzhu_type.push(data.orderStatu)
  328. console.log(_self.xuzhu_type)
  329. }
  330. })
  331. } else {
  332. console.log('获取订单列表失败')
  333. }
  334. });
  335. },
  336. // 跳转到入住须知
  337. navigateToXuzhi(){
  338. uni.navigateTo({
  339. url: "../ruzhuxuzhi/ruzhuxuzhi",
  340. });
  341. },
  342. // 跳转到公寓详情
  343. navigateToXiangqing(){
  344. uni.navigateTo({
  345. url: "../gongyuxiangqing/gongyuxiangqing",
  346. });
  347. },
  348. // 订房间
  349. navigateToOrderRoom(enableNum,id,typeName) {
  350. if (enableNum>=1){
  351. uni.navigateTo({
  352. url: "../order_room/order_room?roomTypeId="+id +"&enableStartTime="+this.startDate+"&enableEndTime="+this.endDate+"&startTime="+this.startTime+"&endTime="+this.endTime+"&startWeek="+this.startWeek+"&endWeek="+this.endWeek+"&typeName="+typeName,
  353. });
  354. }
  355. },
  356. //办理入住跳转
  357. navigateToDairuzhu(){
  358. uni.navigateTo({
  359. url: "../my_orderlist/my_orderlist?Inv=2",
  360. })
  361. },
  362. //办理退房
  363. navigateToTuifang(){
  364. uni.navigateTo({
  365. url:"../my_orderlist/my_orderlist?Inv=3"
  366. })
  367. },
  368. //户型详情弹窗
  369. inputDialogToggle(id) {
  370. this.$refs.popup.open()
  371. this.getRoomTypeInfo(id)
  372. },
  373. popupClose() {
  374. this.$refs.popup.close()
  375. },
  376. //办理续住弹窗
  377. navigateToXuzhu(){
  378. this.xuzhu_panduan=[]
  379. setTimeout(() => {
  380. this.getOrderPage()
  381. },1)
  382. setTimeout(() => {
  383. for (let i=0;i<this.xuzhu_type.length;i++){
  384. this.xuzhu_type.forEach(val => {
  385. if(val[i]==3) {
  386. this.xuzhu_panduan.push(val)
  387. }
  388. })
  389. }
  390. console.log(this.xuzhu_panduan)
  391. if(this.xuzhu_panduan.length>1) {
  392. uni.navigateTo({
  393. url:"../my_orderlist/my_orderlist?Inv=3"
  394. })
  395. }else if(this.xuzhu_panduan.length==1) {
  396. this.$refs.popup_xuzhu.open()
  397. }else if(this.xuzhu_panduan.length==0) {
  398. this.$refs.popup_xuzhu_no.open()
  399. }
  400. },150)
  401. },
  402. popupXuzhuClose() {
  403. this.$refs.popup_xuzhu.close()
  404. },
  405. // 不可续住关闭弹窗
  406. dialogClose(){
  407. this.$refs.popup_xuzhu_no.close()
  408. },
  409. // 日期选择器弹窗开启
  410. openCalendar() {
  411. this.$refs.popup_picker.open()
  412. },
  413. change(e) {
  414. console.log('1change 返回:', e)
  415. // 模拟动态打卡
  416. // if (this.info.selected.length > 3) return
  417. this.info.selected.push({
  418. date: e.range.before,
  419. info: '到店'
  420. })
  421. this.info.selected.push({
  422. date: e.range.after,
  423. info: '离店'
  424. })
  425. if(e.range.before!=''&&e.range.after=='') {
  426. this.startWeek='周'+e.lunar.ncWeek.substring(2,3)
  427. } else if(e.range.before!=''&&e.range.after!=''){
  428. this.endWeek='周'+e.lunar.ncWeek.substring(2,3)
  429. }
  430. this.startTime=e.range.before.substring(5,7)+'月'+e.range.before.substring(8,10)+'日'
  431. this.endTime=e.range.after.substring(5,7)+'月'+e.range.after.substring(8,10)+'日'
  432. this.startDate = e.range.before +' 14:00:00'
  433. this.endDate = e.range.after +' 12:00:00'
  434. if(this.endDate !=' 12:00:00') {
  435. this.getRoomType()
  436. }
  437. },
  438. // 续住里日期选择器弹窗
  439. openXuCalendar() {
  440. this.$refs.popup_xu.open()
  441. },
  442. changeXu(e) {
  443. console.log('1change 返回:', e)
  444. // 模拟动态打卡
  445. if (this.infoXu.selected.length > 5) return
  446. this.infoXu.selected.push({
  447. date: e.range.before,
  448. info: '到店'
  449. })
  450. this.infoXu.selected.push({
  451. date: e.range.after,
  452. info: '离店'
  453. })
  454. },
  455. //拨打电话
  456. telphone(phone){
  457. uni.makePhoneCall({
  458. phoneNumber: phone ,
  459. }) // 传参带入号码即可
  460. },
  461. // 初次位置授权
  462. getAuthorize() {
  463. return new Promise((resolve, reject) => {
  464. uni.authorize({
  465. scope: "scope.userLocation",
  466. success: () => {
  467. resolve(); // 允许授权
  468. },
  469. fail: () => {
  470. reject(); // 拒绝授权
  471. },
  472. });
  473. });
  474. },
  475. // 确认授权后,获取用户位置
  476. getLocationInfo() {
  477. const that = this;
  478. uni.getLocation({
  479. type: "gcj02",
  480. success: function(res) {
  481. // 暂时
  482. that.longitude = res.longitude; //118.787575;
  483. that.latitude = res.latitude; //32.05024;
  484. console.log("获取当前的用户经度", that.longitude);
  485. console.log("获取当前的用户纬度", that.latitude);
  486. var long = 0;
  487. var lat = 0;
  488. //小数点保留六位 经度
  489. if (that.longitude.toString().indexOf('.') > 0) {
  490. const longlatsplit = that.longitude.toString().split('.');
  491. if (longlatsplit.length >= 2) {
  492. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  493. }
  494. }
  495. if (that.latitude.toString().indexOf('.') > 0) {
  496. const longlatsplit1 = that.latitude.toString().split('.');
  497. if (longlatsplit1.length >= 2) {
  498. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  499. }
  500. }
  501. // cookie.set("longitude", long);
  502. // cookie.set("latitude", lat);
  503. console.log("纬度", lat);
  504. // this.distance(that.latitude,that.longitude);
  505. that.markers = [{
  506. id: "",
  507. latitude: res.latitude,
  508. longitude: res.longitude,
  509. iconPath: "../../static/img/phone.png",
  510. width: that.markerHeight, //宽
  511. height: that.markerHeight, //高
  512. }, ];
  513. that.getList();
  514. },
  515. });
  516. },
  517. // 拒绝授权后,弹框提示是否手动打开位置授权
  518. openConfirm() {
  519. return new Promise((resolve, reject) => {
  520. uni.showModal({
  521. title: "请求授权当前位置",
  522. content: "我们需要获取地理位置信息,为您推荐附近的美食",
  523. success: (res) => {
  524. if (res.confirm) {
  525. uni.openSetting().then((res) => {
  526. if (res[1].authSetting["scope.userLocation"] === true) {
  527. resolve(); // 打开地图权限设置
  528. } else {
  529. reject();
  530. }
  531. });
  532. } else if (res.cancel) {
  533. reject();
  534. }
  535. },
  536. });
  537. });
  538. },
  539. // 彻底拒绝位置获取
  540. rejectGetLocation() {
  541. uni.showToast({
  542. title: "你拒绝了授权,无法获得周边信息",
  543. icon: "none",
  544. duration: 2000,
  545. });
  546. },
  547. //打开地图导航
  548. mapDaohang(lon,lat){
  549. console.log("获取经纬度ssssfff", lon, lat);
  550. //打开地图,并将门店位置传入
  551. uni.getLocation({
  552. success: res => {
  553. // res.latitude=lat;
  554. // res.longitude=lon;
  555. console.log('location success', parseFloat(lat), parseFloat(lon))
  556. uni.openLocation({
  557. latitude: parseFloat(lat),
  558. longitude: parseFloat(lon),
  559. scale: 18
  560. })
  561. }
  562. })
  563. // uni.chooseLocation({
  564. // success: (res) => {
  565. // console.log('位置名称:' + res.name);
  566. // console.log('详细地址:' + res.address);
  567. // console.log('纬度:' + res.latitude);
  568. // console.log('经度:' + res.longitude);
  569. // this.positionName = res.name
  570. // }
  571. // })
  572. },
  573. }
  574. }
  575. </script>
  576. <style>
  577. @import url("./css/index.css");
  578. </style>