rescue.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <view class="box">
  3. <map :latitude="latitude"
  4. :longitude="longitude" :markers="covers"
  5. @poitap="tapfn" class="mapbox"
  6. :include-points="points" ></map><!-- @regionchange="regionchangefn" :style="{height:mapHeight + 'px'}" -->
  7. <view class="contBox" >
  8. <view class="tab">
  9. <view class="tabLine" :class="{tabActive:tabIndex==0}" @click="tabClick(0)">现在</view>
  10. <view class="tabLine" :class="{tabActive:tabIndex==1}" @click="tabClick(1)">预约</view>
  11. </view>
  12. <view class="timeBox">
  13. <view class="time">预约救援时间</view>
  14. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 30rpx;height: 30rpx;"></image>
  15. </view>
  16. <view class="typeBox">
  17. <view class="box2">
  18. <image src="../../static/img/icon_dadian_N.png" mode="" class="typeImg"></image>
  19. <view class="title">搭电</view>
  20. </view>
  21. <view class="box2">
  22. <image src="../../static/img/icon_tuoche_N.png" mode="" class="typeImg"></image>
  23. <view class="title">拖车</view>
  24. </view>
  25. <view class="box2">
  26. <image src="../../static/img/icon_luntai_N.png" mode="" class="typeImg"></image>
  27. <view class="title">换胎</view>
  28. </view>
  29. </view>
  30. <view class="price">服务费用 199元/次</view>
  31. <view class="shopBox">
  32. <view class="left">
  33. <view class="graypoint"></view>
  34. <view class="leftTitle">门店</view>
  35. <view class="content">服务门店可修改</view>
  36. </view>
  37. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 30rpx;height: 30rpx;"></image>
  38. </view>
  39. <view class="shopBox">
  40. <view class="left">
  41. <view class="graypoint"></view>
  42. <view class="leftTitle">位置</view>
  43. <view class="content">{{currentAddress}}</view>
  44. </view>
  45. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 30rpx;height: 30rpx;"></image>
  46. </view>
  47. <view class="shopBox" @click="endBtn">
  48. <view class="left">
  49. <view class="graypoint"></view>
  50. <view class="leftTitle">终点</view>
  51. <view class="content">{{endAddress}}</view>
  52. </view>
  53. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 30rpx;height: 30rpx;"></image>
  54. </view>
  55. </view>
  56. <view class="bottomView">
  57. <view class="sure" @click="sure">确定</view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import QQMapWX from '@/utils/qqmap-wx-jssdk.js'
  63. export default {
  64. data() {
  65. return {
  66. latitude: '',
  67. longitude: '',
  68. covers: [
  69. // {
  70. // latitude: 39.909,
  71. // longitude: 116.39742,
  72. // iconPath: '../../static/img/icon_qidian.png'
  73. // }, {
  74. // latitude: 39.90,
  75. // longitude: 116.39,
  76. // iconPath: '../../static/img/icon_zhongdian.png'
  77. // },
  78. ],
  79. tabIndex: 0,
  80. tMap:'',
  81. mapHeight:200,
  82. currentAddress:'',
  83. endAddress:'',
  84. points: [],
  85. }
  86. },
  87. onLoad() {
  88. var that = this
  89. const tMap = new QQMapWX({
  90. key: 'L2GBZ-CIS6J-HRFFV-K5LO6-QROT7-BQFXZ' //开发者密钥 //这里要换成自己的key
  91. });
  92. this.tMap=tMap
  93. // uni.getSystemInfo({
  94. // success: (res) => {
  95. // this.mapHeight = res.windowHeight *2 - 664 - 120
  96. // }
  97. // })
  98. uni.getLocation({
  99. type: 'gcj02',
  100. success: function (res) {
  101. console.log('当前位置的经度:' + res.longitude);
  102. console.log('当前位置的纬度:' + res.latitude);
  103. that.latitude=res.latitude;
  104. that.longitude=res.longitude;
  105. var obj={
  106. latitude: that.latitude,
  107. longitude: that.longitude,
  108. iconPath: '../../static/img/icon_qidian.png',
  109. width:36,
  110. height:56
  111. }
  112. that.covers.push(obj);
  113. that.points.push({
  114. longitude: that.longitude,
  115. latitude:that.latitude
  116. })
  117. that.tMap.reverseGeocoder({
  118. location: {
  119. latitude: that.latitude,
  120. longitude: that.longitude
  121. },
  122. success: function(res) {
  123. console.log(res)
  124. that.currentAddress=res.result.formatted_addresses.recommend
  125. },
  126. fail: function(res) {
  127. console.log(res);
  128. },
  129. })
  130. }
  131. });
  132. },
  133. methods: {
  134. endBtn(){
  135. var that=this;
  136. uni.getSetting({
  137. success(res) {
  138. if (!res.authSetting['scope.userLocation']) {
  139. uni.authorize({
  140. scope: 'scope.userLocation',
  141. success() {
  142. that.chooseLocation()
  143. return;
  144. }
  145. })
  146. }else{
  147. that.chooseLocation()
  148. return;
  149. }
  150. }
  151. })
  152. },
  153. chooseLocation(){
  154. var that=this;
  155. uni.chooseLocation({
  156. success: function (res) {
  157. console.log(res);
  158. that.endAddress=res.name
  159. // console.log('位置名称:' + res.name);
  160. // console.log('详细地址:' + res.address);
  161. // console.log('纬度:' + res.latitude);
  162. // console.log('经度:' + res.longitude);
  163. var longitude=res.longitude
  164. var latitude=res.latitude
  165. var obj={
  166. latitude: latitude,
  167. longitude: longitude,
  168. iconPath: '../../static/img/icon_zhongdian.png',
  169. width:36,
  170. height:56,
  171. // label:{
  172. // content:'文本'
  173. // },
  174. callout: { //自定义标记点上方的气泡窗口 点击有效
  175. content: '拖到这里', //文本
  176. color: '#ffffff', //文字颜色
  177. fontSize: 15, //文本大小
  178. borderRadius: 15, //边框圆角
  179. padding: '10',
  180. bgColor: '#FF0000', //背景颜色
  181. display: 'ALWAYS', //常显
  182. }
  183. }
  184. var obj2={
  185. longitude: longitude,
  186. latitude:latitude
  187. }
  188. if(that.covers.length>1){
  189. that.covers[1]=obj;
  190. that.points[1]=obj2;
  191. }else{
  192. that.covers.push(obj);
  193. that.points.push(obj2)
  194. }
  195. console.log(that.covers)
  196. },
  197. fail(err){
  198. console.log(err)
  199. }
  200. })
  201. },
  202. regionchangefn(e){
  203. console.log(e)
  204. var that=this;
  205. if(e.detail.centerLocation){
  206. var latitude=e.detail.centerLocation.latitude;
  207. var longitude=e.detail.centerLocation.longitude;
  208. var obj={
  209. latitude: latitude,
  210. longitude: longitude,
  211. iconPath: '../../static/img/icon_qidian.png',
  212. width:36,
  213. height:56
  214. }
  215. this.covers=[];
  216. this.covers.push(obj)
  217. }
  218. },
  219. tapfn(e){
  220. //点击获取位置
  221. console.log(e);
  222. var that=this;
  223. var latitude=e.detail.latitude;
  224. var longitude=e.detail.longitude;
  225. var obj={
  226. latitude: latitude,
  227. longitude: longitude,
  228. iconPath: '../../static/img/icon_qidian.png',
  229. width:36,
  230. height:56
  231. }
  232. this.covers=[];
  233. this.covers.push(obj)
  234. this.tMap.reverseGeocoder({
  235. location: {
  236. latitude: latitude,
  237. longitude: longitude
  238. },
  239. success: function(res) {
  240. //console.log(res)
  241. that.currentAddress=res.result.formatted_addresses.recommend;
  242. //console.log(this.currentAddress)
  243. //this.$set(this, 'currentAddress', this.currentAddress)
  244. },
  245. fail: function(res) {
  246. console.log(res);
  247. },
  248. })
  249. },
  250. tabClick(num) {
  251. this.tabIndex = num;
  252. },
  253. }
  254. }
  255. </script>
  256. <style>
  257. .box {
  258. width: 100vw;
  259. min-height: 100vh;
  260. background-color: #FFFFFF;
  261. }
  262. map {
  263. width: 750rpx;
  264. height: calc(100vh - 664rpx - 120rpx);
  265. }
  266. .contBox {
  267. width: 100%;
  268. height: 664rpx;
  269. }
  270. .tab {
  271. background: #FFFFFF;
  272. display: flex;
  273. justify-content: space-between;
  274. align-items: center;
  275. padding-left: 230rpx;
  276. padding-right: 230rpx;
  277. height: 92rpx;
  278. line-height: 60rpx;
  279. }
  280. .tabLine {
  281. font-size: 30rpx;
  282. color: #333333;
  283. text-align: center;
  284. }
  285. .tabActive {
  286. color: #FF0000;
  287. font-weight: bold;
  288. border-bottom: 4rpx solid #FF0000;
  289. }
  290. .timeBox {
  291. padding-top: 20rpx;
  292. display: flex;
  293. justify-content: center;
  294. align-items: center;
  295. }
  296. .time {
  297. color: #959595;
  298. font-size: 24rpx;
  299. }
  300. .typeBox {
  301. padding: 30rpx 115rpx;
  302. display: flex;
  303. justify-content: space-between;
  304. }
  305. .box2 {
  306. display: flex;
  307. align-items: center;
  308. padding: 20rpx;
  309. background: #FFFFFF;
  310. height: 32rpx;
  311. border-radius: 10rpx;
  312. border: 2rpx solid #CCCCCC;
  313. }
  314. .typeImg {
  315. width: 34rpx;
  316. height: 34rpx;
  317. margin-right: 10rpx;
  318. }
  319. .title {
  320. height: 40rpx;
  321. font-size: 28rpx;
  322. font-weight: 400;
  323. color: #666666;
  324. line-height: 40rpx;
  325. }
  326. .price {
  327. padding-bottom: 30rpx;
  328. font-size: 24rpx;
  329. font-weight: 400;
  330. color: #D53533;
  331. text-align: center;
  332. }
  333. .shopBox {
  334. padding: 30rpx 24rpx;
  335. border-top: 1rpx solid #EEEEEE;
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. }
  340. .left {
  341. display: flex;
  342. align-items: center;
  343. }
  344. .leftTitle{
  345. width: 56rpx;
  346. font-size: 28rpx;
  347. font-weight: 400;
  348. color: #666666;
  349. line-height: 40rpx;
  350. margin-left: 16rpx;
  351. margin-right: 30rpx;
  352. }
  353. .graypoint {
  354. width: 14rpx;
  355. height: 14rpx;
  356. background: #DDDDDD;
  357. border-radius: 7rpx;
  358. }
  359. .bluepoint {
  360. width: 14rpx;
  361. height: 14rpx;
  362. background: #3F90F7;
  363. border-radius: 7rpx;
  364. }
  365. .redpoint {
  366. width: 14rpx;
  367. height: 14rpx;
  368. background: #FF0000;
  369. border-radius: 7rpx;
  370. }
  371. .bottomView {
  372. border-top: 1rpx solid #EEEEEE;
  373. background-color: #FFFFFF;
  374. width: 100%;
  375. height: 120rpx;
  376. position: fixed;
  377. bottom: 0rpx;
  378. /* padding-bottom: constant(safe-area-inset-bottom);
  379. padding-bottom: env(safe-area-inset-bottom); */
  380. }
  381. .content{
  382. width: 540rpx;
  383. word-wrap: break-word; /*强制换行*/
  384. overflow: hidden; /*超出隐藏*/
  385. text-overflow: ellipsis;/*隐藏后添加省略号*/
  386. white-space: nowrap;/*强制不换行*/
  387. }
  388. .sure {
  389. background-color: #D53533;
  390. margin: 23rpx 30rpx;
  391. height: 74rpx;
  392. border-radius: 37rpx;
  393. color: #FFFFFF;
  394. font-size: 30rpx;
  395. font-weight: bold;
  396. text-align: center;
  397. line-height: 74rpx;
  398. }
  399. </style>