cm-unit-suppor-popup.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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"> <cmUnitPrice :skuProduct="skuProduct"></cmUnitPrice> </view>
  9. </view>
  10. <view class="tui-sku-unit">
  11. <view class="sku-unit-h1">规格:</view>
  12. <view class="sku-unit-li">
  13. <view
  14. class="unit-li"
  15. v-for="(sku, index) in skuList"
  16. @click="handleChoisSku(sku, index)"
  17. :key="index"
  18. :class="skuIndex === index ? 'active' : ''"
  19. >
  20. {{ sku.unit }} <text class="tips" v-if="sku.stock === 0">缺货</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="sku-unit-ladel" v-if="isShowLadder" @click.stop="showLaddePopup"> 此规格商品存在阶梯价格,点击查看 >>> </view>
  25. </view>
  26. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  27. <view class="tui-modal-flex">
  28. <button
  29. class="tui-modal-button confirm"
  30. :disabled="isBtnDisabled"
  31. :class="[isBtnDisabled ? 'disabled' : '']"
  32. @click="handleConfirm"
  33. >
  34. 确定
  35. </button>
  36. </view>
  37. </view>
  38. </view>
  39. </tui-bottom-popup>
  40. </template>
  41. <script>
  42. import { mapState, mapMutations } from 'vuex'
  43. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  44. import cmUnitPrice from './cm-unit-price.vue'
  45. export default {
  46. name: 'cm-unit-popup',
  47. components: {
  48. uniGrader,
  49. cmUnitPrice
  50. },
  51. props: {
  52. skuProduct: {
  53. type: Object
  54. },
  55. popupShow: {
  56. type: Boolean,
  57. default: false
  58. },
  59. type: {
  60. type: Number,
  61. default: 1
  62. }
  63. },
  64. data() {
  65. return {
  66. isShowLadder:false,
  67. isBtnDisabled:false,
  68. skuIndex: 0,
  69. userIdentity: 0,
  70. number: 0,
  71. buyRetailPrice: 0,
  72. ladderPriceList: [],
  73. handleUnit:'',
  74. handleMinNumber:0,
  75. handleStock:0,
  76. skuList: []
  77. }
  78. },
  79. filters: {
  80. NumFormat(value) {
  81. //处理金额
  82. return Number(value).toFixed(2)
  83. }
  84. },
  85. created() {
  86. this.skuList = this.skuProduct.skus
  87. this.productCount = this.skuList[0].minBuyNumber
  88. this.handleMinNumber = this.skuList[0].minBuyNumber
  89. this.handleStock = this.skuList[0].stock
  90. this.initData()
  91. },
  92. computed: {
  93. ...mapState(['hasLogin'])
  94. },
  95. methods: {
  96. async initData(data) {
  97. const userInfo = await this.$api.getStorage()
  98. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  99. //处理禁用按钮商品
  100. this.isBtnDisabled = this.isDisabledFlag(this.skuProduct)
  101. if(this.product.skuList[0].ladderPriceList){ this.isShowLadder = true }
  102. },
  103. isDisabledFlag(pros){
  104. // 非会员
  105. if (!this.vipFlag === 1) return true
  106. // 商品已下架 || 库存为0
  107. if (pros.validFlag == 3 || pros.stock == 0) return true
  108. // 商品价格不公开
  109. if (pros.priceFlag === 1) return true
  110. // 商品价格仅资质机构可见 && 机构为普通机构
  111. if (pros.priceFlag === 2 && this.userIdentity === 4 ) return true
  112. // 商品价格仅医美机构可见 && 机构为普通机构
  113. if (pros.priceFlag === 3 && this.userIdentity === 4 ) return true
  114. // 商品价格仅医美机构可见 && 机构为资质机构 && 不是医美机构
  115. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType != 1) return true
  116. //其他
  117. return false
  118. },
  119. handleConfirm() {
  120. const data = { unit : this.handleUnit,number:this.handleMinNumber}
  121. this.$emit('btnConfirm', data)
  122. this.$parent.popupShow1 = false
  123. },
  124. handleChoisSku(sku, index) {
  125. // 选择SKU
  126. this.skuIndex = index
  127. this.handleUnit = sku.unit
  128. this.ladderPriceList = sku.ladderPriceList
  129. this.isShowLadder = sku.ladderPriceList ? true : false
  130. this.isBtnDisabled = sku.stock === 0
  131. this.$emit('skuClick', sku)
  132. },
  133. showLaddePopup(){
  134. // 点击显示阶梯价
  135. this.laddePopupShow = true
  136. },
  137. hidePopup() {
  138. //隐藏
  139. this.$parent.popupShow1 = false
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss">
  145. .tui-popup-box {
  146. padding: 40rpx 24rpx 0 24rpx;
  147. }
  148. .tui-shopping-main {
  149. width: 100%;
  150. .tui-sku-title {
  151. width: 100%;
  152. height: 136rpx;
  153. float: left;
  154. margin-bottom: 30rpx;
  155. .tui-sku-image {
  156. width: 138rpx;
  157. height: 138rpx;
  158. float: left;
  159. border-radius: 8rpx;
  160. margin-right: 30rpx;
  161. box-sizing: border-box;
  162. border: 1px dashed #e1e1e1;
  163. image {
  164. width: 134rpx;
  165. height: 134rpx;
  166. border-radius: 10rpx;
  167. }
  168. }
  169. .tui-sku-price {
  170. height: 136rpx;
  171. float: left;
  172. }
  173. }
  174. .tui-sku-unit {
  175. width: 100%;
  176. height: auto;
  177. float: left;
  178. .sku-unit-h1 {
  179. font-size: 28rpx;
  180. line-height: 40rpx;
  181. color: #333333;
  182. font-weight: bold;
  183. }
  184. .sku-unit-li {
  185. width: 100%;
  186. height: auto;
  187. .unit-li {
  188. padding: 0 24rpx;
  189. line-height: 48rpx;
  190. text-align: center;
  191. font-size: 24rpx;
  192. color: #666666;
  193. background: #f5f5f5;
  194. float: left;
  195. margin-right: 16rpx;
  196. margin-top: 12rpx;
  197. margin-bottom: 12rpx;
  198. border-radius: 24rpx;
  199. position: relative;
  200. box-sizing: border-box;
  201. border: 1px solid #f5f5f5;
  202. &.active {
  203. border-color: $color-system;
  204. background: #fff1eb;
  205. color: $color-system;
  206. .tips {
  207. background: #FF5B00;
  208. }
  209. }
  210. .tips {
  211. padding: 0 10rpx;
  212. line-height: 32rpx;
  213. text-align: center;
  214. font-size: 22rpx;
  215. color: #ffffff;
  216. background: #cccccc;
  217. float: left;
  218. border-radius: 16rpx;
  219. position: absolute;
  220. right: -12rpx;
  221. top: -15rpx;
  222. }
  223. }
  224. }
  225. }
  226. .sku-unit-ladel {
  227. width: 100%;
  228. height: 64rpx;
  229. line-height: 64rpx;
  230. float: left;
  231. margin-top: 20rpx;
  232. text-align: center;
  233. font-size: 24rpx;
  234. background: #fffaf8;
  235. color: #FF5B00;
  236. }
  237. }
  238. .tui-modal-flex {
  239. width: 100%;
  240. height: 84rpx;
  241. margin-top: 40rpx;
  242. display: flex;
  243. .tui-modal-button {
  244. flex: 1;
  245. line-height: 84rpx;
  246. font-size: $font-size-28;
  247. text-align: center;
  248. border-radius: 42rpx;
  249. padding: 0;
  250. margin: 0 15rpx;
  251. box-sizing: border-box;
  252. &.cancel {
  253. background: #ffe6dc;
  254. color: #FF5B00;
  255. }
  256. &.confirm {
  257. background: $btn-confirm;
  258. color: #ffffff;
  259. &.disabled {
  260. background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
  261. }
  262. }
  263. }
  264. }
  265. </style>