app-commodity.vue 5.2 KB

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