orderdetails.vue 12 KB

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