index.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  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. // alert(res.latitude)
  393. // 暂时
  394. that.longitude = res.longitude;
  395. that.latitude = res.latitude;
  396. var long = 0;
  397. var lat = 0;
  398. //小数点保留六位 经度
  399. if (that.longitude.toString().indexOf('.') > 0) {
  400. const longlatsplit = that.longitude.toString().split('.');
  401. if (longlatsplit.length >= 2) {
  402. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  403. }
  404. }
  405. if (that.latitude.toString().indexOf('.') > 0) {
  406. const longlatsplit1 = that.latitude.toString().split('.');
  407. if (longlatsplit1.length >= 2) {
  408. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  409. }
  410. }
  411. that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
  412. that.markers = [{
  413. id: "",
  414. latitude: res.latitude,
  415. longitude: res.longitude,
  416. iconPath: "../../static/img/phone.png",
  417. width: that.markerHeight, //宽
  418. height: that.markerHeight, //高
  419. }, ];
  420. },
  421. });
  422. // 不同意给出弹框,再次确认
  423. // this.openConfirm()
  424. // .then(() => {
  425. // this.getLocationInfo();
  426. // })
  427. // .catch(() => {
  428. // this.rejectGetLocation();
  429. // });
  430. });
  431. },
  432. methods: {
  433. // 截取 url中的code方法
  434. handleUrlCode() {
  435. var url = location.href; //获取打开的公众号的路径
  436. // alert(url)
  437. var theRequest = new Object();
  438. if (url.indexOf('?') != -1) {
  439. var str = url.substr(url.indexOf('?') + 1);
  440. var strs = str.split('&');
  441. for (var i = 0; i < strs.length; i++) {
  442. var items = strs[i].split('=');
  443. if(strs[i].split('=')[0]=='code'){
  444. var code=strs[i].split('=')[1]
  445. localStorage.setItem('code',code)
  446. }
  447. theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
  448. theRequest[i] = strs[i].split('=')[1];
  449. }
  450. // alert(code+'p'+localStorage.getItem('code'))
  451. }
  452. },
  453. //获取支付openId
  454. getOpenId(){
  455. let _self = this
  456. // alert('p'+localStorage.getItem('code'))
  457. var data='?wxcode='+localStorage.getItem('code')
  458. // {
  459. // 'wxcode':'061NSw100t8LAS1pXH0004UsUs1NSw1c'//
  460. // }
  461. getpayOpenId(data).then((res) => {
  462. if (res.success) {
  463. localStorage.setItem('openId2',res.message)
  464. // alert('openid时'+localStorage.getItem('openId2'))
  465. } else if(res.code=='500'){
  466. // uni.showModal({
  467. // content:res.message
  468. // })
  469. }
  470. }).catch((err) => {
  471. // uni.showModal({
  472. // content:err.message
  473. // })
  474. });
  475. },
  476. //公寓整体配置
  477. getAllset(){
  478. let _self = this
  479. _self.roomType = []
  480. apartSet().then((res) => {
  481. if (res.success) {
  482. this.apartList=res.data
  483. this.phone=this.apartList.phoneNumbr
  484. localStorage.setItem('liveTime',this.apartList.liveTime)
  485. localStorage.setItem('leaveTime',this.apartList.leaveTime)
  486. this.startDate = getDate(new Date()).fullDate+" "+this.apartList.liveTime
  487. this.endDate = getDate(new Date(),1).fullDate+" "+this.apartList.leaveTime
  488. this.startTime = getDate(new Date()).fullTime
  489. this.endTime = getDate(new Date(),1).fullTime
  490. this.ruzhu_num=1
  491. this.startWeek = getDate(new Date()).sWeek
  492. this.endWeek = getDate(new Date(),1).eWeek
  493. this.hourruzhu= getDate(new Date()).fullDate
  494. this.hourTime=this.apartList.hourTime
  495. // alert('8')
  496. this.selectedValue=''
  497. this.sourceId=''
  498. this.getRoomType()
  499. return;
  500. } else {
  501. uni.showModal({
  502. content:"没有符合条件的数据!"
  503. })
  504. }
  505. }).catch((err) => {
  506. // uni.showModal({
  507. // content:err.message
  508. // })
  509. });
  510. },
  511. onReachBottom: function() {
  512. console.log('当前长度',this.roomType.length)
  513. if (this.roomType.length < this.totalCount) {
  514. wx.showLoading({
  515. title: '加载中...',
  516. })
  517. this.page = this.page + 1;
  518. this.getRoomType()
  519. } else {
  520. }
  521. },
  522. onPullDownRefresh: function() {
  523. this.page = 1;
  524. this.getRoomType();
  525. },
  526. //切换房型
  527. changeType(){
  528. if(this.roomtype==1){
  529. this.roomtype=2
  530. this.page = 1;
  531. this.startDate = getDate(new Date()).fullDate+" "+getDate(new Date()).fullDate2.substring(11,19)
  532. this.endDate = getDate(new Date()).fullDate+" "+"23:59:00"
  533. this.hourruzhu = getDate(new Date()).fullDate.substring(5,7)+'月'+getDate(new Date()).fullDate.substring(8,10)+'日'
  534. this.getRoomType();
  535. }else if(this.roomtype==2){
  536. this.roomtype=1
  537. this.page = 1;
  538. this.startDate = getDate(new Date()).fullDate+" "+this.apartList.liveTime
  539. this.endDate = getDate(new Date(),1).fullDate+" "+this.apartList.leaveTime
  540. this.getRoomType();
  541. }
  542. this.startTime = getDate(new Date()).fullTime
  543. this.endTime = getDate(new Date(),1).fullTime
  544. this.ruzhu_num=1
  545. this.startWeek = getDate(new Date()).sWeek
  546. this.endWeek = getDate(new Date(),1).eWeek
  547. this.hourruzhu= getDate(new Date()).fullDate
  548. },
  549. //钟点房选择日期
  550. changezhong(e){
  551. console.log(e,getDate(new Date()).fullDate,getDate(new Date()).fullDate<e,'l')
  552. this.hourruzhu=e
  553. if(getDate(new Date()).fullDate<e){
  554. this.startDate = e+" "+"00:00:00"
  555. this.endDate = e+" "+"23:59:00"
  556. }else{
  557. this.startDate = e+" "+getDate(new Date()).fullDate2.substring(11,19)
  558. this.endDate = e+" "+"23:59:00"
  559. }
  560. this.hourruzhu = e.substring(5,7)+'月'+e.substring(8,10)+'日'
  561. this.getRoomType();
  562. },
  563. // 房型接口
  564. getRoomType() {
  565. let _self = this
  566. var data="?page="+_self.page+"&size="+_self.size+"&type="+_self.roomtype+"&startTime="+_self.startDate+"&endTime="+_self.endDate
  567. getroomtype(data).then((res) => {
  568. if (res.success) {
  569. this.totalCount = res.data.total
  570. // res.data.records.forEach(data => {
  571. // // if (data.houseStatus == '1') {//房间可订
  572. // _self.roomType.push(data)
  573. // // }
  574. // })
  575. if (this.page == 1) {
  576. _self.roomType = res.data.records
  577. } else {
  578. _self.roomType = [..._self.roomType, ...res.data.records]
  579. }
  580. uni.stopPullDownRefresh();
  581. uni.hideLoading()
  582. } else {
  583. uni.showModal({
  584. content:"没有符合条件的数据!"
  585. })
  586. // this.$message.warning('没有符合条件的数据!')
  587. }
  588. }).catch((err) => {
  589. // uni.showModal({
  590. // content:err.message
  591. // })
  592. // this.$message.error(err.message)
  593. });
  594. },
  595. // 房型详情接口
  596. getRoomTypeInfo(id) {
  597. let _self = this
  598. _self.typeText=''
  599. _self.img=[]
  600. var data="?houseId="+id
  601. getroomtypeinfo(data).then((res) => {
  602. if (res.success) {
  603. _self.typeText=res.data.introductory
  604. _self.img=res.data.housePicture.split(',')
  605. return;
  606. } else {
  607. this.$message.warning('没有符合条件的数据!')
  608. }
  609. }).catch((err) => {
  610. this.$message.error(err.message)
  611. });
  612. },
  613. // 订单列表
  614. getOrderPage() {
  615. let _self = this
  616. _self.xuzhu_type=[]
  617. _self.tui_type=[]
  618. _self.dai_type=[]
  619. var data='?curPage=1&pageSize=100'
  620. getorderpage(data).then((res) => {
  621. if (res.success) {
  622. console.log(res)
  623. res.data.list.forEach(data => {
  624. if (data.flag !== '-1') {
  625. _self.xuzhu_type.push(data.orderStatu)
  626. _self.tui_type.push(data.orderStatu)
  627. _self.dai_type.push(data.orderStatu)
  628. // console.log(_self.xuzhu_type)
  629. }
  630. })
  631. return;
  632. } else {
  633. this.$message.warning('没有符合条件的数据!')
  634. }
  635. }).catch((err) => {
  636. this.$message.error(err.message)
  637. });
  638. // this.$axios.get("/hotel/ihotel-api/ihotel/hotelOrder/user/order/page?curPage=1&pageSize=100",
  639. // {
  640. // headers:{
  641. // 'user_token':localStorage.getItem('token')
  642. // }
  643. // }).then(res => {
  644. // res = res.data
  645. // if (res.success) {
  646. // res.data.list.forEach(data => {
  647. // if (data.flag !== '-1') {
  648. // _self.xuzhu_type.push(data.orderStatu)
  649. // _self.tui_type.push(data.orderStatu)
  650. // _self.dai_type.push(data.orderStatu)
  651. // // console.log(_self.xuzhu_type)
  652. // }
  653. // })
  654. // } else {
  655. // console.log('获取订单列表失败')
  656. // }
  657. // });
  658. },
  659. // 跳转到入住须知
  660. navigateToXuzhi(){
  661. uni.navigateTo({
  662. url: "/pages/ruzhuxuzhi/ruzhuxuzhi",
  663. });
  664. },
  665. // 跳转到公寓详情
  666. navigateToXiangqing(){
  667. uni.navigateTo({
  668. url: "/pages/gongyuxiangqing/gongyuxiangqing",
  669. });
  670. },
  671. // 订房间
  672. navigateToOrderRoom(houseStatus,id,roomName,item) {
  673. this.xuanId=id
  674. this.xuanroomName=roomName
  675. this.itenxuan=item
  676. this.ifRuzhu()
  677. // let _self = this
  678. // _self.roomType = []
  679. // if (houseStatus==1){
  680. // uni.navigateTo({
  681. // 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="
  682. // +item.roomArea+"&roomType="+item.roomType+"&roomConfiguration="+item.roomConfiguration+"&roomPrice="+item.roomPrice+'&surplusCount='+item.surplusCount+'&zhongTime='+this.apartList.hourTime+'&zhongshi='+item.roomLiveTime+'&source='+this.selectedValue,
  683. // });
  684. // }
  685. // this.getRoomType()
  686. },
  687. //订房前判断是否有入住资格
  688. ifRuzhu(){
  689. // alert('订房')
  690. this.options=[]
  691. let _self = this
  692. var data='?userId='+localStorage.getItem('usersId')+
  693. '&liveTime='+_self.startDate+'&leaveTime='+_self.endDate
  694. ifyuding(data).then((res) => {
  695. if (res.success) {
  696. _self.options=res.data
  697. console.log(_self.options,'iii')
  698. if(_self.options.length>0){
  699. _self.$refs.popupRuzhu.open();
  700. }else{
  701. _self.selectedValue=''
  702. _self.sourceId=''
  703. let temporaryObj = {
  704. roomTypeId:_self.xuanId,
  705. enableStartTime:_self.startDate,
  706. enableEndTime:_self.endDate,
  707. startTime:_self.startTime,
  708. endTime:_self.endTime,
  709. typeName:_self.xuanroomName,
  710. ruzhu_num:_self.ruzhu_num,
  711. roomArea:_self.itenxuan.roomArea,
  712. roomType:_self.itenxuan.roomType,
  713. roomConfiguration:_self.itenxuan.roomConfiguration,
  714. roomPrice:_self.itenxuan.roomPrice,
  715. surplusCount:_self.itenxuan.surplusCount,
  716. zhongTime:_self.apartList.hourTime,
  717. zhongshi:_self.itenxuan.roomLiveTime,
  718. source:_self.selectedValue,
  719. sourceId:_self.sourceId
  720. }
  721. //传参对象,使用encodeURIComponent编码
  722. let str = JSON.stringify(temporaryObj)
  723. //注意这里——————————————————————
  724. str = str.replace(/%/g, '%25')
  725. //这里———————————————————————————
  726. let query = encodeURIComponent(str)
  727. uni.navigateTo({
  728. url: "/pages/order_room/order_room?data="+query
  729. // 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="
  730. // +_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
  731. // +'&source='+_self.selectedValue+'&sourceId='+_self.sourceId,
  732. });
  733. }
  734. } else if(res.code=='500'){
  735. uni.showModal({
  736. title: '提示',
  737. content: res.message,
  738. success: function (res) {
  739. if (res.confirm) {
  740. _self.selectedValue=''
  741. _self.sourceId=''
  742. let temporaryObj = {
  743. roomTypeId:_self.xuanId,
  744. enableStartTime:_self.startDate,
  745. enableEndTime:_self.endDate,
  746. startTime:_self.startTime,
  747. endTime:_self.endTime,
  748. typeName:_self.xuanroomName,
  749. ruzhu_num:_self.ruzhu_num,
  750. roomArea:_self.itenxuan.roomArea,
  751. roomType:_self.itenxuan.roomType,
  752. roomConfiguration:_self.itenxuan.roomConfiguration,
  753. roomPrice:_self.itenxuan.roomPrice,
  754. surplusCount:_self.itenxuan.surplusCount,
  755. zhongTime:_self.apartList.hourTime,
  756. zhongshi:_self.itenxuan.roomLiveTime,
  757. source:_self.selectedValue,
  758. sourceId:_self.sourceId
  759. }
  760. //传参对象,使用encodeURIComponent编码
  761. let str = JSON.stringify(temporaryObj)
  762. //注意这里——————————————————————
  763. str = str.replace(/%/g, '%25')
  764. //这里———————————————————————————
  765. let query = encodeURIComponent(str)
  766. uni.navigateTo({
  767. url: "/pages/order_room/order_room?data="+query
  768. });
  769. } else if (res.cancel) {
  770. _self.selectedValue=''
  771. _self.sourceId=''
  772. }
  773. }
  774. });
  775. }
  776. }).catch((err) => {
  777. // alert(err)
  778. uni.showModal({
  779. content:err
  780. })
  781. });
  782. },
  783. radioChange(e){
  784. // console.log(e,'ll')
  785. for (let i = 0; i < this.options.length; i++) {
  786. if (this.options[i].name === e.detail.value) {
  787. this.selectedValue=this.options[i].source
  788. this.sourceId=this.options[i].sourceId
  789. break;
  790. }
  791. }
  792. },
  793. //订房选中流程
  794. confirmSelection() {
  795. console.log('选中的值:', this.selectedValue);
  796. this.$refs.popupRuzhu.close()
  797. // alert('跳转')
  798. let temporaryObj = {
  799. roomTypeId:this.xuanId,
  800. enableStartTime:this.startDate,
  801. enableEndTime:this.endDate,
  802. startTime:this.startTime,
  803. endTime:this.endTime,
  804. typeName:this.xuanroomName,
  805. ruzhu_num:this.ruzhu_num,
  806. roomArea:this.itenxuan.roomArea,
  807. roomType:this.itenxuan.roomType,
  808. roomConfiguration:this.itenxuan.roomConfiguration,
  809. roomPrice:this.itenxuan.roomPrice,
  810. surplusCount:this.itenxuan.surplusCount,
  811. zhongTime:this.apartList.hourTime,
  812. zhongshi:this.itenxuan.roomLiveTime,
  813. source:this.selectedValue,
  814. sourceId:this.sourceId
  815. }
  816. //传参对象,使用encodeURIComponent编码
  817. let str = JSON.stringify(temporaryObj)
  818. //注意这里——————————————————————
  819. str = str.replace(/%/g, '%25')
  820. //这里———————————————————————————
  821. let query = encodeURIComponent(str)
  822. uni.navigateTo({
  823. url: "/pages/order_room/order_room?data="+query,
  824. // 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="
  825. // +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,
  826. });
  827. },
  828. //取消预订
  829. quxiaoyuding(){
  830. this.selectedValue=''
  831. this.sourceId=''
  832. this.$refs.popupRuzhu.close()
  833. let temporaryObj = {
  834. roomTypeId:this.xuanId,
  835. enableStartTime:this.startDate,
  836. enableEndTime:this.endDate,
  837. startTime:this.startTime,
  838. endTime:this.endTime,
  839. typeName:this.xuanroomName,
  840. ruzhu_num:this.ruzhu_num,
  841. roomArea:this.itenxuan.roomArea,
  842. roomType:this.itenxuan.roomType,
  843. roomConfiguration:this.itenxuan.roomConfiguration,
  844. roomPrice:this.itenxuan.roomPrice,
  845. surplusCount:this.itenxuan.surplusCount,
  846. zhongTime:this.apartList.hourTime,
  847. zhongshi:this.itenxuan.roomLiveTime,
  848. source:this.selectedValue,
  849. sourceId:this.sourceId
  850. }
  851. //传参对象,使用encodeURIComponent编码
  852. let str = JSON.stringify(temporaryObj)
  853. //注意这里——————————————————————
  854. str = str.replace(/%/g, '%25')
  855. //这里———————————————————————————
  856. let query = encodeURIComponent(str)
  857. uni.navigateTo({
  858. url: "/pages/order_room/order_room?data="+query
  859. });
  860. },
  861. //办理入住跳转
  862. navigateToDairuzhu(type){
  863. this.dai_panduan=[]
  864. setTimeout(() => {
  865. this.getOrderPage()
  866. },1)
  867. setTimeout(() => {
  868. for (let i=0;i<this.dai_type.length;i++){
  869. this.dai_type.forEach(val => {
  870. if(val[i]==2) {
  871. this.dai_panduan.push(val)
  872. }
  873. })
  874. }
  875. if(this.dai_panduan.length>=1) {
  876. uni.navigateTo({
  877. url:"/pages/my_orderlist/my_orderlist?Inv=2"
  878. })
  879. }else if(this.dai_panduan.length<1) {
  880. this.msgType = type
  881. this.order_txt='请先订房!'
  882. this.$refs.popup_order.open()
  883. }
  884. },150)
  885. },
  886. //办理退房
  887. navigateToTuifang(type){
  888. this.tui_panduan=[]
  889. setTimeout(() => {
  890. this.getOrderPage()
  891. },1)
  892. setTimeout(() => {
  893. for (let i=0;i<this.tui_type.length;i++){
  894. this.tui_type.forEach(val => {
  895. if(val[i]==3) {
  896. this.tui_panduan.push(val)
  897. }
  898. })
  899. }
  900. if(this.tui_panduan.length>=1) {
  901. uni.navigateTo({
  902. url:"/pages/my_orderlist/my_orderlist?Inv=3"
  903. })
  904. }else if(this.tui_panduan.length<1) {
  905. this.msgType = type
  906. this.$refs.popup_tui.open()
  907. }
  908. },150)
  909. },
  910. //户型详情弹窗
  911. inputDialogToggle(id) {
  912. this.$refs.popup.open()
  913. this.getRoomTypeInfo(id)
  914. },
  915. popupClose() {
  916. this.$refs.popup.close()
  917. },
  918. //办理续住弹窗
  919. navigateToXuzhu(){
  920. this.xuzhu_panduan=[]
  921. setTimeout(() => {
  922. this.getOrderPage()
  923. },1)
  924. setTimeout(() => {
  925. for (let i=0;i<this.xuzhu_type.length;i++){
  926. this.xuzhu_type.forEach(val => {
  927. if(val[i]==3) {
  928. this.xuzhu_panduan.push(val)
  929. }
  930. })
  931. }
  932. console.log(this.xuzhu_panduan)
  933. if(this.xuzhu_panduan.length>1) {
  934. uni.navigateTo({
  935. url:"/pages/my_orderlist/my_orderlist?Inv=3"
  936. })
  937. }else if(this.xuzhu_panduan.length==1) {
  938. this.$refs.popup_xuzhu.open()
  939. }else if(this.xuzhu_panduan.length==0) {
  940. this.$refs.popup_xuzhu_no.open()
  941. }
  942. },150)
  943. },
  944. popupXuzhuClose() {
  945. this.$refs.popup_xuzhu.close()
  946. },
  947. // 不可续住关闭弹窗
  948. dialogClose(){
  949. this.$refs.popup_xuzhu_no.close()
  950. },
  951. // 日期选择器弹窗开启
  952. openCalendar() {
  953. this.$refs.popup_picker.open()
  954. },
  955. // 关闭全日房日历
  956. popup_pickerClose(){
  957. this.$refs.popup_picker.close()
  958. },
  959. change(e) {
  960. this.info.selected=[
  961. {
  962. date: e.range.before,
  963. info: '到店'
  964. },
  965. {
  966. date: e.range.after,
  967. info: '离店'
  968. }
  969. ]
  970. if(e.range.before!=''&&e.range.after=='') {
  971. this.startWeek='周'+e.lunar.ncWeek.substring(2,3)
  972. } else if(e.range.before!=''&&e.range.after!=''){
  973. if((new Date(e.range.after).getTime())<(new Date(e.range.before).getTime())) {
  974. this.order_txt='离店日期不能小于到店日期'
  975. this.$refs.popup_order.open()
  976. this.info.selected=[]
  977. }else if(parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)>2){
  978. this.order_txt='预订时间不能超过两晚'
  979. this.$refs.popup_order.open()
  980. this.info.selected=[]
  981. }else if(parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)==2){
  982. this.order_txt='您此次申请了两晚,请注意若只住一晚可能会导致流程管理次数失效。'
  983. this.$refs.popup_order.open()
  984. this.endWeek='周'+e.lunar.ncWeek.substring(2,3)
  985. this.startTime=e.range.before.substring(5,7)+'月'+e.range.before.substring(8,10)+'日'
  986. this.endTime=e.range.after.substring(5,7)+'月'+e.range.after.substring(8,10)+'日'
  987. this.startDate = e.range.before +' '+this.apartList.liveTime
  988. this.endDate = e.range.after +' '+this.apartList.leaveTime
  989. this.ruzhu_num=parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)
  990. if(this.endDate !=this.apartList.leaveTime) {
  991. this.getRoomType()
  992. }
  993. }else{
  994. this.endWeek='周'+e.lunar.ncWeek.substring(2,3)
  995. this.startTime=e.range.before.substring(5,7)+'月'+e.range.before.substring(8,10)+'日'
  996. this.endTime=e.range.after.substring(5,7)+'月'+e.range.after.substring(8,10)+'日'
  997. this.startDate = e.range.before +' '+this.apartList.liveTime
  998. this.endDate = e.range.after +' '+this.apartList.leaveTime
  999. this.ruzhu_num=parseInt(((new Date(e.range.after).getTime())-(new Date(e.range.before).getTime()))/1000/60/60/24)
  1000. if(this.endDate !=this.apartList.leaveTime) {
  1001. this.getRoomType()
  1002. }
  1003. }
  1004. }
  1005. },
  1006. // 续住里日期选择器弹窗
  1007. openXuCalendar() {
  1008. this.$refs.popup_xu.open()
  1009. },
  1010. changeXu(e) {
  1011. console.log('1change 返回:', e)
  1012. // 模拟动态打卡
  1013. if (this.infoXu.selected.length > 5) return
  1014. this.infoXu.selected.push({
  1015. date: e.range.before,
  1016. info: '到店'
  1017. })
  1018. this.infoXu.selected.push({
  1019. date: e.range.after,
  1020. info: '离店'
  1021. })
  1022. },
  1023. //拨打电话
  1024. telphone(phone){
  1025. uni.makePhoneCall({
  1026. phoneNumber: phone ,
  1027. }) // 传参带入号码即可
  1028. },
  1029. // 初次位置授权
  1030. getAuthorize() {
  1031. return new Promise((resolve, reject) => {
  1032. uni.authorize({
  1033. scope: "scope.userLocation",
  1034. success: () => {
  1035. resolve(); // 允许授权
  1036. },
  1037. fail: () => {
  1038. reject(); // 拒绝授权
  1039. },
  1040. });
  1041. });
  1042. },
  1043. // 确认授权后,获取用户位置
  1044. getLocationInfo() {
  1045. const that = this;
  1046. uni.getLocation({
  1047. type: "wgs84",
  1048. geocode: true,
  1049. highAccuracyExpireTime: 100,
  1050. success: function(res) {
  1051. // 暂时
  1052. that.longitude = res.longitude; //118.787575;
  1053. that.latitude = res.latitude; //32.05024;
  1054. console.log("获取当前的用户经度", that.longitude);
  1055. console.log("获取当前的用户纬度", that.latitude);
  1056. var long = 0;
  1057. var lat = 0;
  1058. //小数点保留六位 经度
  1059. if (that.longitude.toString().indexOf('.') > 0) {
  1060. const longlatsplit = that.longitude.toString().split('.');
  1061. if (longlatsplit.length >= 2) {
  1062. long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
  1063. }
  1064. }
  1065. if (that.latitude.toString().indexOf('.') > 0) {
  1066. const longlatsplit1 = that.latitude.toString().split('.');
  1067. if (longlatsplit1.length >= 2) {
  1068. lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
  1069. }
  1070. }
  1071. that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
  1072. // alert(that.distance)
  1073. that.markers = [{
  1074. id: "",
  1075. latitude: res.latitude,
  1076. longitude: res.longitude,
  1077. iconPath: "../../static/img/phone.png",
  1078. width: that.markerHeight, //宽
  1079. height: that.markerHeight, //高
  1080. }, ];
  1081. },
  1082. fail: function () {
  1083. uni.showToast({
  1084. title: '获取地址失败,将导致部分功能不可用',
  1085. icon:'none'
  1086. });
  1087. }
  1088. });
  1089. },
  1090. // 拒绝授权后,弹框提示是否手动打开位置授权
  1091. openConfirm() {
  1092. return new Promise((resolve, reject) => {
  1093. uni.showModal({
  1094. title: "请求授权当前位置",
  1095. content: "我们需要获取地理位置信息,为您推荐路线",
  1096. success: (res) => {
  1097. // if (res.confirm) {
  1098. // uni.openSetting().then((res) => {
  1099. // if (res[1].authSetting["scope.userLocation"] === true) {
  1100. // resolve(); // 打开地图权限设置
  1101. // } else {
  1102. // reject();
  1103. // console.log('reject')
  1104. // }
  1105. // });
  1106. // } else if (res.cancel) {
  1107. // reject();
  1108. // }
  1109. },
  1110. });
  1111. });
  1112. },
  1113. // 彻底拒绝位置获取
  1114. rejectGetLocation() {
  1115. uni.showToast({
  1116. title: "你拒绝了授权,无法获得周边信息",
  1117. icon: "none",
  1118. duration: 2000,
  1119. });
  1120. },
  1121. //打开地图导航
  1122. mapDaohang(lon,lat){
  1123. },
  1124. //进行经纬度转换为距离的计算
  1125. Rad(d) {
  1126. return d * Math.PI / 180.0; //经纬度转换成三角函数中度分表形式。
  1127. },
  1128. /*
  1129. 计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  1130. 默认单位km
  1131. */
  1132. getMapDistance(lat1, lng1, lat2, lng2) {
  1133. var radLat1 = this.Rad(lat1);
  1134. var radLat2 = this.Rad(lat2);
  1135. var a = radLat1 - radLat2;
  1136. var b = this.Rad(lng1) - this.Rad(lng2);
  1137. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  1138. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  1139. s = s * 6378.137; // EARTH_RADIUS;
  1140. s = Math.round(s * 10000) / 10000; //输出为公里
  1141. s=s.toFixed(2);
  1142. return s;
  1143. },
  1144. }
  1145. }
  1146. </script>
  1147. <style>
  1148. @import url("./css/index.css");
  1149. </style>