Dacheshouye.nvue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <view>
  3. <view class="topContentV">
  4. <view class="contentInRowS" style="width:700rpx">
  5. <image style="width: 56rpx;height: 56rpx;" src="/static/images/fanhuiy@3x.png" mode="scaleToFill" @click="fanhui"></image>
  6. <image style="width: 44rpx;height: 44rpx;" src="/static/images/dache/546@3x.png" mode="scaleToFill" @click="navbarsel(0)"></image>
  7. </view>
  8. </view>
  9. <view class="leftpopo">
  10. <uni-drawer ref="showLeft" mode="left" :width="250" @change="change($event,'showLeft')">
  11. <view class="leftpopo">
  12. <view class="contentInRowR" style="margin-top: 100rpx;margin-right: 16rpx;" @click="closeDrawer('showLeft')">
  13. <image style="width: 60rpx;height: 60rpx;" src="/static/images/dache/dacha@3x.png" mode="scaleToFill"></image>
  14. </view>
  15. <view class="contentInRowL" style="margin-top: 20rpx;margin-bottom: 30rpx;margin-left: 30rpx;align-items: center;" @click="gotousercenter">
  16. <netImage class="iconImg" width="120" height="120" bradius="60" :mysrc="userInfo.avatar" mymode="scaleToFill"></netImage>
  17. <view v-if="userInfo!=''" class="contentColumn" style="padding-left: 20rpx;">
  18. <text class="nameText">{{userInfo.nickName}}</text>
  19. <text class="phoneText">{{userInfo.userName}}</text>
  20. </view>
  21. </view>
  22. <view class="contentInRowL drawerlist" @click="gotochezhurz(1)">
  23. <image class="drawerlistIcon" src="/static/images/dache/xingchengjil.png" mode="scaleToFill"></image>
  24. <text class="drawerlisttext">{{i18n('dache.xingchengjl')}}</text>
  25. </view>
  26. <view class="contentInRowL drawerlist" @click="gotochezhurz(2)">
  27. <image class="drawerlistIcon" src="/static/images/dache/kfzx@3x.png" mode="scaleToFill"></image>
  28. <text class="drawerlisttext">{{i18n('dache.lianxikefu')}}</text>
  29. </view>
  30. </view>
  31. </uni-drawer>
  32. </view>
  33. <view class="mapcontentV" :style="'height:'+mapHeight+'px;'">
  34. <map id="map" class="mapbody" scale="18" show-location="true" :style="'height:'+mapHeight+'px;'" :latitude="latitude" :longitude="longitude">
  35. </map>
  36. </view>
  37. <view class="bottomfloatV">
  38. <dachexingcheng v-if="actIndex==0" :xiugai="xiugaimdd" :weizhifu="wzfState" v-on:EXCactSelect="XCactSelect"></dachexingcheng>
  39. <dachexuancx v-if="actIndex==1" :XChengObj="XChengObj" v-on:EQuerenhj="Querenhj"></dachexuancx>
  40. <dachedengdai v-if="actIndex==2" :timeInde="dengdai" v-on:EddSelect="dengdaiSel"></dachedengdai>
  41. <dachesijijied v-if="actIndex==3" :XChengObj="XChengObj" v-on:EJDactSelect="JDactSelect"></dachesijijied>
  42. <dachejiesuan v-if="actIndex==4" :XChengObj="XChengObj" :qibuf="qibuf"></dachejiesuan>
  43. </view>
  44. <uni-popup style="z-index: 9999;" ref="popMsg" type="center" :isMaskClick="true" :safeArea="true">
  45. <view class="contentColumnC popviewContent">
  46. <text style="text-align: center;font-size: 32rpx;margin-top: 80rpx;">订单已超5分钟,此时取消 需支付一定的费用</text>
  47. <view class="contentInRowS" style="width: 80%;">
  48. <text class="quxiaoBt" @click="popQueren(0)">取消</text>
  49. <text class="querenBt" @click="popQueren(1)">确认</text>
  50. </view>
  51. </view>
  52. </uni-popup>
  53. <!-- <view class="querenBt" style="margin-left: 200rpx;margin-top: 300rpx;">
  54. <text @click="popQueren(3)">确认</text>
  55. </view> -->
  56. </view>
  57. </template>
  58. <script>
  59. import api from "@/pages/api/api.js"
  60. export default {
  61. data() {
  62. return {
  63. mapHeight:0,
  64. latitude: 22.84585,
  65. longitude:108.324762,
  66. mapContext:Object,
  67. showLeft: false,
  68. userInfo:'',
  69. tableList:[],
  70. toptableindex:0,
  71. actIndex:0,
  72. xiugaimdd:0,
  73. wzfState:0,
  74. TPricesObj:'',
  75. XChengObj:'',
  76. qibuf:0,
  77. dengdai:0,
  78. timer:''
  79. }
  80. },
  81. onLoad() {
  82. var token = getApp().globalData.token;
  83. this.getUserMsg(token);
  84. var info = uni.getSystemInfoSync();
  85. this.mapHeight=info.screenHeight;
  86. this.getTaxiPrices();
  87. this.getOrderlist();
  88. },
  89. onUnload() {
  90. clearInterval(this.timer);
  91. },
  92. onReady() {
  93. this.mapContext = uni.createMapContext("map",this);
  94. console.log('---------1')
  95. // if(!this.isAndroid){
  96. // this.setCenter();
  97. // }
  98. this.gotoLocat();
  99. },
  100. onShow() {
  101. this.tableList=[
  102. { value: -1, text: this.i18n('order.quanbudd') },
  103. { value: 0, text: this.i18n('order.daifukuan') },
  104. { value: 5, text: this.i18n('order.yiwancheng')},
  105. ];
  106. },
  107. methods: {
  108. i18n(str){
  109. return getApp().globalData.$t(str);
  110. },
  111. gotoLocat(){
  112. var that = this;
  113. uni.getLocation({
  114. type: "wgs84", //默认为 wgs84 返回 gps 坐标//谷歌地图使用 wgs84 坐标,其他地图使用 gcj02 坐标
  115. geocode: "true",
  116. isHighAccuracy: "true",
  117. accuracy: "best", // 精度值为20m
  118. success: function (res) {
  119. console.log(res);
  120. var latlon= res.latitude+','+res.longitude;
  121. that.movetoCenter(res.latitude,res.longitude,false);
  122. },
  123. fail(err) {
  124. console.log('--------getLocation',err)
  125. }
  126. });
  127. },
  128. movetoCenter(latitude,longitude,sLb){
  129. console.log(longitude)
  130. this.latitude=latitude-0.001;
  131. this.longitude=longitude;
  132. },
  133. navbarsel(index){
  134. this.$refs.showLeft.open()
  135. },
  136. closeDrawer(e){
  137. this.$refs[e].close()
  138. },
  139. // 抽屉状态发生变化触发
  140. change(e, type) {
  141. //console.log((type === 'showLeft' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
  142. this[type] = e
  143. },
  144. fanhui(){
  145. uni.navigateBack();
  146. },
  147. gotousercenter(){
  148. uni.navigateTo({
  149. url:'/pages/UserCenter/UserCenter'
  150. })
  151. },
  152. gotochezhurz(index){
  153. if(index==1){
  154. uni.navigateTo({
  155. url:'/pages/dache/XingchengList'
  156. })
  157. }
  158. if(index==2){//联系客服,直接打电话
  159. uni.navigateTo({
  160. url:'/pages/dache/Xiaoxijiaohu'
  161. })
  162. }
  163. },
  164. getUserMsg(token){
  165. //console.log('getUserMsg')
  166. api('getUserMsg',{
  167. },res=>{
  168. //console.log(res.data)
  169. if(res.data.code==200){
  170. console.log('this.userInfo',res.data)
  171. this.userInfo=res.data.data;
  172. uni.setStorageSync('userInfo',res.data.data);
  173. if(res.data.data.userType==1){
  174. this.isShangjia=true;
  175. }
  176. }
  177. },failc=>{
  178. //console.log('getadvertis----',failc)
  179. })
  180. },
  181. tableselct(value,index){
  182. this.toptableindex = index;
  183. },
  184. popQueren(index){
  185. if(index==0){
  186. this.$refs.popMsg.close();
  187. return;
  188. }
  189. if(index==1){
  190. this.$refs.popMsg.close();
  191. console.log('确认')
  192. return;
  193. }
  194. if(index==3){
  195. this.$refs.popMsg.open('center');
  196. }
  197. },
  198. XCactSelect(index,mdaddr){
  199. if(index==0){//处理未完成订单
  200. uni.navigateTo({
  201. url:'/pages/dache/XingchengList'
  202. })
  203. return;
  204. }
  205. if(index==1){//刷新定位
  206. this.gotoLocat();
  207. }
  208. if(index==2){//我要叫车
  209. this.actIndex=1;
  210. this.jisuanxingcheng();
  211. }
  212. if(index==3){//确认修改目的地
  213. this.actIndex=0;
  214. }
  215. if(index==4){//输入目的地
  216. }
  217. },
  218. Querenhj(obj){
  219. var distance=obj.distance;
  220. var fare = (distance-this.TPricesObj.startingDistance)*this.TPricesObj.skipPrice;
  221. var amount=fare+this.TPricesObj.startingPrice;
  222. obj.fare = fare;
  223. obj.amount = amount;
  224. this.addTxorder(obj);
  225. },
  226. JDactSelect(index){
  227. if(index==0){//取消订单
  228. var that = this;
  229. uni.showModal({
  230. title:'取消行程',
  231. content:'确认取消行程吗?',
  232. cancelText:that.i18n('order.quxiao'),
  233. confirmText:that.i18n('comp.queren'),
  234. success: function (res) {
  235. if (res.confirm) { //这里是点击了确定以后
  236. var data = {
  237. id:that.XChengObj.id,
  238. state:6
  239. }
  240. that.SetTxorder(data,0);
  241. } else { //这里是点击了取消以后
  242. console.log('用户点击取消')
  243. }
  244. }
  245. })
  246. }
  247. if(index==1){//打电话
  248. }
  249. if(index==2){//司机聊天
  250. uni.navigateTo({
  251. url:'/pages/dache/Xiaoxijiaohu?id='+this.XChengObj.id
  252. })
  253. }
  254. if(index==3){//一键报警
  255. }
  256. if(index==4){//客服中心,直接电话联系
  257. }
  258. if(index==5){//申请修改目的地
  259. this.actIndex=0;
  260. this.xiugaimdd=1;
  261. }
  262. if(index==6){//语音留言
  263. }
  264. },
  265. startTime(){
  266. this.dengdai=0;
  267. this.timer = setInterval(() => {
  268. this.dengdai=this.dengdai+1;
  269. }, 1000);
  270. },
  271. endTime(){
  272. this.dengdai=0;
  273. clearInterval(this.timer);
  274. },
  275. dengdaiSel(index){
  276. //取消订单
  277. var that = this;
  278. uni.showModal({
  279. title:'取消行程',
  280. content:'确认取消行程吗?',
  281. cancelText:that.i18n('order.quxiao'),
  282. confirmText:that.i18n('comp.queren'),
  283. success: function (res) {
  284. if (res.confirm) { //这里是点击了确定以后
  285. var data = {
  286. id:that.XChengObj.id,
  287. state:6
  288. }
  289. that.SetTxorder(data,0);
  290. } else { //这里是点击了取消以后
  291. console.log('用户点击取消')
  292. }
  293. }
  294. })
  295. },
  296. //data ready--------------------
  297. jisuanxingcheng(){
  298. var distance=20.5;
  299. var fare = (distance-this.TPricesObj.startingDistance)*this.TPricesObj.skipPrice;
  300. var amount=fare+this.TPricesObj.startingPrice;
  301. this.XChengObj={
  302. "fare":fare, //路程车费
  303. "taxiType": "0", //订单类型(0快车,1顺风车)
  304. "amount": amount, //订单实制金额
  305. "intoLongitude":this.longitude, //上车经度
  306. "intoLatitude":this.latitude, //上车纬度
  307. "notes": "", //备注
  308. "coupon": 0, //优惠金额
  309. "distance":distance, //路程距离
  310. "boardingAddress": "衡阳路112号栖木咖啡", //上车地址
  311. "estimatedDuration": "56分钟", //路上预计用时
  312. "userId": this.userInfo.userId,
  313. "downLatitude": 108.562067, //下车维度
  314. "downLongitude": 22.745051, //下车经度
  315. "downAddress": "民族大道民歌湖广场" //下车地址
  316. }
  317. },
  318. //net work---------------------------------
  319. getTaxiPrices(){
  320. api('getTaxiPrices',{
  321. },res=>{
  322. console.log('getTaxiPrices-------',res)
  323. if(res.data.code==200){
  324. this.TPricesObj=res.data.data;
  325. }
  326. else{
  327. uni.showToast({
  328. title:'获取打车价格失败',//that.i18n('api.wangluoshibai'),
  329. icon: 'none',
  330. duration: 2500
  331. })
  332. }
  333. },failc=>{
  334. //console.log('getTaxiPrices----',failc)
  335. uni.showToast({
  336. title:'网络错误',//that.i18n('api.wangluoshibai'),
  337. icon: 'none',
  338. duration: 2500
  339. })
  340. })
  341. },
  342. addTxorder(data){
  343. api('addTxorder',data,res=>{
  344. console.log('addTxorder-------',res)
  345. if(res.data.code==200){
  346. this.actIndex=2;
  347. this.XChengObj=res.data.data;
  348. this.startTime();
  349. uni.setStorageSync('dachexiaoxi','');
  350. }
  351. else{
  352. uni.showToast({
  353. title:'叫车失败',//that.i18n('api.wangluoshibai'),
  354. icon: 'none',
  355. duration: 2500
  356. })
  357. }
  358. },failc=>{
  359. //console.log('getTaxiPrices----',failc)
  360. uni.showToast({
  361. title:'网络错误',//that.i18n('api.wangluoshibai'),
  362. icon: 'none',
  363. duration: 2500
  364. })
  365. })
  366. },
  367. SetTxorder(data,index){
  368. api('SetTxorder',data,res=>{
  369. console.log('SetTxorder------',res)
  370. if(res.data.code==200){
  371. this.actIndex=index;
  372. if(index==0){//取消成功
  373. uni.showToast({
  374. title:'取消成功',//that.i18n('api.wangluoshibai'),
  375. icon: 'none',
  376. duration: 2500
  377. })
  378. this.XChengObj = '';
  379. this.endTime();
  380. return;
  381. }
  382. uni.showToast({
  383. title:'修改成功',//that.i18n('api.wangluoshibai'),
  384. icon: 'none',
  385. duration: 2500
  386. })
  387. }
  388. else{
  389. uni.showToast({
  390. title:'修改失败',//that.i18n('api.wangluoshibai'),
  391. icon: 'none',
  392. duration: 2500
  393. })
  394. }
  395. },failc=>{
  396. //console.log('getTaxiPrices----',failc)
  397. uni.showToast({
  398. title:'网络错误',//that.i18n('api.wangluoshibai'),
  399. icon: 'none',
  400. duration: 2500
  401. })
  402. })
  403. },
  404. getOrderlist(){
  405. console.log('-----getOrderlist')
  406. api('getUsTxorder',{
  407. page:1,
  408. size:20,
  409. state:'',
  410. type:0
  411. },res=>{
  412. console.log('getUsTxorder-------',res)
  413. if(res.data.code==200){
  414. for(var i=0;i<res.data.data.length;i++){
  415. var tempObj = res.data.data[i];
  416. if(tempObj.state<4){
  417. this.XChengObj = tempObj;
  418. this.qibuf=this.TPricesObj.startingPrice;
  419. if(tempObj.state==0){
  420. this.actIndex=2
  421. this.startTime();
  422. }
  423. if(tempObj.state==1||tempObj.state==2){
  424. this.actIndex=3
  425. }
  426. if(tempObj.state==3){
  427. this.actIndex=4
  428. }
  429. this.wzfState=1;
  430. return;
  431. }
  432. }
  433. }
  434. else{
  435. uni.showToast({
  436. title:'获取列表失败',//that.i18n('api.wangluoshibai'),
  437. icon: 'none',
  438. duration: 2500
  439. })
  440. }
  441. },failc=>{
  442. //console.log('getTaxiPrices----',failc)
  443. uni.showToast({
  444. title:'网络错误',//that.i18n('api.wangluoshibai'),
  445. icon: 'none',
  446. duration: 2500
  447. })
  448. })
  449. },
  450. },
  451. onNavigationBarButtonTap(e) {
  452. if (this.showLeft) {
  453. this.$refs.showLeft.close()
  454. } else {
  455. this.$refs.showLeft.open()
  456. }
  457. },
  458. // app端拦截返回事件 ,仅app端生效
  459. onBackPress() {
  460. if (this.showLeft) {
  461. this.$refs.showLeft.close()
  462. return true
  463. }
  464. },
  465. }
  466. </script>
  467. <style lang="scss">
  468. .mapbody{
  469. position: absolute;
  470. width: 750rpx;
  471. }
  472. .mapcontentV{
  473. position: absolute;
  474. width: 750rpx;
  475. background-color:deeppink;
  476. }
  477. .leftpopo{
  478. z-index: 9999;
  479. }
  480. .topContentV{
  481. position: fixed;
  482. justify-content: center;
  483. align-items: center;
  484. padding-top: 100rpx;
  485. left: 0;
  486. right: 0;
  487. top: 0;
  488. z-index: 999;
  489. }
  490. .iconImg{
  491. margin-top: 20rpx;
  492. margin-bottom: 20rpx;
  493. width: 110rpx;
  494. height: 110rpx;
  495. border-radius: 55rpx;
  496. background-color: #1A1A1A;
  497. }
  498. .nameText{
  499. font-size: 32rpx;
  500. color: black;
  501. }
  502. .phoneText{
  503. font-size: 26rpx;
  504. color: black;
  505. }
  506. .drawerlist{
  507. width: 400rpx;
  508. height: 100rpx;
  509. align-items: center;
  510. border: solid lavender;
  511. border-width: 0px 0px 1rpx 0px;
  512. }
  513. .drawerlistIcon{
  514. margin-left: 30rpx;
  515. width: 60rpx;
  516. height: 60rpx;
  517. }
  518. .drawerlisttext{
  519. font-size: 26rpx;
  520. margin-left: 8rpx;
  521. width: 280rpx;
  522. }
  523. .popviewContent{
  524. width:80vw;
  525. background-color: white;
  526. border-radius: 10rpx;
  527. }
  528. .quxiaoBt{
  529. margin-top: 30rpx;
  530. margin-bottom: 30rpx;
  531. padding-left: 50rpx;
  532. padding-right: 50rpx;
  533. font-size: 32rpx;
  534. font-weight: bold;
  535. line-height: 60rpx;
  536. border-radius: 30rpx;
  537. text-align: center;
  538. background-color: #E86E48;
  539. color: white;
  540. }
  541. .querenBt{
  542. margin-top: 30rpx;
  543. margin-bottom: 30rpx;
  544. padding-left: 50rpx;
  545. padding-right: 50rpx;
  546. font-size: 32rpx;
  547. font-weight: bold;
  548. border: 1rpx solid darkgray;
  549. line-height: 60rpx;
  550. border-radius: 30rpx;
  551. text-align: center;
  552. background-color: white;
  553. color: #1A1A1A;
  554. }
  555. .bottomfloatV{
  556. position: fixed;
  557. flex-direction: row;
  558. justify-content: center;
  559. align-items: center;
  560. left: 0;
  561. right: 0;
  562. bottom: 80rpx;
  563. z-index: 999;
  564. }
  565. </style>