immediately.vue 8.5 KB

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