orderdetails.vue 12 KB

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