cm-unit-suppor-popup.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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="product.image" mode=""></image> </view>
  8. <view class="tui-sku-price"> <cmUnitPrice :product="product"></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">缺货</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. product: {
  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. isQuantity: false,
  74. handleUnit:'',
  75. skuList: [
  76. {
  77. unit: '135ml70ml', // 规格
  78. normalPrice: 1000, // 市场价
  79. price: 500, // 售价
  80. costPrice: 500, // 结算价
  81. stock: 100 // 库存
  82. },
  83. {
  84. unit: ' 精华70ml', // 规格
  85. normalPrice: 1000, // 市场价
  86. price: 500, // 售价
  87. costPrice: 500, // 结算价
  88. stock: 100 // 库存
  89. },
  90. {
  91. unit: '精华70ml', // 规格
  92. normalPrice: 1000, // 市场价
  93. price: 500, // 售价
  94. costPrice: 500, // 结算价
  95. stock: 100 // 库存
  96. },
  97. {
  98. unit: '【70ml】2瓶', // 规格
  99. normalPrice: 1000, // 市场价
  100. price: 500, // 售价
  101. costPrice: 500, // 结算价
  102. stock: 100 // 库存
  103. },
  104. {
  105. unit: '【50ml】3瓶', // 规格
  106. normalPrice: 1000, // 市场价
  107. price: 500, // 售价
  108. costPrice: 500, // 结算价
  109. stock: 100 // 库存
  110. },
  111. {
  112. unit: '【50ml】3瓶', // 规格
  113. normalPrice: 1000, // 市场价
  114. price: 500, // 售价
  115. costPrice: 500, // 结算价
  116. stock: 100 // 库存
  117. },
  118. {
  119. unit: '【50ml】3瓶', // 规格
  120. normalPrice: 1000, // 市场价
  121. price: 500, // 售价
  122. costPrice: 500, // 结算价
  123. stock: 100 // 库存
  124. },
  125. {
  126. unit: '【50ml】3瓶', // 规格
  127. normalPrice: 1000, // 市场价
  128. price: 500, // 售价
  129. costPrice: 500, // 结算价
  130. stock: 100 // 库存
  131. },
  132. {
  133. unit: '【50ml】3瓶', // 规格
  134. normalPrice: 1000, // 市场价
  135. price: 500, // 售价
  136. costPrice: 500, // 结算价
  137. stock: 100 // 库存
  138. },
  139. {
  140. unit: '【50ml】3瓶', // 规格
  141. normalPrice: 1000, // 市场价
  142. price: 500, // 售价
  143. costPrice: 500, // 结算价
  144. stock: 100 // 库存
  145. },
  146. {
  147. unit: '【50ml】3瓶', // 规格
  148. normalPrice: 1000, // 市场价
  149. price: 500, // 售价
  150. costPrice: 500, // 结算价
  151. stock: 100 // 库存
  152. },
  153. {
  154. unit: '【50ml】3瓶', // 规格
  155. normalPrice: 1000, // 市场价
  156. price: 500, // 售价
  157. costPrice: 500, // 结算价
  158. stock: 100 // 库存
  159. },
  160. {
  161. unit: '【50ml】3瓶', // 规格
  162. normalPrice: 1000, // 市场价
  163. price: 500, // 售价
  164. costPrice: 500, // 结算价
  165. stock: 100 // 库存
  166. },
  167. {
  168. unit: '【50ml】3瓶', // 规格
  169. normalPrice: 1000, // 市场价
  170. price: 500, // 售价
  171. costPrice: 500, // 结算价
  172. stock: 100 // 库存
  173. },
  174. {
  175. unit: '【50ml】3瓶', // 规格
  176. normalPrice: 1000, // 市场价
  177. price: 500, // 售价
  178. costPrice: 500, // 结算价
  179. stock: 100 // 库存
  180. },
  181. {
  182. unit: '【50ml】3瓶', // 规格
  183. normalPrice: 1000, // 市场价
  184. price: 500, // 售价
  185. costPrice: 500, // 结算价
  186. stock: 100 // 库存
  187. },
  188. {
  189. unit: '【50ml】3瓶', // 规格
  190. normalPrice: 1000, // 市场价
  191. price: 500, // 售价
  192. costPrice: 500, // 结算价
  193. stock: 100 // 库存
  194. },
  195. {
  196. unit: '【50ml】3瓶', // 规格
  197. normalPrice: 1000, // 市场价
  198. price: 500, // 售价
  199. costPrice: 500, // 结算价
  200. stock: 100 // 库存
  201. },
  202. {
  203. unit: '【50ml】3瓶', // 规格
  204. normalPrice: 1000, // 市场价
  205. price: 500, // 售价
  206. costPrice: 500, // 结算价
  207. stock: 100 // 库存
  208. },
  209. {
  210. unit: '【35ml】4瓶', // 规格
  211. normalPrice: 1000, // 市场价
  212. price: 500, // 售价
  213. costPrice: 500, // 结算价
  214. stock: 100 // 库存
  215. }
  216. ]
  217. }
  218. },
  219. filters: {
  220. NumFormat(value) {
  221. //处理金额
  222. return Number(value).toFixed(2)
  223. }
  224. },
  225. created() {
  226. this.number = this.product.minBuyNumber
  227. this.buyRetailPrice = this.product.price
  228. this.initData()
  229. },
  230. computed: {
  231. ...mapState(['hasLogin'])
  232. },
  233. methods: {
  234. async initData(data) {
  235. const userInfo = await this.$api.getStorage()
  236. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  237. //处理禁用按钮商品
  238. this.isBtnDisabled = this.isDisabledFlag(this.product)
  239. if(this.product.skuList[0].ladderPriceList){ this.isShowLadder = true }
  240. },
  241. isDisabledFlag(pros){
  242. // 非会员
  243. if (!this.vipFlag === 1) return true
  244. // 商品已下架 || 库存为0
  245. if (pros.validFlag == 3 || pros.stock == 0) return true
  246. // 商品价格不公开
  247. if (pros.priceFlag === 1) return true
  248. // 商品价格仅资质机构可见 && 机构为普通机构
  249. if (pros.priceFlag === 2 && this.userIdentity === 4 ) return true
  250. // 商品价格仅医美机构可见 && 机构为普通机构
  251. if (pros.priceFlag === 3 && this.userIdentity === 4 ) return true
  252. // 商品价格仅医美机构可见 && 机构为资质机构 && 不是医美机构
  253. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType != 1) return true
  254. //其他
  255. return false
  256. },
  257. handleConfirm() {
  258. const data = { unit : this.handleUnit}
  259. this.$emit('btnConfirm', data)
  260. this.$parent.popupShow1 = false
  261. },
  262. handleChoisSku(sku, index) {
  263. // 选择SKU
  264. this.skuIndex = index
  265. this.handleUnit = sku.unit
  266. this.ladderPriceList = sku.ladderPriceList
  267. this.isShowLadder = sku.ladderPriceList ? true : false
  268. },
  269. showLaddePopup(){
  270. // 点击显示阶梯价
  271. this.laddePopupShow = true
  272. },
  273. hidePopup() {
  274. //隐藏
  275. this.$parent.popupShow1 = false
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss">
  281. .tui-popup-box {
  282. padding: 40rpx 24rpx 0 24rpx;
  283. }
  284. .tui-shopping-main {
  285. width: 100%;
  286. .tui-sku-title {
  287. width: 100%;
  288. height: 136rpx;
  289. float: left;
  290. margin-bottom: 30rpx;
  291. .tui-sku-image {
  292. width: 138rpx;
  293. height: 138rpx;
  294. float: left;
  295. border-radius: 8rpx;
  296. margin-right: 30rpx;
  297. box-sizing: border-box;
  298. border: 1px dashed #e1e1e1;
  299. image {
  300. width: 134rpx;
  301. height: 134rpx;
  302. border-radius: 10rpx;
  303. }
  304. }
  305. .tui-sku-price {
  306. height: 136rpx;
  307. float: left;
  308. }
  309. }
  310. .tui-sku-unit {
  311. width: 100%;
  312. height: auto;
  313. float: left;
  314. .sku-unit-h1 {
  315. font-size: 28rpx;
  316. line-height: 40rpx;
  317. color: #333333;
  318. font-weight: bold;
  319. }
  320. .sku-unit-li {
  321. width: 100%;
  322. height: auto;
  323. .unit-li {
  324. padding: 0 24rpx;
  325. line-height: 48rpx;
  326. text-align: center;
  327. font-size: 24rpx;
  328. color: #666666;
  329. background: #f5f5f5;
  330. float: left;
  331. margin-right: 16rpx;
  332. margin-top: 12rpx;
  333. margin-bottom: 12rpx;
  334. border-radius: 24rpx;
  335. position: relative;
  336. box-sizing: border-box;
  337. border: 1px solid #f5f5f5;
  338. &.active {
  339. border-color: $color-system;
  340. background: #fff1eb;
  341. color: $color-system;
  342. .tips {
  343. background: #e15616;
  344. }
  345. }
  346. .tips {
  347. padding: 0 10rpx;
  348. line-height: 32rpx;
  349. text-align: center;
  350. font-size: 22rpx;
  351. color: #ffffff;
  352. background: #cccccc;
  353. float: left;
  354. border-radius: 16rpx;
  355. position: absolute;
  356. right: -12rpx;
  357. top: -15rpx;
  358. }
  359. }
  360. }
  361. }
  362. .sku-unit-ladel {
  363. width: 100%;
  364. height: 64rpx;
  365. line-height: 64rpx;
  366. float: left;
  367. margin-top: 20rpx;
  368. text-align: center;
  369. font-size: 24rpx;
  370. background: #fffaf8;
  371. color: #e15616;
  372. }
  373. }
  374. .tui-modal-flex {
  375. width: 100%;
  376. height: 84rpx;
  377. margin-top: 40rpx;
  378. display: flex;
  379. .tui-modal-button {
  380. flex: 1;
  381. line-height: 84rpx;
  382. font-size: $font-size-28;
  383. text-align: center;
  384. border-radius: 42rpx;
  385. padding: 0;
  386. margin: 0 15rpx;
  387. box-sizing: border-box;
  388. &.cancel {
  389. background: #ffe6dc;
  390. color: #e15616;
  391. }
  392. &.confirm {
  393. background: $btn-confirm;
  394. color: #ffffff;
  395. &.disabled {
  396. background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
  397. }
  398. }
  399. }
  400. }
  401. </style>