stock-shortage-popup.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <u-popup v-model="show" mode="bottom" border-radius="24" height="600rpx">
  3. <view class="stock-shortage-popup">
  4. <view class="popup-header">
  5. <text>如遇缺货</text>
  6. <u-icon name="close" size="28" color="#999" class="close-icon" @click="close"></u-icon>
  7. </view>
  8. <view class="option-list">
  9. <view class="option-item" v-for="(item, index) in options" :key="index" @click="selectOption(index)">
  10. <view class="option-text">{{ item.text }}</view>
  11. <view class="option-check">
  12. <u-icon name="checkmark-circle-fill" size="40" :color="selectedIndex === index ? '#38C148' : '#ccc'"></u-icon>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="popup-footer">
  17. <u-button type="primary" shape="circle" @click="confirm">确认</u-button>
  18. </view>
  19. </view>
  20. </u-popup>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. value: {
  26. type: Boolean,
  27. default: false
  28. }
  29. },
  30. data() {
  31. return {
  32. show: false,
  33. selectedIndex: 1, // Default to "其他商品继续发货"
  34. options: [
  35. { text: '缺货时电话与我沟通', value: 1 },
  36. { text: '其他商品继续发货(缺货商品退款)', value: 2 },
  37. { text: '有缺货直接取消订单', value: 3 }
  38. ]
  39. }
  40. },
  41. watch: {
  42. value(val) {
  43. this.show = val;
  44. },
  45. show(val) {
  46. this.$emit('input', val);
  47. }
  48. },
  49. methods: {
  50. close() {
  51. this.show = false;
  52. },
  53. selectOption(index) {
  54. this.selectedIndex = index;
  55. },
  56. confirm() {
  57. this.$emit('confirm', this.options[this.selectedIndex]);
  58. this.close();
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .stock-shortage-popup {
  65. height: 100%;
  66. display: flex;
  67. flex-direction: column;
  68. overflow-y: hidden;
  69. .popup-header {
  70. padding: 30rpx;
  71. text-align: center;
  72. font-size: 32rpx;
  73. font-weight: bold;
  74. position: relative;
  75. border-bottom: 1rpx solid #eee;
  76. .close-icon {
  77. position: absolute;
  78. right: 30rpx;
  79. top: 40rpx;
  80. }
  81. }
  82. .option-list {
  83. flex: 1;
  84. padding: 20rpx;
  85. max-height: 400rpx;
  86. overflow-y: auto;
  87. .option-item {
  88. display: flex;
  89. justify-content: space-between;
  90. align-items: center;
  91. padding: 20rpx 30rpx;
  92. .option-text {
  93. font-size: 28rpx;
  94. color: #333;
  95. }
  96. }
  97. }
  98. .popup-footer {
  99. padding: 20rpx 40rpx;
  100. padding-bottom: env(safe-area-inset-bottom);
  101. }
  102. }
  103. </style>