cm-unit-popup.vue 9.1 KB

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