cm-unit-popup.vue 9.0 KB

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