immediately.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view class="container all-type-list-wrapper">
  3. <immediately-list ref="productList"
  4. :search-status="true"
  5. @operationConfim="hanldOperationConfim"
  6. @goCartPage="hanldToCartPage">
  7. </immediately-list>
  8. <!--底部选择模态层弹窗组件 -->
  9. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="hideSpec">
  10. <!-- 遮罩层 -->
  11. <view class="mask"></view>
  12. <view class="layer" @tap.stop="discard">
  13. <view class="content">
  14. <view class="layer-smimg">
  15. <image :src="handleData.mainImage" mode=""></image>
  16. </view>
  17. <view class="layer-nunbox">
  18. <view class="layer-nunbox-t">
  19. <view class="layer-nunbox-text">数量:</view>
  20. <view class="number-box">
  21. <view class="iconfont icon-jianhao" :class="[isQuantity==true?'disabled':'']" @click="changeCountSub()"></view>
  22. <input class="btn-input" type="number" v-model="number" maxlength='4' @blur="changeNumber($event)">
  23. <view class="iconfont icon-jiahao" :class="[isStock==true?'disabled':'']" @click="changeCountAdd()"></view>
  24. </view>
  25. </view>
  26. <view class="layer-nunbox-b">
  27. <view class="text">单价:
  28. <text class="p sm">¥</text>
  29. <text class="p bg">{{buyRetailPrice.toFixed(2)}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="btn">
  35. <view class="button add" @click="getAddProductCart">加入购物车</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import immediatelyList from '@/components/module/listTemplate/immediatelyList'
  43. import { getSellerProductNum ,shoppingCartAddCart} from "@/api/seller.js"
  44. export default{
  45. components:{
  46. immediatelyList
  47. },
  48. data(){
  49. return{
  50. clubID:'', //机构ID
  51. serviceProviderId:'',//协销ID
  52. serverUrl: '',
  53. emptyText: '',
  54. lastPageType: '',
  55. lastPageVal: '',
  56. specClass: '',//规格弹窗css类,控制开关动画
  57. handleData:{},
  58. isQuantity:false,
  59. isStock:false,
  60. minBuyNumber:0,
  61. number:0,
  62. buyRetailPrice:0
  63. }
  64. },
  65. onLoad() {
  66. },
  67. methods:{
  68. getClubProductNum(){
  69. getSellerProductNum({clubId:this.clubID,serviceProviderId:this.serviceProviderId}).then(response =>{
  70. this.$refs.productList.cartQuantity = response.data
  71. })
  72. },
  73. hanldOperationConfim(data){//显示选择数量确认弹窗
  74. this.specClass = 'show';
  75. this.handleData = data
  76. this.number = data.minBuyNumber
  77. this.minBuyNumber = data.minBuyNumber
  78. this.buyRetailPrice = data.retailPrice;
  79. },
  80. hideSpec() {//关闭选择数量确认弹窗
  81. this.specClass = 'hide';
  82. setTimeout(() => {
  83. this.specClass = 'none';
  84. }, 200);
  85. },
  86. changeCountAdd(){//popup弹窗数量增加按钮
  87. this.number++
  88. if(this.handleData.ladderPriceFlag == '1'){
  89. this.handleData.ladderPriceList.forEach((item,index)=>{
  90. if(this.number>=item.buyNum){
  91. this.buyRetailPrice = item.buyPrice
  92. }
  93. })
  94. }
  95. },
  96. changeCountSub(){//popup弹窗数量减按钮
  97. if(this.number<=this.minBuyNumber){
  98. this.number= this.minBuyNumber
  99. this.isQuantity =true
  100. this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  101. return
  102. }else{
  103. this.number--
  104. if(this.handleData.ladderPriceFlag == '1'){
  105. this.handleData.ladderPriceList.forEach((item,index)=>{
  106. if(this.number>=item.buyNum){
  107. this.buyRetailPrice = item.buyPrice
  108. }
  109. })
  110. }
  111. this.isQuantity =false
  112. }
  113. },
  114. changeNumber(e){
  115. let _value = e.detail.value;
  116. if(!this.$api.isNumber(_value)){
  117. this.number = this.minBuyNumber
  118. }else if(_value < this.minBuyNumber){
  119. this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  120. this.number = this.minBuyNumber
  121. }else{
  122. this.number = e.detail.value
  123. }
  124. },
  125. getAddProductCart(){//增加购物车成功和toast弹窗提示成功
  126. let params ={
  127. productId:this.handleData.productID,
  128. clubId:this.clubID,
  129. serviceProviderId:this.serviceProviderId,
  130. num:this.number
  131. }
  132. shoppingCartAddCart(params).then(response => {
  133. this.specClass = 'hide';
  134. this.$util.msg('加入购物车成功',1500,true,'success')
  135. this.getClubProductNum()
  136. setTimeout(() => {this.specClass = 'none'}, 200)
  137. }).catch(response =>{
  138. this.$util.msg(response.msg,2000);
  139. })
  140. },
  141. hanldToCartPage(){
  142. this.$api.navigateTo('/market/pages/cart/cart')
  143. },
  144. discard(){
  145. //丢弃
  146. }
  147. },
  148. onShow() {
  149. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  150. this.clubID = resolve.clubID
  151. })
  152. this.$api.getStorage().then((resolve) =>{
  153. this.serviceProviderId = resolve.serviceProviderID
  154. this.getClubProductNum()
  155. })
  156. },
  157. }
  158. </script>
  159. <style lang="scss">
  160. page {
  161. background: $sub-bg-color;
  162. .all-type-list-wrapper {
  163. display: flex;
  164. flex-direction: column;
  165. }
  166. }
  167. /* 加入购物模态层*/
  168. @keyframes showPopup {
  169. 0% {
  170. opacity: 0;
  171. }
  172. 100% {
  173. opacity: 1;
  174. }
  175. }
  176. @keyframes hidePopup {
  177. 0% {
  178. opacity: 1;
  179. }
  180. 100% {
  181. opacity: 0;
  182. }
  183. }
  184. @keyframes showLayer {
  185. 0% {
  186. transform: translateY(0);
  187. }
  188. 100% {
  189. transform: translateY(-100%);
  190. }
  191. }
  192. @keyframes hideLayer {
  193. 0% {
  194. transform: translateY(-100%);
  195. }
  196. 100% {
  197. transform: translateY(0);
  198. }
  199. }
  200. @keyframes showAmnation {
  201. 0% {
  202. top: -12rpx;
  203. opacity: 0;
  204. }
  205. 50% {
  206. top: -60rpx;
  207. opacity: 1;
  208. }
  209. 100% {
  210. top: -100rpx;
  211. opacity: 0;
  212. }
  213. }
  214. @keyframes hideAmnation {
  215. 0% {
  216. top: -100rpx;
  217. opacity: 0;
  218. }
  219. 100% {
  220. top: -12rpx;
  221. opacity: 0;
  222. }
  223. }
  224. .popup {
  225. position: fixed;
  226. top: 0;
  227. width: 100%;
  228. height: 100%;
  229. z-index: 999;
  230. display: none;
  231. .mask{
  232. position: fixed;
  233. top: 0;
  234. width: 100%;
  235. height: 100%;
  236. z-index: 21;
  237. background-color: rgba(0, 0, 0, 0.6);
  238. }
  239. .layer {
  240. position: fixed;
  241. z-index: 22;
  242. bottom: -294rpx;
  243. width: 702rpx;
  244. padding: 24rpx 24rpx 36rpx 24rpx;
  245. height: 236rpx;
  246. border-radius: 30rpx 30rpx 0 0;
  247. background-color: #fff;
  248. display: flex;
  249. flex-wrap: wrap;
  250. align-content: space-between;
  251. .content {
  252. width: 100%;
  253. }
  254. .btn {
  255. width: 100%;
  256. height: 88rpx;
  257. display: flex;
  258. .button {
  259. width: 702rpx;
  260. height: 88rpx;
  261. color: #fff;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. font-size: $font-size-28;
  266. border-radius: 14rpx;
  267. background: $btn-confirm;
  268. }
  269. }
  270. }
  271. &.show {
  272. display: block;
  273. .mask{
  274. animation: showPopup 0.2s linear both;
  275. }
  276. .layer {
  277. animation: showLayer 0.2s linear both;
  278. }
  279. }
  280. &.hide {
  281. display: block;
  282. .mask{
  283. animation: hidePopup 0.2s linear both;
  284. }
  285. .layer {
  286. animation: hideLayer 0.2s linear both;
  287. }
  288. }
  289. &.none {
  290. display: none;
  291. }
  292. &.service {
  293. .row {
  294. margin: 30upx 0;
  295. .title {
  296. font-size: 30upx;
  297. margin: 10upx 0;
  298. }
  299. .description {
  300. font-size: 28upx;
  301. color: #999;
  302. }
  303. }
  304. }
  305. .layer-smimg{
  306. width: 114rpx;
  307. height: 114rpx;
  308. float: left;
  309. border-radius: 10rpx;
  310. margin-right: 24rpx;
  311. image{
  312. width: 114rpx;
  313. height: 114rpx;
  314. border-radius: 10rpx;
  315. }
  316. }
  317. .layer-nunbox{
  318. justify-content: space-between;
  319. align-items: center;
  320. width: 536rpx;
  321. height: 88rpx;
  322. padding: 13rpx 0 0 0;
  323. float: left;
  324. .layer-nunbox-t{
  325. width: 100%;
  326. height:44rpx;
  327. position:relative;
  328. display: flex;
  329. .layer-nunbox-text{
  330. line-height: 44rpx;
  331. font-size: $font-size-28;
  332. }
  333. .number-box{
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. .iconfont{
  338. font-size: $font-size-32;
  339. padding:0 20rpx;
  340. font-size: $text-color;
  341. }
  342. .btn-input{
  343. width: 62rpx;
  344. height: 48rpx;
  345. line-height: 48rpx;
  346. background: #F8F8F8;
  347. border-radius: 4rpx;
  348. text-align: center;
  349. font-size: $font-size-28;
  350. }
  351. }
  352. .product-step{
  353. position: absolute;
  354. left: 45rpx;
  355. bottom: 0;
  356. height: 44rpx;
  357. background: #FFFFFF;
  358. }
  359. }
  360. .layer-nunbox-b{
  361. width: 100%;
  362. height:44rpx;
  363. margin-top: 13rpx;
  364. }
  365. .text{
  366. line-height: 44rpx;
  367. font-size: $font-size-28;
  368. .p{
  369. color: #FF2A2A;
  370. }
  371. .p:first-child{
  372. margin-left: 30rpx;
  373. }
  374. .p.sm{
  375. font-size: $font-size-24;
  376. }
  377. }
  378. }
  379. }
  380. </style>