takefood.vue 17 KB

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