orderdetails.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. :title="title"
  5. :placeholder="true"
  6. @leftClick="leftClick"
  7. :autoBack="true"
  8. :safeAreaInsetTop="true"
  9. >
  10. </u-navbar>
  11. <u-loading-page :loading="loadingPage"></u-loading-page>
  12. <view class="page-wrap">
  13. <view class="box distribution u-flex u-row-between"
  14. v-if="orderDetails.status>0"
  15. @click="statusClick">
  16. <view class="left u-flex">
  17. <u--image :showLoading="false" :src="staticUrl+'/img/car.png'" width="48rpx" height="48rpx"></u--image>
  18. <view class="text">
  19. <view class="status">{{orderDetails.status|filterOrderState}}</view>
  20. <view>{{orderDetails.createTime}}</view>
  21. </view>
  22. </view>
  23. <u-icon name="arrow-right" color="#676767" size="24rpx"></u-icon>
  24. </view>
  25. <view class="box addr u-flex u-row-between" v-if="orderDetails.logisticsType!=1">
  26. <view class="left">
  27. <view class="top">
  28. <text class="label" v-if="orderDetails.ifDefault">默认</text>{{orderDetails.address||''}}
  29. </view>
  30. <view class="center">{{orderDetails.receiveAdress}}</view>
  31. <view class="bottom">{{orderDetails.receiveName}} {{orderDetails.receivePhone}}</view>
  32. </view>
  33. <!-- <u-icon name="arrow-right" color="#676767" size="20" @click="selectAddr"></u-icon> -->
  34. </view>
  35. <view class="box pickup-info" v-else>
  36. <view class="item u-flex u-row-between">
  37. <view class="left">
  38. 提货人:
  39. <text>{{pickupInfo.pickupName}}</text>
  40. <text>{{pickupInfo.pickupMobile}}</text>
  41. </view>
  42. <!-- <view class="right">
  43. <u-icon name="arrow-right" color="#676767" size="20"></u-icon>
  44. </view> -->
  45. </view>
  46. <view class="item u-flex u-row-between" @click="pickupTimeShow=true">
  47. <view class="left">
  48. 预约提货时间:
  49. <text>{{pickupInfo.pickupTime}}</text>
  50. </view>
  51. <!-- <view class="right">
  52. <u-icon name="arrow-right" color="#676767" size="20"></u-icon>
  53. </view> -->
  54. </view>
  55. <view class="item u-flex u-row-between">
  56. <view class="left u-flex">
  57. <text style="flex: 1;white-space: nowrap;">自提地点:</text>
  58. <text class="ellipsis-1">{{pickupInfo.pickupAddress}}</text>
  59. </view>
  60. <view class="right">
  61. <u-icon @click="goMap" :name="staticUrl+'/img/go-map-icon-y.png'" color="#676767" size="20"></u-icon>
  62. </view>
  63. </view>
  64. </view>
  65. <!-- <view class="payway page-wrap u-flex u-row-between">
  66. <view class="left">支付方式</view>
  67. <view class="u-flex">
  68. 微信支付
  69. <u-icon name="arrow-right" color="#676767" size="20"></u-icon>
  70. </view>
  71. </view> -->
  72. <view class="box order-product">
  73. <view class="product u-flex" v-for="(item,index) in orderDetails.detailList" :key="item.id">
  74. <u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
  75. <view class="text">
  76. <view class="up">
  77. <view class="name ellipsis-2">{{item.goodsName}}</view>
  78. <view class="info">
  79. {{item.specification}}
  80. {{item.unit}}
  81. </view>
  82. </view>
  83. <view class="down u-flex u-row-between">
  84. <view class="left">
  85. <text class="price">¥ <text class="price-num">{{item.price}}</text></text>
  86. </view>
  87. <u-number-box v-model="item.quantity" :disabled="true" @change="changeQuantity(index, $event)" integer></u-number-box>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- logisticsType==1 自提 -->
  92. <view class="" v-if="orderDetails.logisticsType==1" style="font-size: 24rpx;color: #00A447;text-align: right;">
  93. <view class="" v-if="orderDetails.status<=2">请尽快在{{orderDetails.orderShowTime}}小时内提走商品哦</view>
  94. </view>
  95. <!-- logisticsType==2 同城配送 -->
  96. <view class="" v-if="orderDetails.logisticsType==2" style="font-size: 24rpx;color: #00A447;text-align: right;">
  97. <view class="" v-if="orderDetails.status>1">商品将在{{orderDetails.orderShowTime}}小时内配送完成</view>
  98. <view class="" v-else>商品即将开始配送请耐心等待</view>
  99. </view>
  100. </view>
  101. <!-- <view class="page-wrap order-reduced">
  102. <view class="reduced-item u-flex u-row-between u-border-bottom">
  103. <view class="left">
  104. <text>优惠券</text>
  105. <text class="label">已选一张</text>
  106. </view>
  107. <view class="right u-flex">
  108. <text class="price red">-¥ <text class="price-num">1000</text></text>
  109. <u-icon name="arrow-right" color="#676767" size="20"></u-icon>
  110. </view>
  111. </view>
  112. <view class="reduced-item integral u-flex u-row-between">
  113. <view class="left">
  114. <text>积分</text>
  115. <text class="num">3676</text>
  116. <text class="tip">满1000可用</text>
  117. </view>
  118. <view class="right u-flex">
  119. <text class="price red" v-if="useIntegral">-¥ <text class="price-num">1000</text></text>
  120. <u-checkbox-group @change="integralCheckboxChange">
  121. <u-checkbox shape="circle" activeColor="#02AB35" name="integral" ></u-checkbox>
  122. </u-checkbox-group>
  123. </view>
  124. </view>
  125. </view> -->
  126. <view class="box total">
  127. <view class="total-item u-flex u-row-between u-border-bottom">
  128. <view class="left">
  129. 实付金额
  130. </view>
  131. <view class="right red">
  132. ¥ {{orderDetails.realPrice}}
  133. </view>
  134. </view>
  135. <view class="total-item u-flex u-row-between u-border-bottom" v-if="orderDetails.logisticsType!=1">
  136. <view class="left">
  137. 运费
  138. <!-- <text class="gray">总重:{{totalWeight}}</text> -->
  139. </view>
  140. <view class="right red">
  141. <text v-if="orderDetails.originalFreightPrice">+ ¥ {{orderDetails.originalFreightPrice}}</text>
  142. <text v-else>免运费</text>
  143. </view>
  144. </view>
  145. <view class="total-item u-flex u-row-between u-border-bottom">
  146. <view class="left">
  147. 收货方式
  148. </view>
  149. <view class="right red">
  150. {{orderDetails.logisticsType|filterLogisticsType}}
  151. </view>
  152. </view>
  153. </view>
  154. <view class="box order-info page-wrap" v-if="orderDetails.status>0">
  155. <view class="order-info-item" v-for="(item,index) in orderInfo[orderDetails.status]" :key="index">
  156. <text class="til">{{item.name}}</text>
  157. <text class="con">
  158. <text v-if="item.key=='payType'">{{orderDetails[item.key]|filterPayType}}</text>
  159. <text v-else>{{orderDetails[item.key]}}</text>
  160. </text>
  161. </view>
  162. </view>
  163. </view>
  164. <view class="cart-bottom">
  165. <view class="inner u-flex u-row-between">
  166. <view class="left u-flex">
  167. <view class="total-price" v-if="orderDetails.status==0">
  168. 待支付:<text class="red">¥ {{orderDetails.orderPrice}}</text>
  169. </view>
  170. </view>
  171. <!-- <view class="btn" @click="submitOrder">去结算</view> -->
  172. <view class="btn-wrap u-flex">
  173. <view
  174. class="btn"
  175. :class="btn.class"
  176. @click.stop="clickEven(btn.fun,orderDetails)"
  177. v-for="(btn,index) in statusBtn[orderDetails.status]" :key="index">
  178. {{btn.name}}
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. </template>
  185. <script>
  186. export default {
  187. data() {
  188. return {
  189. loadingPage:true,
  190. id:'',
  191. title:'订单详情',
  192. orderDetails:{},
  193. fromPage:'',
  194. useIntegral:false,
  195. dataList:[],
  196. theAddr:{},
  197. isDefaultAddr:false,
  198. staticUrl:this.$commonConfig.staticUrl,
  199. statusBtn:{
  200. 0:[{name:'取消订单',fun:'cancelOrder',class:''},{name:'去支付',fun:'pay',class:'red'}],
  201. 1:[{name:'申请退款',fun:'refund',class:''}],
  202. 2:[{name:'查看物流',fun:'logistics',class:''},{name:'确认收货',fun:'confirmReceipt',class:'green'}],
  203. 3:[{name:'评价',fun:'evaluate',class:'green'}],
  204. // 4:[{name:'查看物流',fun:'logistics',class:''},{name:'评价',fun:'evaluate',class:'green'}],
  205. 5:[{name:'查看退款',fun:'viewRefund',class:''}],
  206. // 6:[{name:'查看退款',fun:'viewRefund',class:'green'}],
  207. 7:[{name:'查看退款',fun:'viewRefund',class:''}]
  208. },
  209. orderInfo:{
  210. 0:[],
  211. 1:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'},{name:'支付方式',key:'payType'},{name:'支付时间',key:'payTime'}],
  212. 2:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'},{name:'支付方式',key:'payType'},{name:'支付时间',key:'payTime'}],
  213. 3:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'},{name:'支付方式',key:'payType'},{name:'支付时间',key:'payTime'},{name:'收货时间',key:'receiveTime'}],
  214. 4:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'}],
  215. 5:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'},{name:'支付方式',key:'payType'},{name:'支付时间',key:'payTime'}],
  216. 6:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'},{name:'支付方式',key:'payType'},{name:'支付时间',key:'payTime'}],
  217. 7:[{name:'订单编号',key:'orderNum'},{name:'下单时间',key:'createTime'},{name:'支付方式',key:'payType'},{name:'支付时间',key:'payTime'}],
  218. },
  219. pickupInfo:{}
  220. }
  221. },
  222. onLoad(page) {
  223. // console.log('page',page);
  224. this.id = page.id;
  225. },
  226. onShow() {
  227. this.getOrderDetails(this.id);
  228. },
  229. computed:{
  230. payType(){
  231. return function(value){
  232. let payTypeList = ['', '微信', '余额', '积分']
  233. return '-' + payTypeList[value]
  234. }
  235. }
  236. },
  237. methods: {
  238. leftClick(){
  239. console.log('orderdetails leftClick');
  240. },
  241. getOrderDetails(id){
  242. this.$u.api.orderDetails({id:id}).then(res=>{
  243. this.loadingPage = false;
  244. this.orderDetails = res.data
  245. this.pickupInfo = res.data.pickupInfo;
  246. // console.log('orderDetails',JSON.parse(JSON.stringify(res.data)));
  247. }).catch(err=>{
  248. console.log('getOrderDetails',err);
  249. })
  250. },
  251. clickEven(fun,item){
  252. // console.log('fun',fun);
  253. let funObj = {
  254. pay: this.pay,
  255. logistics:this.logistics,
  256. evaluate:this.evaluate,
  257. refund:this.refund,
  258. cancelOrder:this.cancelOrder,
  259. viewRefund:this.viewRefund,
  260. confirmReceipt:this.confirmReceipt
  261. };
  262. // console.log('funObj[fun]',funObj[fun]);
  263. if (fun in funObj) {
  264. funObj[fun](item);
  265. }
  266. },
  267. pay(item){
  268. console.log('pay',item);
  269. uni.$u.route('/shopping/pay', {
  270. orderId: item.id,
  271. // openid: that.vuex_wechatOpenid,
  272. payAmount:item.orderPrice
  273. });
  274. },
  275. logistics(item){
  276. // console.log('logistics',item);
  277. uni.$u.route('/shopping/distribution', {
  278. orderId: item.id
  279. });
  280. },
  281. evaluate(item){
  282. // console.log('logistics',item);
  283. uni.$u.route('/shopping/evaluate', {
  284. id: item.id
  285. });
  286. },
  287. refund(item){
  288. // console.log('logistics',item);
  289. uni.$u.route('/shopping/refund', {
  290. id: item.id
  291. });
  292. },
  293. cancelOrder(item){
  294. let that = this;
  295. uni.showModal({
  296. title: '提示',
  297. content: '确认取消吗!',
  298. success: res => {
  299. if (res.confirm) {
  300. this.$u.api.cancelOrder({orderId:item.id}).then(res=>{
  301. this.$refs.uToast.show({
  302. message:res.msg,
  303. complete() {
  304. that.getOrderDetails(that.id);
  305. }
  306. });
  307. // uni.$u.toast(res.msg);
  308. console.log('res',res.data);
  309. }).catch(err=>{
  310. console.log('cancelOrder',err);
  311. })
  312. }
  313. }
  314. });
  315. // console.log('logistics',item);
  316. },
  317. viewRefund(item){
  318. uni.$u.route('/shopping/viewRefund', {
  319. orderId: item.id
  320. });
  321. },
  322. confirmReceipt(item){
  323. let that = this;
  324. uni.showModal({
  325. title: '提示',
  326. content: '确认收货吗!',
  327. success: res => {
  328. if (res.confirm) {
  329. this.$u.api.confirmReceipt({orderId:item.id}).then(res=>{
  330. uni.showToast({
  331. title:res.msg,
  332. duration:2000,
  333. complete() {
  334. that.evaluate(item)
  335. that.getOrderDetails(that.id);
  336. }
  337. });
  338. console.log('res',res.data);
  339. }).catch(err=>{
  340. console.log('confirmReceipt',err);
  341. })
  342. }
  343. }
  344. })
  345. },
  346. goMap(){
  347. uni.openLocation({
  348. latitude: Number(this.pickupInfo.pickupLatitude), //维度
  349. longitude: Number(this.pickupInfo.pickupLongitude), //经度
  350. name: "商行地址", //目的地定位名称
  351. scale: 15, //缩放比例
  352. address: this.pickupInfo.pickupAddress //导航详细地址
  353. })
  354. },
  355. statusClick(){
  356. if (['1', '2'].includes(this.orderDetails.logisticsType)) {
  357. uni.$u.toast('暂无物流信息');
  358. }else{
  359. uni.$u.route('/shopping/distribution', {
  360. orderId: this.orderDetails.id
  361. });
  362. }
  363. }
  364. }
  365. }
  366. </script>
  367. <style>
  368. page{
  369. background-color: #F5F5F5;
  370. }
  371. </style>
  372. <style lang="scss" scoped>
  373. .box{
  374. margin-bottom: 20rpx;
  375. background-color: #fff;
  376. border-radius: 8rpx;
  377. padding: 20rpx;
  378. }
  379. .addr{
  380. .top{
  381. margin-bottom: 16rpx;
  382. font-size: 26rpx;
  383. color: #999;
  384. .label{
  385. background-color: #FFEBEB;
  386. border: 1px solid #FF5F62;
  387. color: #FF5F62;
  388. padding: 5rpx 20rpx;
  389. border-radius: 30rpx;
  390. margin-right: 10rpx;
  391. }
  392. }
  393. .center{
  394. margin-bottom: 10rpx;
  395. font-size: 30rpx;
  396. color: #333;
  397. line-height: 50rpx;
  398. font-weight: 600;
  399. }
  400. .bottom{
  401. font-size: 30rpx;
  402. color: #666;
  403. }
  404. }
  405. .order-reduced{
  406. .reduced-item{
  407. padding-bottom: 30rpx;
  408. &:not(:last-child){
  409. margin-bottom: 30rpx;
  410. }
  411. .label{
  412. border-radius: 2px;
  413. border: 1px solid #FF3C3F;
  414. margin-left: 20rpx;
  415. font-size: 20rpx;
  416. color: #FF3C3F;
  417. padding: 0 10rpx;
  418. }
  419. }
  420. .integral{
  421. .num{
  422. font-size: 30rpx;
  423. color: #02AB35;
  424. font-weight: 600;
  425. margin-left: 30rpx;
  426. margin-right: 16rpx;
  427. }
  428. .tip{
  429. font-size: 24rpx;
  430. color: #999;
  431. }
  432. .price{
  433. margin-right: 10rpx;
  434. }
  435. }
  436. }
  437. .total{
  438. .total-item{
  439. padding-bottom: 30rpx;
  440. &:not(:last-child){
  441. margin-bottom: 30rpx;
  442. }
  443. .right{
  444. font-weight: 600;
  445. }
  446. }
  447. .gray{
  448. font-size: 24rpx;
  449. margin-left: 15rpx;
  450. }
  451. }
  452. .cart-bottom{
  453. height: 98rpx;
  454. .inner{
  455. position: fixed;
  456. background-color: #fff;
  457. height: 98rpx;
  458. left: 0;
  459. right: 0;
  460. bottom: 0;
  461. padding: 0 20rpx;
  462. .total-price{
  463. font-size: 30rpx;
  464. color: #333;
  465. font-weight: 600;
  466. margin-left: 30rpx;
  467. }
  468. .btn{
  469. font-size: 26rpx;
  470. height: 64rpx;
  471. line-height: 64rpx;
  472. border-radius: 50rpx;
  473. padding: 0 40rpx;
  474. border: 1px solid #333;
  475. color: #333;
  476. text-align: center;
  477. background-color: transparent;
  478. margin-left: 10rpx;
  479. &.red{
  480. border-color: #FF3C3F;
  481. background-color: #FF3C3F;
  482. color: #fff;
  483. }
  484. &.green{
  485. border-color: #00A447;
  486. background-color: #00A447;
  487. color: #fff;
  488. }
  489. }
  490. }
  491. }
  492. .product{
  493. .text{
  494. .name{
  495. height: auto;
  496. }
  497. .info{
  498. font-size: 24rpx;
  499. font-weight: 400;
  500. color: #666666;
  501. }
  502. }
  503. }
  504. .order-info{
  505. .order-info-item{
  506. font-size: 30rpx;
  507. font-weight: 400;
  508. color: #333333;
  509. line-height: 42rpx;
  510. padding: 30rpx 20rpx;
  511. &:not(:last-child){
  512. border-bottom: 0.5px solid #eee;
  513. }
  514. .til{
  515. font-size: 24rpx;
  516. font-weight: 400;
  517. color: #999999;
  518. margin-right: 90rpx;
  519. }
  520. }
  521. }
  522. .distribution{
  523. font-size: 24rpx;
  524. font-weight: 400;
  525. color: #00A447;
  526. line-height: 33rpx;
  527. .text{
  528. margin-left: 16rpx;
  529. }
  530. .status{
  531. margin-bottom: 10rpx;
  532. font-size: 30rpx;
  533. font-weight: 600;
  534. color: #00A447;
  535. line-height: 38rpx;
  536. }
  537. }
  538. </style>