cm-unit-popup.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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. 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.skuProduct.price = this.skuList[0].price;
  119. this.initData()
  120. },
  121. computed: {
  122. ...mapState(['hasLogin'])
  123. },
  124. methods: {
  125. async initData(data) {
  126. const userInfo = await this.$api.getStorage()
  127. this.addParams.userId = userInfo.userId ? userInfo.userId : 0
  128. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  129. },
  130. skuChangNumberSub() {// 减数
  131. if ( this.addParams.count <= this.handleMinNumber) {
  132. this.addParams.count = this.handleMinNumber
  133. } else {
  134. this.addParams.count--
  135. }
  136. },
  137. skuChangNumberAdd() {// 加数
  138. this.addParams.count++;
  139. },
  140. skuChangNumberChange(e) {// 修改.
  141. let _value = e.detail.value
  142. if (!this.$api.isNumber(_value)) {
  143. this.addParams.count = this.handleMinNumber
  144. } else if (_value < this.handleMinNumber) {
  145. this.addParams.count = this.handleMinNumber
  146. } else {
  147. this.addParams.count = _value
  148. }
  149. },
  150. handleConfirm() {
  151. if(this.isBtnDisable){ return }
  152. this.$emit('skuBtnConfirm', this.addParams)
  153. this.$parent.popupShow2 = false
  154. },
  155. handleChoisSku(sku, index) {
  156. // 选择SKU
  157. this.skuIndex = index
  158. this.addParams.newSkuId = sku.skuId;
  159. this.addParams.count = sku.minBuyNumber;
  160. this.handleMinNumber = sku.minBuyNumber;
  161. this.skuProduct.price = sku.price;
  162. this.skuProduct.originalPrice = sku.originalPrice;
  163. },
  164. hidePopup() {
  165. this.$parent.popupShow2 = false
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss">
  171. .tui-popup-box {
  172. padding: 40rpx 24rpx 0 24rpx;
  173. }
  174. .tui-shopping-main {
  175. width: 100%;
  176. .tui-sku-title {
  177. width: 100%;
  178. height: 136rpx;
  179. float: left;
  180. margin-bottom: 30rpx;
  181. .tui-sku-image {
  182. width: 138rpx;
  183. height: 138rpx;
  184. float: left;
  185. border-radius: 8rpx;
  186. margin-right: 30rpx;
  187. box-sizing: border-box;
  188. border: 1px dashed #e1e1e1;
  189. image {
  190. width: 134rpx;
  191. height: 134rpx;
  192. border-radius: 10rpx;
  193. }
  194. }
  195. .tui-sku-price {
  196. height: 136rpx;
  197. float: left;
  198. .sku-price-viw {
  199. width: 100%;
  200. height: 40rpx;
  201. margin-bottom: 24rpx;
  202. .sku-price-text {
  203. font-size: 28rpx;
  204. line-height: 40rpx;
  205. color: #f94b4b;
  206. font-weight: bold;
  207. .sku-price-l{
  208. float: left;
  209. font-weight: normal;
  210. }
  211. &.none {
  212. text-decoration: line-through;
  213. color: #999999;
  214. font-weight: normal;
  215. }
  216. }
  217. }
  218. .sku-price-vip {
  219. width: 100%;
  220. height: 40rpx;
  221. }
  222. }
  223. }
  224. .tui-sku-unit {
  225. width: 100%;
  226. height: auto;
  227. float: left;
  228. .sku-unit-h1 {
  229. font-size: 28rpx;
  230. line-height: 40rpx;
  231. color: #333333;
  232. font-weight: bold;
  233. }
  234. .sku-unit-li {
  235. width: 100%;
  236. height: auto;
  237. .unit-li {
  238. padding: 0 24rpx;
  239. line-height: 48rpx;
  240. text-align: center;
  241. font-size: 24rpx;
  242. color: #666666;
  243. background: #f5f5f5;
  244. float: left;
  245. margin-right: 16rpx;
  246. margin-top: 12rpx;
  247. margin-bottom: 12rpx;
  248. border-radius: 24rpx;
  249. position: relative;
  250. box-sizing: border-box;
  251. border: 1px solid #f5f5f5;
  252. &.active {
  253. border-color: $color-system;
  254. background: #fff1eb;
  255. color: $color-system;
  256. .tips {
  257. background: #FF5B00;
  258. }
  259. }
  260. .tips {
  261. padding: 0 10rpx;
  262. line-height: 32rpx;
  263. text-align: center;
  264. font-size: 22rpx;
  265. color: #ffffff;
  266. background: #cccccc;
  267. float: left;
  268. border-radius: 16rpx;
  269. position: absolute;
  270. right: -12rpx;
  271. top: -15rpx;
  272. }
  273. }
  274. }
  275. }
  276. .sku-unit-nunbox {
  277. justify-content: space-between;
  278. align-items: center;
  279. width: 100%;
  280. height: auto;
  281. float: left;
  282. margin-top: 30rpx;
  283. .sku-unit-nunbox-t {
  284. width: 100%;
  285. height: 44rpx;
  286. position: relative;
  287. margin-bottom: 20rpx;
  288. .text {
  289. font-size: $font-size-24;
  290. line-height: 48rpx;
  291. color: #999999;
  292. }
  293. .sku-unit-nunbox-text {
  294. line-height: 44rpx;
  295. font-size: $font-size-28;
  296. float: left;
  297. font-weight: bold;
  298. }
  299. .sku-unit-nunbox-num{
  300. float: right;
  301. .number-box {
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. border: 2rpx solid #ffe6dc;
  306. border-radius: 30rpx;
  307. height: 48rpx;
  308. margin-left: 20rpx;
  309. .iconfont {
  310. font-size: $font-size-24;
  311. padding: 0 18rpx;
  312. color: #333333;
  313. text-align: center;
  314. line-height: 48rpx;
  315. font-weight: bold;
  316. background: #fef6f3;
  317. &.icon-jianhao {
  318. border-radius: 30rpx 0 0 30rpx;
  319. }
  320. &.icon-jiahao {
  321. border-radius: 0 30rpx 30rpx 0;
  322. }
  323. }
  324. .btn-input {
  325. width: 62rpx;
  326. height: 48rpx;
  327. line-height: 48rpx;
  328. background: #ffffff;
  329. border-radius: 4rpx;
  330. text-align: center;
  331. font-size: $font-size-28;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. }
  338. .tui-popup-btn{
  339. width: 100%;
  340. float: left;
  341. .tui-modal-flex {
  342. width: 100%;
  343. height: 84rpx;
  344. margin-top: 40rpx;
  345. display: flex;
  346. .tui-modal-button {
  347. flex: 1;
  348. line-height: 84rpx;
  349. font-size: $font-size-28;
  350. text-align: center;
  351. border-radius: 42rpx;
  352. padding: 0;
  353. margin: 0 15rpx;
  354. box-sizing: border-box;
  355. &.cancel {
  356. background: #ffe6dc;
  357. color: #FF5B00;
  358. }
  359. &.confirm {
  360. background: $btn-confirm;
  361. color: #ffffff;
  362. &.disabled {
  363. background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
  364. }
  365. }
  366. }
  367. }
  368. }
  369. </style>