cm-unit-popup.vue 11 KB

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