takefood.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view class="pages" v-if="XCXIsSelect=='是'">
  3. <!-- 余额 -->
  4. <view class="tosend" v-if="dataDet">
  5. <view class="tosend_text" v-if="dataDet.status == 3&&dataDet.orderType==1">待取餐</view>
  6. <view class="tosend_text" v-if="dataDet.status == 3&&dataDet.orderType==2">配送中</view>
  7. <view class="tosend_text" v-if="dataDet.status == 4">已完成</view>
  8. <view class="tosend_text" v-if="dataDet.status == 5">已取消</view>
  9. <view class="tosend_text" v-if="dataDet.status == 6">制作中</view>
  10. <view class="tosend_text" v-if="dataDet.status == 7">待接单</view>
  11. <view class="tosend_text" v-if="dataDet.status == 8">已取消</view>
  12. <view class="flex justify-center" v-if="dataDet.orderType==1" style="width: 100%;height: 140rpx;margin-bottom: 30rpx;">
  13. <view class="flex justify-center" style="width: 94%;height: 100%;border-radius: 18rpx;background-color: #ffffff;padding: 3%;">
  14. <view class="flex justify-between align-center" style="width: 100%;height: 100%;">
  15. <image :src="shopInfo.shopCover?shopInfo.shopCover:'../../static/logo.png'" style="width: 110rpx;height: 110rpx;border-radius: 8rpx;" mode=""></image>
  16. <view class="flex flex-wrap align-center" style="width: 80%;height: 100%;">
  17. <view class="" style="width: 100%;font-size: 30rpx;" @click="call">
  18. <text style="font-weight: bold;">{{shopInfo.shopName?shopInfo.shopName:''}}</text>
  19. <text style="margin-left: 10rpx;font-weight: bold;">{{shopInfo.phones?shopInfo.phones:''}}</text>
  20. <u-icon name="phone" size="30" color="#999999" style=""></u-icon>
  21. </view>
  22. <view class="flex align-center" style="width: 100%;color: #999999;font-size: 24rpx;" @click="goMaps">
  23. <u-icon name="map" size="30" color="#999999" style="margin-right: 10rpx;"></u-icon>
  24. {{shopInfo.detailedAddress?shopInfo.detailedAddress:''}}
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="tosend_header">
  31. <!-- 排序 -->
  32. <view class="cont_two_top" v-if="dataDet.status == 3&&dataDet.orderType==1">
  33. <view class="cont_two_top_le">取餐号码</view>
  34. <!-- <view class="cont_two_top_ri">制作中</view> -->
  35. </view>
  36. <view v-if="dataDet.status == 3&&dataDet.orderType==1" class="cont_two_text">{{dataDet.orderCode}}
  37. </view>
  38. <view v-if="dataDet.status == 3&&dataDet.orderType==1" class="cont_two_text2">
  39. 前面还有<text>{{dataDet.countOrder}}</text>个订单</view>
  40. <!-- 商品列表 -->
  41. <view v-if="dataDet" class="tosend_header_food" v-for="(item,index) in dataDet.orderGoodsList"
  42. :key='index'>
  43. <view class="tosend_header_food_le">
  44. <image :src="item.goodsPicture[0]" style="border-radius: 10rpx;" mode=""></image>
  45. </view>
  46. <view class="flex-sub margin-left-sm">
  47. <view class="flex justify-between align-center">
  48. <view class="text-lg text-bold text-black">{{item.goodsName}}</view>
  49. <view class="text-lg text-bold text-black"><text class="text-sm">¥</text>{{item.goodsPrice}}
  50. </view>
  51. </view>
  52. <view class="flex justify-between align-center text-gray">
  53. <view v-if="item.skuMessage">{{item.skuMessage}}</view>
  54. <view>X{{item.goodsNum}}</view>
  55. </view>
  56. <view class="flex justify-between align-center text-gray" v-if="item.goodsPack">
  57. <view>打包费</view>
  58. <view>¥{{item.goodsPack}} / 份</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="tosend_header_do " v-if="dataDet.couponMoney>0">
  63. <view>优惠券</view>
  64. <view class="tosend_header_do_ri">-¥{{dataDet.couponMoney}}</view>
  65. </view>
  66. <view class="tosend_header_do do_bot" v-if="dataDet.errandMoney>0&&dataDet.orderType==2">
  67. <view>跑腿费</view>
  68. <view class="tosend_header_do_ri">¥{{dataDet.errandMoney}}</view>
  69. </view>
  70. <view class="tosend_header_do">
  71. <view class="tosend_header_do_le2">实付</view>
  72. <view class="tosend_header_do_ri2"><text>¥</text>{{dataDet.payMoney}}</view>
  73. </view>
  74. </view>
  75. <view class="text-center" v-if="dataDet">
  76. <map v-if="dataDet.status == 3 && latitude && longitude" id="map" @tap="goMap"
  77. style="width: 95%; height: 300rpx;margin: 20rpx auto 0;" :markers="markers" :latitude="latitude"
  78. :longitude="longitude"></map>
  79. </view>
  80. <!-- 骑手信息 -->
  81. <view class="rider_box" v-if="dataDet&&(dataDet.status == 3||dataDet.status == 4)&&dataDet.riderUserId">
  82. <view class="flex justify-between align-center padding">
  83. <view style="font-size: 31rpx;color: black;">联系骑手</view>
  84. <image @click="complaint" src="../../static/images/order/tousu.png"
  85. style="width: 43rpx;height: 39rpx;" mode=""></image>
  86. </view>
  87. <view>
  88. <u-line color="#F2F2F2" />
  89. </view>
  90. <view style="padding: 20rpx 25rpx;display: flex;justify-content: space-between;align-items: center;">
  91. <view style="display: flex;">
  92. <view class="rider_left">
  93. <image :src="dataDet.riderAvatar"></image>
  94. </view>
  95. <view style="margin-left: 10rpx;color: #333333;">
  96. <view>{{dataDet.riderUserName}}</view>
  97. <view>{{dataDet.riderPhone1}}</view>
  98. </view>
  99. </view>
  100. <view class="phone" @click="bindphone(dataDet.riderPhone)">联系TA</view>
  101. </view>
  102. </view>
  103. <!-- 其他信息 -->
  104. <view class="tosend_cont" v-if="dataDet">
  105. <view class="tosend_header_text">
  106. <text>订单信息</text>
  107. </view>
  108. <view class="tosend_cont_infor" v-if="dataDet.orderType==1">
  109. <view class="tosend_cont_infor_le">取餐号码</view>
  110. <view class="tosend_cont_infor_ri">{{dataDet.orderCode}}</view>
  111. </view>
  112. <view class="tosend_cont_infor">
  113. <view class="tosend_cont_infor_le">订单编号</view>
  114. <view class="tosend_cont_infor_ri">{{dataDet.orderNumber}}
  115. <u-icon @click="copy(dataDet.orderNumber)" name="order" style="margin-left: 6rpx;" size="32">
  116. </u-icon>
  117. </view>
  118. </view>
  119. <view class="tosend_cont_infor">
  120. <view class="tosend_cont_infor_le">下单时间</view>
  121. <view class="tosend_cont_infor_ri">{{dataDet.payTime}}</view>
  122. </view>
  123. <view class="tosend_cont_infor">
  124. <view class="tosend_cont_infor_le">支付方式</view>
  125. <view class="tosend_cont_infor_ri" v-if="dataDet.payType==1">微信支付</view>
  126. <view class="tosend_cont_infor_ri" v-if="dataDet.payType==2">余额支付</view>
  127. </view>
  128. <view class="tosend_cont_infor" v-if="dataDet.orderType==2">
  129. <view class="tosend_cont_infor_le">联系人</view>
  130. <view class="tosend_cont_infor_ri">{{dataDet.address.userName}}</view>
  131. </view>
  132. <view class="tosend_cont_infor" v-if="dataDet.orderType==2">
  133. <view class="tosend_cont_infor_le">联系方式</view>
  134. <view class="tosend_cont_infor_ri">{{dataDet.address.userPhone}}</view>
  135. </view>
  136. <view class="tosend_cont_infor" v-if="dataDet.orderType==2">
  137. <view class="tosend_cont_infor_le">详细地址</view>
  138. <view class="tosend_cont_infor_ri">
  139. {{dataDet.address.province}}{{dataDet.address.city}}{{dataDet.address.district}}{{dataDet.address.addressDetail}}
  140. </view>
  141. </view>
  142. <view class="tosend_cont_infor" v-if="dataDet.remark">
  143. <view class="tosend_cont_infor_le">订单备注</view>
  144. <view class="tosend_cont_infor_ri">
  145. {{dataDet.remark}}
  146. </view>
  147. </view>
  148. </view>
  149. </view>
  150. <view style="width: 100rpx;height: 100rpx;position: fixed;bottom: 100rpx;right: 70rpx;" v-if="dataDet">
  151. <image src="../../static/images/order/kefu.png" style="width: 100%;height: 100%;" @click="goChat()" mode="">
  152. </image>
  153. <view class="shopxiaoix" v-if="RiderUnreadCount>0">{{RiderUnreadCount}}</view>
  154. </view>
  155. </view>
  156. </template>
  157. <script>
  158. export default {
  159. data() {
  160. return {
  161. orderId: '',
  162. dataDet: '',
  163. markers: [], //标记点
  164. latitude: '',
  165. longitude: '',
  166. RiderUnreadCount: 0,
  167. XCXIsSelect: '是',
  168. shopId:'',
  169. shopInfo:{},
  170. }
  171. },
  172. onLoad(option) {
  173. this.XCXIsSelect = this.$queue.getData('XCXIsSelect');
  174. if (this.XCXIsSelect == '否') {
  175. uni.setNavigationBarTitle({
  176. title: '隐私政策'
  177. });
  178. } else {
  179. uni.setNavigationBarTitle({
  180. title: '订单详情'
  181. });
  182. }
  183. let that = this
  184. uni.showLoading({
  185. title: '加载中...'
  186. })
  187. that.orderId = option.orderId
  188. that.shopId = option.shopId
  189. uni.getLocation({
  190. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  191. success: function(res) {
  192. that.lat = res.latitude;
  193. that.lng = res.longitude;
  194. that.getDataDet()
  195. },fail(e) {
  196. uni.hideLoading();
  197. uni.showModal({
  198. title: '温馨提示',
  199. content: '您的定位权限未开启,请开启后再来操作吧!',
  200. showCancel: true,
  201. cancelText: '取消',
  202. confirmText: '确认',
  203. success: res => {
  204. if(res.confirm){
  205. uni.openSetting({ // 打开设置页
  206. success(rea) {
  207. console.log(rea.authSetting)
  208. }
  209. });
  210. }
  211. }
  212. });
  213. }
  214. });
  215. this.getRiderUnreadCount()
  216. this.getShopInfo()
  217. },
  218. created() {
  219. this.RiderUnreadCount = setInterval(() => {
  220. this.getRiderUnreadCount()
  221. }, 5000)
  222. },
  223. methods: {
  224. // 点击调起地图查看位置
  225. goMaps() {
  226. let that = this;
  227. let lati = parseFloat(that.shopInfo.shopLat);
  228. let longi = parseFloat(that.shopInfo.shopLng);
  229. uni.authorize({
  230. scope: 'scope.userLocation',
  231. success(res) {
  232. uni.openLocation({
  233. name: that.shopInfo.shopName,
  234. latitude: lati,
  235. longitude: longi,
  236. success: function() {}
  237. });
  238. },
  239. fail(err) {}
  240. });
  241. },
  242. // 打电话
  243. call() {
  244. uni.makePhoneCall({
  245. phoneNumber: this.shopInfo.phone
  246. });
  247. },
  248. //获取店铺信息
  249. getShopInfo(){
  250. let data ={
  251. shopId:this.shopId
  252. }
  253. this.$Request.get("/app/shop/selectShopMessage", data).then(res => {
  254. if(res.code == 0 && res.data){
  255. this.shopInfo = res.data
  256. let phoneNumber = this.shopInfo.phone.toString() //先强制转换成字符串类型
  257. this.shopInfo.phones = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2')
  258. }
  259. })
  260. },
  261. getDataDet() {
  262. let data = {
  263. orderId: this.orderId
  264. }
  265. this.$Request.get("/app/order/selectOrderById", data).then(res => {
  266. uni.hideLoading()
  267. if (res.code == 0) {
  268. this.dataDet = res.data
  269. // this.dataDet.goodsMessage = JSON.parse(this.dataDet.goodsMessage)
  270. this.dataDet.orderCode = this.dataDet.orderCode.substring(this.dataDet.orderCode.length -
  271. 3, this.dataDet.orderCode.length)
  272. this.dataDet.orderGoodsList.forEach(res => {
  273. res.goodsPicture = res.goodsPicture.split(',')
  274. })
  275. if (this.dataDet.riderPhone) {
  276. this.dataDet.riderPhone1 = this.dataDet.riderPhone.substring(0, 3) + "****" + this
  277. .dataDet.riderPhone.substring(7, 11);
  278. }
  279. this.dataDet.address = this.dataDet.address ? JSON.parse(this.dataDet.address) : ''
  280. console.log(this.dataDet.address)
  281. if (this.dataDet.riderUserId) {
  282. this.getLocation(this.dataDet.riderUserId)
  283. }
  284. }
  285. });
  286. },
  287. goChat() {
  288. uni.navigateTo({
  289. url: '/pages/index/shop/im?ordersId=' + this.orderId
  290. })
  291. },
  292. getLocation(e) {
  293. let data = {
  294. riderUserId: e,
  295. lat: this.lat,
  296. lng: this.lng
  297. }
  298. this.$Request.getT('/timedtask/selectRiderLocation', data).then(res => {
  299. if (res.code === 0) {
  300. console.log(res.data, '经纬度')
  301. this.latitude = res.data.riderLocation.lat;
  302. this.longitude = res.data.riderLocation.lng;
  303. this.markers = [{
  304. id: 1,
  305. latitude: res.data.riderLocation.lat,
  306. longitude: res.data.riderLocation.lng,
  307. iconPath: '../../static/images/order/rider.png',
  308. width: '40',
  309. height: '40'
  310. }]
  311. }
  312. });
  313. },
  314. goMap() {
  315. uni.navigateTo({
  316. url: '/pages/order/waimaiMap?orderId=' + this.orderId
  317. })
  318. },
  319. // 拨打电话
  320. bindphone(e) {
  321. console.log(e)
  322. uni.makePhoneCall({
  323. phoneNumber: e
  324. });
  325. },
  326. complaint() {
  327. uni.navigateTo({
  328. url: '/pages/order/complaint/complaint?indentNumber=' + this.dataDet.indentNumber +
  329. '&indentType=5'
  330. })
  331. },
  332. copy(e) {
  333. uni.setClipboardData({
  334. data: e,
  335. success: () => {
  336. uni.showToast({
  337. title: '复制成功'
  338. })
  339. }
  340. })
  341. },
  342. getRiderUnreadCount() {
  343. let that = this
  344. let data = {
  345. ordersId: that.orderId
  346. }
  347. that.$Request.getT("/app/ordersChat/selectUserUnreadCount", data).then(res => {
  348. if (res.code == 0) {
  349. if (res.data > 0) {
  350. if (that.RiderUnreadCount != res.data) {
  351. that.aplayAudio()
  352. that.RiderUnreadCount = res.data
  353. }
  354. } else {
  355. that.RiderUnreadCount = 0
  356. }
  357. }
  358. });
  359. },
  360. // 语音播报
  361. aplayAudio() {
  362. // const audio = document.getElementById('audio')
  363. // audio.play()
  364. // console.log('语音提示')
  365. const innerAudioContext = uni.createInnerAudioContext();
  366. innerAudioContext.autoplay = true;
  367. innerAudioContext.src =
  368. 'https://pw.xianmxkj.com/file/uploadPath/2022/01/19/0753211f78d718d44ee6372e33eae9ee.mp3';
  369. innerAudioContext.onPlay(() => {
  370. console.log('开始播放');
  371. });
  372. innerAudioContext.onError((res) => {
  373. console.log(res.errMsg);
  374. console.log(res.errCode);
  375. });
  376. },
  377. }
  378. }
  379. </script>
  380. <style scoped>
  381. /* 余额 */
  382. .tosend {
  383. width: 100%;
  384. height: 280rpx;
  385. background: -webkit-linear-gradient(top, #FCD202, #F5F5F5);
  386. }
  387. .tosend_text {
  388. padding: 3% 3% 4%;
  389. font-size: 48rpx;
  390. font-weight: 800;
  391. color: #333333;
  392. }
  393. .tosend_header {
  394. width: 94%;
  395. background-color: #FFFFFF;
  396. margin: 0 auto;
  397. border-radius: 18rpx;
  398. padding: 3%;
  399. }
  400. /* 排序 */
  401. .cont_two_top {
  402. width: 100%;
  403. display: flex;
  404. justify-content: space-between;
  405. }
  406. .cont_two_top_le {
  407. font-size: 30rpx;
  408. font-weight: 500;
  409. color: #333333;
  410. }
  411. .cont_two_top_ri {
  412. padding: 6rpx 10rpx;
  413. text-align: center;
  414. background: rgba(255, 19, 10, 0.2);
  415. font-size: 24rpx;
  416. border: 2rpx solid #FF130A;
  417. color: #FF130A;
  418. opacity: 0.6;
  419. border-radius: 8rpx;
  420. }
  421. .cont_two_text {
  422. font-size: 56rpx;
  423. text-align: center;
  424. font-weight: bold;
  425. color: #333333;
  426. margin: 5% 0;
  427. line-height: 32rpx;
  428. }
  429. .cont_two_text2 {
  430. font-size: 30rpx;
  431. width: 100%;
  432. font-weight: 500;
  433. color: #333333;
  434. text-align: center;
  435. padding-bottom: 4%;
  436. line-height: 32rpx;
  437. border-bottom: 1rpx solid #E6E6E6;
  438. }
  439. .cont_two_text2 text {
  440. color: #FF130A;
  441. }
  442. /* 商品列表 */
  443. .tosend_header_text {
  444. font-weight: 800;
  445. color: #333333;
  446. line-height: 2;
  447. font-size: 30rpx;
  448. display: flex;
  449. justify-content: space-between;
  450. }
  451. .tosend_header_food {
  452. width: 100%;
  453. display: flex;
  454. margin-top: 3%;
  455. }
  456. .tosend_header_food_le {
  457. width: 15%;
  458. }
  459. .tosend_header_food_le image {
  460. width: 110rpx;
  461. height: 110rpx;
  462. }
  463. .tosend_header_food_ce {
  464. margin: 0 0 0 4%;
  465. width: 57%;
  466. }
  467. .tosend_header_food_ri {
  468. text-align: right;
  469. width: 25%;
  470. }
  471. .tosend_header_food_text {
  472. font-size: 34rpx;
  473. font-weight: 500;
  474. color: #333333;
  475. line-height: 1.8;
  476. }
  477. .tosend_header_food_text text {
  478. font-size: 25rpx;
  479. }
  480. .tosend_header_food_text2 {
  481. font-size: 30rpx;
  482. font-weight: 500;
  483. color: #999999;
  484. }
  485. .do_top {
  486. padding-top: 3%;
  487. }
  488. .do_bot {
  489. padding-bottom: 3%;
  490. border-bottom: 2rpx solid #E6E6E6;
  491. }
  492. .tosend_header_do {
  493. width: 100%;
  494. color: #333333;
  495. font-size: 30rpx;
  496. display: flex;
  497. line-height: 1.5;
  498. }
  499. .tosend_header_do view {
  500. flex: 1;
  501. }
  502. .tosend_header_do_ri {
  503. text-align: right;
  504. }
  505. .tosend_header_do_le2 {
  506. font-family: PingFang SC;
  507. font-weight: 500;
  508. color: #999999;
  509. padding-top: 1.5%;
  510. }
  511. .tosend_header_do_ri2 {
  512. text-align: right;
  513. color: #EA0000;
  514. font-size: 40rpx;
  515. }
  516. .tosend_header_do_ri2 text {
  517. font-size: 30rpx;
  518. }
  519. /* 其他信息 */
  520. .tosend_cont {
  521. width: 94%;
  522. background-color: #FFFFFF;
  523. margin: 3% auto;
  524. border-radius: 18rpx;
  525. padding: 3%;
  526. }
  527. .tosend_cont_infor {
  528. display: flex;
  529. margin-top: 3%;
  530. }
  531. .tosend_cont_infor_le {
  532. flex: 1;
  533. color: #999999;
  534. }
  535. .tosend_cont_infor_ri {
  536. flex: 2;
  537. text-align: right;
  538. color: #333333;
  539. }
  540. .tosend_cont_text {
  541. text-align: right;
  542. }
  543. /* 联系骑手 */
  544. .rider_box {
  545. width: 95%;
  546. margin: 0 auto;
  547. background: #ffffff;
  548. margin-top: 20rpx;
  549. border-radius: 10rpx;
  550. }
  551. .rider_left image {
  552. width: 80rpx;
  553. height: 85rpx;
  554. border-radius: 60%;
  555. }
  556. .phone {
  557. background: #FD6416;
  558. color: #ffffff;
  559. padding: 8rpx 15rpx;
  560. border-radius: 13rpx;
  561. font-size: 24rpx;
  562. }
  563. .shopxiaoix {
  564. background: red;
  565. color: #ffffff;
  566. width: auto;
  567. padding: 5rpx 12rpx;
  568. height: auto;
  569. text-align: center;
  570. border-radius: 30rpx;
  571. position: absolute;
  572. top: -4rpx;
  573. right: -4rpx;
  574. }
  575. </style>