orderDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view class="orderDetail-digitalShel flex flex_column">
  3. <view class="contHead" :style="{background:state!= 'error'&&state!= 'AUDIT_REJECT'&&state!='CANCEL'&&state!='WAIT_PAY' ? '#066cff':'#e61100',color:'#fff'}">
  4. <view class="statusH">
  5. <view class="flex flex_column align_center">
  6. <view class="status-row">
  7. <u-icon :name="statusIcon" size="42" color="#fff">
  8. </u-icon>
  9. <text>{{statusText}}</text>
  10. </view>
  11. <view v-if="info.billStatus=='WAIT_PAY'" class="messageText">
  12. 请尽快支付,
  13. <u-count-down separator="zh" :separator-size="24" bg-color="none" color="#ffff7f" separator-color="#ffff7f" :timestamp="info.timestamp" :show-days="false" :show-hours="false" @end="countDownEnd()"></u-count-down>
  14. 后订单将自动取消。
  15. </view>
  16. <view v-else class="messageText"><text>{{statusMessage}}</text></view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="order-body">
  21. <view class="info partList" v-if="partList.length" style="max-height: 50vh;overflow: auto;">
  22. <view class="infoList">
  23. <view class="title">
  24. 产品列表
  25. </view>
  26. <view v-if="info">
  27. 共<text class="cText">{{info.totalCategory}}</text>款
  28. </view>
  29. </view>
  30. <view v-for="(item,dix) in partList" :key="item.id" class="item-list-box">
  31. <view class="item-list flex">
  32. <view style="height: 160rpx;width: 160rpx;">
  33. <u-image :src="item.product.images ? item.product.images+'?x-oss-process=image/resize,p_50':'/static/def_imgs.png'" border-radius="16" width="160" height="160" bg-color="#EBEBEB" ></u-image>
  34. </view>
  35. <view>
  36. <view class="item-name">
  37. <text>{{item.product.productName}}</text>
  38. </view>
  39. <view class="item-nums" v-if="item.product&&item.product.code">
  40. <text>{{item.product.code}}</text>
  41. </view>
  42. <view class="item-nums" v-if="item.product&&item.product.origCode">
  43. <text style="color: #00aaff;">{{item.product.origCode}}</text>
  44. </view>
  45. <view class="item-head">
  46. <view class="flex align_center">
  47. <view class="price-txt">¥<text>{{item.priceStr[0]}}</text>.{{item.priceStr[1]}}</view>
  48. <view class="flex align_center rebate-tag" v-if="item.promoProductType=='TICKET_PRODUCT'">
  49. 返<text>{{item.resultValue}}</text>元
  50. </view>
  51. <view class="flex align_center rebate-tag" v-if="item.promoProductType=='REGULAR_PRODUCT'">
  52. 买{{item.conditionValue}}赠{{item.resultValue}}
  53. </view>
  54. <view class="flex align_center tejia-tag" v-if="item.promoProductType=='SPECIAL_PRODUCT'">
  55. 特价<text>¥{{item.priceOrig}}</text>
  56. </view>
  57. </view>
  58. <view>
  59. X <text class="cText">{{item.qty}}</text>{{item.product&&item.product.unit||''}}
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 赠品 -->
  65. <view class="item-list flex gift-box" v-if="item.giftObj">
  66. <view style="height: 120rpx;width: 120rpx;margin-left: 40rpx;">
  67. <u-image :src="item.giftObj.product.images ? item.giftObj.product.images+'?x-oss-process=image/resize,p_50':'/static/def_imgs.png'" border-radius="16" width="120" height="120" bg-color="#EBEBEB" ></u-image>
  68. </view>
  69. <view>
  70. <view class="item-name flex align_center">
  71. <view class="flex align_center rebate-tag">
  72. 赠品
  73. </view>
  74. <text class="ellipsis-one">{{item.giftObj.product.productName}}</text>
  75. </view>
  76. <view class="item-nums ellipsis-one" v-if="item.giftObj.product&&item.giftObj.product.code">
  77. <text>{{item.giftObj.product.code}}</text>
  78. </view>
  79. <view class="item-nums ellipsis-one" v-if="item.giftObj.product&&item.giftObj.product.origCode">
  80. <text style="color: #666;">{{item.giftObj.product.origCode}}</text>
  81. </view>
  82. <view class="item-head">
  83. <view class="flex align_center"></view>
  84. <view>
  85. X <text class="cText">{{item.giftObj.qty}}</text>{{item.giftObj.product&&item.giftObj.product.unit||''}}
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- 分页 -->
  92. <view class="product-pages" v-if="totalPages>1">
  93. <uni-pages-nav :totalPages="totalPages" :showShadow="false" :currentPage="pageNo" @pagechanged="getRow"></uni-pages-nav>
  94. </view>
  95. </view>
  96. <view class="info" v-if="info">
  97. <view class="infoList">
  98. <text>总金额</text>
  99. <view class="price-txt">¥<text>{{Number(info.totalAmount).toFixed(2)}}</text></view>
  100. </view>
  101. <view class="infoList gray-text" v-if="info.totalSpecialGiveAmount">
  102. <text>总优惠</text>
  103. <text class="cText">¥{{Number(info.totalSpecialGiveAmount).toFixed(2)}}</text>
  104. </view>
  105. <view class="infoList gray-text" v-if="info.totalTicketGiveAmount">
  106. <text>代金券</text>
  107. <text class="cText">¥{{Number(info.totalTicketGiveAmount).toFixed(2)}}</text>
  108. </view>
  109. </view>
  110. <view class="info" v-if="info">
  111. <view class="infoList">
  112. <view class="title">订单信息</view>
  113. <view class="statu"></view>
  114. </view>
  115. <view class="infoList dju">
  116. <text>订单编号</text>
  117. <text>{{info.purchaseNo||'--'}}</text>
  118. </view>
  119. <view class="infoList">
  120. <text>下单时间</text>
  121. <text>{{info.purchaseDate||'--'}}</text>
  122. </view>
  123. <view class="infoList">
  124. <text>下单人员</text>
  125. <text>{{info.purchaserName || '--'}}</text>
  126. </view>
  127. <!-- 线上支付 显示 -->
  128. <view v-if="hasPay">
  129. <view class="infoList" v-if="info&&info.billStatus != 'WAIT_AUDIT'&&info.billStatus != 'WAIT_PAY'&&isPayOk">
  130. <text>审核时间</text>
  131. <text>{{info.auditDate||'--'}}</text>
  132. </view>
  133. <view class="infoList" v-if="isPayOk">
  134. <text>支付方式</text>
  135. <text>{{info.payInfo.payWay=='WXPAY_ONLINE_XCX'?'微信支付':'--'}}</text>
  136. </view>
  137. <view class="infoList" v-if="isPayOk">
  138. <text>支付时间</text>
  139. <text>{{info.payInfo.payDate||'--'}}</text>
  140. </view>
  141. <view class="infoList" v-if="info&&info.billStatus == 'CANCEL'&&isPayOk">
  142. <text>退款方式</text>
  143. <text>原支付返回</text>
  144. </view>
  145. <view class="infoList" v-if="info&&info.billStatus == 'CANCEL'&&isPayOk">
  146. <text>退款时间</text>
  147. <text>{{info.payInfo.refundDate ||'--'}}</text>
  148. </view>
  149. <view class="infoList" v-if="info&&info.billStatus == 'CANCEL'">
  150. <text>取消时间</text>
  151. <text>{{info.cancelDate ||'--'}}</text>
  152. </view>
  153. <view class="infoList" v-if="shelfInfo">
  154. <text>配送汽配商</text>
  155. <text>{{shelfInfo.dealerName}}</text>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. <view v-if="info&&info.billStatus == 'WAIT_AUDIT'||info.billStatus == 'WAIT_PAY'||info.billStatus == 'WAIT_RECEIVE'" style="background-color: #fff;">
  161. <view class="footer flex align_center justify_center">
  162. <u-button style="margin-left: 10px;" v-if="info.billStatus == 'WAIT_AUDIT'||info.billStatus == 'WAIT_PAY'" size="medium" shape="round" type="default" plain @click="cancelOrder(info)">取消订单</u-button>
  163. <u-button style="margin-left: 10px;" v-if="info.billStatus == 'WAIT_PAY'" size="medium" shape="round" type="error" plain @click="payOrder(info)">立即支付</u-button>
  164. <!-- <u-button style="margin-left: 10px;" v-if="info.billStatus == 'FINISH'" size="medium" shape="round" type="error" plain @click="buyAgain(info)">再次购买</u-button> -->
  165. <u-button style="margin-left: 10px;" v-if="info.billStatus == 'WAIT_RECEIVE'" size="medium" shape="round" type="error" plain @click="receiveOrder(info)">确认收货</u-button>
  166. </view>
  167. <view :style="{height:safeAreaBottom+'px'}"></view>
  168. </view>
  169. <!-- 付款弹框 -->
  170. <payModal :showPopu="showPopu" :payInfo="info" :payData="payData" @close="showPopu=false" @payComplete="payComplete"></payModal>
  171. </view>
  172. </template>
  173. <script>
  174. import payModal from '../components/payModal.vue'
  175. import { purchaseQueryDetailPage,purchaseQueryPage,purchaseCancel,purchaseReceive,purchasePay } from '@/api/purchase.js'
  176. import moment from 'moment'
  177. export default {
  178. name: 'procureDetailOrder',
  179. components:{
  180. payModal
  181. },
  182. data() {
  183. return {
  184. loading: false,
  185. info: null,
  186. statusText: '',
  187. statusIcon: '', // 结算状态icon
  188. statusMessage: '请耐心等待汽配经销商进行配送',
  189. partList: [], // 配件列表
  190. state: 'success',
  191. pageNo:1,
  192. pageSize: 30,
  193. total: 0,
  194. purchaseSn: null,
  195. showPopu: false,
  196. safeAreaBottom: 0, // 底部安全区域高度
  197. payData: null
  198. }
  199. },
  200. onLoad(option) {
  201. this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
  202. uni.setNavigationBarTitle({
  203. title: '采购订单详情'
  204. })
  205. // 查明细
  206. if(option.purchaseSn){
  207. this.getDetail()
  208. }else{
  209. // 从列表过来不需要查
  210. const data = this.$store.state.vuex_tempOrderData //获取订单信息
  211. if(data){
  212. this.pageInit(data)
  213. }
  214. }
  215. },
  216. onUnload() {
  217. this.$store.state.vuex_tempOrderData = null
  218. },
  219. computed: {
  220. totalPages(){
  221. return Math.ceil(this.total / this.pageSize)
  222. },
  223. // 货架经销商信息
  224. shelfInfo(){
  225. return this.$store.state.vuex_storeShelf
  226. },
  227. //是否有支付信息
  228. hasPay(){
  229. return this.info&&this.info.payOnlineFlag==1&&this.info.payInfo
  230. },
  231. //是否已付款
  232. isPayOk(){
  233. const item = this.info
  234. return this.hasPay && item.payInfo.payState=='FINISH'
  235. },
  236. },
  237. methods: {
  238. pageInit(data){
  239. // 计算待付款剩余倒计时
  240. if(data.billStatus== 'WAIT_PAY'){
  241. data.timestamp = (new Date(data.createDate.replace(/-/g,'/')).getTime() + 1800000 - new Date().getTime())/1000
  242. }
  243. data.payOk = data.payOnlineFlag==1&&data.payInfo&&data.payInfo.payState=='FINISH'
  244. this.info = data
  245. if(this.info.payInfo){
  246. this.info.payInfo.payDate = moment(this.info.payInfo.payDate).format('YYYY-MM-DD hh:mm:ss')
  247. }
  248. this.state = data.billStatus
  249. this.purchaseSn = data.purchaseSn
  250. const stateText = {'WAIT_AUDIT':'待审核','WAIT_PAY':'待付款','AUDIT_REJECT':'审核不通过','WAIT_OUT_WAREHOUSE':'待收货','WAIT_RECEIVE':'待收货','FINISH':'已完结','CANCEL':'已取消'}
  251. this.statusText = stateText[this.state]
  252. this.statusIcon = this.state == 'FINISH' ? 'checkmark-circle' : ((this.state == 'AUDIT_REJECT'||this.state == 'CANCEL')?'close-circle':'hourglass')
  253. this.statusMessage = this.state == 'WAIT_OUT_WAREHOUSE'||this.state == 'WAIT_RECEIVE' ? '请耐心等待汽配经销商进行配送' : ''
  254. // 更改标题栏背景色
  255. uni.setNavigationBarColor({
  256. frontColor: '#ffffff',
  257. backgroundColor: this.state!= 'error'&&this.state!= 'AUDIT_REJECT'&&this.state!= 'CANCEL'&&this.state!= 'WAIT_PAY' ? '#066cff':'#e61100',
  258. })
  259. // 获取明细列表
  260. this.getDetailList()
  261. },
  262. // 实时查询详情
  263. getDetail(){
  264. purchaseQueryPage({pageNo:1,pageSize:1,purchaseSn: this.purchaseSn}).then(res => {
  265. const data = res.data ? res.data.list[0] : null
  266. if(data){
  267. data.billStatus = data.billStatus == 'WAIT_AUDIT'&&data.payOnlineFlag==1&&data.payInfo&&data.payInfo.payState=='WAIT'?'WAIT_PAY':data.billStatus
  268. this.pageInit(data)
  269. }
  270. })
  271. },
  272. getRow(pageNo){
  273. this.pageNo = pageNo
  274. this.getDetailList()
  275. },
  276. getDetailList(){
  277. uni.showLoading({
  278. title: '加载中'
  279. })
  280. purchaseQueryDetailPage({purchaseSn: this.purchaseSn,pageNo:this.pageNo,pageSize:this.pageSize}).then(res => {
  281. if(res.status == 200){
  282. this.partList = res.data ? res.data.list : []
  283. // 是否有赠品
  284. const giftList = this.partList.filter(item => item.promoProductType == 'GIFT_PRODUCT')
  285. // 正品
  286. this.partList = this.partList.filter(item => item.promoProductType !== 'GIFT_PRODUCT')
  287. this.partList.map(item=>{
  288. // 关联赠品
  289. item.giftObj = giftList.find(gift => gift.purchaseDetailParentSn == item.purchaseDetailSn)
  290. item.priceStr = Number(item.price).toFixed(2).toString().split('.')
  291. })
  292. this.total = res.data ? res.data.count : 0
  293. }
  294. // 滚动到顶部
  295. this.$nextTick(()=>{
  296. uni.pageScrollTo({
  297. scrollTop: 0,
  298. duration: 300
  299. });
  300. uni.hideLoading()
  301. })
  302. })
  303. },
  304. message(title){
  305. uni.showToast({
  306. icon:'none',
  307. title: title
  308. })
  309. },
  310. // 取消订单
  311. cancelOrder(item){
  312. let _this = this
  313. uni.showModal({
  314. title: '提示',
  315. content: !item.payOk ? '确定取消订单吗?':'取消后订单金额将于1-3个工作日到账(原路返回)?',
  316. success: function (res) {
  317. if (res.confirm) {
  318. purchaseCancel({purchaseSn:_this.purchaseSn}).then(res => {
  319. if (res.status == 200) {
  320. _this.message('取消成功')
  321. uni.$emit('refreshPurcaOrder',item,'CANCEL')
  322. uni.navigateBack()
  323. } else {
  324. _this.message(res.message)
  325. }
  326. })
  327. }
  328. }
  329. });
  330. },
  331. // 倒计时结束,取消订单刷新页面
  332. countDownEnd(){
  333. this.showPopu = false
  334. const _this = this
  335. uni.showModal({
  336. title: '提示',
  337. content: '订单超过30分钟已自动取消',
  338. showCancel:false,
  339. confirmText:'知道了',
  340. success: function (res) {
  341. uni.$emit('refreshPurcaOrder',_this.info,'CANCEL')
  342. _this.state = 'CANCEL'
  343. _this.info.billStatus = 'CANCEL'
  344. _this.statusText = '已取消'
  345. _this.statusIcon = 'close-circle'
  346. _this.statusMessage = '订单超过30分钟已自动取消'
  347. _this.info.cancelDate = moment().format('YYYY-MM-DD hh:mm:ss')
  348. // 更改标题栏背景色
  349. uni.setNavigationBarColor({
  350. frontColor: '#ffffff',
  351. backgroundColor: '#e61100',
  352. })
  353. }
  354. });
  355. },
  356. // 立即支付
  357. payOrder(item){
  358. uni.showLoading({
  359. title: '加载中...'
  360. })
  361. purchasePay({
  362. bizSn:item.purchaseSn,
  363. bizNo:item.purchaseNo,
  364. bizType:'PURCHASE',
  365. payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid')
  366. }).then(res=>{
  367. this.showPopu = true
  368. this.payData = res.data?res.data.payRequestRest:null
  369. uni.hideLoading()
  370. })
  371. },
  372. // 付款成功,isOk: false 取消支付或支付失败,true 支付完成
  373. payComplete(item,isOk){
  374. this.showPopu = false
  375. if(isOk){
  376. uni.$emit('refreshPurcaOrder',item,'WAIT_AUDIT')
  377. uni.navigateBack()
  378. }
  379. },
  380. // 再次购买
  381. buyAgain(item){
  382. },
  383. // 确认收货
  384. receiveOrder(item){
  385. let _this = this
  386. uni.showModal({
  387. title: '提示',
  388. content: '确定收货吗?',
  389. success: function (res) {
  390. if (res.confirm) {
  391. purchaseReceive({purchaseSn:_this.purchaseSn}).then(res => {
  392. if (res.status == 200) {
  393. _this.message('收货成功')
  394. uni.$emit('refreshPurcaOrder',item,'FINISH')
  395. uni.navigateBack()
  396. } else {
  397. _this.message(res.message)
  398. }
  399. })
  400. }
  401. }
  402. });
  403. },
  404. }
  405. }
  406. </script>
  407. <style lang="less">
  408. page{
  409. height: 100%;
  410. }
  411. .orderDetail-digitalShel{
  412. height: 100%;
  413. .redText{
  414. color: #FB1E1E;
  415. margin: 0 10rpx;
  416. }
  417. .cText{
  418. color: #666;
  419. margin: 0 6rpx;
  420. font-size: 14px;
  421. }
  422. .gray-text{
  423. text{
  424. font-size: 14px;
  425. color: #999;
  426. }
  427. }
  428. .order-body{
  429. flex-grow: 1;
  430. overflow: auto;
  431. .partList{
  432. margin-top: 20rpx;
  433. }
  434. }
  435. .contHead {
  436. .statusH{
  437. > view{
  438. padding: 10upx 12%;
  439. font-size: 34upx;
  440. }
  441. .status-row{
  442. font-size: 42upx;
  443. text{
  444. margin-left: 10rpx;
  445. }
  446. }
  447. .messageText{
  448. font-size: 28upx;
  449. text-align: center;
  450. text{
  451. color: #f3e781;
  452. }
  453. padding: 20rpx 0;
  454. }
  455. }
  456. }
  457. .price-txt{
  458. color: red;
  459. display: flex;
  460. align-items: baseline;
  461. font-size: 12px;
  462. text{
  463. font-size: 32rpx;
  464. }
  465. }
  466. .info{
  467. background-color: #FFFFFF;
  468. padding: 10rpx 30upx;
  469. font-size: 32rpx;
  470. margin-bottom: 20rpx;
  471. .infoList{
  472. display: flex;
  473. justify-content: space-between;
  474. align-items: center;
  475. padding: 20rpx 0;
  476. border-bottom: 2rpx solid #f2f2f2;
  477. &:last-child{
  478. border: none;
  479. }
  480. .title{
  481. font-weight: bold;
  482. > text{
  483. color: #ff9808;
  484. font-size: 24upx;
  485. }
  486. }
  487. > text{
  488. &:first-child{
  489. color: #666E75;
  490. }
  491. }
  492. }
  493. .item-list-box{
  494. border-bottom: 2rpx solid #f2f2f2;
  495. &:last-child{
  496. border: none;
  497. }
  498. }
  499. .item-list{
  500. padding: 20rpx 0;
  501. > view{
  502. &:first-child{
  503. margin-right: 20rpx;
  504. position: relative;
  505. overflow: hidden;
  506. width: 160rpx;
  507. height: 160rpx;
  508. border-radius: 6px;
  509. border: 1px solid #eee;
  510. }
  511. &:last-child{
  512. flex-grow: 1;
  513. width: 60%;
  514. }
  515. }
  516. .item-name{
  517. word-wrap: break-word;
  518. font-size: 28rpx;
  519. color: #333;
  520. font-weight: bold;
  521. }
  522. .item-nums{
  523. text{
  524. font-size: 28rpx;
  525. color: #666;
  526. }
  527. }
  528. .item-head{
  529. display: flex;
  530. align-items: center;
  531. justify-content: space-between;
  532. color: #666;
  533. margin-top: 5px;
  534. > view:last-child{
  535. font-size: 24rpx;
  536. text{
  537. margin: 0 10rpx;
  538. font-size: 28rpx;
  539. }
  540. }
  541. }
  542. .rebate-tag{
  543. background: #ffe7df;
  544. color: #E91E63;
  545. padding: 2px 5px;
  546. font-size: 10px;
  547. border-radius: 3px;
  548. margin-left: 6px;
  549. }
  550. .tejia-tag{
  551. color: #E91E63;
  552. margin-left: 6px;
  553. font-size: 12px;
  554. text{
  555. font-size: 12px;
  556. color: #999;
  557. margin-left: 5px;
  558. text-decoration: line-through;
  559. }
  560. }
  561. }
  562. }
  563. .gift-box.item-list{
  564. .item-name{
  565. color: #666;
  566. font-size: 12px;
  567. font-weight: normal;
  568. }
  569. .item-nums{
  570. text{
  571. color: #666;
  572. font-size: 12px;
  573. }
  574. }
  575. .rebate-tag{
  576. margin-left: 0;
  577. margin-right: 5px;
  578. }
  579. .ellipsis-one{
  580. flex-grow: 1;
  581. width:80%;
  582. }
  583. }
  584. .footer{
  585. padding: 20upx;
  586. background: #FFFFFF;
  587. }
  588. }
  589. </style>