Item.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="product">
  3. <view class="item-cmd_bx">
  4. <view class="img_bx">
  5. <view v-if="info.status == 2" class="sold-out">
  6. <view class="sold-out-xj">已下架</view>
  7. </view>
  8. <image :src="info.cover" style="width:160upx;height:160upx;" lazy-load="true" :lazy-load-margin="0"></image>
  9. </view>
  10. <view class="cmd-info_bx" @click="pageTo({url: '/admin/item/detail',query: {id: info.id}})">
  11. <view class="tit">{{ info.itemName || "" }}</view>
  12. <view class="kc">¥{{ parseFloat(info.price) }}</view>
  13. <view class="num-open_bx">
  14. <view>
  15. <view class="open-bx" >
  16. <text style="color:#333333;">¥{{ parseFloat(info.skPrice) }}</text>
  17. <view class="hd-price-area">
  18. <input class="change-input" @click.stop @blur="savePrice" @focus="modifyPrice = ''" placeholder-style="color:#CCCCCC" v-model="modifyPrice" type="digit" placeholder="花店价" />
  19. </view>
  20. <view class="sk-price-area">
  21. <input class="change-input" @click.stop @blur="saveSkPrice" @focus="skModifyPrice = ''" placeholder-style="color:#CCCCCC" v-model="skModifyPrice" type="digit" placeholder="散客价" />
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="level-price">
  29. <text>剩余 {{showStock}}</text>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: "Commodity",
  36. components: {
  37. },
  38. props: {
  39. isPrice: {
  40. type: Boolean,
  41. default: true
  42. },
  43. isEdit: {
  44. type: Boolean,
  45. default: true
  46. },
  47. info: {
  48. required: true
  49. }
  50. },
  51. data() {
  52. return {
  53. modifyPrice:'',
  54. skModifyPrice:'',
  55. showStock:''
  56. };
  57. },
  58. watch: {
  59. modifyPrice: {
  60. handler(newValue) {
  61. this.skModifyPrice = Number(newValue)+Number(this.info.skMore)
  62. this.skModifyPrice = parseFloat(this.skModifyPrice.toFixed(2))
  63. }
  64. }
  65. },
  66. mounted(){
  67. let info = this.info
  68. this.showStock = ''
  69. if(Number(info.stock)>1){
  70. this.showStock += Math.trunc(info.stock)+info.bigUnit
  71. }
  72. let decimal = Number(info.stock) - Math.trunc(info.stock)
  73. decimal = decimal.toFixed(2)
  74. if(decimal > 0){
  75. this.showStock += parseFloat((decimal*info.ratio).toFixed(2))+info.smallUnit
  76. }
  77. },
  78. methods: {
  79. savePrice() {
  80. if(Number(this.modifyPrice)>0 && Number(this.skModifyPrice)){
  81. this.$emit("savePrice",this.modifyPrice,this.skModifyPrice,this.info.id)
  82. }
  83. },
  84. saveSkPrice(){
  85. if(Number(this.modifyPrice)>0 && Number(this.skModifyPrice)){
  86. this.$emit("savePrice",this.modifyPrice,this.skModifyPrice,this.info.id)
  87. }
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .product{
  94. height:230upx;
  95. .level-price{
  96. display:flex;
  97. color:#999999;
  98. text-align: right;
  99. font-size:24upx;
  100. justify-content:space-around;
  101. }
  102. }
  103. .item-cmd_bx {
  104. height:160upx;
  105. position: relative;
  106. margin-bottom: 20upx;
  107. .img_bx {
  108. height: 160upx;
  109. width: 160upx;
  110. position: absolute;
  111. left: 0upx;
  112. top: 0upx;
  113. .sold-out{
  114. width:160upx;
  115. height:160upx;
  116. background-color:black;
  117. position:absolute;
  118. top:0;
  119. left:0;
  120. opacity: 0.6;
  121. color:white;
  122. text-align:center;
  123. .sold-out-xj{
  124. line-height:160upx;
  125. font-size:28upx;
  126. }
  127. }
  128. }
  129. .cmd-info_bx {
  130. position: relative;
  131. padding-left: 177upx;
  132. &.active{
  133. &:before{
  134. content: ' ';
  135. height: 22upx;
  136. width: 22upx;
  137. border-width: 2upx 2upx 0 0;
  138. border-color: #b2b2b2;
  139. border-style: solid;
  140. -webkit-transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  141. transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  142. position: absolute;
  143. top: 50%;
  144. margin-top: -12upx;
  145. right: 30upx;
  146. }
  147. }
  148. & .tit {
  149. font-size: 30upx;
  150. font-weight: bold;
  151. color: #333333;
  152. padding-top: 0upx;
  153. overflow: hidden;
  154. white-space: nowrap;
  155. text-overflow: ellipsis;
  156. width:200upx;
  157. }
  158. & .kc {
  159. color:red;
  160. font-size: 31upx;
  161. padding: 17upx 0 24upx;
  162. font-weight: 700;
  163. }
  164. & .num-open_bx {
  165. display: flex;
  166. align-items: center;
  167. & .price {
  168. font-size: 30upx;
  169. color: red;
  170. flex: 1;
  171. }
  172. & .open-bx {
  173. color:#999999;
  174. width:300upx;
  175. text{
  176. font-size: 24upx;
  177. }
  178. *.warn {
  179. color: $redColor;
  180. }
  181. .hd-price-area{
  182. width:190upx;
  183. position: absolute;
  184. top:10upx;
  185. right:0upx;
  186. .change-input {
  187. width: 150upx;
  188. height: 60upx;
  189. line-height: 60upx;
  190. text-align: center;
  191. background: #ffffff;
  192. border: 1upx solid #b4b4b4;
  193. border-radius: 4upx;
  194. font-size: 25upx;
  195. color:#777777;
  196. display:inline-block;
  197. }
  198. .change-text{
  199. font-size:22upx;
  200. }
  201. }
  202. .sk-price-area{
  203. width:190upx;
  204. position: absolute;
  205. top:95upx;
  206. right:0upx;
  207. .change-input {
  208. width: 150upx;
  209. height: 60upx;
  210. line-height: 60upx;
  211. text-align: center;
  212. background: #ffffff;
  213. border: 1upx solid #b4b4b4;
  214. border-radius: 4upx;
  215. font-size: 25upx;
  216. color:#777777;
  217. display:inline-block;
  218. }
  219. .change-text{
  220. font-size:22upx;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>