index.vue 25 KB

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