popupGoods.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template name="popup">
  2. <!-- 规格-模态层弹窗 -->
  3. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="hideSpec">
  4. <!-- 遮罩层 -->
  5. <view class="mask"></view>
  6. <view class="layer" @tap.stop="discard">
  7. <view class="content">
  8. <view class="layer-smimg">
  9. <image src="https://img.caimei365.com/group1/M00/02/6D/Cmis21xFeHGAIyUTAAPeRga1_H464.JPEG" mode=""></image>
  10. </view>
  11. <view class="layer-nunbox">
  12. <view class="layer-nunbox-t">
  13. <view class="text">
  14. 数量:
  15. <uni-number-box
  16. class="product-step"
  17. :min="minBuyNumber"
  18. :max="stock"
  19. :value="minBuyNumber>stock?stock:minBuyNumber"
  20. :isMax="minBuyNumber>=stock?true:false"
  21. :isMin="minBuyNumber===minBuyNumber"
  22. @eventChange="numberChang"
  23. >
  24. </uni-number-box>
  25. </view>
  26. </view>
  27. <view class="layer-nunbox-b">
  28. <view class="text">单价:
  29. <text class="p sm">¥</text>
  30. <text class="p bg">{{goodsData.retailPrice}}</text>
  31. <text class="p sm">{{goodsData.smallMoney== '0'?'.00':goodsData.smallMoney}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="btn"><view class="button" @tap="btnConfirm">确定</view></view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. var self;
  42. import uniNumberBox from '@/components/uni-number-box.vue'
  43. export default{
  44. name:'popup',
  45. components:{
  46. uniNumberBox
  47. },
  48. props:['goodsData','minBuyNumber','stock'],
  49. data() {
  50. return{
  51. specClass: '',//规格弹窗css类,控制开关动画
  52. isType:'',
  53. // productData:''
  54. }
  55. },
  56. created() {
  57. // this.productData = this.$parent.productData;
  58. console.log(this.goodsData)
  59. },
  60. methods:{
  61. //数量
  62. numberChange(data){
  63. console.log(data);
  64. },
  65. //规格弹窗
  66. showSpec(type) {
  67. console.log('show');
  68. this.isType = type
  69. this.specClass = 'show';
  70. },
  71. //关闭规格弹窗
  72. hideSpec() {
  73. this.specClass = 'hide';
  74. setTimeout(() => {
  75. this.specClass = 'none';
  76. }, 200);
  77. },
  78. //加入购物车关闭规格弹窗
  79. btnConfirm() {
  80. this.specClass = 'hide';
  81. setTimeout(() => {
  82. this.specClass = 'none';
  83. }, 200);
  84. console.log(this.isType);
  85. if(this.isType == 'add'){
  86. uni.showToast({
  87. title: "已加入购物车",
  88. duration:2000,
  89. icon:'success',
  90. mask:false
  91. });
  92. }else{
  93. this.toConfirmation()
  94. }
  95. },
  96. //跳转确认订单页面
  97. toConfirmation(){
  98. uni.navigateTo({
  99. url:'/pages/user/order/confirmation'
  100. })
  101. },
  102. discard() {
  103. //丢弃
  104. }
  105. },
  106. }
  107. </script>
  108. <style lang="scss">
  109. /* 加入购物模态层*/
  110. @keyframes showPopup {
  111. 0% {
  112. opacity: 0;
  113. }
  114. 100% {
  115. opacity: 1;
  116. }
  117. }
  118. @keyframes hidePopup {
  119. 0% {
  120. opacity: 1;
  121. }
  122. 100% {
  123. opacity: 0;
  124. }
  125. }
  126. @keyframes showLayer {
  127. 0% {
  128. transform: translateY(0);
  129. }
  130. 100% {
  131. transform: translateY(-100%);
  132. }
  133. }
  134. @keyframes hideLayer {
  135. 0% {
  136. transform: translateY(-100%);
  137. }
  138. 100% {
  139. transform: translateY(0);
  140. }
  141. }
  142. .popup {
  143. position: fixed;
  144. top: 0;
  145. width: 100%;
  146. height: 100%;
  147. z-index: 999;
  148. display: none;
  149. .mask{
  150. position: fixed;
  151. top: 0;
  152. width: 100%;
  153. height: 100%;
  154. z-index: 21;
  155. background-color: rgba(0, 0, 0, 0.6);
  156. }
  157. .layer {
  158. position: fixed;
  159. z-index: 22;
  160. bottom: -270rpx;
  161. width: 702rpx;
  162. padding: 24rpx 24rpx 10rpx 24rpx;
  163. height: 236rpx;
  164. border-radius: 30rpx 30rpx 0 0;
  165. background-color: #fff;
  166. display: flex;
  167. flex-wrap: wrap;
  168. align-content: space-between;
  169. .content {
  170. width: 100%;
  171. }
  172. .btn {
  173. width: 100%;
  174. height: 88rpx;
  175. .button {
  176. width: 100%;
  177. height: 88rpx;
  178. color: #fff;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. background-color: #000000;
  183. font-size: $font-size-28;
  184. }
  185. }
  186. }
  187. &.show {
  188. display: block;
  189. .mask{
  190. animation: showPopup 0.2s linear both;
  191. }
  192. .layer {
  193. animation: showLayer 0.2s linear both;
  194. }
  195. }
  196. &.hide {
  197. display: block;
  198. .mask{
  199. animation: hidePopup 0.2s linear both;
  200. }
  201. .layer {
  202. animation: hideLayer 0.2s linear both;
  203. }
  204. }
  205. &.none {
  206. display: none;
  207. }
  208. &.service {
  209. .row {
  210. margin: 30upx 0;
  211. .title {
  212. font-size: 30upx;
  213. margin: 10upx 0;
  214. }
  215. .description {
  216. font-size: 28upx;
  217. color: #999;
  218. }
  219. }
  220. }
  221. .layer-smimg{
  222. width: 114rpx;
  223. height: 114rpx;
  224. float: left;
  225. border-radius: 10rpx;
  226. margin-right: 24rpx;
  227. image{
  228. width: 114rpx;
  229. height: 114rpx;
  230. border-radius: 10rpx;
  231. }
  232. }
  233. .layer-nunbox{
  234. justify-content: space-between;
  235. align-items: center;
  236. width: 536rpx;
  237. height: 88rpx;
  238. padding: 13rpx 0 0 0;
  239. float: left;
  240. .layer-nunbox-t{
  241. width: 100%;
  242. height:44rpx;
  243. position:relative;
  244. .product-step{
  245. position: absolute;
  246. left: 45rpx;
  247. bottom: 0;
  248. height: 44rpx;
  249. background: #FFFFFF;
  250. }
  251. }
  252. .layer-nunbox-b{
  253. width: 100%;
  254. height:44rpx;
  255. margin-top: 13rpx;
  256. }
  257. .text{
  258. line-height: 44rpx;
  259. font-size: $font-size-28;
  260. .p{
  261. color: #FF2A2A;
  262. }
  263. .p:first-child{
  264. margin-left: 30rpx;
  265. }
  266. .p.sm{
  267. font-size: $font-size-24;
  268. }
  269. }
  270. }
  271. }
  272. </style>