cm-unit-popup.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template name="cm-parameter">
  2. <!-- 相关规格 -->
  3. <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup()">
  4. <view class="tui-popup-box clearfix">
  5. <view class="tui-shopping-main" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  6. <view class="tui-sku-title">
  7. <view class="tui-sku-image"> <image :src="skuProduct.image" mode=""></image> </view>
  8. <view class="tui-sku-price">
  9. <view class="sku-price-viw">
  10. <view class="sku-price-text"
  11. :class="PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1 ? 'none' : ''"
  12. >
  13. ¥{{
  14. (PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  15. ? skuProduct.originalPrice
  16. : skuProduct.price) | NumFormat
  17. }}
  18. </view>
  19. </view>
  20. <view class="sku-price-vip">
  21. <view class="floor-item-act">
  22. <view class="coupon-tags" v-if="skuProduct.couponsLogo">优惠券</view>
  23. <template v-if="skuProduct.actStatus == 1 && skuProduct.promotions">
  24. <view v-if="PromotionsFormat(skuProduct.promotions)" class="floor-tags">
  25. {{ skuProduct.promotions.name }}
  26. <text v-if="skuProduct.promotions != null && skuProduct.promotions.type != 3">
  27. :¥{{
  28. skuProduct.promotions == null
  29. ? '0.00'
  30. : skuProduct.promotions.touchPrice | NumFormat
  31. }}
  32. </text>
  33. </view>
  34. <view v-else-if="skuProduct.promotions.type != 3" class="floor-tags">
  35. {{ skuProduct.promotions.name }}
  36. </view>
  37. </template>
  38. <template v-if="skuProduct.actStatus == null && skuProduct.ladderFlag == 1">
  39. <view class="floor-tags">阶梯价格</view>
  40. </template>
  41. <template v-if="skuProduct.svipProductFlag == 1">
  42. <view class="svip-tags">
  43. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  44. <view class="price" v-if="isShowVipFlag(skuProduct)">{{
  45. skuProduct.svipPriceTag
  46. }}</view>
  47. </view>
  48. </template>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="tui-sku-unit">
  54. <view class="sku-unit-h1">规格:</view>
  55. <view class="sku-unit-li">
  56. <view
  57. class="unit-li"
  58. v-for="(sku, index) in skuList"
  59. @click="handleChoisSku(sku, index)"
  60. :key="index"
  61. :class="skuIndex === index ? 'active' : ''"
  62. >
  63. {{ sku.unit }} <text class="tips" v-if="sku.stock === 0">缺货</text>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="sku-unit-nunbox">
  68. <view class="sku-unit-nunbox-t" v-if="skuProduct.step === 2">
  69. <view class="text">该商品只能以起订量的整数倍购买</view>
  70. </view>
  71. <view class="sku-unit-nunbox-t">
  72. <view class="sku-unit-nunbox-text">购买数量:</view>
  73. <view class="sku-unit-nunbox-num">
  74. <view class="number-box">
  75. <view
  76. class="iconfont icon-jianhao"
  77. @click="skuChangNumberSub"
  78. ></view>
  79. <input
  80. class="btn-input"
  81. type="number"
  82. v-model="addParams.count"
  83. maxlength="4"
  84. @blur="skuChangNumberChange($event)"
  85. cursor-spacing="40"
  86. />
  87. <view
  88. class="iconfont icon-jiahao"
  89. @click="skuChangNumberAdd"
  90. ></view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  97. <view class="tui-modal-flex">
  98. <view class="tui-modal-button cancel" @click="hidePopup">取消</view>
  99. <view class="tui-modal-button confirm" :class="isBtnDisable ? 'disabled' :''" @click="handleConfirm">确定</view>
  100. </view>
  101. </view>
  102. </view>
  103. </tui-bottom-popup>
  104. </template>
  105. <script>
  106. import { mapState, mapMutations } from 'vuex'
  107. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  108. export default {
  109. name: 'cm-unit-popup',
  110. components: {
  111. uniGrader
  112. },
  113. props: {
  114. skuProduct: {
  115. type: Object
  116. },
  117. popupShow: {
  118. type: Boolean,
  119. default: false
  120. },
  121. type: {
  122. type: Number,
  123. default: 1
  124. }
  125. },
  126. data() {
  127. return {
  128. isBtnDisable:false,
  129. vipFlag: 0, // 是否是超级会员 0否 1是
  130. skuIndex: 0,
  131. number: 0,
  132. ladderPriceList: [],
  133. isQuantity: false,
  134. skuList: [],
  135. handleStock:0,// 规格库存
  136. handleMinNumber:1, // 规格起订量
  137. addParams:{
  138. oldSkuId:0,
  139. newSkuId:0,
  140. count:0,
  141. productId:0,
  142. userId:0,
  143. source:1
  144. },
  145. }
  146. },
  147. filters: {
  148. NumFormat(value) {
  149. //处理金额
  150. return Number(value).toFixed(2)
  151. }
  152. },
  153. created() {
  154. this.skuList = this.skuProduct.skus
  155. this.addParams.productId = this.skuProduct.productId
  156. this.addParams.oldSkuId = this.skuProduct.skuId
  157. this.addParams.count = this.skuList[0].minBuyNumber
  158. this.handleMinNumber = this.skuList[0].minBuyNumber
  159. this.handleStock = this.skuList[0].stock
  160. this.skuProduct.price = this.skuList[0].price;
  161. this.isBtnDisable = this.skuList[0].stock === 0;
  162. this.initData()
  163. },
  164. computed: {
  165. ...mapState(['hasLogin'])
  166. },
  167. methods: {
  168. async initData(data) {
  169. const userInfo = await this.$api.getStorage()
  170. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  171. this.addParams.userId = userInfo.userId ? userInfo.userId : 0
  172. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  173. },
  174. PromotionsFormat(promo) {
  175. //促销活动类型数据处理
  176. if (promo != null) {
  177. if (promo.type == 1 && promo.mode == 1) {
  178. return true
  179. } else {
  180. return false
  181. }
  182. }
  183. return false
  184. },
  185. isShowVipFlag(pros) {
  186. // 未登录 || 非会员
  187. if (!this.hasLogin || !this.vipFlag === 1) return false
  188. // 商品所有机构可见
  189. if (pros.priceFlag === 0) return true
  190. // 商品价格仅资质机构可见
  191. if (pros.priceFlag === 2 && this.userIdentity === 2) return true
  192. // 商品价格仅医美机构可见
  193. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  194. // 其它
  195. return false
  196. },
  197. skuChangNumberSub() {// 减数
  198. if ( this.addParams.count <= this.handleMinNumber) {
  199. this.addParams.count = this.handleMinNumber
  200. } else {
  201. if (this.skuProduct.step == 2) {
  202. this.addParams.count -= this.handleMinNumber
  203. } else {
  204. this.addParams.count--
  205. }
  206. }
  207. },
  208. skuChangNumberAdd() {// 加数
  209. if(this.addParams.count === this.handleStock){ return }
  210. if (this.skuProduct.step === 2) {
  211. this.addParams.count += this.handleMinNumber;
  212. } else {
  213. this.addParams.count++;
  214. }
  215. },
  216. skuChangNumberChange() {// 修改
  217. if (this.addParams.count < this.handleMinNumber || this.addParams.count % this.handleMinNumber != 0) {
  218. this.addParams.count = this.handleMinNumber;
  219. }else if(this.addParams.count > this.handleStock) {
  220. this.addParams.count = this.handleStock;
  221. }
  222. },
  223. handleConfirm() {
  224. if(this.isBtnDisable){ return }
  225. this.$emit('skuBtnConfirm', this.addParams)
  226. this.$parent.popupShow2 = false
  227. },
  228. handleChoisSku(sku, index) {
  229. // 选择SKU
  230. this.skuIndex = index
  231. this.addParams.newSkuId = sku.skuId;
  232. this.addParams.count = sku.minBuyNumber;
  233. this.handleStock = sku.stock;
  234. this.handleMinNumber = sku.minBuyNumber;
  235. this.skuProduct.price = sku.price;
  236. this.skuProduct.originalPrice = sku.originalPrice;
  237. this.isBtnDisable = sku.stock === 0;
  238. },
  239. hidePopup() {
  240. this.$parent.popupShow2 = false
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. .tui-popup-box {
  247. padding: 40rpx 24rpx 0 24rpx;
  248. }
  249. .tui-shopping-main {
  250. width: 100%;
  251. .tui-sku-title {
  252. width: 100%;
  253. height: 136rpx;
  254. float: left;
  255. margin-bottom: 30rpx;
  256. .tui-sku-image {
  257. width: 138rpx;
  258. height: 138rpx;
  259. float: left;
  260. border-radius: 8rpx;
  261. margin-right: 30rpx;
  262. box-sizing: border-box;
  263. border: 1px dashed #e1e1e1;
  264. image {
  265. width: 134rpx;
  266. height: 134rpx;
  267. border-radius: 10rpx;
  268. }
  269. }
  270. .tui-sku-price {
  271. height: 136rpx;
  272. float: left;
  273. .sku-price-viw {
  274. width: 100%;
  275. height: 40rpx;
  276. margin-bottom: 24rpx;
  277. .sku-price-text {
  278. font-size: 28rpx;
  279. line-height: 40rpx;
  280. color: #f94b4b;
  281. font-weight: bold;
  282. .sku-price-l{
  283. float: left;
  284. font-weight: normal;
  285. }
  286. &.none {
  287. text-decoration: line-through;
  288. color: #999999;
  289. font-weight: normal;
  290. }
  291. }
  292. }
  293. .sku-price-vip {
  294. width: 100%;
  295. height: 40rpx;
  296. }
  297. }
  298. }
  299. .tui-sku-unit {
  300. width: 100%;
  301. height: auto;
  302. float: left;
  303. .sku-unit-h1 {
  304. font-size: 28rpx;
  305. line-height: 40rpx;
  306. color: #333333;
  307. font-weight: bold;
  308. }
  309. .sku-unit-li {
  310. width: 100%;
  311. height: auto;
  312. .unit-li {
  313. padding: 0 24rpx;
  314. line-height: 48rpx;
  315. text-align: center;
  316. font-size: 24rpx;
  317. color: #666666;
  318. background: #f5f5f5;
  319. float: left;
  320. margin-right: 16rpx;
  321. margin-top: 12rpx;
  322. margin-bottom: 12rpx;
  323. border-radius: 24rpx;
  324. position: relative;
  325. box-sizing: border-box;
  326. border: 1px solid #f5f5f5;
  327. &.active {
  328. border-color: $color-system;
  329. background: #fff1eb;
  330. color: $color-system;
  331. .tips {
  332. background: #FF5B00;
  333. }
  334. }
  335. .tips {
  336. padding: 0 10rpx;
  337. line-height: 32rpx;
  338. text-align: center;
  339. font-size: 22rpx;
  340. color: #ffffff;
  341. background: #cccccc;
  342. float: left;
  343. border-radius: 16rpx;
  344. position: absolute;
  345. right: -12rpx;
  346. top: -15rpx;
  347. }
  348. }
  349. }
  350. }
  351. .sku-unit-nunbox {
  352. justify-content: space-between;
  353. align-items: center;
  354. width: 100%;
  355. height: auto;
  356. float: left;
  357. margin-top: 30rpx;
  358. .sku-unit-nunbox-t {
  359. width: 100%;
  360. height: 44rpx;
  361. position: relative;
  362. margin-bottom: 20rpx;
  363. .text {
  364. font-size: $font-size-24;
  365. line-height: 48rpx;
  366. color: #FF5B00;
  367. }
  368. .sku-unit-nunbox-text {
  369. line-height: 44rpx;
  370. font-size: $font-size-28;
  371. float: left;
  372. font-weight: bold;
  373. }
  374. .sku-unit-nunbox-num{
  375. float: right;
  376. .number-box {
  377. display: flex;
  378. justify-content: center;
  379. align-items: center;
  380. border: 2rpx solid #ffe6dc;
  381. border-radius: 30rpx;
  382. height: 48rpx;
  383. margin-left: 20rpx;
  384. .iconfont {
  385. font-size: $font-size-24;
  386. padding: 0 18rpx;
  387. color: #999999;
  388. text-align: center;
  389. line-height: 48rpx;
  390. font-weight: bold;
  391. background: #fef6f3;
  392. &.icon-jianhao {
  393. border-radius: 30rpx 0 0 30rpx;
  394. }
  395. &.icon-jiahao {
  396. border-radius: 0 30rpx 30rpx 0;
  397. }
  398. }
  399. .btn-input {
  400. width: 62rpx;
  401. height: 48rpx;
  402. line-height: 48rpx;
  403. background: #ffffff;
  404. border-radius: 4rpx;
  405. text-align: center;
  406. font-size: $font-size-28;
  407. }
  408. }
  409. }
  410. }
  411. }
  412. }
  413. .tui-popup-btn{
  414. width: 100%;
  415. float: left;
  416. .tui-modal-flex {
  417. width: 100%;
  418. height: 84rpx;
  419. margin-top: 40rpx;
  420. display: flex;
  421. .tui-modal-button {
  422. flex: 1;
  423. line-height: 84rpx;
  424. font-size: $font-size-28;
  425. text-align: center;
  426. border-radius: 42rpx;
  427. padding: 0;
  428. margin: 0 15rpx;
  429. box-sizing: border-box;
  430. &.cancel {
  431. background: #ffe6dc;
  432. color: #FF5B00;
  433. }
  434. &.confirm {
  435. background: $btn-confirm;
  436. color: #ffffff;
  437. &.disabled {
  438. background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
  439. }
  440. }
  441. }
  442. }
  443. }
  444. </style>