item.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="item-cmd_bx" @click="customNum(info.variety)">
  3. <view class="img_bx" style="background:#eeeeee" @click.stop="showBigImg">
  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" >
  8. <text style="font-size:20upx;border:1upx solid #3385ff;color:white;background-color:#3385ff;margin-right:5upx;padding-left:5upx;padding-right:5upx;"
  9. v-if="info.presell == 1">预售</text>
  10. <text style="font-size:20upx;border:1upx solid red;color:white;background-color:red;margin-right:5upx;padding-left:5upx;padding-right:5upx;"
  11. v-if="info.limitBuy > 0">限购{{ info.limitBuy }}份</text>
  12. {{ info.name||''}}
  13. </view>
  14. <view class="kc num-open_bx flex-space">
  15. <view>
  16. <view class="flex-space" v-if="Number(info.discountPrice)>0" style="position:absolute;top:14upx;">
  17. <view style="padding:2upx 10upx 5upx 10upx;text-align: center;color: red;border: 1px solid red;margin-right: 20upx;line-height: 1;font-size: 20upx">
  18. {{parseFloat(((Number(info.discountPrice)/Number(info.prePrice)).toFixed(2)*10).toFixed(1))+'折'}}
  19. </view>
  20. <text style="text-decoration:line-through;color:#A9A9A9">¥{{parseFloat(info.prePrice)}}</text>
  21. </view>
  22. <view class="flex-space" style="color:#333333;position:absolute;top:13upx;" v-else>
  23. <block v-if="info.ratioType == 0">
  24. {{info.ratio}}{{info.smallUnit}}/{{info.bigUnit}}
  25. </block>
  26. <block v-else>
  27. 若干{{info.smallUnit}}/{{info.bigUnit}}
  28. </block>
  29. </view>
  30. <view class="price" v-if="info.myLevel && info.myLevel == 2">
  31. <!--平潭满天星,不展示原价,比较特殊-->
  32. <text style="color:#a7a2a2;text-decoration:line-through;font-size:30upx;font-weight:bold;" v-if="Number(shopId)!=38322">¥{{parseFloat(info.defaultGradePrice) }}</text>
  33. <text style="font-weight:bold;margin-left:10upx;font-size:30upx;">会员¥{{ parseFloat(info.price) }}</text>
  34. </view>
  35. <view class="price" style="font-weight:bold;font-size:30upx;" v-else>¥{{ info.price ? parseFloat(info.price) : 0 }}</view>
  36. </view>
  37. <view style="text-align: right" >
  38. <view class="open-bx" >
  39. <i class="iconfont iconjian" @click.stop="delEvent(info.variety)" v-if="bigCount > 0 || smallCount > 0"></i>
  40. <text class="num">
  41. <text v-if="bigCount > 0" style="font-weight:bold;color:#3385ff;">{{ `${bigCount}` }}</text>
  42. <text v-if="smallCount > 0" >{{ `${smallCount}` }}</text>
  43. </text>
  44. <i class="iconfont iconzeng" @click.stop="addEvents(info.variety)"></i>
  45. </view>
  46. <stock v-if="showStock && showStock == '1'">
  47. <text v-if="Number(info.stock) > Number(info.stockWarning)" style="color:#333;margin-right:55upx;">还剩 {{ parseFloat(info.stock) }}</text>
  48. <text v-else style="color:red;font-weight:bold;margin-right:55upx;">还剩 {{ parseFloat(info.stock) }}</text>
  49. </stock>
  50. <stock v-else>
  51. <stock v-if="showSold && showSold == 1">
  52. <text style="color:#333;margin-right:55upx;">已售 {{ info.actualSold ? parseInt(info.actualSold):0 }}</text>
  53. </stock>
  54. </stock>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. name: "item",
  63. mixins: [],
  64. props: {
  65. info: {
  66. required: true,
  67. type: Object,
  68. default() {
  69. return {};
  70. }
  71. },
  72. bigCount: {
  73. type: Number,
  74. default: 0
  75. },
  76. smallCount: {
  77. type: Number,
  78. default: 0
  79. },
  80. showSold:{
  81. type: Number,
  82. default: 0
  83. },
  84. shopId:{
  85. type: [Number, String],
  86. default: 0
  87. },
  88. showStock:{
  89. type: String,
  90. default: '0'
  91. },
  92. offVerifyRepertory: {
  93. type: Boolean,
  94. default: false
  95. },
  96. },
  97. data() {
  98. return {}
  99. },
  100. methods: {
  101. showBigImg(){
  102. this.$emit("showBigCover", this.info);
  103. },
  104. addEvents(variety) {
  105. if(variety == 0){
  106. const ratio = Number(this.info.ratio);
  107. if(this.offVerifyRepertory){
  108. if(this.info.stock<=0){
  109. uni.showToast({title:'没有货了',icon:'none'})
  110. return
  111. }
  112. if (Number(this.bigCount) * ratio + Number(this.smallCount) >Number(this.info.bigNum) * ratio + Number(this.info.smallNum)) {
  113. this.$msg("库存只剩"+this.info.bigNum);
  114. return
  115. }
  116. }
  117. this.$emit("add", this.info);
  118. }else{
  119. //去特殊品种页
  120. this.$emit("goToSpecialVariety", this.info);
  121. }
  122. },
  123. delEvent(variety) {
  124. if(variety == 0){
  125. this.$emit("del", this.info);
  126. }else{
  127. //去特殊品种页
  128. this.$emit("goToSpecialVariety", this.info);
  129. }
  130. },
  131. customNum(variety) {
  132. if(variety == 0){
  133. if(this.info.stock<=0){
  134. uni.showToast({title:'没有货了',icon:'none'})
  135. return
  136. }
  137. if(!this.bigCount && !this.smallCount){
  138. let params = {
  139. ...this.info,
  140. bigCount: this.bigCount,
  141. smallCount: this.smallCount
  142. };
  143. this.$emit("addOneEvent", this.info,params);
  144. }
  145. this.$emit("customNum", {
  146. ...this.info,
  147. bigCount: this.bigCount,
  148. smallCount: this.smallCount
  149. });
  150. }else{
  151. //去特殊品种页
  152. this.$emit("goToSpecialVariety", this.info);
  153. }
  154. }
  155. }
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .item-cmd_bx {
  160. position: relative;
  161. margin-bottom: 20upx;
  162. .img_bx {
  163. height: 140upx;
  164. width: 140upx;
  165. position: absolute;
  166. left: 0upx;
  167. top: 0upx;
  168. image{
  169. width: 100%;
  170. height: 100%;
  171. }
  172. }
  173. .cmd-info_bx {
  174. padding-left: 160upx;
  175. padding-bottom: 30upx;
  176. & .tit {
  177. font-size:30upx;
  178. font-weight:700;
  179. color: #333333;
  180. overflow: hidden;
  181. white-space: nowrap;
  182. width:390upx;
  183. }
  184. & .kc {
  185. position: relative;
  186. color: #999999;
  187. font-size: 24upx;
  188. .price{
  189. position: absolute;
  190. left: 0;
  191. bottom: 0;
  192. }
  193. }
  194. & .num-open_bx {
  195. display: flex;
  196. align-items: center;
  197. & .price {
  198. font-size: 28upx;
  199. color: #ff2842;
  200. flex: 1;
  201. top:60upx;
  202. font-weight:550;
  203. }
  204. & .open-bx {
  205. display: flex;
  206. align-items: center;
  207. & .iconfont {
  208. color: #09C567;
  209. font-size: 55upx;
  210. }
  211. & > .num {
  212. display: inline-block;
  213. width: 100upx;
  214. height:40upx;
  215. line-height:40upx;
  216. text-align:center;
  217. margin: 0 8upx;
  218. color: #868686;
  219. border-radius: 22upx;
  220. background-color: #f5f5f5;
  221. font-size: 24upx;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>