CommodityPurchase.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view
  3. class="item-cmd_bx"
  4. @click="customNum"
  5. >
  6. <view class="img_bx">
  7. <app-img
  8. :src="info.cover"
  9. alt="商品图"
  10. mode="aspectFit"
  11. :height="160"
  12. />
  13. </view>
  14. <view class="cmd-info_bx">
  15. <view class="tit">
  16. {{ info.itemName || "" }}
  17. </view>
  18. <view class="num-open_bx">
  19. <view style="position: relative;">
  20. <view class="kc">{{ info.rank }}级</view>
  21. </view>
  22. <view>
  23. <view class="open-bx">
  24. <i
  25. class="iconfont iconjian"
  26. :class="delAnimationData?'animation':''"
  27. @click.stop="delEvent"
  28. v-if="bigCount > 0 || smallCount > 0"
  29. ></i>
  30. <text
  31. class="num"
  32. @click.stop="customNum"
  33. >
  34. <!-- <text class="num" @click="customNum" v-if="bigCount > 0 || smallCount > 0">-->
  35. <text v-if="bigCount > 0 || smallCount > 0">{{ `${bigCount}` }}</text>
  36. <text v-if="smallCount > 0">/</text>
  37. <text v-if="smallCount > 0">{{ `${smallCount}` }}</text>
  38. </text>
  39. <i
  40. class="iconfont iconzeng"
  41. :class="addAnimationData?'animation':''"
  42. @click.stop="customNum"
  43. ></i>
  44. </view>
  45. <view class="price">
  46. <!--<text class="unit">¥</text><text>{{ info.price }}</text>-->
  47. <text class="unit">还剩:{{ info.stock }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import { COMMODITY_TYPE } from "@/utils/declare";
  56. import AppImg from "@/components/app-img";
  57. import animationMins from "@/mixins/animation";
  58. export default {
  59. name: "Commodity",
  60. components: {
  61. AppImg
  62. },
  63. mixins: [animationMins],
  64. props: {
  65. info: {
  66. required: true,
  67. type: Object,
  68. default () {
  69. return {};
  70. }
  71. },
  72. type: {
  73. type: String,
  74. default: COMMODITY_TYPE.COMMON
  75. },
  76. bigCount: {
  77. type: Number,
  78. default: 0
  79. },
  80. smallCount: {
  81. type: Number,
  82. default: 0
  83. },
  84. autoPrice: {
  85. type: Number,
  86. default: 0
  87. },
  88. itemPrice: {
  89. type: Number,
  90. default: 0
  91. },
  92. },
  93. data () {
  94. return {
  95. COMMODITY_TYPE
  96. };
  97. },
  98. created () { },
  99. methods: {
  100. addEvent () {
  101. this.animationFun('add');
  102. // let params = {
  103. // ...this.info,
  104. // bigCount: this.bigCount,
  105. // smallCount: this.smallCount
  106. // };
  107. this.$emit("add", this.info);
  108. },
  109. delEvent () {
  110. this.animationFun('del');
  111. this.$emit("del", this.info);
  112. },
  113. removeEvent () {
  114. this.$emit("remove", this.info);
  115. },
  116. changePriceEvent (event) {
  117. const {
  118. detail: { value }
  119. } = event;
  120. this.$emit("changePrice", this.info, value);
  121. },
  122. customNum () {
  123. if (!this.bigCount && !this.smallCount) {
  124. let params = {
  125. ...this.info,
  126. bigCount: this.bigCount,
  127. smallCount: this.smallCount,
  128. itemPrice: this.itemPrice
  129. };
  130. this.$emit("addOneEvent", this.info, params, 'noAdd');
  131. }
  132. this.$emit("customNum", {
  133. ...this.info,
  134. bigCount: this.bigCount,
  135. smallCount: this.smallCount,
  136. itemPrice: this.itemPrice
  137. });
  138. }
  139. }
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .item-cmd_bx {
  144. position: relative;
  145. margin-bottom: 20px;
  146. .img_bx {
  147. height: 140px;
  148. width: 140px;
  149. position: absolute;
  150. left: 0px;
  151. top: 0px;
  152. }
  153. .cmd-info_bx {
  154. padding-left: 167px;
  155. margin-bottom: 40px;
  156. & .tit {
  157. font-size: 32px;
  158. font-weight: 700;
  159. color: #333333;
  160. padding-top: 10px;
  161. }
  162. & .kc {
  163. color: #ff2842;
  164. font-size: 24px;
  165. padding: 10px 0 0;
  166. position: absolute;
  167. width: 50px;
  168. text-align: left;
  169. bottom: 0;
  170. left: 0;
  171. }
  172. & .num-open_bx {
  173. text-align: right;
  174. display: flex;
  175. justify-content: space-between;
  176. // align-items: center;
  177. & .price {
  178. font-size: 28rpx;
  179. color: #999999;
  180. -webkit-box-flex: 1;
  181. -webkit-flex: 1;
  182. flex: 1;
  183. margin-right: 50px;
  184. .unit {
  185. font-size: 22upx;
  186. }
  187. }
  188. & .open-bx {
  189. // display: flex;
  190. align-items: center;
  191. display: inline-flex;
  192. & .iconfont {
  193. color: #4db0e4;
  194. font-size: 42px;
  195. }
  196. .icondelete {
  197. margin: 0 10px 0 30px;
  198. color: #ccc;
  199. &.edit {
  200. color: #4db0e4;
  201. }
  202. }
  203. & > .num {
  204. display: inline-block;
  205. width: 120rpx;
  206. height: 45rpx;
  207. text-align: center;
  208. margin: 0 8px;
  209. color: #868686;
  210. border-radius: 22px;
  211. background-color: #f5f5f5;
  212. padding: 3px 0;
  213. font-size: 25rpx;
  214. }
  215. .change-input {
  216. width: 164px;
  217. height: 60px;
  218. line-height: 60px;
  219. text-align: center;
  220. background: #ffffff;
  221. border: 1px solid #dddddd;
  222. border-radius: 4px;
  223. font-size: 28px;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. </style>