app-commodity.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="item-cmd_bx" @click="showAddModelFn()">
  3. <view class="img_bx" style="background:#eeeeee">
  4. <image :src="info.cover" lazy-load="true" :lazy-load-margin="0"></image>
  5. </view>
  6. <view class="cmd-info_bx">
  7. <view class="tit" >{{ info.itemName || "" }}</view>
  8. <view class="kc" style="position:absolute;top:55upx;">
  9. <block v-if="info.ratioType == 0">{{info.ratio}}{{info.smallUnit}}/{{info.bigUnit}}</block>
  10. <block v-else>若干{{info.smallUnit}}/{{info.bigUnit}}</block>
  11. </view>
  12. <view class="kc num-open_bx flex-end">
  13. <view class="price" style="position:absolute;top:55upx;font-weight:bold;">¥{{ parseFloat(info.price) }}</view>
  14. <view style="text-align: right;margin-right:20upx;" >
  15. <view class="open-bx" >
  16. <i class="iconfont iconjian" @click.stop="reduceItemFn()" v-if="bigCount > 0 || smallCount > 0"></i>
  17. <text class="num" >
  18. <text style="font-weight:bold;color:#3385ff;" v-if="bigCount > 0">{{ `${bigCount}` }}</text>
  19. <text v-if="smallCount > 0">{{ `${smallCount}` }}</text>
  20. </text>
  21. <i class="iconfont iconzeng" @click.stop="addItemFn()"></i>
  22. </view>
  23. <text v-if="Number(info.stock) > Number(info.stockWarning)" style="color:#333;margin-right:65upx;">还剩 {{ parseFloat(info.stock) }}</text>
  24. <text v-else style="color:red;font-weight:bold;margin-right:65upx;">还剩 {{ parseFloat(info.stock) }}</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. name: "Commodity",
  33. components: {},
  34. mixins: [],
  35. props: {
  36. info: {
  37. required: true,
  38. type: Object,
  39. default() {
  40. return {};
  41. }
  42. },
  43. scrollTop: {
  44. type: Number,
  45. default: 0
  46. },
  47. autoPrice: {},
  48. isActive: {
  49. type: Boolean,
  50. default: false
  51. },
  52. checkStock: {
  53. type: Boolean,
  54. default: false
  55. },
  56. isAlterPrice: {
  57. type: Boolean,
  58. default: false
  59. },
  60. selectJobType:{
  61. type: String,
  62. default: ''
  63. }
  64. },
  65. data() {
  66. return {
  67. isAlterMoney:false,
  68. isAloneAllActive: false,
  69. isAloneAllFocus: false,
  70. changeAutoPrice:'',
  71. showPrice:0.00,
  72. oldPrice:0.00,
  73. ifFocus:false,
  74. bigCount:0,
  75. smallCount:0,
  76. userPrice:0
  77. };
  78. },
  79. watch:{
  80. info:{
  81. handler(newValue){
  82. this.bigCount = newValue.bigCount
  83. this.smallCount = newValue.smallCount
  84. this.userPrice = newValue.userPrice
  85. },
  86. deep:true
  87. }
  88. },
  89. created() {},
  90. computed: {
  91. },
  92. mounted() {
  93. if(this.info.priceLabel == 2){
  94. this.changeAutoPrice = this.info.price
  95. }
  96. this.showPrice = this.info.priceLabel==1?null:this.info.price
  97. this.oldPrice = (Number(this.info.cost) + Number(this.info.addPrice)).toFixed(2)
  98. this.bigCount = this.info.bigCount
  99. this.smallCount = this.info.smallCount
  100. this.userPrice = this.info.userPrice
  101. },
  102. methods: {
  103. addItemFn () {
  104. this.$emit("replaceItemFn", this.info,0,'add')
  105. },
  106. reduceItemFn() {
  107. this.$emit("replaceItemFn", this.info,0,'sub')
  108. },
  109. showAddModelFn() {
  110. this.$emit("showAddModelFn", { ...this.info, bigCount: this.bigCount, smallCount: this.smallCount, userPrice: this.userPrice})
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. .item-cmd_bx {
  117. position: relative;
  118. margin-bottom: 20upx;
  119. .img_bx {
  120. height: 140upx;
  121. width: 140upx;
  122. position: absolute;
  123. left: 0upx;
  124. top: 0upx;
  125. image{
  126. width: 100%;
  127. height: 100%;
  128. }
  129. }
  130. .cmd-info_bx {
  131. padding-left: 160upx;
  132. padding-bottom: 30upx;
  133. & .tit {
  134. font-size: 32upx;
  135. font-weight: 700;
  136. color: #333333;
  137. overflow: hidden;
  138. white-space: nowrap;
  139. text-overflow: ellipsis;
  140. width:380upx;
  141. }
  142. & .kc {
  143. position: relative;
  144. color: #999999;
  145. font-size: 24upx;
  146. .price{
  147. position: absolute;
  148. left: 0;
  149. bottom: 0;
  150. }
  151. }
  152. & .num-open_bx {
  153. display: flex;
  154. align-items: center;
  155. & .price {
  156. font-size: 28upx;
  157. color: #ff2842;
  158. flex: 1;
  159. }
  160. & .open-bx {
  161. display: flex;
  162. align-items: center;
  163. & .iconfont {
  164. color: #3385ff;
  165. font-size: 55upx;
  166. }
  167. .position{
  168. display: block;
  169. width: 70upx;
  170. text-align: center;
  171. }
  172. .iconcachu {
  173. margin: 0 6upx 0 20upx;
  174. color: #ccc;
  175. &.edit {
  176. color: #3385ff;
  177. }
  178. }
  179. & > .num {
  180. display: inline-block;
  181. width: 100upx;
  182. height:50upx;
  183. line-height:50upx;
  184. text-align:center;
  185. margin: 0 20upx;
  186. color: #868686;
  187. border-radius: 22upx;
  188. background-color: #f5f5f5;
  189. font-size: 28upx;
  190. }
  191. .change-input {
  192. width: 164upx;
  193. height: 60upx;
  194. line-height: 60upx;
  195. text-align: center;
  196. background: #ffffff;
  197. border: 1upx solid #dddddd;
  198. border-radius: 4upx;
  199. font-size: 25upx;
  200. }
  201. .btn-box{
  202. width: 100upx;
  203. height: 60upx;
  204. line-height: 60upx;
  205. color: #ffffff;
  206. background: #3385ff;
  207. text-align: center;
  208. border-radius: 10upx;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. </style>