price-edit-modal.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="price-edit-modal">
  3. <!-- 遮罩层 -->
  4. <view class="mask" @tap="close"></view>
  5. <!-- 弹窗内容 -->
  6. <view class="modal-content">
  7. <view class="modal-header">修改销售价</view>
  8. <!-- 商品类型选择 -->
  9. <view class="goods-type">
  10. <text class="label">商品类型:</text>
  11. <radio-group @change="handleTypeChange">
  12. <view v-for="item in goodsTypes" :key="item.value" class="radio-item">
  13. <label>
  14. <radio :value="item.value" :checked="currentType === item.value" color="#007AFF"/>
  15. {{ item.label }}
  16. </label>
  17. </view>
  18. </radio-group>
  19. </view>
  20. <!-- 价格输入区域 -->
  21. <view class="price-input">
  22. <text class="tip">最低销售价格不能小于:{{ minPrice }}</text>
  23. <view class="input-row">
  24. <text>销售价:</text>
  25. <input
  26. type="number"
  27. v-model="currentPrice"
  28. placeholder="请输入销售价"
  29. :min="minPrice"
  30. @input="calculateProfit"
  31. />
  32. </view>
  33. </view>
  34. <!-- 计算结果显示 -->
  35. <view class="profit-display">
  36. <view>养老金:{{ pensionFund.toFixed(2) }}</view>
  37. <view>创客利润:{{ makerProfit.toFixed(2) }}</view>
  38. </view>
  39. <button class="confirm-btn" @tap="handleConfirm">确定</button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. props: {
  46. minPrice: { type: Number, default: 8.75 },
  47. originalPrice: { type: Number, required: true },
  48. goodsType: { type: String, default: 1 }
  49. },
  50. data() {
  51. return {
  52. currentPrice: this.originalPrice,
  53. currentType: this.goodsType,
  54. pensionFund: 0,
  55. makerProfit: 1.75,
  56. goodsTypes: [
  57. { label: '普通商品', value: 1 },
  58. { label: '会员商品', value: 8 },
  59. { label: '高级会员商品', value: 10 },
  60. { label: '合伙人商品', value: 14 },
  61. { label: '股权商品', value: 15 },
  62. { label: '合伙人+股权商品', value: 16 }
  63. ]
  64. }
  65. },
  66. methods: {
  67. handleTypeChange(e) {
  68. this.currentType = e.detail.value
  69. // 这里可以添加不同类型的价格计算逻辑
  70. },
  71. calculateProfit() {
  72. // 示例计算逻辑,实际根据业务需求修改
  73. this.pensionFund = this.currentPrice * 0.05
  74. this.makerProfit = this.currentPrice * 0.15
  75. },
  76. handleConfirm() {
  77. if (this.currentPrice < this.minPrice) {
  78. uni.showToast({ title: '价格不能低于最低价', icon: 'none' })
  79. return
  80. }
  81. this.$emit('confirm', {
  82. price: Number(this.currentPrice),
  83. type: this.currentType
  84. })
  85. },
  86. close() {
  87. this.$emit('close')
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped>
  93. /* 弹窗公共样式 */
  94. .mask {
  95. position: fixed;
  96. top: 0;
  97. left: 0;
  98. right: 0;
  99. bottom: 0;
  100. background: rgba(0,0,0,0.5);
  101. z-index: 999;
  102. }
  103. .modal-content {
  104. position: fixed;
  105. top: 50%;
  106. left: 50%;
  107. transform: translate(-50%, -50%);
  108. width: 85%;
  109. max-width: 600rpx;
  110. background: #fff;
  111. border-radius: 12rpx;
  112. padding: 30rpx;
  113. z-index: 1000;
  114. }
  115. .modal-header {
  116. font-size: 18px;
  117. font-weight: bold;
  118. margin-bottom: 20rpx;
  119. text-align: center;
  120. }
  121. /* 商品类型选择样式 */
  122. .goods-type {
  123. margin-bottom: 30rpx;
  124. }
  125. .radio-item {
  126. margin: 15rpx 0;
  127. display: flex;
  128. align-items: center;
  129. }
  130. /* 输入区域样式 */
  131. .price-input {
  132. margin: 20rpx 0;
  133. }
  134. .input-row {
  135. display: flex;
  136. align-items: center;
  137. margin: 15rpx 0;
  138. }
  139. input {
  140. border: 1rpx solid #ddd;
  141. padding: 10rpx;
  142. border-radius: 8rpx;
  143. flex: 1;
  144. margin-left: 15rpx;
  145. }
  146. /* 按钮样式 */
  147. .confirm-btn {
  148. background: #007AFF;
  149. color: white;
  150. margin-top: 30rpx;
  151. border-radius: 8rpx;
  152. }
  153. .profit-display {
  154. padding: 15rpx 0;
  155. border-top: 1rpx solid #eee;
  156. margin-top: 20rpx;
  157. }
  158. </style>