orderdetails.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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:'logistics',class:''}],
  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.getOrderDetails(that.id);
  286. }
  287. });
  288. console.log('res',res.data);
  289. }).catch(err=>{
  290. console.log('confirmReceipt',err);
  291. })
  292. }
  293. }
  294. })
  295. }
  296. }
  297. }
  298. </script>
  299. <style>
  300. page{
  301. background-color: #F5F5F5;
  302. }
  303. </style>
  304. <style lang="scss" scoped>
  305. .box{
  306. margin-bottom: 20rpx;
  307. background-color: #fff;
  308. border-radius: 8rpx;
  309. padding: 20rpx;
  310. }
  311. .addr{
  312. .top{
  313. margin-bottom: 16rpx;
  314. font-size: 26rpx;
  315. color: #999;
  316. .label{
  317. background-color: #FFEBEB;
  318. border: 1px solid #FF5F62;
  319. color: #FF5F62;
  320. padding: 5rpx 20rpx;
  321. border-radius: 30rpx;
  322. margin-right: 10rpx;
  323. }
  324. }
  325. .center{
  326. margin-bottom: 10rpx;
  327. font-size: 30rpx;
  328. color: #333;
  329. line-height: 50rpx;
  330. font-weight: 600;
  331. }
  332. .bottom{
  333. font-size: 30rpx;
  334. color: #666;
  335. }
  336. }
  337. .order-reduced{
  338. .reduced-item{
  339. padding-bottom: 30rpx;
  340. &:not(:last-child){
  341. margin-bottom: 30rpx;
  342. }
  343. .label{
  344. border-radius: 2px;
  345. border: 1px solid #FF3C3F;
  346. margin-left: 20rpx;
  347. font-size: 20rpx;
  348. color: #FF3C3F;
  349. padding: 0 10rpx;
  350. }
  351. }
  352. .integral{
  353. .num{
  354. font-size: 30rpx;
  355. color: #02AB35;
  356. font-weight: 600;
  357. margin-left: 30rpx;
  358. margin-right: 16rpx;
  359. }
  360. .tip{
  361. font-size: 24rpx;
  362. color: #999;
  363. }
  364. .price{
  365. margin-right: 10rpx;
  366. }
  367. }
  368. }
  369. .total{
  370. .total-item{
  371. padding-bottom: 30rpx;
  372. &:not(:last-child){
  373. margin-bottom: 30rpx;
  374. }
  375. .right{
  376. font-weight: 600;
  377. }
  378. }
  379. .gray{
  380. font-size: 24rpx;
  381. margin-left: 15rpx;
  382. }
  383. }
  384. .cart-bottom{
  385. height: 98rpx;
  386. .inner{
  387. position: fixed;
  388. background-color: #fff;
  389. height: 98rpx;
  390. left: 0;
  391. right: 0;
  392. bottom: 0;
  393. padding: 0 20rpx;
  394. .total-price{
  395. font-size: 30rpx;
  396. color: #333;
  397. font-weight: 600;
  398. margin-left: 30rpx;
  399. }
  400. .btn{
  401. font-size: 26rpx;
  402. height: 64rpx;
  403. line-height: 64rpx;
  404. border-radius: 50rpx;
  405. padding: 0 40rpx;
  406. border: 1px solid #333;
  407. color: #333;
  408. text-align: center;
  409. background-color: transparent;
  410. margin-left: 10rpx;
  411. &.red{
  412. border-color: #FF3C3F;
  413. background-color: #FF3C3F;
  414. color: #fff;
  415. }
  416. &.green{
  417. border-color: #00A447;
  418. background-color: #00A447;
  419. color: #fff;
  420. }
  421. }
  422. }
  423. }
  424. .product{
  425. .text{
  426. .name{
  427. height: auto;
  428. }
  429. .info{
  430. font-size: 24rpx;
  431. font-weight: 400;
  432. color: #666666;
  433. }
  434. }
  435. }
  436. .order-info{
  437. .order-info-item{
  438. font-size: 30rpx;
  439. font-weight: 400;
  440. color: #333333;
  441. line-height: 42rpx;
  442. padding: 30rpx 20rpx;
  443. &:not(:last-child){
  444. border-bottom: 0.5px solid #eee;
  445. }
  446. .til{
  447. font-size: 24rpx;
  448. font-weight: 400;
  449. color: #999999;
  450. margin-right: 90rpx;
  451. }
  452. }
  453. }
  454. .distribution{
  455. font-size: 24rpx;
  456. font-weight: 400;
  457. color: #00A447;
  458. line-height: 33rpx;
  459. .text{
  460. margin-left: 16rpx;
  461. }
  462. .status{
  463. margin-bottom: 10rpx;
  464. font-size: 30rpx;
  465. font-weight: 600;
  466. color: #00A447;
  467. line-height: 38rpx;
  468. }
  469. }
  470. </style>