index.vue 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. <template>
  2. <view class="content">
  3. <!-- 背景图 -->
  4. <view class="index_bg">
  5. <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
  6. <swiper-item v-for="(item,index) in apartList.coverPicture" :key="index">
  7. <image class="welcome_img" :src="item.url"></image>
  8. <!-- <view class="swiper-item">1</view> -->
  9. </swiper-item>
  10. </swiper>
  11. <!-- <view class="welcome" v-for="(item,index) in apartList.coverPicture" :key="index">
  12. <image class="welcome_img" :src="item.url"></image>
  13. </view> -->
  14. </view>
  15. <!-- 第一层公寓名称卡片 -->
  16. <view class="uni-ka" style="margin-top: -40px;margin-bottom:0px;">
  17. <text class="uni-title">{{apartList.name}}(南昌交通学院)</text>
  18. <text class="uni-sub-title">2021年装修 | 智能门锁 | 房间wifi | 免费停车</text>
  19. <text class="uni-extra" @click="navigateToXiangqing">设施/详情></text>
  20. <text class="uni-body">江西省宜春市靖安县墨轩湖大道1号</text>
  21. <image class="uni-phone" @click="telphone(phone)" src="../../static/index/index_phone.svg"></image>
  22. <a href="https://uri.amap.com/marker?position=115.387261,28.788671&name=南昌交通学院智慧公寓">
  23. <image class="uni-map" @click="mapDaohang('115.387261','28.788671')" src="../../static/index/index_map.svg"></image>
  24. </a>
  25. <!-- <br><text class="uni-body2">距离我{{distance}}km</text> -->
  26. </view>
  27. <!-- 第二层工具 -->
  28. <!-- <view class="item-list">
  29. <view class="item-list-one" @click="navigateToXuzhi">
  30. <image src="../../static/index/xuzhi.png" class="img-btn" height="100%" width="100%"></image>
  31. <text class="list-txt">入住须知</text>
  32. </view>
  33. <view class="item-list-one" @click="navigateToDairuzhu('warn')">
  34. <image src="../../static/index/ruzhu.png" class="img-btn"></image>
  35. <text class="list-txt">办理入住</text>
  36. </view> -->
  37. <!-- <view class="item-list-one" @click="navigateToXuzhu">
  38. <image src="../../static/index/index_xuzhu.svg" class="img-btn"></image>
  39. <text class="list-txt">办理续住</text>
  40. </view> -->
  41. <!-- <view class="item-list-one" @click="navigateToTuifang('warn')">
  42. <image src="../../static/index/tuifang.png" class="img-btn"></image>
  43. <text class="list-txt">办理退房</text>
  44. </view>
  45. </view> -->
  46. <!-- 退房失败时弹框 -->
  47. <!-- <uni-popup ref="popup_tui" type="center" width="300rpx" height="300rpx" background-color="#fff">
  48. <view class="kuang_txt_tui">
  49. <text>请先订房</text>
  50. </view>
  51. </uni-popup> -->
  52. <uni-popup ref="popup_tui" type="dialog">
  53. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" content="请先订房!" @confirm="dialogConfirm"
  54. @close="dialogClose"></uni-popup-dialog>
  55. </uni-popup>
  56. <!-- 切换全日房和钟点房 -->
  57. <view class="select-type" v-if="roomtype==1" @click="changeType">
  58. <view class="allday">全日房</view>
  59. <view class="hourday_no">钟点房</view>
  60. </view>
  61. <view class="select-type" v-else-if="roomtype==2" @click="changeType">
  62. <view class="allday2">全日房</view>
  63. <view class="hourday_no2">钟点房</view>
  64. </view>
  65. <!-- 第三层订房 -->
  66. <view class="room-list">
  67. <!-- 选择住房日期 -->
  68. <!-- 全日房 -->
  69. <view class="select-time" @click="openCalendar" v-if="roomtype==1">
  70. <view class="select-time-one">
  71. <text class="select-list">{{startWeek}}入住</text>
  72. <text class="select-list-time">{{startTime}}</text>
  73. </view>
  74. <view class="select-center">
  75. <view class="select-line1"></view>
  76. <view class="select-circle">{{ruzhu_num}}晚</view>
  77. <view class="select-line2"></view>
  78. </view>
  79. <view class="select-time-one">
  80. <text class="select-list">{{endWeek}}离店</text>
  81. <text class="select-list-time">{{endTime}}</text>
  82. </view>
  83. </view>
  84. <!-- 钟点房 -->
  85. <view class="select-time" v-else>
  86. <view class="hourtime">
  87. <uni-datetime-picker type="date" v-model="hourruzhu" @change="changezhong" :start="mindate" :end="info.endDate">
  88. 入住时间
  89. <text class="select-list-time" style="margin-left: 26rpx;">{{hourruzhu}}</text>
  90. <image class="hour_right" src="../../static/index/hour_right.png"></image>
  91. </uni-datetime-picker>
  92. <view class="hour_line"></view>
  93. </view>
  94. </view>
  95. <!-- 全日房选择时间 -->
  96. <uni-popup ref="popup_picker" :mask-click="true">
  97. <!-- <view class=popup_bg_picker> -->
  98. <!-- <text class="popup_title">取消</text> -->
  99. <uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert" :lunar="info.lunar" :startDate="info.startDate"
  100. :endDate="info.endDate" :range="info.range" @change="change"/>
  101. <view style="height: 60px; background-color: #fff;">
  102. <view class="riliQueren" @click="popup_pickerClose">确定{{ruzhu_num}}晚</view>
  103. </view>
  104. <!-- </view> -->
  105. </uni-popup>
  106. <!-- 房型列表-->
  107. <view class="room-kuang">
  108. <view class="room-xinxi" v-for="(item,index) in roomType" :key="index">
  109. <image class="room-image" :src="item.roomPicture" @click="inputDialogToggle(item.id)"></image>
  110. <view style="padding-top: 10px;display: grid;width: 47%;">
  111. <text class="room-name">
  112. {{item.roomName}}
  113. <view class="room-time3" v-if="item.roomType==2">{{item.roomLiveTime}}小时</view>
  114. </text>
  115. <view class="room-icon">
  116. <image :src="item2.iconPath" v-for="(item2,index2) in item.roomConfigurationPicture" :key="index2" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  117. <!-- <image src="../../static/index/index_kongtiao.svg" style="width: 26rpx;height: 26rpx;margin-left: 10rpx;"></image>
  118. <image src="../../static/index/index_nosmoking.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  119. <image src="../../static/index/index_lock.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
  120. <image src="../../static/index/index_wifi.svg" style="width: 30rpx;height: 30rpx;"></image>
  121. <image src="../../static/index/index_kongtiao.svg" style="width: 26rpx;height: 26rpx;margin-left: 10rpx;"></image> -->
  122. </view>
  123. <view class="room-time2" v-if="item.roomType==2">
  124. <text class="zhongtime" v-for="(item3,index3) in apartList.hourTime.split(',')" :key="index3">{{item3}}</text>
  125. </view>
  126. <view class="shengyu-jian">剩余{{item.surplusCount}}间</view>
  127. </view>
  128. <view style="display: flex;align-items: end;flex: 1;margin-right: 5px;" v-if="item.roomType==1">
  129. <view class="room-price">¥{{item.roomPrice}}</view>
  130. <view class="room-button" :class="{'room-button2': item.houseStatus == 2}">
  131. <text v-if="item.houseStatus==2">已满</text>
  132. <text v-else-if="item.houseStatus==1" @click="navigateToOrderRoom(item.houseStatus,item.id,item.roomName,item)">订</text>
  133. </view>
  134. </view>
  135. <view v-if="item.roomType==2" style="display: grid;align-items: end;flex: 1;margin-right: 5px;">
  136. <view class="room-price2">¥{{item.roomPrice}}</view>
  137. <view class="room-buttonZ" :class="{'room-button2Z': item.houseStatus == 2}">
  138. <text v-if="item.houseStatus==2">已满</text>
  139. <text v-else-if="item.houseStatus==1" @click="navigateToOrderRoom(item.houseStatus,item.id,item.roomName,item)">订</text>
  140. </view>
  141. </view>
  142. <view class="room-line" v-if="index<(roomType.length) && index>0"></view>
  143. </view>
  144. </view>
  145. </view>
  146. <!-- 订房时弹框 -->
  147. <!-- <uni-popup ref="popup_order" type="center" width="300rpx" height="300rpx" background-color="#fff">
  148. <view class="kuang_txt">
  149. <text>{{order_txt}}</text>
  150. </view>
  151. </uni-popup> -->
  152. <uni-popup ref="popup_order" type="dialog">
  153. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" :content="order_txt" @confirm="dialogConfirm"
  154. @close="dialogClose"></uni-popup-dialog>
  155. </uni-popup>
  156. <!-- 房间样式弹窗页面 -->
  157. <uni-popup ref="popup" type="dialog" :mask-click="false">
  158. <view class="popup_bg">
  159. <text class="popup_title">户型详情</text>
  160. <text class="popup_error" @click="popupClose"></text>
  161. <!-- 轮播图 -->
  162. <swiper class="swiper" circular :indicator-dots="indicatorDots">
  163. <swiper-item v-for="(item, index) in img" :key="index">
  164. <view class="swiper-item">
  165. <image :src="item" class="swiper-img"></image>
  166. </view>
  167. </swiper-item>
  168. </swiper>
  169. <text class="popup_title2">便利设施</text>
  170. <view class="popup_txt"><view class="popup_txt_in">{{typeText}}</view></view>
  171. </view>
  172. </uni-popup>
  173. <!-- 有一个可续住订单时办理续住弹窗页面 -->
  174. <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
  175. <view class="popup_bg_xu">
  176. <text class="popup_title">办理续住</text>
  177. <text class="popup_error" @click="popupXuzhuClose"></text>
  178. <text class="popup_xu_line"></text>
  179. <!-- 时间选择 -->
  180. <view class="select-time-xu" @click="openXuCalendar">
  181. <view class="select-time-one-xu">
  182. <text class="select-list">周四入住</text>
  183. <text class="select-list-time">07月21日</text>
  184. </view>
  185. <view class="select-center">
  186. <view class="select-line1"></view>
  187. <view class="select-circle">1晚</view>
  188. <view class="select-line2"></view>
  189. </view>
  190. <view class="select-time-one-xu">
  191. <text class="select-list">周五离店</text>
  192. <text class="select-list-time">07月22日</text>
  193. </view>
  194. </view>
  195. <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
  196. <!-- 支付框 -->
  197. <view class="fukuan">
  198. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
  199. <view class="fu-zhifu">立即支付</view>
  200. </view>
  201. </view>
  202. </uni-popup>
  203. <uni-popup ref="popup_xu" :mask-click="true">
  204. <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert" :lunar="infoXu.lunar" :startDate="infoXu.startDate"
  205. :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu"/>
  206. </uni-popup>
  207. <!-- 无可续住订单时办理续住弹窗页面 -->
  208. <uni-popup ref="popup_xuzhu_no" type="dialog">
  209. <uni-popup-dialog cancelText="关闭" confirmText="确定" content="请先订房"
  210. @close="dialogClose"></uni-popup-dialog>
  211. </uni-popup>
  212. <!-- 预订时判断是否有入住资格弹框 -->
  213. <uni-popup ref="popupRuzhu" :mask-click="false">
  214. <view class="popup-content">
  215. <view class="popup-zige">免费入住资格筛选</view>
  216. <!-- 多选框组 -->
  217. <!--" -->
  218. <radio-group v-model="selectedValue" @change="radioChange">
  219. <radio v-for="(item, index) in options" :key="index" :value="item.name" :disabled="item.count == 0">
  220. {{ item.name }}
  221. <text style="margin-left: 30px;">{{item.count}}间</text>
  222. </radio>
  223. </radio-group>
  224. <!-- 确认和取消按钮 -->
  225. <button @click="confirmSelection" class="xuanzesuccess">选择完成</button>
  226. <!-- <button class="xuanzesuccess2" v-else>选择完成</button> -->
  227. <!-- <button @click="quxiaoyuding" class="xuanzesuccess">取消</button> -->
  228. <view style="height: 20px;"></view>
  229. </view>
  230. </uni-popup>
  231. </view>
  232. </template>
  233. <script>
  234. /**
  235. * 获取任意时间
  236. */
  237. function getDate(date, AddDayCount = 0) {
  238. if (!date) {
  239. date = new Date()
  240. }
  241. if (typeof date !== 'object') {
  242. date = date.replace(/-/g, '/')
  243. }
  244. const dd = new Date(date)
  245. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  246. var a = new Array("日", "一", "二", "三", "四", "五", "六","日");
  247. var week = new Date().getDay();
  248. var week2 = new Date().getDay()+1;
  249. const y = dd.getFullYear()
  250. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  251. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  252. const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  253. const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  254. const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  255. return {
  256. fullDate: y + '-' + m + '-' + d,
  257. fullDate2: y + '-' + m + '-' + d+' '+h+':'+f+':'+s,
  258. fullTime: m + '月' + d + '日',
  259. year: y,
  260. month: m,
  261. date: d,
  262. day: dd.getDay(),
  263. sWeek:"周"+ a[week],
  264. eWeek:"周"+ a[week2]
  265. }
  266. }
  267. import {
  268. getroomtype,
  269. getroomtypeinfo,
  270. getorderpage,
  271. apartSet,
  272. getpayOpenId,
  273. ifyuding
  274. } from '../../utils/api_hotel.js'
  275. // 导入图片
  276. import AMap from "../../lib/qqmap-wx-jssdk.js"
  277. export default {
  278. data() {
  279. return {
  280. indicatorDots: true,
  281. autoplay: true,
  282. interval: 2000,
  283. duration: 500,
  284. showCalendar: false,
  285. info: {
  286. lunar: true,
  287. range: true,
  288. insert: true,
  289. selected: [],
  290. startDate:'',
  291. date:'',
  292. endDate:''
  293. },
  294. msgType: 'warn',
  295. distance: 0, //"距离"
  296. startTime:'',//默认到店日期
  297. endTime:'',//默认离店日期
  298. startDate:'',//默认到店日期接口数据
  299. endDate:'',//默认离店日期接口数据
  300. startWeek:'',// 默认入店日
  301. endWeek:'',// 默认离店
  302. payMount:0,//房间价格
  303. freeRoom:0,//房间剩余
  304. ruzhu_num:1,//入住夜晚数
  305. //续住里选择器
  306. infoXu: {
  307. lunar: true,
  308. range: true,
  309. insert: true,
  310. selected: [],
  311. startDate:'',
  312. date:'',
  313. endDate:''
  314. },
  315. roomType:[
  316. ],
  317. typeText:'',//房型详细描述
  318. indicatorDots: true,//滚动图片提示条默认出现
  319. img:[],//轮播图里图片
  320. phone:'',//电话
  321. latitude: '', // 默认当前纬度
  322. longitude:'',
  323. scale: 12, // 默认16
  324. markers: [],
  325. markerHeight: 30,
  326. xuzhu_type:[],// 办理续住判断条件
  327. xuzhu_panduan:[],// 办理续住判断条件赋值
  328. tui_type:[],// 办理退房判断条件
  329. tui_panduan:[],// 办理退房判断条件赋值
  330. dai_type:[],// 办理入住判断条件
  331. dai_panduan:[],// 办理入住判断条件赋值
  332. order_txt:'',//订房事故时信息
  333. roomtype:1,//区分房型,1全日房 ;2钟点房
  334. hourruzhu:'',//钟点房入住时间
  335. mindate:new Date().toISOString().slice(0, 10),
  336. page:1,
  337. size:10,
  338. totalCount: 0,
  339. apartList:{},
  340. hourTime:'',//钟点房营业时间
  341. selectedValue: '', // 选中的值
  342. sourceId:'',
  343. options: [],
  344. xuanId:'',
  345. xuanroomName:'',
  346. itenxuan:{},//选中的数据
  347. }
  348. },
  349. onShow() {
  350. // this.getLocationInfo()
  351. this.getAllset()
  352. },
  353. onLoad() {
  354. this.getAllset()
  355. this.handleUrlCode()
  356. },
  357. mounted() {
  358. },
  359. onReady() {
  360. this.$nextTick(() => {
  361. this.showCalendar = true
  362. })
  363. // TODO 模拟请求异步同步数据
  364. setTimeout(() => {
  365. // console.log('date:'+getDate(new Date()).fullDate)
  366. // console.log('startDate:'+getDate(new Date()).fullDate)
  367. // console.log('endDate:'+getDate(new Date(),6).fullDate)
  368. this.info.date = getDate(new Date()).fullDate
  369. this.info.startDate = getDate(new Date()).fullDate
  370. this.info.endDate = getDate(new Date(),8).fullDate
  371. this.infoXu.date = getDate(new Date()).fullDate
  372. this.infoXu.startDate = getDate(new Date()).fullDate
  373. this.infoXu.endDate = getDate(new Date(),8).fullDate
  374. this.startTime = getDate(new Date()).fullTime
  375. this.endTime = getDate(new Date(),1).fullTime
  376. this.hourruzhu= getDate(new Date()).fullDate
  377. this.startWeek = getDate(new Date()).sWeek
  378. this.endWeek = getDate(new Date(),1).eWeek
  379. }, 1)
  380. // this.getLocationInfo()
  381. // wx请求获取位置权限
  382. this.getAuthorize()
  383. .then(() => {
  384. 同意后获取
  385. // this.getLocationInfo();
  386. })
  387. .catch(() => {
  388. // const that = this;
  389. // uni.getLocation({
  390. // type: "gcj02",
  391. // success: function(res) {
  392. // console.log(res,'经纬度22')
  393. // alert(res.latitude)
  394. // // 暂时
  395. // that.longitude = res.longitude;
  396. // that.latitude = res.latitude;
  397. // var long = 0;
  398. // var lat = 0;
  399. // //小数点保留六位 经度
  400. // if (that.longitude.toString().indexOf('.') > 0) {
  401. // const longlatsplit = that.longitude.toString().split('.');
  402. // if (longlatsplit.length >= 2) {
  403. // long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  404. // }
  405. // }
  406. // if (that.latitude.toString().indexOf('.') > 0) {
  407. // const longlatsplit1 = that.latitude.toString().split('.');
  408. // if (longlatsplit1.length >= 2) {
  409. // lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  410. // }
  411. // }
  412. // that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
  413. // that.markers = [{
  414. // id: "",
  415. // latitude: res.latitude,
  416. // longitude: res.longitude,
  417. // iconPath: "../../static/img/phone.png",
  418. // width: that.markerHeight, //宽
  419. // height: that.markerHeight, //高
  420. // }, ];
  421. // },
  422. // });
  423. // 不同意给出弹框,再次确认
  424. // this.openConfirm()
  425. // .then(() => {
  426. // this.getLocationInfo();
  427. // })
  428. // .catch(() => {
  429. // this.rejectGetLocation();
  430. // });
  431. });
  432. },
  433. methods: {
  434. // 截取 url中的code方法
  435. handleUrlCode() {
  436. var url = location.href; //获取打开的公众号的路径
  437. // alert(url)
  438. var theRequest = new Object();
  439. if (url.indexOf('?') != -1) {
  440. var str = url.substr(url.indexOf('?') + 1);
  441. var strs = str.split('&');
  442. for (var i = 0; i < strs.length; i++) {
  443. var items = strs[i].split('=');
  444. if(strs[i].split('=')[0]=='code'){
  445. var code=strs[i].split('=')[1]
  446. localStorage.setItem('code',code)
  447. }
  448. theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
  449. theRequest[i] = strs[i].split('=')[1];
  450. }
  451. // alert(code+'p'+localStorage.getItem('code'))
  452. }
  453. },
  454. //获取支付openId
  455. getOpenId(){
  456. let _self = this
  457. // alert('p'+localStorage.getItem('code'))
  458. var data='?wxcode='+localStorage.getItem('code')
  459. // {
  460. // 'wxcode':'061NSw100t8LAS1pXH0004UsUs1NSw1c'//
  461. // }
  462. getpayOpenId(data).then((res) => {
  463. if (res.success) {
  464. localStorage.setItem('openId2',res.message)
  465. // alert('openid时'+localStorage.getItem('openId2'))
  466. } else if(res.code=='500'){
  467. // uni.showModal({
  468. // content:res.message
  469. // })
  470. }
  471. }).catch((err) => {
  472. // uni.showModal({
  473. // content:err.message
  474. // })
  475. });
  476. },
  477. //公寓整体配置
  478. getAllset(){
  479. let _self = this
  480. _self.roomType = []
  481. apartSet().then((res) => {
  482. if (res.success) {
  483. this.apartList=res.data
  484. this.phone=this.apartList.phoneNumbr
  485. localStorage.setItem('liveTime',this.apartList.liveTime)
  486. localStorage.setItem('leaveTime',this.apartList.leaveTime)
  487. this.startDate = getDate(new Date()).fullDate+" "+this.apartList.liveTime
  488. this.endDate = getDate(new Date(),1).fullDate+" "+this.apartList.leaveTime
  489. this.startTime = getDate(new Date()).fullTime
  490. this.endTime = getDate(new Date(),1).fullTime
  491. this.ruzhu_num=1
  492. this.startWeek = getDate(new Date()).sWeek
  493. this.endWeek = getDate(new Date(),1).eWeek
  494. this.hourruzhu= getDate(new Date()).fullDate
  495. this.hourTime=this.apartList.hourTime
  496. // alert('8')
  497. this.selectedValue=''
  498. this.sourceId=''
  499. this.getRoomType()
  500. return;
  501. } else {
  502. uni.showModal({
  503. content:"没有符合条件的数据!"
  504. })
  505. }
  506. }).catch((err) => {
  507. // uni.showModal({
  508. // content:err.message
  509. // })
  510. });
  511. },
  512. onReachBottom: function() {
  513. console.log('当前长度',this.roomType.length)
  514. if (this.roomType.length < this.totalCount) {
  515. wx.showLoading({
  516. title: '加载中...',
  517. })
  518. this.page = this.page + 1;
  519. this.getRoomType()
  520. } else {
  521. }
  522. },
  523. onPullDownRefresh: function() {
  524. this.page = 1;
  525. this.getRoomType();
  526. },
  527. //切换房型
  528. changeType(){
  529. if(this.roomtype==1){
  530. this.roomtype=2
  531. this.page = 1;
  532. this.startDate = getDate(new Date()).fullDate+" "+getDate(new Date()).fullDate2.substring(11,19)
  533. this.endDate = getDate(new Date()).fullDate+" "+"23:59:00"
  534. this.hourruzhu = getDate(new Date()).fullDate.substring(5,7)+'月'+getDate(new Date()).fullDate.substring(8,10)+'日'
  535. this.getRoomType();
  536. }else if(this.roomtype==2){
  537. this.roomtype=1
  538. this.page = 1;
  539. this.startDate = getDate(new Date()).fullDate+" "+this.apartList.liveTime
  540. this.endDate = getDate(new Date(),1).fullDate+" "+this.apartList.leaveTime
  541. this.getRoomType();
  542. }
  543. this.startTime = getDate(new Date()).fullTime
  544. this.endTime = getDate(new Date(),1).fullTime
  545. this.ruzhu_num=1
  546. this.startWeek = getDate(new Date()).sWeek
  547. this.endWeek = getDate(new Date(),1).eWeek
  548. this.hourruzhu= getDate(new Date()).fullDate
  549. },
  550. //钟点房选择日期
  551. changezhong(e){
  552. console.log(e,getDate(new Date()).fullDate,getDate(new Date()).fullDate<e,'l')
  553. this.hourruzhu=e
  554. if(getDate(new Date()).fullDate<e){
  555. this.startDate = e+" "+"00:00:00"
  556. this.endDate = e+" "+"23:59:00"
  557. }else{
  558. this.startDate = e+" "+getDate(new Date()).fullDate2.substring(11,19)
  559. this.endDate = e+" "+"23:59:00"
  560. }
  561. this.hourruzhu = e.substring(5,7)+'月'+e.substring(8,10)+'日'
  562. this.getRoomType();
  563. },
  564. // 房型接口
  565. getRoomType() {
  566. let _self = this
  567. var data="?page="+_self.page+"&size="+_self.size+"&type="+_self.roomtype+"&startTime="+_self.startDate+"&endTime="+_self.endDate
  568. getroomtype(data).then((res) => {
  569. if (res.success) {
  570. this.totalCount = res.data.total
  571. // res.data.records.forEach(data => {
  572. // // if (data.houseStatus == '1') {//房间可订
  573. // _self.roomType.push(data)
  574. // // }
  575. // })
  576. if (this.page == 1) {
  577. _self.roomType = res.data.records
  578. } else {
  579. _self.roomType = [..._self.roomType, ...res.data.records]
  580. }
  581. uni.stopPullDownRefresh();
  582. uni.hideLoading()
  583. } else {
  584. uni.showModal({
  585. content:"没有符合条件的数据!"
  586. })
  587. // this.$message.warning('没有符合条件的数据!')
  588. }
  589. }).catch((err) => {
  590. // uni.showModal({
  591. // content:err.message
  592. // })
  593. // this.$message.error(err.message)
  594. });
  595. },
  596. // 房型详情接口
  597. getRoomTypeInfo(id) {
  598. let _self = this
  599. _self.typeText=''
  600. _self.img=[]
  601. var data="?houseId="+id
  602. getroomtypeinfo(data).then((res) => {
  603. if (res.success) {
  604. _self.typeText=res.data.introductory
  605. _self.img=res.data.housePicture.split(',')
  606. return;
  607. } else {
  608. this.$message.warning('没有符合条件的数据!')
  609. }
  610. }).catch((err) => {
  611. this.$message.error(err.message)
  612. });
  613. },
  614. // 订单列表
  615. getOrderPage() {
  616. let _self = this
  617. _self.xuzhu_type=[]
  618. _self.tui_type=[]
  619. _self.dai_type=[]
  620. var data='?curPage=1&pageSize=100'
  621. getorderpage(data).then((res) => {
  622. if (res.success) {
  623. console.log(res)
  624. res.data.list.forEach(data => {
  625. if (data.flag !== '-1') {
  626. _self.xuzhu_type.push(data.orderStatu)
  627. _self.tui_type.push(data.orderStatu)
  628. _self.dai_type.push(data.orderStatu)
  629. // console.log(_self.xuzhu_type)
  630. }
  631. })
  632. return;
  633. } else {
  634. this.$message.warning('没有符合条件的数据!')
  635. }
  636. }).catch((err) => {
  637. this.$message.error(err.message)
  638. });
  639. // this.$axios.get("/hotel/ihotel-api/ihotel/hotelOrder/user/order/page?curPage=1&pageSize=100",
  640. // {
  641. // headers:{
  642. // 'user_token':localStorage.getItem('token')
  643. // }
  644. // }).then(res => {
  645. // res = res.data
  646. // if (res.success) {
  647. // res.data.list.forEach(data => {
  648. // if (data.flag !== '-1') {
  649. // _self.xuzhu_type.push(data.orderStatu)
  650. // _self.tui_type.push(data.orderStatu)
  651. // _self.dai_type.push(data.orderStatu)
  652. // // console.log(_self.xuzhu_type)
  653. // }
  654. // })
  655. // } else {
  656. // console.log('获取订单列表失败')
  657. // }
  658. // });
  659. },
  660. // 跳转到入住须知
  661. navigateToXuzhi(){
  662. uni.navigateTo({
  663. url: "/pages/ruzhuxuzhi/ruzhuxuzhi",
  664. });
  665. },
  666. // 跳转到公寓详情
  667. navigateToXiangqing(){
  668. uni.navigateTo({
  669. url: "/pages/gongyuxiangqing/gongyuxiangqing",
  670. });
  671. },
  672. // 订房间
  673. navigateToOrderRoom(houseStatus,id,roomName,item) {
  674. this.xuanId=id
  675. this.xuanroomName=roomName
  676. this.itenxuan=item
  677. this.ifRuzhu()
  678. // let _self = this
  679. // _self.roomType = []
  680. // if (houseStatus==1){
  681. // uni.navigateTo({
  682. // url: "/pages/order_room/order_room?roomTypeId="+id +"&enableStartTime="+this.startDate+"&enableEndTime="+this.endDate+"&startTime="+this.startTime+"&endTime="+this.endTime+"&typeName="+roomName+"&ruzhu_num="+this.ruzhu_num+"&roomArea="
  683. // +item.roomArea+"&roomType="+item.roomType+"&roomConfiguration="+item.roomConfiguration+"&roomPrice="+item.roomPrice+'&surplusCount='+item.surplusCount+'&zhongTime='+this.apartList.hourTime+'&zhongshi='+item.roomLiveTime+'&source='+this.selectedValue,
  684. // });
  685. // }
  686. // this.getRoomType()
  687. },
  688. //订房前判断是否有入住资格
  689. ifRuzhu(){
  690. // alert('订房')
  691. this.options=[]
  692. let _self = this
  693. var data='?userId='+localStorage.getItem('usersId')+
  694. '&liveTime='+_self.startDate+'&leaveTime='+_self.endDate
  695. ifyuding(data).then((res) => {
  696. if (res.success) {
  697. _self.options=res.data
  698. console.log(_self.options,'iii')
  699. if(_self.options.length>0){
  700. _self.$refs.popupRuzhu.open();
  701. }else{
  702. _self.selectedValue=''
  703. _self.sourceId=''
  704. let temporaryObj = {
  705. roomTypeId:_self.xuanId,
  706. enableStartTime:_self.startDate,
  707. enableEndTime:_self.endDate,
  708. startTime:_self.startTime,
  709. endTime:_self.endTime,
  710. typeName:_self.xuanroomName,
  711. ruzhu_num:_self.ruzhu_num,
  712. roomArea:_self.itenxuan.roomArea,
  713. roomType:_self.itenxuan.roomType,
  714. roomConfiguration:_self.itenxuan.roomConfiguration,
  715. roomPrice:_self.itenxuan.roomPrice,
  716. surplusCount:_self.itenxuan.surplusCount,
  717. zhongTime:_self.apartList.hourTime,
  718. zhongshi:_self.itenxuan.roomLiveTime,
  719. source:_self.selectedValue,
  720. sourceId:_self.sourceId
  721. }
  722. //传参对象,使用encodeURIComponent编码
  723. let str = JSON.stringify(temporaryObj)
  724. //注意这里——————————————————————
  725. str = str.replace(/%/g, '%25')
  726. //这里———————————————————————————
  727. let query = encodeURIComponent(str)
  728. uni.navigateTo({
  729. url: "/pages/order_room/order_room?data="+query
  730. // url: "/pages/order_room/order_room?roomTypeId="+_self.xuanId +"&enableStartTime="+_self.startDate+"&enableEndTime="+_self.endDate+"&startTime="+_self.startTime+"&endTime="+_self.endTime+"&typeName="+_self.xuanroomName+"&ruzhu_num="+_self.ruzhu_num+"&roomArea="
  731. // +_self.itenxuan.roomArea+"&roomType="+_self.itenxuan.roomType+"&roomConfiguration="+_self.itenxuan.roomConfiguration+"&roomPrice="+_self.itenxuan.roomPrice+'&surplusCount='+_self.itenxuan.surplusCount+'&zhongTime='+_self.apartList.hourTime+'&zhongshi='+_self.itenxuan.roomLiveTime
  732. // +'&source='+_self.selectedValue+'&sourceId='+_self.sourceId,
  733. });
  734. }
  735. } else if(res.code=='500'){
  736. uni.showModal({
  737. title: '提示',
  738. content: res.message,
  739. success: function (res) {
  740. if (res.confirm) {
  741. _self.selectedValue=''
  742. _self.sourceId=''
  743. let temporaryObj = {
  744. roomTypeId:_self.xuanId,
  745. enableStartTime:_self.startDate,
  746. enableEndTime:_self.endDate,
  747. startTime:_self.startTime,
  748. endTime:_self.endTime,
  749. typeName:_self.xuanroomName,
  750. ruzhu_num:_self.ruzhu_num,
  751. roomArea:_self.itenxuan.roomArea,
  752. roomType:_self.itenxuan.roomType,
  753. roomConfiguration:_self.itenxuan.roomConfiguration,
  754. roomPrice:_self.itenxuan.roomPrice,
  755. surplusCount:_self.itenxuan.surplusCount,
  756. zhongTime:_self.apartList.hourTime,
  757. zhongshi:_self.itenxuan.roomLiveTime,
  758. source:_self.selectedValue,
  759. sourceId:_self.sourceId
  760. }
  761. //传参对象,使用encodeURIComponent编码
  762. let str = JSON.stringify(temporaryObj)
  763. //注意这里——————————————————————
  764. str = str.replace(/%/g, '%25')
  765. //这里———————————————————————————
  766. let query = encodeURIComponent(str)
  767. uni.navigateTo({
  768. url: "/pages/order_room/order_room?data="+query
  769. });
  770. } else if (res.cancel) {
  771. _self.selectedValue=''
  772. _self.sourceId=''
  773. }
  774. }
  775. });
  776. }
  777. }).catch((err) => {
  778. // alert(err)
  779. uni.showModal({
  780. content:err
  781. })
  782. });
  783. },
  784. radioChange(e){
  785. // console.log(e,'ll')
  786. for (let i = 0; i < this.options.length; i++) {
  787. if (this.options[i].name === e.detail.value) {
  788. this.selectedValue=this.options[i].source
  789. this.sourceId=this.options[i].sourceId
  790. break;
  791. }
  792. }
  793. },
  794. //订房选中流程
  795. confirmSelection() {
  796. console.log('选中的值:', this.selectedValue);
  797. this.$refs.popupRuzhu.close()
  798. // alert('跳转')
  799. let temporaryObj = {
  800. roomTypeId:this.xuanId,
  801. enableStartTime:this.startDate,
  802. enableEndTime:this.endDate,
  803. startTime:this.startTime,
  804. endTime:this.endTime,
  805. typeName:this.xuanroomName,
  806. ruzhu_num:this.ruzhu_num,
  807. roomArea:this.itenxuan.roomArea,
  808. roomType:this.itenxuan.roomType,
  809. roomConfiguration:this.itenxuan.roomConfiguration,
  810. roomPrice:this.itenxuan.roomPrice,
  811. surplusCount:this.itenxuan.surplusCount,
  812. zhongTime:this.apartList.hourTime,
  813. zhongshi:this.itenxuan.roomLiveTime,
  814. source:this.selectedValue,
  815. sourceId:this.sourceId
  816. }
  817. //传参对象,使用encodeURIComponent编码
  818. let str = JSON.stringify(temporaryObj)
  819. //注意这里——————————————————————
  820. str = str.replace(/%/g, '%25')
  821. //这里———————————————————————————
  822. let query = encodeURIComponent(str)
  823. uni.navigateTo({
  824. url: "/pages/order_room/order_room?data="+query,
  825. // url: "/pages/order_room/order_room?roomTypeId="+this.xuanId +"&enableStartTime="+this.startDate+"&enableEndTime="+this.endDate+"&startTime="+this.startTime+"&endTime="+this.endTime+"&typeName="+this.xuanroomName+"&ruzhu_num="+this.ruzhu_num+"&roomArea="
  826. // +this.itenxuan.roomArea+"&roomType="+this.itenxuan.roomType+"&roomConfiguration="+this.itenxuan.roomConfiguration+"&roomPrice="+this.itenxuan.roomPrice+'&surplusCount='+this.itenxuan.surplusCount+'&zhongTime='+this.apartList.hourTime+'&zhongshi='+this.itenxuan.roomLiveTime+'&source='+this.selectedValue+'&sourceId='+_self.sourceId,
  827. });
  828. },
  829. //取消预订
  830. quxiaoyuding(){
  831. this.selectedValue=''
  832. this.sourceId=''
  833. this.$refs.popupRuzhu.close()
  834. let temporaryObj = {
  835. roomTypeId:this.xuanId,
  836. enableStartTime:this.startDate,
  837. enableEndTime:this.endDate,
  838. startTime:this.startTime,
  839. endTime:this.endTime,
  840. typeName:this.xuanroomName,
  841. ruzhu_num:this.ruzhu_num,
  842. roomArea:this.itenxuan.roomArea,
  843. roomType:this.itenxuan.roomType,
  844. roomConfiguration:this.itenxuan.roomConfiguration,
  845. roomPrice:this.itenxuan.roomPrice,
  846. surplusCount:this.itenxuan.surplusCount,
  847. zhongTime:this.apartList.hourTime,
  848. zhongshi:this.itenxuan.roomLiveTime,
  849. source:this.selectedValue,
  850. sourceId:this.sourceId
  851. }
  852. //传参对象,使用encodeURIComponent编码
  853. let str = JSON.stringify(temporaryObj)
  854. //注意这里——————————————————————
  855. str = str.replace(/%/g, '%25')
  856. //这里———————————————————————————
  857. let query = encodeURIComponent(str)
  858. uni.navigateTo({
  859. url: "/pages/order_room/order_room?data="+query
  860. });
  861. },
  862. //办理入住跳转
  863. navigateToDairuzhu(type){
  864. this.dai_panduan=[]
  865. setTimeout(() => {
  866. this.getOrderPage()
  867. },1)
  868. setTimeout(() => {
  869. for (let i=0;i<this.dai_type.length;i++){
  870. this.dai_type.forEach(val => {
  871. if(val[i]==2) {
  872. this.dai_panduan.push(val)
  873. }
  874. })
  875. }
  876. if(this.dai_panduan.length>=1) {
  877. uni.navigateTo({
  878. url:"/pages/my_orderlist/my_orderlist?Inv=2"
  879. })
  880. }else if(this.dai_panduan.length<1) {
  881. this.msgType = type
  882. this.order_txt='请先订房!'
  883. this.$refs.popup_order.open()
  884. }
  885. },150)
  886. },
  887. //办理退房
  888. navigateToTuifang(type){
  889. this.tui_panduan=[]
  890. setTimeout(() => {
  891. this.getOrderPage()
  892. },1)
  893. setTimeout(() => {
  894. for (let i=0;i<this.tui_type.length;i++){
  895. this.tui_type.forEach(val => {
  896. if(val[i]==3) {
  897. this.tui_panduan.push(val)
  898. }
  899. })
  900. }
  901. if(this.tui_panduan.length>=1) {
  902. uni.navigateTo({
  903. url:"/pages/my_orderlist/my_orderlist?Inv=3"
  904. })
  905. }else if(this.tui_panduan.length<1) {
  906. this.msgType = type
  907. this.$refs.popup_tui.open()
  908. }
  909. },150)
  910. },
  911. //户型详情弹窗
  912. inputDialogToggle(id) {
  913. this.$refs.popup.open()
  914. this.getRoomTypeInfo(id)
  915. },
  916. popupClose() {
  917. this.$refs.popup.close()
  918. },
  919. //办理续住弹窗
  920. navigateToXuzhu(){
  921. this.xuzhu_panduan=[]
  922. setTimeout(() => {
  923. this.getOrderPage()
  924. },1)
  925. setTimeout(() => {
  926. for (let i=0;i<this.xuzhu_type.length;i++){
  927. this.xuzhu_type.forEach(val => {
  928. if(val[i]==3) {
  929. this.xuzhu_panduan.push(val)
  930. }
  931. })
  932. }
  933. console.log(this.xuzhu_panduan)
  934. if(this.xuzhu_panduan.length>1) {
  935. uni.navigateTo({
  936. url:"/pages/my_orderlist/my_orderlist?Inv=3"
  937. })
  938. }else if(this.xuzhu_panduan.length==1) {
  939. this.$refs.popup_xuzhu.open()
  940. }else if(this.xuzhu_panduan.length==0) {
  941. this.$refs.popup_xuzhu_no.open()
  942. }
  943. },150)
  944. },
  945. popupXuzhuClose() {
  946. this.$refs.popup_xuzhu.close()
  947. },
  948. // 不可续住关闭弹窗
  949. dialogClose(){
  950. this.$refs.popup_xuzhu_no.close()
  951. },
  952. // 日期选择器弹窗开启
  953. openCalendar() {
  954. this.$refs.popup_picker.open()
  955. },
  956. // 关闭全日房日历
  957. popup_pickerClose(){
  958. this.$refs.popup_picker.close()
  959. },
  960. change(e) {
  961. this.info.selected=[
  962. {
  963. date: e.range.before,
  964. info: '到店'
  965. },
  966. {
  967. date: e.range.after,
  968. info: '离店'
  969. }
  970. ]
  971. if(e.range.before!=''&&e.range.after=='') {
  972. this.startWeek='周'+e.lunar.ncWeek.substring(2,3)
  973. } else if(e.range.before!=''&&e.range.after!=''){
  974. if((new Date(e.range.after).getTime())<(new Date(e.range.before).getTime())) {
  975. this.order_txt='离店日期不能小于到店日期'
  976. this.$refs.popup_order.open()
  977. this.info.selected=[]
  978. }else if(parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)>2){
  979. this.order_txt='预订时间不能超过两晚'
  980. this.$refs.popup_order.open()
  981. this.info.selected=[]
  982. }else if(parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)==2){
  983. this.order_txt='您此次申请了两晚,请注意若只住一晚可能会导致流程管理次数失效。'
  984. this.$refs.popup_order.open()
  985. this.endWeek='周'+e.lunar.ncWeek.substring(2,3)
  986. this.startTime=e.range.before.substring(5,7)+'月'+e.range.before.substring(8,10)+'日'
  987. this.endTime=e.range.after.substring(5,7)+'月'+e.range.after.substring(8,10)+'日'
  988. this.startDate = e.range.before +' '+this.apartList.liveTime
  989. this.endDate = e.range.after +' '+this.apartList.leaveTime
  990. this.ruzhu_num=parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)
  991. if(this.endDate !=this.apartList.leaveTime) {
  992. this.getRoomType()
  993. }
  994. }else{
  995. this.endWeek='周'+e.lunar.ncWeek.substring(2,3)
  996. this.startTime=e.range.before.substring(5,7)+'月'+e.range.before.substring(8,10)+'日'
  997. this.endTime=e.range.after.substring(5,7)+'月'+e.range.after.substring(8,10)+'日'
  998. this.startDate = e.range.before +' '+this.apartList.liveTime
  999. this.endDate = e.range.after +' '+this.apartList.leaveTime
  1000. this.ruzhu_num=parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)
  1001. if(this.endDate !=this.apartList.leaveTime) {
  1002. this.getRoomType()
  1003. }
  1004. }
  1005. }
  1006. },
  1007. // 续住里日期选择器弹窗
  1008. openXuCalendar() {
  1009. this.$refs.popup_xu.open()
  1010. },
  1011. changeXu(e) {
  1012. console.log('1change 返回:', e)
  1013. // 模拟动态打卡
  1014. if (this.infoXu.selected.length > 5) return
  1015. this.infoXu.selected.push({
  1016. date: e.range.before,
  1017. info: '到店'
  1018. })
  1019. this.infoXu.selected.push({
  1020. date: e.range.after,
  1021. info: '离店'
  1022. })
  1023. },
  1024. //拨打电话
  1025. telphone(phone){
  1026. uni.makePhoneCall({
  1027. phoneNumber: phone ,
  1028. }) // 传参带入号码即可
  1029. },
  1030. // 初次位置授权//uni-app不可用
  1031. getAuthorize() {
  1032. return new Promise((resolve, reject) => {
  1033. uni.authorize({
  1034. scope: "scope.userLocation",
  1035. success: () => {
  1036. resolve(); // 允许授权
  1037. },
  1038. fail: () => {
  1039. reject(); // 拒绝授权
  1040. },
  1041. });
  1042. });
  1043. },
  1044. // 确认授权后,获取用户位置
  1045. getLocationInfo() {
  1046. uni.showToast({
  1047. title: '获取',
  1048. icon:'none'
  1049. });
  1050. const that = this;
  1051. uni.getLocation({
  1052. type: "gcj02",//gcj02,wgs84
  1053. // geocode: true,
  1054. // highAccuracyExpireTime: 100,
  1055. success: function(res) {
  1056. alert('location',res)
  1057. // 暂时
  1058. that.longitude = res.longitude; //118.787575;
  1059. that.latitude = res.latitude; //32.05024;
  1060. console.log("获取当前的用户经度", that.longitude);
  1061. console.log("获取当前的用户纬度", that.latitude);
  1062. var long = 0;
  1063. var lat = 0;
  1064. //小数点保留六位 经度
  1065. if (that.longitude.toString().indexOf('.') > 0) {
  1066. const longlatsplit = that.longitude.toString().split('.');
  1067. if (longlatsplit.length >= 2) {
  1068. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  1069. }
  1070. }
  1071. if (that.latitude.toString().indexOf('.') > 0) {
  1072. const longlatsplit1 = that.latitude.toString().split('.');
  1073. if (longlatsplit1.length >= 2) {
  1074. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  1075. }
  1076. }
  1077. that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
  1078. // alert(that.distance)
  1079. that.markers = [{
  1080. id: "",
  1081. latitude: res.latitude,
  1082. longitude: res.longitude,
  1083. iconPath: "../../static/img/phone.png",
  1084. width: that.markerHeight, //宽
  1085. height: that.markerHeight, //高
  1086. }, ];
  1087. },
  1088. fail: function (err) {
  1089. uni.showModal({
  1090. content:'获取地址失败,将导致部分功能不可用'+JSON.stringify(err),
  1091. })
  1092. // uni.showToast({
  1093. // title: '获取地址失败,将导致部分功能不可用'+JSON.stringify(err),
  1094. // icon:'none'
  1095. // });
  1096. }
  1097. });
  1098. },
  1099. // 天地图获取经纬度
  1100. // 拒绝授权后,弹框提示是否手动打开位置授权
  1101. openConfirm() {
  1102. return new Promise((resolve, reject) => {
  1103. uni.showModal({
  1104. title: "请求授权当前位置",
  1105. content: "我们需要获取地理位置信息,为您推荐路线",
  1106. success: (res) => {
  1107. // if (res.confirm) {
  1108. // uni.openSetting().then((res) => {
  1109. // if (res[1].authSetting["scope.userLocation"] === true) {
  1110. // resolve(); // 打开地图权限设置
  1111. // } else {
  1112. // reject();
  1113. // console.log('reject')
  1114. // }
  1115. // });
  1116. // } else if (res.cancel) {
  1117. // reject();
  1118. // }
  1119. },
  1120. });
  1121. });
  1122. },
  1123. // 彻底拒绝位置获取
  1124. rejectGetLocation() {
  1125. uni.showToast({
  1126. title: "你拒绝了授权,无法获得周边信息",
  1127. icon: "none",
  1128. duration: 2000,
  1129. });
  1130. },
  1131. //打开地图导航
  1132. mapDaohang(lon,lat){
  1133. },
  1134. //进行经纬度转换为距离的计算
  1135. Rad(d) {
  1136. return d * Math.PI / 180.0; //经纬度转换成三角函数中度分表形式。
  1137. },
  1138. /*
  1139. 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  1140. 默认单位km
  1141. */
  1142. getMapDistance(lat1, lng1, lat2, lng2) {
  1143. var radLat1 = this.Rad(lat1);
  1144. var radLat2 = this.Rad(lat2);
  1145. var a = radLat1 - radLat2;
  1146. var b = this.Rad(lng1) - this.Rad(lng2);
  1147. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  1148. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  1149. s = s * 6378.137; // EARTH_RADIUS;
  1150. s = Math.round(s * 10000) / 10000; //输出为公里
  1151. s=s.toFixed(2);
  1152. return s;
  1153. },
  1154. }
  1155. }
  1156. </script>
  1157. <style>
  1158. @import url("./css/index.css");
  1159. </style>