index.vue 26 KB

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