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.

215 lines
4.4 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 { cancelOrder } from "@/api/system/user.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.id) {
  59. uni.showToast({
  60. title: '订单信息不完整',
  61. icon: 'none'
  62. });
  63. return;
  64. }
  65. // 显示加载中
  66. uni.showLoading({
  67. title: '处理中...'
  68. });
  69. // 调用取消订单API
  70. cancelOrder(this.order.id, this.cancelReason).then(res => {
  71. uni.hideLoading();
  72. if (res && res.code === 200) {
  73. // 成功
  74. uni.showToast({
  75. title: '订单已取消',
  76. icon: 'success'
  77. });
  78. // 通知父组件订单已取消
  79. this.$emit('cancel', this.order, this.cancelReason);
  80. // 关闭弹窗
  81. this.close();
  82. } else {
  83. // 失败
  84. uni.showToast({
  85. title: res?.msg || '取消失败,请联系客服',
  86. icon: 'none'
  87. });
  88. }
  89. }).catch(error => {
  90. uni.hideLoading();
  91. uni.showToast({
  92. title: '取消失败,请稍后再试',
  93. icon: 'none'
  94. });
  95. });
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .cancel-popup {
  102. // position: fixed;
  103. // top: 0;
  104. // left: 0;
  105. // right: 0;
  106. // bottom: 0;
  107. // z-index: 999;
  108. display: flex;
  109. justify-content: center;
  110. align-items: center;
  111. .popup-content {
  112. position: relative;
  113. width: 600rpx;
  114. background-color: #FFFFFF;
  115. border-radius: 12rpx;
  116. overflow: hidden;
  117. z-index: 1000;
  118. }
  119. .popup-header {
  120. padding: 30rpx;
  121. text-align: center;
  122. background-color: #FFAA48;
  123. }
  124. .popup-title {
  125. font-size: 32rpx;
  126. font-weight: bold;
  127. color: #fff;
  128. }
  129. .popup-body {
  130. padding: 30rpx;
  131. display: flex;
  132. flex-direction: column;
  133. align-items: center;
  134. }
  135. .popup-text {
  136. font-size: 28rpx;
  137. color: #333333;
  138. margin-bottom: 20rpx;
  139. text-align: center;
  140. }
  141. .popup-subtext {
  142. font-size: 24rpx;
  143. color: #999999;
  144. margin-bottom: 20rpx;
  145. text-align: center;
  146. }
  147. .qrcode-container {
  148. width: 300rpx;
  149. height: 300rpx;
  150. margin: 20rpx 0;
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. }
  155. .qrcode-image {
  156. width: 100%;
  157. height: 100%;
  158. }
  159. .popup-footer {
  160. display: flex;
  161. border-top: 1px solid #EEEEEE;
  162. }
  163. .popup-btn {
  164. flex: 1;
  165. padding: 30rpx 0;
  166. text-align: center;
  167. font-size: 28rpx;
  168. }
  169. .cancel-btn {
  170. color: #666666;
  171. border-right: 1px solid #EEEEEE;
  172. }
  173. .confirm-btn {
  174. color: #FFAA48;
  175. }
  176. .reason-container {
  177. width: 100%;
  178. margin-bottom: 20rpx;
  179. background-color: #F7F7F7;
  180. border-radius: 8rpx;
  181. }
  182. .reason-input {
  183. width: 100%;
  184. height: 150rpx;
  185. font-size: 28rpx;
  186. color: #666;
  187. line-height: 1.5;
  188. padding: 20rpx;
  189. }
  190. }
  191. </style>