cm-unit-popup.vue 8.0 KB

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