Chakanditu.nvue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="i18n('dache.chakandit')" tinColor="#006AFF" jiantou="0" ></customNav>
  4. <!-- <view class="mapcontentV" :style="'height:'+mapHeight+'px;'">
  5. <map id="map" class="mapbody" scale="18" show-location="true" :style="'height:'+mapHeight+'px;'" :latitude="latitude" :longitude="longitude">
  6. </map>
  7. </view> -->
  8. <view class="" v-if="isShow">
  9. <web-view style="background-color: #fafafa;" ref="webview" :style="{ height: statusBarHeight + 'px' }" @onPostMessage="getMessage" :src="webUrl"></web-view>
  10. </view>
  11. <view class="bottomfloatV">
  12. <view v-if="obj!=''" class="floatView">
  13. <view class="contentInRowS bottomborder">
  14. <view class="contentInRowC">
  15. <image class="userIconm" src="/static/imags/dache/yhtoux@3x.png" mode="scaleToFill"></image>
  16. <text style="padding-left: 10rpx;font-size: 38rpx;font-weight: bold;">{{obj.user.phone.slice(-4)}}</text>
  17. </view>
  18. <view class="contentColumnC" style="margin-right: 20rpx;">
  19. <text style="font-size: 34rpx;font-weight:bold;color:#E86E48;">{{obj.amount}}{{i18n('api.huobidanwei')}}</text>
  20. <text class="notetextst">{{i18n('dache.juninjuli')}}{{jiejia}}</text>
  21. </view>
  22. </view>
  23. <view class="contentColumn rowContentVst">
  24. <text class="notetextst">{{i18n('dache.qidian')}}</text>
  25. <text class="addrTextst">{{obj.boardingAddress}}</text>
  26. </view>
  27. <view class="contentColumn rowContentVst">
  28. <view class="contentInRowS">
  29. <text class="notetextst">{{i18n('dache.zhongdian')}}</text>
  30. <text class="notetextst">{{i18n('dache.quancheng')}}{{obj.distance}}Km</text>
  31. </view>
  32. <text class="addrTextst">{{obj.downAddress}}</text>
  33. </view>
  34. <view v-if="obj.state==0" class="contentInRowC">
  35. <text class="qushcBt" @click="qiangdan(obj)">{{i18n('order.qiangdan')}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import api from "@/pages/api/api.js"
  43. export default {
  44. data() {
  45. return {
  46. mapHeight:0,
  47. latitude: 22.84585,
  48. longitude:108.324762,
  49. mapContext:Object,
  50. userInfo:'',
  51. obj:'',
  52. jiejia:0,
  53. statusBarHeight: 0, //可视屏幕的高度
  54. webUrl: '',
  55. isShow: false,
  56. lat: '',
  57. lng: '',
  58. }
  59. },
  60. onLoad() {
  61. var info = uni.getSystemInfoSync();
  62. this.mapHeight=info.screenHeight;
  63. this.userInfo = uni.getStorageSync('userInfo');
  64. this.obj = uni.getStorageSync('TaxiOrder');
  65. this.computedScreenHeight();
  66. // #ifdef APP-PLUS
  67. //this.getlocetion();
  68. // #endif
  69. // #ifdef H5
  70. this.lng = 113.64360881345777;
  71. this.lat = 34.738282020827825;
  72. //this.webUrl = '/hybrid/html/maps/mapindex.html?lat=' + this.lat + '&lng=' + this.lng+'&nlng=0&nlat=0';
  73. this.isShow = true;
  74. // #endif
  75. },
  76. onReady() {
  77. //this.mapContext = uni.createMapContext("map",this);
  78. console.log('---------1')
  79. // if(!this.isAndroid){
  80. // this.setCenter();
  81. // }
  82. //this.isReady=true;
  83. //this.gotoLocat();
  84. if(this.obj.state>1){
  85. this.setRouteSN();
  86. }
  87. else{
  88. this.gotoLocat();
  89. }
  90. },
  91. methods: {
  92. i18n(str){
  93. return getApp().globalData.$t(str);
  94. },
  95. gotoLocat(){
  96. var that = this;
  97. uni.getLocation({
  98. type: "wgs84", //默认为 wgs84 返回 gps 坐标//谷歌地图使用 wgs84 坐标,其他地图使用 gcj02 坐标
  99. geocode: "true",
  100. isHighAccuracy: "true",
  101. accuracy: "best", // 精度值为20m
  102. success: function (res) {
  103. console.log(res);
  104. var latlon= res.latitude+','+res.longitude;
  105. that.movetoCenter(res.latitude,res.longitude,false);
  106. },
  107. fail(err) {
  108. console.log('--------getLocation',err)
  109. }
  110. });
  111. },
  112. movetoCenter(latitude,longitude,sLb){
  113. console.log(longitude)
  114. this.latitude=latitude-0.001;
  115. this.longitude=longitude;
  116. this.setRouteSN();
  117. },
  118. //net work ------------------
  119. qiangdan(obj){
  120. var data={
  121. id:obj.id,
  122. state:1,
  123. driverId:this.userInfo.userId
  124. }
  125. this.SetTxorder(data,1);
  126. },
  127. SetTxorder(data,index){
  128. api('SetTxorder',data,res=>{
  129. console.log('SetTxorder------',res)
  130. if(res.data.code==200){
  131. if(index==1){//抢单成功
  132. uni.setStorageSync('TaxiOrder',this.obj);
  133. uni.navigateTo({
  134. url:'/pages/dache/Zhengzaijiesong'
  135. })
  136. return;
  137. }
  138. uni.showToast({
  139. title:'修改成功',//that.i18n('api.wangluoshibai'),
  140. icon: 'none',
  141. duration: 2500
  142. })
  143. }
  144. else{
  145. uni.showToast({
  146. title:'修改失败',//that.i18n('api.wangluoshibai'),
  147. icon: 'none',
  148. duration: 2500
  149. })
  150. }
  151. },failc=>{
  152. //console.log('getTaxiPrices----',failc)
  153. uni.showToast({
  154. title:'网络错误',//that.i18n('api.wangluoshibai'),
  155. icon: 'none',
  156. duration: 2500
  157. })
  158. })
  159. },
  160. //-----------------
  161. /**
  162. 设置起点和终点
  163. **/
  164. setRouteSN(){
  165. var slat,slng,jlat,jlng,nlat,nlng;
  166. if(this.obj.state>1){
  167. slat=this.obj.intoLatitude;
  168. slng=this.obj.intoLongitude;
  169. nlat=this.obj.downLatitude;
  170. nlng=this.obj.downLongitude;
  171. //this.webUrl = '/hybrid/html/maps/mapindex.html?lat='+slat+'&lng='+slng+'&nlat='+nlat+'&nlng='+nlng;
  172. }
  173. else{
  174. slat=this.latitude;
  175. slng=this.longitude;
  176. jlat=this.obj.intoLatitude;
  177. jlng=this.obj.intoLongitude;
  178. nlat=this.obj.downLatitude;
  179. nlng=this.obj.downLongitude;
  180. //this.webUrl = '/hybrid/html/maps/mapindex.html?lat='+slat+'&lng='+slng+'&jlat='+jlat+'&jlng='+jlng+'&nlat='+nlat+'&nlng='+nlng;
  181. }
  182. this.isShow = true;
  183. },
  184. /**
  185. * 特别注意这里 nvue和vue页面 web-view---->vue ||nvue方式不一样 详情请查看官网 https://uniapp.dcloud.net.cn/component/web-view.html#web-view
  186. *
  187. * */
  188. getMessage(e) {
  189. console.log("--getMessage--",e.detail.data[0]);
  190. var msgObj=e.detail.data[0];
  191. if(msgObj.type==2){
  192. this.jiejia = msgObj.distance;
  193. }
  194. },
  195. // 计算屏幕的高度
  196. computedScreenHeight() {
  197. uni.getSystemInfo({
  198. success: function(e) {
  199. // #ifndef MP
  200. Vue.prototype.StatusBar = e.statusBarHeight;
  201. if (e.platform == 'android') {
  202. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  203. } else {
  204. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  205. }
  206. // #endif
  207. // #ifdef MP-WEIXIN
  208. Vue.prototype.StatusBar = e.statusBarHeight;
  209. let custom = wx.getMenuButtonBoundingClientRect();
  210. Vue.prototype.Custom = custom;
  211. Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  212. // #endif
  213. // #ifdef MP-ALIPAY
  214. Vue.prototype.StatusBar = e.statusBarHeight;
  215. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  216. // #endif
  217. let unitRatio = 750 / uni.getSystemInfoSync().windowWidth;
  218. Vue.prototype.StatusBarRpx = Vue.prototype.StatusBar * unitRatio;
  219. Vue.prototype.CustomBarRpx = Vue.prototype.CustomBar * unitRatio;
  220. Vue.prototype.unitRatio = unitRatio;
  221. Vue.mixin({
  222. data() {
  223. return {
  224. StatusBar: Vue.prototype.StatusBar, //状态栏高度(px)
  225. CustomBar: Vue.prototype.CustomBar, //整个标题栏高度(px)
  226. StatusBarRpx: Vue.prototype.StatusBarRpx, //状态栏高度(rpx)
  227. CustomBarRpx: Vue.prototype.CustomBarRpx //整个标题栏高度(rpx)
  228. };
  229. }
  230. });
  231. }
  232. });
  233. // 状态栏高度 导航高度 tab切换的高度 底部导航的高度
  234. this.statusBarHeight = uni.getSystemInfoSync().screenHeight;
  235. },
  236. }
  237. }
  238. </script>
  239. <style lang="scss">
  240. .mapbody{
  241. position: absolute;
  242. width: 750rpx;
  243. }
  244. .mapcontentV{
  245. position: absolute;
  246. width: 750rpx;
  247. background-color:deeppink;
  248. }
  249. .bottomfloatV{
  250. position: fixed;
  251. flex-direction: column;
  252. justify-content: center;
  253. align-items: center;
  254. left: 0;
  255. right: 0;
  256. bottom: 80rpx;
  257. z-index: 999;
  258. //background-color: white;
  259. }
  260. .floatView{
  261. display: flex;
  262. flex-direction: column;
  263. width: 700rpx;
  264. background-color: white;
  265. border-radius: 20rpx;
  266. }
  267. .userIconm{
  268. width: 100rpx;
  269. height: 100rpx;
  270. margin-left:4rpx;
  271. margin-top: 4rpx;
  272. }
  273. .bottomborder{
  274. padding-bottom: 16rpx;
  275. border: solid lavender;
  276. border-width: 0px 0px 1rpx 0px;
  277. }
  278. .rowContentVst{
  279. width:660rpx;
  280. margin-top: 10rpx;
  281. padding-bottom: 10rpx;
  282. border: solid lavender;
  283. border-width: 0px 0px 1rpx 0px;
  284. }
  285. .addrTextst{
  286. width:660rpx;
  287. font-size: 32rpx;
  288. }
  289. .notetextst{
  290. font-size: 28rpx;
  291. color: darkgray;
  292. }
  293. .qushcBt{
  294. margin-top: 30rpx;
  295. margin-bottom: 30rpx;
  296. font-size: 32rpx;
  297. padding-left: 42rpx;
  298. padding-right: 42rpx;
  299. font-weight: bold;
  300. color: white;
  301. line-height: 60rpx;
  302. border-radius: 30rpx;
  303. text-align: center;
  304. background-color: #E86E48;
  305. }
  306. </style>