order-review.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="container">
  3. <view v-if="loading" class="loading-wrap">
  4. <text class="loading-text">加载中...</text>
  5. </view>
  6. <scroll-view v-else scroll-y class="content">
  7. <!-- 订单头 -->
  8. <view class="order-header-section">
  9. <view class="order-no-row">
  10. <text class="order-no">订单号:{{ order.orderNo }}</text>
  11. <text class="status-tag">{{ statusLabel(order.status) }}</text>
  12. </view>
  13. <text class="order-hint">订单尚未支付,可进行审核修改</text>
  14. </view>
  15. <!-- 商品信息 -->
  16. <view class="section">
  17. <text class="section-title">商品信息</text>
  18. <view class="product-card">
  19. <image class="product-cover" :src="order.coverImage || ''" mode="aspectFill" />
  20. <view class="product-info-wrap">
  21. <text class="product-name">{{ order.productName }}</text>
  22. <text class="product-qty">x{{ order.quantity || 1 }}</text>
  23. <text class="product-price">¥{{ formatPrice(order.unitPrice) }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 修改价格 -->
  28. <view class="section">
  29. <text class="section-title">修改价格</text>
  30. <view class="edit-row" @click="showPriceInput">
  31. <text class="edit-label">当前单价</text>
  32. <text class="edit-value">{{ formatPrice(order.unitPrice) }}</text>
  33. <text class="edit-hint">点击修改</text>
  34. </view>
  35. <view v-if="priceInput" class="price-input-row">
  36. <text class="input-label">新单价(元)</text>
  37. <input class="price-input" type="digit" v-model="newUnitPrice" placeholder="输入新单价" />
  38. <text class="price-preview">新总价:¥{{ formatPrice(newUnitPrice * (order.quantity || 1)) }}</text>
  39. </view>
  40. </view>
  41. <!-- 修改配送方式 -->
  42. <view class="section">
  43. <text class="section-title">修改配送方式</text>
  44. <view class="edit-row" @click="showDeliveryInput">
  45. <text class="edit-label">当前配送方式</text>
  46. <text class="edit-value">{{ deliveryLabel(order.deliveryMethod) }}</text>
  47. <text class="edit-hint">点击修改</text>
  48. </view>
  49. <view v-if="deliveryInput" class="delivery-options">
  50. <view class="delivery-option" :class="newDeliveryMethod === 1 ? 'selected' : ''" @click="newDeliveryMethod = 1">
  51. <text>快递配送</text>
  52. </view>
  53. <view class="delivery-option" :class="newDeliveryMethod === 2 ? 'selected' : ''" @click="newDeliveryMethod = 2">
  54. <text>自提</text>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 添加优惠券 -->
  59. <view class="section">
  60. <text class="section-title">添加优惠券</text>
  61. <view v-if="!order.couponId" class="edit-row" @click="showCouponInput">
  62. <text class="edit-label">优惠券</text>
  63. <text class="edit-value">未使用</text>
  64. <text class="edit-hint">点击添加</text>
  65. </view>
  66. <view v-else class="coupon-info">
  67. <text class="coupon-tag">已添加优惠券</text>
  68. </view>
  69. <view v-if="couponInput" class="coupon-input-row">
  70. <text class="input-label">优惠券金额(元)</text>
  71. <input class="coupon-input" type="digit" v-model="couponValue" placeholder="输入优惠券金额" />
  72. </view>
  73. </view>
  74. <!-- 添加赠品 -->
  75. <view class="section">
  76. <text class="section-title">添加赠品</text>
  77. <view class="edit-row" @click="showGiftInput">
  78. <text class="edit-label">当前赠品</text>
  79. <text class="edit-value">{{ giftCount }} 件</text>
  80. <text class="edit-hint">点击添加</text>
  81. </view>
  82. <view v-if="giftInput" class="gift-input-row">
  83. <input class="gift-input" type="text" v-model="giftProductName" placeholder="赠品名称" />
  84. <input class="gift-input" type="text" v-model="giftProductImage" placeholder="赠品图片URL(选填)" />
  85. <view class="gift-add-btn" @click="addGift">+ 添加</view>
  86. </view>
  87. <view v-if="giftList.length > 0" class="gift-list">
  88. <view v-for="gift in giftList" :key="gift.id" class="gift-item">
  89. <image class="gift-img" :src="gift.giftProductImage || ''" mode="aspectFill" />
  90. <text class="gift-name">{{ gift.giftProductName }}</text>
  91. <text class="gift-qty">x{{ gift.quantity }}</text>
  92. </view>
  93. </view>
  94. </view>
  95. <!-- 修改备注 -->
  96. <view class="section">
  97. <text class="section-title">修改备注</text>
  98. <textarea class="remark-textarea" v-model="remarkInput" placeholder="输入修改原因或备注(选填)" maxlength="200" />
  99. </view>
  100. <!-- 修改历史 -->
  101. <view v-if="order.remark" class="section">
  102. <text class="section-title">修改记录</text>
  103. <text class="remark-history">{{ order.remark }}</text>
  104. </view>
  105. </scroll-view>
  106. <!-- 底部操作栏 -->
  107. <view class="bottom-bar">
  108. <button class="btn-save" @click="onSave">保存修改</button>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import { productOrderDetail, productOrderReviewUpdate } from '@/utils/api.js'
  114. export default {
  115. data() {
  116. return {
  117. order: {},
  118. loading: false,
  119. orderNo: '',
  120. priceInput: false,
  121. newUnitPrice: '',
  122. deliveryInput: false,
  123. newDeliveryMethod: null,
  124. couponInput: false,
  125. couponValue: '',
  126. giftInput: false,
  127. giftList: [],
  128. giftProductName: '',
  129. giftProductImage: '',
  130. remarkInput: ''
  131. }
  132. },
  133. onLoad(options) {
  134. if (options.orderNo) {
  135. this.orderNo = options.orderNo
  136. this.loadDetail()
  137. }
  138. },
  139. computed: {
  140. giftCount() {
  141. return this.giftList.length
  142. }
  143. },
  144. methods: {
  145. loadDetail() {
  146. this.loading = true
  147. productOrderDetail({ orderNo: this.orderNo }).then(res => {
  148. this.loading = false
  149. if (res.code === 200 && res.data) {
  150. this.order = res.data
  151. } else {
  152. uni.showToast({ title: res.message || '加载失败', icon: 'none' })
  153. }
  154. }).catch(function () {
  155. this.loading = false
  156. })
  157. },
  158. showPriceInput() {
  159. this.priceInput = true
  160. this.newUnitPrice = String(this.order.unitPrice ? Math.round(this.order.unitPrice / 100) : '')
  161. },
  162. showDeliveryInput() {
  163. this.deliveryInput = true
  164. this.newDeliveryMethod = this.order.deliveryMethod
  165. },
  166. showCouponInput() {
  167. this.couponInput = true
  168. this.couponValue = ''
  169. },
  170. showGiftInput() {
  171. this.giftInput = true
  172. this.giftProductName = ''
  173. this.giftProductImage = ''
  174. },
  175. addGift() {
  176. if (!this.giftProductName) {
  177. uni.showToast({ title: '请填写赠品名称', icon: 'none' })
  178. return
  179. }
  180. this.giftList.push({
  181. id: Date.now(),
  182. giftType: 'product',
  183. giftProductName: this.giftProductName,
  184. giftProductImage: this.giftProductImage,
  185. quantity: 1
  186. })
  187. this.giftProductName = ''
  188. this.giftProductImage = ''
  189. },
  190. onSave() {
  191. var params = { orderNo: this.orderNo }
  192. if (this.priceInput && this.newUnitPrice) {
  193. params.unitPrice = parseInt(this.newUnitPrice) * 100
  194. }
  195. if (this.deliveryInput && this.newDeliveryMethod != null) {
  196. params.deliveryMethod = this.newDeliveryMethod
  197. }
  198. if (this.couponInput && this.couponValue && parseInt(this.couponValue) > 0) {
  199. params.couponType = 'ONE_TIME'
  200. params.couponValue = parseInt(this.couponValue) * 100
  201. }
  202. if (this.giftList.length > 0) {
  203. params.giftItems = this.giftList
  204. }
  205. if (this.remarkInput) {
  206. params.remark = this.remarkInput
  207. }
  208. if (!params.unitPrice && !params.deliveryMethod && !params.couponValue && !params.giftItems) {
  209. uni.showToast({ title: '请至少修改一项', icon: 'none' })
  210. return
  211. }
  212. uni.showLoading({ title: '保存中...' })
  213. productOrderReviewUpdate(params).then(function (res) {
  214. uni.hideLoading()
  215. if (res.code === 200) {
  216. uni.showToast({ title: '修改已保存', icon: 'success' })
  217. setTimeout(function () {
  218. uni.navigateBack()
  219. }, 1500)
  220. } else {
  221. uni.showToast({ title: res.message || '保存失败', icon: 'none' })
  222. }
  223. }).catch(function () {
  224. uni.hideLoading()
  225. uni.showToast({ title: '网络错误', icon: 'none' })
  226. })
  227. },
  228. statusLabel(status) {
  229. var map = { pending: '待支付', paid: '已支付', completed: '已完成', cancelled: '已取消' }
  230. return map[status] || status
  231. },
  232. deliveryLabel(method) {
  233. var map = { 1: '快递配送', 2: '自提', 3: '快递/自提可选', 4: '线上-可选人', 5: '线上-单人' }
  234. return map[method] || '未知'
  235. },
  236. formatPrice(value) {
  237. if (!value && value !== 0) return '-'
  238. return (value / 100).toFixed(2)
  239. }
  240. }
  241. }
  242. </script>
  243. <style scoped>
  244. .container {
  245. min-height: 100vh;
  246. background: #f5f5f5;
  247. display: flex;
  248. flex-direction: column;
  249. }
  250. .loading-wrap {
  251. display: flex;
  252. justify-content: center;
  253. padding-top: 200rpx;
  254. }
  255. .loading-text {
  256. font-size: 28rpx;
  257. color: #999;
  258. }
  259. .content {
  260. flex: 1;
  261. height: calc(100vh - 120rpx);
  262. padding-bottom: 120rpx;
  263. }
  264. .order-header-section {
  265. background: linear-gradient(135deg, #F97316, #FB923C);
  266. padding: 40rpx 30rpx;
  267. }
  268. .order-no-row {
  269. display: flex;
  270. justify-content: space-between;
  271. align-items: center;
  272. margin-bottom: 12rpx;
  273. }
  274. .order-no {
  275. font-size: 26rpx;
  276. color: rgba(255,255,255,0.85);
  277. }
  278. .status-tag {
  279. font-size: 24rpx;
  280. padding: 6rpx 20rpx;
  281. border-radius: 20rpx;
  282. background: rgba(255,255,255,0.25);
  283. color: #fff;
  284. }
  285. .order-hint {
  286. font-size: 24rpx;
  287. color: rgba(255,255,255,0.75);
  288. }
  289. .section {
  290. background: #fff;
  291. margin: 20rpx;
  292. border-radius: 16rpx;
  293. padding: 24rpx;
  294. }
  295. .section-title {
  296. font-size: 28rpx;
  297. font-weight: bold;
  298. color: #333;
  299. margin-bottom: 20rpx;
  300. display: block;
  301. }
  302. .product-card {
  303. display: flex;
  304. gap: 20rpx;
  305. align-items: center;
  306. }
  307. .product-cover {
  308. width: 160rpx;
  309. height: 160rpx;
  310. border-radius: 10rpx;
  311. background: #eee;
  312. flex-shrink: 0;
  313. }
  314. .product-info-wrap {
  315. flex: 1;
  316. }
  317. .product-name {
  318. display: block;
  319. font-size: 28rpx;
  320. color: #333;
  321. margin-bottom: 8rpx;
  322. }
  323. .product-qty {
  324. font-size: 24rpx;
  325. color: #999;
  326. margin-bottom: 8rpx;
  327. }
  328. .product-price {
  329. font-size: 30rpx;
  330. color: #F97316;
  331. font-weight: bold;
  332. }
  333. .edit-row {
  334. display: flex;
  335. justify-content: space-between;
  336. align-items: center;
  337. padding: 16rpx 0;
  338. }
  339. .edit-label {
  340. font-size: 26rpx;
  341. color: #666;
  342. }
  343. .edit-value {
  344. font-size: 26rpx;
  345. color: #333;
  346. }
  347. .edit-hint {
  348. font-size: 24rpx;
  349. color: #F97316;
  350. }
  351. .price-input-row,
  352. .coupon-input-row {
  353. margin-top: 16rpx;
  354. padding-top: 16rpx;
  355. border-top: 1rpx solid #f5f5f5;
  356. }
  357. .input-label {
  358. font-size: 26rpx;
  359. color: #666;
  360. margin-bottom: 12rpx;
  361. display: block;
  362. }
  363. .price-input,
  364. .coupon-input {
  365. border: 1rpx solid #ddd;
  366. border-radius: 8rpx;
  367. padding: 12rpx 20rpx;
  368. font-size: 28rpx;
  369. margin-bottom: 12rpx;
  370. width: 100%;
  371. box-sizing: border-box;
  372. }
  373. .price-preview,
  374. .coupon-preview {
  375. font-size: 26rpx;
  376. color: #F97316;
  377. }
  378. .delivery-options {
  379. display: flex;
  380. gap: 20rpx;
  381. margin-top: 16rpx;
  382. }
  383. .delivery-option {
  384. flex: 1;
  385. text-align: center;
  386. padding: 16rpx;
  387. border-radius: 8rpx;
  388. border: 1rpx solid #ddd;
  389. font-size: 26rpx;
  390. color: #333;
  391. }
  392. .delivery-option.selected {
  393. border-color: #F97316;
  394. color: #F97316;
  395. background: #fff7e6;
  396. }
  397. .coupon-info {
  398. padding: 16rpx 0;
  399. }
  400. .coupon-tag {
  401. font-size: 26rpx;
  402. color: #52c41a;
  403. background: #f6ffed;
  404. padding: 8rpx 20rpx;
  405. border-radius: 8rpx;
  406. }
  407. .gift-input-row {
  408. margin-top: 16rpx;
  409. display: flex;
  410. flex-direction: column;
  411. gap: 12rpx;
  412. }
  413. .gift-input {
  414. border: 1rpx solid #ddd;
  415. border-radius: 8rpx;
  416. padding: 12rpx 20rpx;
  417. font-size: 26rpx;
  418. }
  419. .gift-add-btn {
  420. background: #F97316;
  421. color: #fff;
  422. text-align: center;
  423. padding: 16rpx;
  424. border-radius: 8rpx;
  425. font-size: 26rpx;
  426. margin-top: 12rpx;
  427. }
  428. .gift-list {
  429. margin-top: 16rpx;
  430. }
  431. .gift-item {
  432. display: flex;
  433. align-items: center;
  434. gap: 16rpx;
  435. padding: 12rpx 0;
  436. border-bottom: 1rpx solid #f5f5f5;
  437. }
  438. .gift-img {
  439. width: 60rpx;
  440. height: 60rpx;
  441. border-radius: 8rpx;
  442. background: #eee;
  443. }
  444. .gift-name {
  445. font-size: 24rpx;
  446. color: #333;
  447. flex: 1;
  448. }
  449. .gift-qty {
  450. font-size: 24rpx;
  451. color: #999;
  452. }
  453. .remark-textarea {
  454. width: 100%;
  455. height: 120rpx;
  456. border: 1rpx solid #ddd;
  457. border-radius: 8rpx;
  458. padding: 16rpx;
  459. font-size: 26rpx;
  460. box-sizing: border-box;
  461. }
  462. .remark-history {
  463. font-size: 24rpx;
  464. color: #666;
  465. line-height: 1.6;
  466. }
  467. .bottom-bar {
  468. position: fixed;
  469. bottom: 0;
  470. left: 0;
  471. right: 0;
  472. height: 100rpx;
  473. background: #fff;
  474. border-top: 1rpx solid #eee;
  475. display: flex;
  476. align-items: center;
  477. justify-content: flex-end;
  478. padding: 0 30rpx;
  479. z-index: 100;
  480. }
  481. .btn-save {
  482. background: linear-gradient(135deg, #F97316, #FB923C);
  483. color: #fff;
  484. font-size: 28rpx;
  485. padding: 0 60rpx;
  486. height: 72rpx;
  487. line-height: 72rpx;
  488. border-radius: 36rpx;
  489. border: none;
  490. }
  491. .btn-save::after {
  492. border: none;
  493. }
  494. </style>