index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  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. that.$myRequest({
  368. url: '/hotelReservation/zhotel/appday_list.action?date=' + d,
  369. }).then(res => {
  370. // console.log(res.data);
  371. if (res.data.code === 200) {
  372. let data = res.data.data;
  373. data.forEach(item => {
  374. let it = {
  375. date: item.date,
  376. h_type: item.h_type,
  377. id: item.id,
  378. price: item.price,
  379. y_num: item.y_num,
  380. z_num: item.z_num,
  381. s_yum: item.s_yum
  382. }
  383. if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
  384. that.biaozhun_min = item.s_yum
  385. }
  386. if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
  387. that.gaoji_min = item.s_yum
  388. }
  389. if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
  390. that.haohua_min = item.s_yum
  391. }
  392. that.roomType.push(it)
  393. });
  394. } else {
  395. uni.showToast({
  396. title: '未获得房型'
  397. })
  398. }
  399. });
  400. },
  401. // 获取用户信息openid,没有则弹出进行授权
  402. getUserInfo() {
  403. var that = this;
  404. that.$myRequest({
  405. url: '/hotelReservation/zhotel/appuser.action?card_number=' + that.cardNumber,
  406. }).then(res => {
  407. if (res.data.code === 200) {
  408. if (that.$utils.isEmpty(res.data.data.openid)) {
  409. uni.showModal({
  410. title: '授权提示',
  411. content: '获取个人信息',
  412. success(res) {
  413. if (res.confirm) {
  414. // 获取超链接元素
  415. var link = document.getElementById('shouquanId');
  416. // 触发点击事件
  417. link.click();
  418. } else if (res.cancel) {
  419. uni.showToast({
  420. title: '用户取消授权'
  421. })
  422. }
  423. }
  424. })
  425. }
  426. // } else {
  427. // uni.showToast({
  428. // title: res.data.message
  429. // })
  430. }
  431. });
  432. },
  433. // 房型详情接口
  434. getRoomTypeInfo(id) {
  435. let _self = this
  436. _self.typeText = ''
  437. _self.img = []
  438. if (id === 1) {
  439. _self.typeText = '一室一卫,内有沙发、茶几、空调、电视、衣柜、24小时热水,1.35米双人床一张。'
  440. _self.img = ['/static/index/std0.jpg', '/static/index/std.jpg']
  441. } else if (id === 2) {
  442. _self.typeText = '一室一厅一卫,有标准公寓所有设施,客厅配有空调、3座沙发、书桌。1.5米双人床一张。'
  443. _self.img = ['/static/index/adv1.jpg', '/static/index/adv.jpg', '/static/index/adv2.jpg']
  444. } else {
  445. _self.typeText = '一室一厅一卫,有标准公寓所有设施,大客厅配落地空调、5座沙发、书桌。1.5米双人床一张。'
  446. _self.img = ['/static/index/lux.jpg', '/static/index/lux1.jpg', '/static/index/lux2.jpg']
  447. }
  448. },
  449. // 订单列表
  450. getOrderPage() {
  451. let _self = this
  452. _self.xuzhu_type = []
  453. _self.tui_type = []
  454. _self.dai_type = []
  455. this.$axios.get("/hotelReservation/zhotel/order/page?curPage=1&pageSize=100", {
  456. headers: {
  457. 'user_token': localStorage.getItem('token')
  458. }
  459. }).then(res => {
  460. res = res.data
  461. if (res.success) {
  462. res.data.list.forEach(data => {
  463. if (data.flag !== '-1') {
  464. _self.xuzhu_type.push(data.orderStatu)
  465. _self.tui_type.push(data.orderStatu)
  466. _self.dai_type.push(data.orderStatu)
  467. // console.log(_self.xuzhu_type)
  468. }
  469. })
  470. } else {
  471. console.log('获取订单列表失败')
  472. }
  473. });
  474. },
  475. // // 跳转到入住须知
  476. // navigateToXuzhi() {
  477. // uni.navigateTo({
  478. // url: "/pages/ruzhuxuzhi/ruzhuxuzhi",
  479. // });
  480. // },
  481. // 跳转到公寓详情
  482. navigateToXiangqing() {
  483. uni.navigateTo({
  484. url: "/pages/gongyujieshao/gongyujieshao",
  485. });
  486. },
  487. // 订房间
  488. navigateToOrderRoom(enableNum, id, typeName, price) {
  489. // console.log(enableNum, id, typeName, price);
  490. let _self = this
  491. _self.roomType = []
  492. // if (enableNum >= 1) {
  493. uni.navigateTo({
  494. url: "/pages/order_room/order_room?roomTypeId=" + id + "&enableStartTime=" + _self.startDate + "&enableEndTime=" + _self.endDate +
  495. "&startTime=" + _self.startTime + "&endTime=" + _self.endTime + "&ruzhu_num=" + _self.ruzhu_num + "&typeName=" + typeName +
  496. "&freeRoom=" + enableNum + "&price=" + price
  497. });
  498. // }
  499. // this.getRoomType()
  500. },
  501. //办理入住跳转
  502. navigateToDairuzhu(type) {
  503. this.dai_panduan = []
  504. setTimeout(() => {
  505. this.getOrderPage()
  506. }, 1)
  507. setTimeout(() => {
  508. for (let i = 0; i < this.dai_type.length; i++) {
  509. this.dai_type.forEach(val => {
  510. if (val[i] == 2) {
  511. this.dai_panduan.push(val)
  512. }
  513. })
  514. }
  515. if (this.dai_panduan.length >= 1) {
  516. uni.navigateTo({
  517. url: "/pages/my_orderlist/my_orderlist?Inv=2"
  518. })
  519. } else if (this.dai_panduan.length < 1) {
  520. this.msgType = type
  521. this.order_txt = '请先订房!'
  522. this.$refs.popup_order.open()
  523. }
  524. }, 150)
  525. },
  526. //办理退房
  527. navigateToTuifang(type) {
  528. this.tui_panduan = []
  529. setTimeout(() => {
  530. this.getOrderPage()
  531. }, 1)
  532. setTimeout(() => {
  533. for (let i = 0; i < this.tui_type.length; i++) {
  534. this.tui_type.forEach(val => {
  535. if (val[i] == 3) {
  536. this.tui_panduan.push(val)
  537. }
  538. })
  539. }
  540. if (this.tui_panduan.length >= 1) {
  541. uni.navigateTo({
  542. url: "/pages/my_orderlist/my_orderlist?Inv=3"
  543. })
  544. } else if (this.tui_panduan.length < 1) {
  545. this.msgType = type
  546. this.$refs.popup_tui.open()
  547. }
  548. }, 150)
  549. },
  550. // 户型详情弹窗
  551. inputDialogToggle(h_type) {
  552. this.$refs.popup.open()
  553. if (h_type.indexOf('标准') !== -1) {
  554. this.getRoomTypeInfo(1)
  555. } else if (h_type.indexOf('高级') !== -1) {
  556. this.getRoomTypeInfo(2)
  557. } else if (h_type.indexOf('豪华') !== -1) {
  558. this.getRoomTypeInfo(3)
  559. } else {
  560. }
  561. },
  562. popupClose() {
  563. this.$refs.popup.close()
  564. },
  565. //办理续住弹窗
  566. navigateToXuzhu() {
  567. this.xuzhu_panduan = []
  568. setTimeout(() => {
  569. this.getOrderPage()
  570. }, 1)
  571. setTimeout(() => {
  572. for (let i = 0; i < this.xuzhu_type.length; i++) {
  573. this.xuzhu_type.forEach(val => {
  574. if (val[i] == 3) {
  575. this.xuzhu_panduan.push(val)
  576. }
  577. })
  578. }
  579. // console.log(this.xuzhu_panduan)
  580. if (this.xuzhu_panduan.length > 1) {
  581. uni.navigateTo({
  582. url: "/pages/my_orderlist/my_orderlist?Inv=3"
  583. })
  584. } else if (this.xuzhu_panduan.length == 1) {
  585. this.$refs.popup_xuzhu.open()
  586. } else if (this.xuzhu_panduan.length == 0) {
  587. this.$refs.popup_xuzhu_no.open()
  588. }
  589. }, 150)
  590. },
  591. popupXuzhuClose() {
  592. this.$refs.popup_xuzhu.close()
  593. },
  594. // 不可续住关闭弹窗
  595. dialogClose() {
  596. this.$refs.popup_xuzhu_no.close()
  597. },
  598. // 日期选择器弹窗开启
  599. openCalendar() {
  600. this.$refs.popup_picker.open()
  601. },
  602. change(e) {
  603. var that = this;
  604. var before = e.range.before;
  605. var after = e.range.after;
  606. if (before !== '' && after === '')
  607. this.getRoomType(before);
  608. this.dates = this.$utils.generateDates(before, after);
  609. if (this.dates.length !== 0) {
  610. let temp = this.roomType;
  611. this.info.selected = []
  612. this.dates.forEach((date) => {
  613. that.$myRequest({
  614. url: '/hotelReservation/zhotel/appday_list.action?date=' + date,
  615. }).then(res => {
  616. // console.log(res.data);
  617. if (res.data.code === 200) {
  618. var min = 1000;
  619. let data = res.data.data;
  620. data.forEach(item => {
  621. if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
  622. temp.forEach((it) => {
  623. if (it.h_type.indexOf('标准') !== -1)
  624. it.s_yum = item.s_yum
  625. })
  626. }
  627. if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
  628. temp.forEach((it) => {
  629. if (it.h_type.indexOf('高级') !== -1)
  630. it.s_yum = item.s_yum
  631. })
  632. }
  633. if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
  634. temp.forEach((it) => {
  635. if (it.h_type.indexOf('豪华') !== -1)
  636. it.s_yum = item.s_yum
  637. })
  638. }
  639. if (min > item.s_yum)
  640. min = item.s_yum
  641. });
  642. this.info.selected.push({
  643. date: date,
  644. info: min.toString()
  645. })
  646. }
  647. });
  648. });
  649. setTimeout(() => {
  650. this.roomType = []
  651. this.roomType = temp;
  652. }, 2000)
  653. } else {
  654. this.info.selected = [{
  655. date: before,
  656. info: '到店'
  657. },
  658. {
  659. date: after,
  660. info: '离店'
  661. }
  662. ];
  663. }
  664. if (before !== '' && after === '') {
  665. this.startWeek = '周' + e.lunar.ncWeek.substring(2, 3)
  666. } else if (before !== '' && after !== '') {
  667. if ((new Date(after).getTime()) == (new Date(before).getTime())) {
  668. uni.showToast({
  669. title: '不能选同一天',
  670. icon: 'error',
  671. duration: 1500
  672. });
  673. return;
  674. }
  675. if ((new Date(after).getTime()) < (new Date(before).getTime())) {
  676. var temp = before;
  677. before = after;
  678. after = temp;
  679. }
  680. this.endWeek = '周' + e.lunar.ncWeek.substring(2, 3)
  681. this.startTime = before.substring(5, 7) + '月' + before.substring(8, 10) + '日'
  682. this.endTime = after.substring(5, 7) + '月' + after.substring(8, 10) + '日'
  683. this.startDate = before + ' 14:00:00'
  684. this.endDate = after + ' 12:00:00'
  685. this.ruzhu_num = parseInt(((new Date(after).getTime()) - (new Date(before).getTime())) / 1000 / 60 / 60 / 24)
  686. if (this.endDate != ' 12:00:00') {
  687. this.getRoomType()
  688. }
  689. }
  690. },
  691. // 续住里日期选择器弹窗
  692. openXuCalendar() {
  693. this.$refs.popup_xu.open()
  694. },
  695. changeXu(e) {
  696. // console.log('1change 返回:', e)
  697. // 模拟动态打卡
  698. if (this.infoXu.selected.length > 5) return
  699. this.infoXu.selected.push({
  700. date: e.range.before,
  701. info: '到店'
  702. })
  703. this.infoXu.selected.push({
  704. date: e.range.after,
  705. info: '离店'
  706. })
  707. },
  708. //拨打电话
  709. telphone() {
  710. var that = this;
  711. uni.makePhoneCall({
  712. phoneNumber: that.phone,
  713. }) // 传参带入号码即可
  714. },
  715. // 初次位置授权
  716. getAuthorize() {
  717. return new Promise((resolve, reject) => {
  718. uni.authorize({
  719. scope: "scope.userLocation",
  720. success: () => {
  721. resolve(); // 允许授权
  722. },
  723. fail: () => {
  724. reject(); // 拒绝授权
  725. },
  726. });
  727. });
  728. },
  729. // 确认授权后,获取用户位置
  730. getLocationInfo() {
  731. const that = this;
  732. uni.getLocation({
  733. type: "gcj02",
  734. success: function(res) {
  735. // 暂时
  736. that.longitude = res.longitude; //118.787575;
  737. that.latitude = res.latitude; //32.05024;
  738. console.log("获取当前的用户经度", that.longitude);
  739. console.log("获取当前的用户纬度", that.latitude);
  740. var long = 0;
  741. var lat = 0;
  742. //小数点保留六位 经度
  743. if (that.longitude.toString().indexOf('.') > 0) {
  744. const longlatsplit = that.longitude.toString().split('.');
  745. if (longlatsplit.length >= 2) {
  746. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0, 6));
  747. }
  748. }
  749. if (that.latitude.toString().indexOf('.') > 0) {
  750. const longlatsplit1 = that.latitude.toString().split('.');
  751. if (longlatsplit1.length >= 2) {
  752. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0, 6));
  753. }
  754. }
  755. console.log("纬度", lat);
  756. that.distance = that.getMapDistance(lat, long, '28.788671', '115.387261');
  757. console.log(that.distance)
  758. that.markers = [{
  759. id: "",
  760. latitude: res.latitude,
  761. longitude: res.longitude,
  762. iconPath: "../../static/img/phone.png",
  763. width: that.markerHeight, //宽
  764. height: that.markerHeight, //高
  765. }, ];
  766. },
  767. });
  768. },
  769. // 拒绝授权后,弹框提示是否手动打开位置授权
  770. openConfirm() {
  771. return new Promise((resolve, reject) => {
  772. uni.showModal({
  773. title: "请求授权当前位置",
  774. content: "我们需要获取地理位置信息,为您推荐路线",
  775. success: (res) => {
  776. // if (res.confirm) {
  777. // uni.openSetting().then((res) => {
  778. // if (res[1].authSetting["scope.userLocation"] === true) {
  779. // resolve(); // 打开地图权限设置
  780. // } else {
  781. // reject();
  782. // console.log('reject')
  783. // }
  784. // });
  785. // } else if (res.cancel) {
  786. // reject();
  787. // }
  788. },
  789. });
  790. });
  791. },
  792. // 彻底拒绝位置获取
  793. rejectGetLocation() {
  794. uni.showToast({
  795. title: "你拒绝了授权,无法获得周边信息",
  796. icon: "none",
  797. duration: 2000,
  798. });
  799. },
  800. //打开地图导航
  801. mapDaohang(lon, lat) {},
  802. //进行经纬度转换为距离的计算
  803. Rad(d) {
  804. return d * Math.PI / 180.0; //经纬度转换成三角函数中度分表形式。
  805. },
  806. /*
  807. 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  808. 默认单位km
  809. */
  810. getMapDistance(lat1, lng1, lat2, lng2) {
  811. // console.log(this.Rad(lat1))
  812. // console.log(this.Rad(lng1))
  813. // console.log(this.Rad(lat2))
  814. // console.log(this.Rad(lng2))
  815. // console.log(this.Rad(28.678651))
  816. var radLat1 = this.Rad(lat1);
  817. var radLat2 = this.Rad(lat2);
  818. var a = radLat1 - radLat2;
  819. var b = this.Rad(lng1) - this.Rad(lng2);
  820. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  821. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  822. s = s * 6378.137; // EARTH_RADIUS;
  823. s = Math.round(s * 10000) / 10000; //输出为公里
  824. s = s.toFixed(2);
  825. return s;
  826. },
  827. }
  828. }
  829. </script>
  830. <style>
  831. @import url("./css/index.css");
  832. </style>