index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. <template>
  2. <view class="content">
  3. <!-- 背景图 -->
  4. <view class="index_bg">
  5. <view class="welcome">
  6. <image class="welcome_img" src="../../static/index/welcome.png"></image>
  7. </view>
  8. </view>
  9. <!-- 第一层公寓名称卡片 -->
  10. <view class="uni-ka" style="margin-top: -40px;margin-bottom:0px;">
  11. <text class="uni-title">研究生公寓(南昌交通学院)</text>
  12. <text class="uni-sub-title">2021年装修 | 智能门锁 | 房间wifi | 免费停车</text>
  13. <text class="uni-extra" @click="navigateToXiangqing">设施/详情></text>
  14. <text class="uni-body">江西省宜春市靖安县墨轩湖大道1号</text>
  15. <image class="uni-phone" @click="telphone()" src="../../static/index/index_phone.svg"></image>
  16. <a href="https://uri.amap.com/marker?position=115.387261,28.788671&name=南昌交通学院智慧公寓">
  17. <image class="uni-map" @click="mapDaohang('115.387261','28.788671')" src="../../static/index/index_map.svg"></image>
  18. </a>
  19. <br><text class="uni-body2">距离我{{distance}}km</text>
  20. </view>
  21. <!-- 第二层工具 -->
  22. <!-- <view class="item-list">
  23. <view class="item-list-one" @click="navigateToXuzhi">
  24. <image src="../../static/index/xuzhi.png" class="img-btn" height="100%" width="100%"></image>
  25. <text class="list-txt">入住须知</text>
  26. </view>
  27. <view class="item-list-one" @click="navigateToDairuzhu('warn')">
  28. <image src="../../static/index/ruzhu.png" class="img-btn"></image>
  29. <text class="list-txt">办理入住</text>
  30. </view>
  31. <view class="item-list-one" @click="navigateToXuzhu">
  32. <image src="../../static/index/index_xuzhu.svg" class="img-btn"></image>
  33. <text class="list-txt">办理续住</text>
  34. </view>
  35. <view class="item-list-one" @click="navigateToTuifang('warn')">
  36. <image src="../../static/index/tuifang.png" class="img-btn"></image>
  37. <text class="list-txt">办理退房</text>
  38. </view>
  39. </view> -->
  40. <!-- 退房失败时弹框 -->
  41. <!-- <uni-popup ref="popup_tui" type="center" width="300rpx" height="300rpx" background-color="#fff">
  42. <view class="kuang_txt_tui">
  43. <text>请先订房</text>
  44. </view>
  45. </uni-popup> -->
  46. <uni-popup ref="popup_tui" type="dialog">
  47. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" content="请先订房!" @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
  48. </uni-popup>
  49. <!-- 第三层订房 -->
  50. <view class="room-list">
  51. <!-- 选择住房日期 -->
  52. <view class="select-time" @click="openCalendar">
  53. <view class="select-time-one">
  54. <text class="select-list">{{startWeek}}入住</text>
  55. <text class="select-list-time">{{startTime}}</text>
  56. </view>
  57. <view class="select-center">
  58. <view class="select-line1"></view>
  59. <view class="select-circle">{{ ruzhu_num }} 晚</view>
  60. <view class="select-line2"></view>
  61. </view>
  62. <view class="select-time-one">
  63. <text class="select-list">{{endWeek}}离店</text>
  64. <text class="select-list-time">{{endTime}}</text>
  65. </view>
  66. </view>
  67. <uni-popup ref="popup_picker" :mask-click="true">
  68. <view class=popup_bg_picker>
  69. <!-- <text class="popup_title">取消</text>
  70. <text class="popup_error" style="margin-left: 272px;" @click="popup_pickerClose">确定</text> -->
  71. <uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert"
  72. :lunar="info.lunar" :startDate="info.startDate" :endDate="info.endDate" :range="info.range" @change="change" />
  73. </view>
  74. </uni-popup>
  75. <!-- 房型列表 -->
  76. <view class="room-kuang">
  77. <view class="room-xinxi" v-for="(item, index) in roomType" :key="index">
  78. <image v-if="item.h_type.indexOf('标准') !== -1" class="room-image" src="../../static/index/std.jpg" @click="inputDialogToggle(item.h_type)">
  79. </image>
  80. <image v-else-if="item.h_type.indexOf('高级') !== -1" class="room-image" src="../../static/index/adv1.jpg"
  81. @click="inputDialogToggle(item.h_type)"></image>
  82. <image v-else="item.h_type.indexOf('豪华') !== -1" class="room-image" src="../../static/index/lux.jpg"
  83. @click="inputDialogToggle(item.h_type)"></image>
  84. <view class="room-name">{{ item.h_type }}</view>
  85. <view v-if="item.h_type.indexOf('标准') !== -1" class="room-mark">描述:面积约20平方米,配置1.35米双人床一张,点击左侧图片查看更多。</view>
  86. <view v-else-if="item.h_type.indexOf('高级') !== -1" class="room-mark">描述:面积约28平方米,配置1.5米双人床一张,点击左侧图片查看更多。</view>
  87. <view v-else="item.h_type.indexOf('豪华') !== -1" class="room-mark">描述:面积约40平方米,配置1.5米双人床一张,点击左侧图片查看更多。</view>
  88. <view class="room-icon">
  89. <image src="../../static/index/index_wifi.svg" style="width: 30rpx;height: 30rpx;"></image>
  90. <image src="../../static/index/index_kongtiao.svg" style="width: 26rpx;height: 26rpx;margin-left: 10rpx;"></image>
  91. <image src="../../static/index/index_nosmoking.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  92. <image src="../../static/index/index_lock.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  93. </view>
  94. <view class="room-price">¥{{ item.price }}</view>
  95. <view class="room-num">今剩{{ item.s_yum }}间</view>
  96. <view class="room-button" :class="{'room-button2': item.s_yum == 0}">
  97. <text v-if="item.s_yum == 0">已满</text>
  98. <text v-else @click="navigateToOrderRoom(item.s_yum, item.id, item.h_type, item.price)">订</text>
  99. </view>
  100. <view class="room-line" v-if="index < (roomType.length - 1)"></view>
  101. </view>
  102. </view>
  103. </view>
  104. <!-- 订房时弹框 -->
  105. <!-- <uni-popup ref="popup_order" type="center" width="300rpx" height="300rpx" background-color="#fff">
  106. <view class="kuang_txt">
  107. <text>{{order_txt}}</text>
  108. </view>
  109. </uni-popup> -->
  110. <uni-popup ref="popup_order" type="dialog">
  111. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" :content="order_txt" @confirm="dialogConfirm"
  112. @close="dialogClose"></uni-popup-dialog>
  113. </uni-popup>
  114. <!-- 房间样式弹窗页面 -->
  115. <uni-popup ref="popup" type="dialog" :mask-click="false">
  116. <view class="popup_bg">
  117. <text class="popup_title">户型详情</text>
  118. <text class="popup_error" @click="popupClose"></text>
  119. <!-- 轮播图 -->
  120. <swiper class="swiper" circular :indicator-dots="indicatorDots">
  121. <swiper-item v-for="(item, index) in img" :key="index">
  122. <view class="swiper-item">
  123. <image :src="item" class="swiper-img"></image>
  124. </view>
  125. </swiper-item>
  126. </swiper>
  127. <text class="popup_title2">介绍</text>
  128. <view class="popup_txt">
  129. <view class="popup_txt_in">{{ typeText }}</view>
  130. </view>
  131. </view>
  132. </uni-popup>
  133. <!-- 有一个可续住订单时办理续住弹窗页面 -->
  134. <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
  135. <view class="popup_bg_xu">
  136. <text class="popup_title">办理续住</text>
  137. <text class="popup_error" @click="popupXuzhuClose"></text>
  138. <text class="popup_xu_line"></text>
  139. <!-- 时间选择 -->
  140. <view class="select-time-xu" @click="openXuCalendar">
  141. <view class="select-time-one-xu">
  142. <text class="select-list">周四入住</text>
  143. <text class="select-list-time">07月21日</text>
  144. </view>
  145. <view class="select-center">
  146. <view class="select-line1"></view>
  147. <view class="select-circle">1晚</view>
  148. <view class="select-line2"></view>
  149. </view>
  150. <view class="select-time-one-xu">
  151. <text class="select-list">周五离店</text>
  152. <text class="select-list-time">07月22日</text>
  153. </view>
  154. </view>
  155. <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
  156. <!-- 支付框 -->
  157. <view class="fukuan">
  158. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
  159. <view class="fu-zhifu">立即支付</view>
  160. </view>
  161. </view>
  162. </uni-popup>
  163. <uni-popup ref="popup_xu" :mask-click="true">
  164. <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert"
  165. :lunar="infoXu.lunar" :startDate="infoXu.startDate" :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu" />
  166. </uni-popup>
  167. <!-- 无可续住订单时办理续住弹窗页面 -->
  168. <uni-popup ref="popup_xuzhu_no" type="dialog">
  169. <uni-popup-dialog cancelText="关闭" confirmText="确定" content="请先订房" @close="dialogClose"></uni-popup-dialog>
  170. </uni-popup>
  171. <a :href="'https://chtech.ncjti.edu.cn/hotelReservation/zhotel/appcode.action?card_number=' + cardNumber" id="shouquanId"></a>
  172. </view>
  173. </template>
  174. <script>
  175. // 导入qq地图图片
  176. import AMap from "../../lib/qqmap-wx-jssdk.js";
  177. export default {
  178. data() {
  179. return {
  180. showCalendar: false,
  181. info: {
  182. lunar: true,
  183. range: true,
  184. insert: true,
  185. selected: [],
  186. startDate: '',
  187. date: '',
  188. endDate: ''
  189. },
  190. msgType: 'warn',
  191. distance: 0, //"距离"
  192. startTime: '', //默认到店日期
  193. endTime: '', //默认离店日期
  194. startDate: '', //默认到店日期接口数据
  195. endDate: '', //默认离店日期接口数据
  196. startWeek: '', // 默认入店日
  197. endWeek: '', // 默认离店
  198. payMount: 0, //房间价格
  199. freeRoom: 0, //房间剩余
  200. ruzhu_num: 1, //入住夜晚数
  201. //续住里选择器
  202. infoXu: {
  203. lunar: true,
  204. range: true,
  205. insert: true,
  206. selected: [],
  207. startDate: '',
  208. date: '',
  209. endDate: ''
  210. },
  211. roomType: [],
  212. typeText: '', //房型详细描述
  213. indicatorDots: true, //滚动图片提示条默认出现
  214. img: [], //轮播图里图片
  215. phone: '19807957890', //电话
  216. latitude: '', // 默认当前纬度
  217. longitude: '',
  218. scale: 12, // 默认16
  219. markers: [],
  220. markerHeight: 30,
  221. xuzhu_type: [], // 办理续住判断条件
  222. xuzhu_panduan: [], // 办理续住判断条件赋值
  223. tui_type: [], // 办理退房判断条件
  224. tui_panduan: [], // 办理退房判断条件赋值
  225. dai_type: [], // 办理入住判断条件
  226. dai_panduan: [], // 办理入住判断条件赋值
  227. order_txt: '', //订房事故时信息
  228. cardNumber: '',
  229. dates: [],
  230. biaozhun_min: 1000,
  231. gaoji_min: 1000,
  232. haohua_min: 1000
  233. }
  234. },
  235. onLoad(options) {
  236. // console.log('index.options:', options.card_number);
  237. if (!options.hasOwnProperty("card_number")) {
  238. uni.showLoading({
  239. title: '加载中...',
  240. mask: true
  241. })
  242. setTimeout(() => {
  243. uni.hideLoading();
  244. }, 1500)
  245. return;
  246. }
  247. var cardNumber = options.card_number;
  248. if (this.$utils.isEmpty(cardNumber)) {
  249. uni.showToast({
  250. title: '未获取用户信息',
  251. duration: 1500
  252. });
  253. return;
  254. }
  255. var cardNumber_store = this.$utils.getEncryptedData('cardNumber');
  256. if (!this.$utils.isEmpty(cardNumber) && !this.$utils.isEmpty(cardNumber_store)) {
  257. if (cardNumber !== cardNumber_store) {
  258. uni.showToast({
  259. title: '用户不合法',
  260. duration: 1500
  261. })
  262. return;
  263. }
  264. // 存储用户卡号
  265. this.$utils.storeEncryptedData('cardNumber', cardNumber);
  266. this.cardNumber = cardNumber;
  267. }
  268. this.startDate = this.$utils.getDate(new Date()).fullDate2
  269. this.endDate = this.$utils.getDate(new Date(), 1).fullDate2
  270. },
  271. mounted() {
  272. },
  273. onReady() {
  274. const that = this;
  275. that.$nextTick(() => {
  276. that.showCalendar = true
  277. })
  278. // TODO 模拟请求异步同步数据
  279. setTimeout(() => {
  280. const now = new Date();
  281. const theEndDate = new Date('2023-09-15');
  282. // console.log('date:'+getDate(new Date()).fullDate)
  283. // console.log('startDate:'+getDate(new Date()).fullDate)
  284. // console.log('startWeek:'+getDate(new Date()).eWeek)
  285. var arrDate = that.$utils.getDateComponents(now, 'date', 'time', 'weekday_cn', 'monthday_cn');
  286. var arrDate_1 = that.$utils.getDateComponents(that.$utils.addDaysToDate(now, 1), 'date', 'time', 'weekday_cn', 'monthday_cn');
  287. var arrDate_6 = that.$utils.getDateComponents(theEndDate, 'date', 'time', 'weekday_cn', 'monthday_cn');
  288. that.info.date = arrDate.date
  289. that.info.startDate = arrDate.date
  290. that.info.endDate = arrDate_6.date
  291. that.infoXu.date = arrDate.date
  292. that.infoXu.startDate = arrDate.date
  293. that.infoXu.endDate = arrDate_6.date
  294. that.startTime = arrDate.monthday_cn
  295. that.endTime = arrDate_1.monthday_cn
  296. that.startWeek = arrDate.weekday_cn
  297. that.endWeek = arrDate_1.weekday_cn
  298. }, 30)
  299. // wx请求获取位置权限
  300. that.getAuthorize()
  301. .then(() => {
  302. // 同意后获取
  303. that.getLocationInfo();
  304. })
  305. .catch(() => {
  306. uni.getLocation({
  307. type: "gcj02",
  308. success: function(res) {
  309. // 暂时
  310. that.longitude = res.longitude;
  311. that.latitude = res.latitude;
  312. var long = 0;
  313. var lat = 0;
  314. //小数点保留六位 经度
  315. if (that.longitude.toString().indexOf('.') > 0) {
  316. const longlatsplit = that.longitude.toString().split('.');
  317. if (longlatsplit.length >= 2) {
  318. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,
  319. 6));
  320. }
  321. }
  322. if (that.latitude.toString().indexOf('.') > 0) {
  323. const longlatsplit1 = that.latitude.toString().split('.');
  324. if (longlatsplit1.length >= 2) {
  325. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,
  326. 6));
  327. }
  328. }
  329. that.distance = that.getMapDistance(lat, long, '28.788671', '115.387261');
  330. that.markers = [{
  331. id: "",
  332. latitude: res.latitude,
  333. longitude: res.longitude,
  334. iconPath: "../../static/img/phone.png",
  335. width: that.markerHeight, //宽
  336. height: that.markerHeight, //高
  337. }, ];
  338. },
  339. });
  340. // 不同意给出弹框,再次确认
  341. // this.openConfirm()
  342. // .then(() => {
  343. // this.getLocationInfo();
  344. // })
  345. // .catch(() => {
  346. // this.rejectGetLocation();
  347. // });
  348. });
  349. // 获取用户信息
  350. this.getUserInfo()
  351. },
  352. onShow() {
  353. // 获取房型
  354. this.getRoomType('')
  355. },
  356. methods: {
  357. // 房型接口
  358. getRoomType(param) {
  359. let that = this
  360. let d = ''
  361. that.roomType = []
  362. if (param == '') {
  363. var arrDate = this.$utils.getDateComponents(new Date(), 'date');
  364. d = arrDate.date
  365. } else
  366. d = param
  367. if (d !== undefined) {
  368. that.$myRequest({
  369. url: '/hotelReservation/zhotel/appday_list.action?date=' + d,
  370. }).then(res => {
  371. // console.log(res.data);
  372. if (res.data.code === 200) {
  373. let data = res.data.data;
  374. data.forEach(item => {
  375. let it = {
  376. date: item.date,
  377. h_type: item.h_type,
  378. id: item.id,
  379. price: item.price,
  380. y_num: item.y_num,
  381. z_num: item.z_num,
  382. s_yum: item.s_yum
  383. }
  384. if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
  385. that.biaozhun_min = item.s_yum
  386. }
  387. if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
  388. that.gaoji_min = item.s_yum
  389. }
  390. if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
  391. that.haohua_min = item.s_yum
  392. }
  393. that.roomType.push(it)
  394. });
  395. } else {
  396. uni.showToast({
  397. title: '未获得房型'
  398. })
  399. }
  400. });
  401. }
  402. },
  403. // 获取用户信息openid,没有则弹出进行授权
  404. getUserInfo() {
  405. var that = this;
  406. that.$myRequest({
  407. url: '/hotelReservation/zhotel/appuser.action?card_number=' + that.cardNumber,
  408. }).then(res => {
  409. if (res.data.code === 200) {
  410. if (that.$utils.isEmpty(res.data.data.openid)) {
  411. uni.showModal({
  412. title: '授权提示',
  413. content: '获取个人信息',
  414. success(res) {
  415. if (res.confirm) {
  416. // 获取超链接元素
  417. var link = document.getElementById('shouquanId');
  418. // 触发点击事件
  419. link.click();
  420. } else if (res.cancel) {
  421. uni.showToast({
  422. title: '用户取消授权'
  423. })
  424. }
  425. }
  426. })
  427. }
  428. // } else {
  429. // uni.showToast({
  430. // title: res.data.message
  431. // })
  432. }
  433. });
  434. },
  435. // 房型详情接口
  436. getRoomTypeInfo(id) {
  437. let _self = this
  438. _self.typeText = ''
  439. _self.img = []
  440. if (id === 1) {
  441. _self.typeText = '一室一卫,内有沙发、茶几、空调、电视、衣柜、24小时热水,1.35米双人床一张。'
  442. _self.img = ['/static/index/std0.jpg', '/static/index/std.jpg']
  443. } else if (id === 2) {
  444. _self.typeText = '一室一厅一卫,有标准公寓所有设施,客厅配有空调、3座沙发、书桌。1.5米双人床一张。'
  445. _self.img = ['/static/index/adv1.jpg', '/static/index/adv.jpg', '/static/index/adv2.jpg']
  446. } else {
  447. _self.typeText = '一室一厅一卫,有标准公寓所有设施,大客厅配落地空调、5座沙发、书桌。1.5米双人床一张。'
  448. _self.img = ['/static/index/lux.jpg', '/static/index/lux1.jpg', '/static/index/lux2.jpg']
  449. }
  450. },
  451. // 订单列表
  452. getOrderPage() {
  453. let _self = this
  454. _self.xuzhu_type = []
  455. _self.tui_type = []
  456. _self.dai_type = []
  457. this.$axios.get("/hotelReservation/zhotel/order/page?curPage=1&pageSize=100", {
  458. headers: {
  459. 'user_token': localStorage.getItem('token')
  460. }
  461. }).then(res => {
  462. res = res.data
  463. if (res.success) {
  464. res.data.list.forEach(data => {
  465. if (data.flag !== '-1') {
  466. _self.xuzhu_type.push(data.orderStatu)
  467. _self.tui_type.push(data.orderStatu)
  468. _self.dai_type.push(data.orderStatu)
  469. // console.log(_self.xuzhu_type)
  470. }
  471. })
  472. } else {
  473. console.log('获取订单列表失败')
  474. }
  475. });
  476. },
  477. // // 跳转到入住须知
  478. // navigateToXuzhi() {
  479. // uni.navigateTo({
  480. // url: "/pages/ruzhuxuzhi/ruzhuxuzhi",
  481. // });
  482. // },
  483. // 跳转到公寓详情
  484. navigateToXiangqing() {
  485. uni.navigateTo({
  486. url: "/pages/gongyujieshao/gongyujieshao",
  487. });
  488. },
  489. // 订房间
  490. navigateToOrderRoom(enableNum, id, typeName, price) {
  491. // console.log(enableNum, id, typeName, price);
  492. let _self = this
  493. _self.roomType = []
  494. // if (enableNum >= 1) {
  495. uni.navigateTo({
  496. url: "/pages/order_room/order_room?roomTypeId=" + id + "&enableStartTime=" + _self.startDate + "&enableEndTime=" + _self.endDate +
  497. "&startTime=" + _self.startTime + "&endTime=" + _self.endTime + "&ruzhu_num=" + _self.ruzhu_num + "&typeName=" + typeName +
  498. "&freeRoom=" + enableNum + "&price=" + price
  499. });
  500. // }
  501. // this.getRoomType()
  502. },
  503. //办理入住跳转
  504. navigateToDairuzhu(type) {
  505. this.dai_panduan = []
  506. setTimeout(() => {
  507. this.getOrderPage()
  508. }, 1)
  509. setTimeout(() => {
  510. for (let i = 0; i < this.dai_type.length; i++) {
  511. this.dai_type.forEach(val => {
  512. if (val[i] == 2) {
  513. this.dai_panduan.push(val)
  514. }
  515. })
  516. }
  517. if (this.dai_panduan.length >= 1) {
  518. uni.navigateTo({
  519. url: "/pages/my_orderlist/my_orderlist?Inv=2"
  520. })
  521. } else if (this.dai_panduan.length < 1) {
  522. this.msgType = type
  523. this.order_txt = '请先订房!'
  524. this.$refs.popup_order.open()
  525. }
  526. }, 150)
  527. },
  528. //办理退房
  529. navigateToTuifang(type) {
  530. this.tui_panduan = []
  531. setTimeout(() => {
  532. this.getOrderPage()
  533. }, 1)
  534. setTimeout(() => {
  535. for (let i = 0; i < this.tui_type.length; i++) {
  536. this.tui_type.forEach(val => {
  537. if (val[i] == 3) {
  538. this.tui_panduan.push(val)
  539. }
  540. })
  541. }
  542. if (this.tui_panduan.length >= 1) {
  543. uni.navigateTo({
  544. url: "/pages/my_orderlist/my_orderlist?Inv=3"
  545. })
  546. } else if (this.tui_panduan.length < 1) {
  547. this.msgType = type
  548. this.$refs.popup_tui.open()
  549. }
  550. }, 150)
  551. },
  552. // 户型详情弹窗
  553. inputDialogToggle(h_type) {
  554. this.$refs.popup.open()
  555. if (h_type.indexOf('标准') !== -1) {
  556. this.getRoomTypeInfo(1)
  557. } else if (h_type.indexOf('高级') !== -1) {
  558. this.getRoomTypeInfo(2)
  559. } else if (h_type.indexOf('豪华') !== -1) {
  560. this.getRoomTypeInfo(3)
  561. } else {
  562. }
  563. },
  564. popupClose() {
  565. this.$refs.popup.close()
  566. },
  567. //办理续住弹窗
  568. navigateToXuzhu() {
  569. this.xuzhu_panduan = []
  570. setTimeout(() => {
  571. this.getOrderPage()
  572. }, 1)
  573. setTimeout(() => {
  574. for (let i = 0; i < this.xuzhu_type.length; i++) {
  575. this.xuzhu_type.forEach(val => {
  576. if (val[i] == 3) {
  577. this.xuzhu_panduan.push(val)
  578. }
  579. })
  580. }
  581. // console.log(this.xuzhu_panduan)
  582. if (this.xuzhu_panduan.length > 1) {
  583. uni.navigateTo({
  584. url: "/pages/my_orderlist/my_orderlist?Inv=3"
  585. })
  586. } else if (this.xuzhu_panduan.length == 1) {
  587. this.$refs.popup_xuzhu.open()
  588. } else if (this.xuzhu_panduan.length == 0) {
  589. this.$refs.popup_xuzhu_no.open()
  590. }
  591. }, 150)
  592. },
  593. popupXuzhuClose() {
  594. this.$refs.popup_xuzhu.close()
  595. },
  596. // 不可续住关闭弹窗
  597. dialogClose() {
  598. this.$refs.popup_xuzhu_no.close()
  599. },
  600. // 日期选择器弹窗开启
  601. openCalendar() {
  602. this.$refs.popup_picker.open()
  603. },
  604. change(e) {
  605. var that = this;
  606. that.biaozhun_min = 1000
  607. that.gaoji_min = 1000
  608. that.haohua_min = 1000
  609. var before = e.range.before;
  610. var after = e.range.after;
  611. if (before !== '' && after === '')
  612. this.getRoomType(before);
  613. this.dates = this.$utils.generateDates(before, after);
  614. if (this.dates.length !== 0) {
  615. let temp = this.roomType;
  616. this.info.selected = []
  617. // 创建一个用于存储请求结果的数组
  618. const results = [];
  619. // 创建一个包含所有请求的Promise数组
  620. const requestPromises = this.dates.map(date => {
  621. return new Promise((resolve, reject) => {
  622. uni.request({
  623. url: '/hotelReservation/zhotel/appday_list.action?date=' + date,
  624. success: res => {
  625. // 将请求结果存储到结果数组中
  626. results.push(res);
  627. resolve();
  628. },
  629. fail: err => {
  630. reject(err);
  631. }
  632. });
  633. });
  634. });
  635. // 使用Promise.all()等待所有请求完成
  636. Promise.all(requestPromises)
  637. .then(() => {
  638. // 所有请求完成后的处理
  639. // 遍历每个元素
  640. results.forEach(result => {
  641. // 遍历每个元素中的"data"数组
  642. result.data.data.forEach(item => {
  643. // console.log(item);
  644. var min = 1000;
  645. // 在这里对每个数据项进行操作
  646. if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
  647. temp.forEach((it) => {
  648. if (it.h_type.indexOf('标准') !== -1) {
  649. this.$set(it, 's_yum', item.s_yum);
  650. that.biaozhun_min = item.s_yum;
  651. }
  652. })
  653. } else if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
  654. temp.forEach((it) => {
  655. if (it.h_type.indexOf('高级') !== -1) {
  656. this.$set(it, 's_yum', item.s_yum);
  657. that.gaoji_min = item.s_yum;
  658. }
  659. })
  660. } else if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
  661. temp.forEach((it) => {
  662. if (it.h_type.indexOf('豪华') !== -1) {
  663. this.$set(it, 's_yum', item.s_yum);
  664. that.haohua_min = item.s_yum;
  665. }
  666. })
  667. }
  668. if (min > item.s_yum)
  669. min = item.s_yum
  670. that.info.selected.push({
  671. date: item.date,
  672. info: min.toString()
  673. })
  674. });
  675. });
  676. setTimeout(() => {
  677. this.roomType = []
  678. this.roomType = temp;
  679. }, 500)
  680. })
  681. .catch(err => {
  682. // 处理错误
  683. console.error('异常:', err);
  684. });
  685. } else {
  686. this.info.selected = [{
  687. date: before,
  688. info: '到店'
  689. },
  690. {
  691. date: after,
  692. info: '离店'
  693. }
  694. ];
  695. }
  696. if (before !== '' && after === '') {
  697. this.startWeek = '周' + e.lunar.ncWeek.substring(2, 3)
  698. } else if (before !== '' && after !== '') {
  699. if ((new Date(after).getTime()) == (new Date(before).getTime())) {
  700. uni.showToast({
  701. title: '不能选同一天',
  702. icon: 'error',
  703. duration: 1500
  704. });
  705. return;
  706. }
  707. if ((new Date(after).getTime()) < (new Date(before).getTime())) {
  708. var temp = before;
  709. before = after;
  710. after = temp;
  711. }
  712. this.endWeek = '周' + e.lunar.ncWeek.substring(2, 3)
  713. this.startTime = before.substring(5, 7) + '月' + before.substring(8, 10) + '日'
  714. this.endTime = after.substring(5, 7) + '月' + after.substring(8, 10) + '日'
  715. this.startDate = before + ' 14:00:00'
  716. this.endDate = after + ' 12:00:00'
  717. this.ruzhu_num = parseInt(((new Date(after).getTime()) - (new Date(before).getTime())) / 1000 / 60 / 60 / 24)
  718. if (this.endDate != ' 12:00:00') {
  719. this.getRoomType()
  720. }
  721. }
  722. },
  723. // 续住里日期选择器弹窗
  724. openXuCalendar() {
  725. this.$refs.popup_xu.open()
  726. },
  727. changeXu(e) {
  728. // console.log('1change 返回:', e)
  729. // 模拟动态打卡
  730. if (this.infoXu.selected.length > 5) return
  731. this.infoXu.selected.push({
  732. date: e.range.before,
  733. info: '到店'
  734. })
  735. this.infoXu.selected.push({
  736. date: e.range.after,
  737. info: '离店'
  738. })
  739. },
  740. //拨打电话
  741. telphone() {
  742. var that = this;
  743. uni.makePhoneCall({
  744. phoneNumber: that.phone,
  745. }) // 传参带入号码即可
  746. },
  747. // 初次位置授权
  748. getAuthorize() {
  749. return new Promise((resolve, reject) => {
  750. uni.authorize({
  751. scope: "scope.userLocation",
  752. success: () => {
  753. resolve(); // 允许授权
  754. },
  755. fail: () => {
  756. reject(); // 拒绝授权
  757. },
  758. });
  759. });
  760. },
  761. // 确认授权后,获取用户位置
  762. getLocationInfo() {
  763. const that = this;
  764. uni.getLocation({
  765. type: "gcj02",
  766. success: function(res) {
  767. // 暂时
  768. that.longitude = res.longitude; //118.787575;
  769. that.latitude = res.latitude; //32.05024;
  770. console.log("获取当前的用户经度", that.longitude);
  771. console.log("获取当前的用户纬度", that.latitude);
  772. var long = 0;
  773. var lat = 0;
  774. //小数点保留六位 经度
  775. if (that.longitude.toString().indexOf('.') > 0) {
  776. const longlatsplit = that.longitude.toString().split('.');
  777. if (longlatsplit.length >= 2) {
  778. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0, 6));
  779. }
  780. }
  781. if (that.latitude.toString().indexOf('.') > 0) {
  782. const longlatsplit1 = that.latitude.toString().split('.');
  783. if (longlatsplit1.length >= 2) {
  784. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0, 6));
  785. }
  786. }
  787. console.log("纬度", lat);
  788. that.distance = that.getMapDistance(lat, long, '28.788671', '115.387261');
  789. console.log(that.distance)
  790. that.markers = [{
  791. id: "",
  792. latitude: res.latitude,
  793. longitude: res.longitude,
  794. iconPath: "../../static/img/phone.png",
  795. width: that.markerHeight, //宽
  796. height: that.markerHeight, //高
  797. }, ];
  798. },
  799. });
  800. },
  801. // 拒绝授权后,弹框提示是否手动打开位置授权
  802. openConfirm() {
  803. return new Promise((resolve, reject) => {
  804. uni.showModal({
  805. title: "请求授权当前位置",
  806. content: "我们需要获取地理位置信息,为您推荐路线",
  807. success: (res) => {
  808. // if (res.confirm) {
  809. // uni.openSetting().then((res) => {
  810. // if (res[1].authSetting["scope.userLocation"] === true) {
  811. // resolve(); // 打开地图权限设置
  812. // } else {
  813. // reject();
  814. // console.log('reject')
  815. // }
  816. // });
  817. // } else if (res.cancel) {
  818. // reject();
  819. // }
  820. },
  821. });
  822. });
  823. },
  824. // 彻底拒绝位置获取
  825. rejectGetLocation() {
  826. uni.showToast({
  827. title: "你拒绝了授权,无法获得周边信息",
  828. icon: "none",
  829. duration: 2000,
  830. });
  831. },
  832. //打开地图导航
  833. mapDaohang(lon, lat) {},
  834. //进行经纬度转换为距离的计算
  835. Rad(d) {
  836. return d * Math.PI / 180.0; //经纬度转换成三角函数中度分表形式。
  837. },
  838. /*
  839. 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  840. 默认单位km
  841. */
  842. getMapDistance(lat1, lng1, lat2, lng2) {
  843. // console.log(this.Rad(lat1))
  844. // console.log(this.Rad(lng1))
  845. // console.log(this.Rad(lat2))
  846. // console.log(this.Rad(lng2))
  847. // console.log(this.Rad(28.678651))
  848. var radLat1 = this.Rad(lat1);
  849. var radLat2 = this.Rad(lat2);
  850. var a = radLat1 - radLat2;
  851. var b = this.Rad(lng1) - this.Rad(lng2);
  852. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  853. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  854. s = s * 6378.137; // EARTH_RADIUS;
  855. s = Math.round(s * 10000) / 10000; //输出为公里
  856. s = s.toFixed(2);
  857. return s;
  858. },
  859. }
  860. }
  861. </script>
  862. <style>
  863. @import url("./css/index.css");
  864. </style>