You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
4.5 KiB

  1. <template>
  2. <uv-popup ref="popup" :safeAreaInsetBottom="false" :round="10">
  3. <view class="cancel-popup">
  4. <view class="popup-content">
  5. <view class="popup-header">
  6. <text class="popup-title">取消订单</text>
  7. </view>
  8. <view class="popup-body">
  9. <text class="popup-text">请添加客服微信方便为您解决订单疑问或退订服务</text>
  10. <view class="qrcode-container">
  11. <image class="qrcode-image" :src="qrCodeUrl" mode="aspectFit" :show-menu-by-longpress="true"></image>
  12. </view>
  13. <text class="popup-text">取消订单原因选填</text>
  14. <view class="reason-container">
  15. <textarea class="reason-input" v-model="cancelReason" placeholder="请填写取消原因,方便我们提升服务"></textarea>
  16. </view>
  17. </view>
  18. <view class="popup-footer">
  19. <view class="popup-btn cancel-btn" @click="close">
  20. <text>不取消</text>
  21. </view>
  22. <view class="popup-btn confirm-btn" @click="confirmCancel">
  23. <text>确认取消</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </uv-popup>
  29. </template>
  30. <script>
  31. import { orderCancel } from "@/api/order/order.js"
  32. export default {
  33. props: {
  34. qrCodeUrl: {
  35. type: String,
  36. default: 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/details/QR_Code.png'
  37. }
  38. },
  39. data(){
  40. return {
  41. order : {},
  42. cancelReason: '',
  43. }
  44. },
  45. methods: {
  46. // 打开弹窗
  47. open(order){
  48. this.order = order;
  49. this.$refs.popup.open();
  50. },
  51. // 关闭弹窗
  52. close() {
  53. this.cancelReason = ''; // 清空取消原因
  54. this.$refs.popup.close();
  55. },
  56. // 确认取消订单
  57. confirmCancel() {
  58. if (!this.order || !this.order.orderId) {
  59. uni.showToast({
  60. title: '订单信息不完整',
  61. icon: 'none'
  62. });
  63. return;
  64. }
  65. // 显示加载中
  66. uni.showLoading({
  67. title: '处理中...'
  68. });
  69. // 调用取消订单API
  70. orderCancel({
  71. id : this.order.orderId,
  72. idList : [this.order.orderId],
  73. remark : this.cancelReason,
  74. }).then(res => {
  75. uni.hideLoading();
  76. if (res && res.code === 200) {
  77. // 成功
  78. uni.showToast({
  79. title: '订单已取消',
  80. icon: 'success'
  81. });
  82. // 通知父组件订单已取消
  83. this.$emit('cancel', this.order, this.cancelReason);
  84. // 关闭弹窗
  85. this.close();
  86. } else {
  87. // 失败
  88. uni.showToast({
  89. title: res?.msg || '取消失败,请联系客服',
  90. icon: 'none'
  91. });
  92. }
  93. }).catch(error => {
  94. uni.hideLoading();
  95. uni.showToast({
  96. title: '取消失败,请稍后再试',
  97. icon: 'none'
  98. });
  99. });
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .cancel-popup {
  106. // position: fixed;
  107. // top: 0;
  108. // left: 0;
  109. // right: 0;
  110. // bottom: 0;
  111. // z-index: 999;
  112. display: flex;
  113. justify-content: center;
  114. align-items: center;
  115. .popup-content {
  116. position: relative;
  117. width: 600rpx;
  118. background-color: #FFFFFF;
  119. border-radius: 12rpx;
  120. overflow: hidden;
  121. z-index: 1000;
  122. }
  123. .popup-header {
  124. padding: 30rpx;
  125. text-align: center;
  126. background-color: #FFAA48;
  127. }
  128. .popup-title {
  129. font-size: 32rpx;
  130. font-weight: bold;
  131. color: #fff;
  132. }
  133. .popup-body {
  134. padding: 30rpx;
  135. display: flex;
  136. flex-direction: column;
  137. align-items: center;
  138. }
  139. .popup-text {
  140. font-size: 28rpx;
  141. color: #333333;
  142. margin-bottom: 20rpx;
  143. text-align: center;
  144. }
  145. .popup-subtext {
  146. font-size: 24rpx;
  147. color: #999999;
  148. margin-bottom: 20rpx;
  149. text-align: center;
  150. }
  151. .qrcode-container {
  152. width: 300rpx;
  153. height: 300rpx;
  154. margin: 20rpx 0;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. }
  159. .qrcode-image {
  160. width: 100%;
  161. height: 100%;
  162. }
  163. .popup-footer {
  164. display: flex;
  165. border-top: 1px solid #EEEEEE;
  166. }
  167. .popup-btn {
  168. flex: 1;
  169. padding: 30rpx 0;
  170. text-align: center;
  171. font-size: 28rpx;
  172. }
  173. .cancel-btn {
  174. color: #666666;
  175. border-right: 1px solid #EEEEEE;
  176. }
  177. .confirm-btn {
  178. color: #FFAA48;
  179. }
  180. .reason-container {
  181. width: 100%;
  182. margin-bottom: 20rpx;
  183. background-color: #F7F7F7;
  184. border-radius: 8rpx;
  185. }
  186. .reason-input {
  187. width: 100%;
  188. height: 150rpx;
  189. font-size: 28rpx;
  190. color: #666;
  191. line-height: 1.5;
  192. padding: 20rpx;
  193. }
  194. }
  195. </style>