orderdetails.vue 12 KB

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