cancelModel.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <Popup title="你想取消付款嘛" isClose ref="popRef">
  3. <template #content>
  4. <view class="content">
  5. <view class="tips">
  6. <trans _t="订单取消后无法恢复,请选择取消付款的原因" />
  7. </view>
  8. <up-textarea
  9. v-model="form.cancelReason"
  10. :placeholder="t('请输入取消原因')"
  11. count
  12. maxlength="200"
  13. class="u-textarea"
  14. ></up-textarea>
  15. <!-- 快捷词条 -->
  16. <view class="quick-phrases">
  17. <view
  18. v-for="(phrase, index) in phrases"
  19. :key="index"
  20. class="phrase-tag"
  21. @click="insertPhrase(phrase)"
  22. >
  23. {{ t(phrase) }}
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <!-- footer -->
  29. <template #footer>
  30. <view class="footer">
  31. <view class="submit_btn submit_close" @click="close">
  32. <trans _t="取消" />
  33. </view>
  34. <view class="submit_btn" @click="submit">
  35. <trans _t="确认" />
  36. </view>
  37. </view>
  38. </template>
  39. </Popup>
  40. </template>
  41. <script setup>
  42. import { reactive, ref, nextTick } from "vue";
  43. import Popup from "@/components/popup.vue";
  44. import { t } from "@/locale";
  45. import { SHOP_ORDER_CANCEL } from "@/api";
  46. import { Toast } from "@/utils";
  47. import { useTabbarStore } from "@/store";
  48. const useTabbar = useTabbarStore();
  49. const props = defineProps({
  50. oid: { type: String, default: "" },
  51. });
  52. const form = reactive({
  53. orderid: 0,
  54. cancelReason: "",
  55. });
  56. const emit = defineEmits(["open", "close"]);
  57. const popRef = ref(null);
  58. // 快捷词条列表
  59. const phrases = ref(["不想要了", "买错了", "价格太贵"]);
  60. // 插入词条方法
  61. const insertPhrase = (phrase) => {
  62. if (!form.cancelReason || form.cancelReason.endsWith(" ")) {
  63. form.cancelReason += t(phrase);
  64. } else {
  65. form.cancelReason += `,${t(phrase)}`;
  66. }
  67. };
  68. const open = (id = 0) => {
  69. form.orderid = id;
  70. form.cancelReason = "";
  71. emit("open");
  72. popRef.value && popRef.value.open();
  73. };
  74. const close = () => {
  75. emit("close");
  76. popRef.value && popRef.value.close();
  77. };
  78. const submit = async () => {
  79. if (!form.cancelReason) {
  80. Toast(t("请输入取消原因"));
  81. return;
  82. }
  83. try {
  84. let res = await SHOP_ORDER_CANCEL(form);
  85. close();
  86. Toast(res.msg, 1000).then(() => {
  87. setTimeout(() => {
  88. uni.switchTab({ url: "/pages/order/index" });
  89. useTabbar.getPageCur("order");
  90. }, 1000);
  91. });
  92. } catch (error) {
  93. Toast(error.msg);
  94. }
  95. };
  96. defineExpose({ open, close });
  97. </script>
  98. <style lang="less" scoped>
  99. @import url("@/style.less");
  100. .content {
  101. width: 100%;
  102. .tips {
  103. color: var(--text-01);
  104. .size(24rpx);
  105. margin: 24rpx 0;
  106. }
  107. .u-textarea {
  108. width: 100%;
  109. height: 200rpx;
  110. background-color: var(--inputBg);
  111. border-radius: 16rpx;
  112. padding: 16rpx;
  113. color: var(--text-01);
  114. .size(24rpx);
  115. box-sizing: border-box;
  116. /deep/ .u-textarea__content {
  117. min-height: 100%;
  118. line-height: 32rpx;
  119. color: var(--text-01);
  120. }
  121. }
  122. .quick-phrases {
  123. display: flex;
  124. flex-wrap: wrap;
  125. gap: 20rpx;
  126. margin-top: 10rpx;
  127. }
  128. .phrase-tag {
  129. padding: 12rpx 24rpx;
  130. background-color: #f0f7ff;
  131. border-radius: 40rpx;
  132. color: #2979ff;
  133. font-size: 26rpx;
  134. border: 1rpx solid #d9e6ff;
  135. }
  136. .phrase-tag:active {
  137. background-color: #e1eeff;
  138. transform: scale(0.98);
  139. }
  140. }
  141. .footer {
  142. .hor(space-between);
  143. column-gap: 20rpx;
  144. .submit_btn {
  145. height: 76rpx;
  146. padding: 16rpx 100rpx;
  147. background-color: var(--black);
  148. color: var(--light);
  149. .flex_center();
  150. border-radius: 16rpx;
  151. .size(24rpx);
  152. &.submit_close {
  153. background-color: var(--bg);
  154. border: 1rpx solid var(--black);
  155. color: var(--black);
  156. }
  157. }
  158. }
  159. </style>