cm-unit-popup.vue 11 KB

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