immediately.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. console.log(data)
  75. this.specClass = 'show';
  76. this.handleData = data
  77. this.number = data.minBuyNumber
  78. this.minBuyNumber = data.minBuyNumber
  79. this.buyRetailPrice = data.retailPrice;
  80. },
  81. hideSpec() {//关闭选择数量确认弹窗
  82. this.specClass = 'hide';
  83. setTimeout(() => {
  84. this.specClass = 'none';
  85. }, 200);
  86. },
  87. changeCountAdd(){//popup弹窗数量增加按钮
  88. this.number++
  89. if(this.handleData.ladderPriceFlag == '1'){
  90. this.handleData.productLadderPrices.forEach((item,index)=>{
  91. if(this.number>=item.buyNum){
  92. this.buyRetailPrice = item.buyPrice
  93. }
  94. })
  95. }
  96. },
  97. changeCountSub(){//popup弹窗数量减按钮
  98. if(this.number<=this.minBuyNumber){
  99. this.number= this.minBuyNumber
  100. this.isQuantity =true
  101. this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  102. return
  103. }else{
  104. this.number--
  105. if(this.handleData.ladderPriceFlag == '1'){
  106. this.handleData.productLadderPrices.forEach((item,index)=>{
  107. if(this.number>=item.buyNum){
  108. this.buyRetailPrice = item.buyPrice
  109. }
  110. })
  111. }
  112. this.isQuantity =false
  113. }
  114. },
  115. changeNumber(e){
  116. let _value = e.detail.value;
  117. if(!this.$api.isNumber(_value)){
  118. this.number = this.minBuyNumber
  119. }else if(_value < this.minBuyNumber){
  120. this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  121. this.number = this.minBuyNumber
  122. }else{
  123. this.number = e.detail.value
  124. }
  125. },
  126. getAddProductCart(){//增加购物车成功和toast弹窗提示成功
  127. let params ={
  128. productId:this.handleData.productID,
  129. clubId:this.clubID,
  130. serviceProviderId:this.serviceProviderId,
  131. num:this.number
  132. }
  133. shoppingCartAddCart(params).then(response => {
  134. this.specClass = 'hide';
  135. this.$util.msg('加入购物车成功',1500,true,'success')
  136. this.getClubProductNum()
  137. setTimeout(() => {this.specClass = 'none'}, 200)
  138. }).catch(response =>{
  139. this.$util.msg(response.msg,2000);
  140. })
  141. },
  142. hanldToCartPage(){
  143. this.$api.navigateTo('/market/pages/cart/cart')
  144. },
  145. discard(){
  146. //丢弃
  147. }
  148. },
  149. onShow() {
  150. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  151. this.clubID = resolve.clubID
  152. })
  153. this.$api.getStorage().then((resolve) =>{
  154. this.serviceProviderId = resolve.serviceProviderID
  155. this.getClubProductNum()
  156. })
  157. },
  158. }
  159. </script>
  160. <style lang="scss">
  161. page {
  162. background: $sub-bg-color;
  163. .all-type-list-wrapper {
  164. display: flex;
  165. flex-direction: column;
  166. }
  167. }
  168. /* 加入购物模态层*/
  169. @keyframes showPopup {
  170. 0% {
  171. opacity: 0;
  172. }
  173. 100% {
  174. opacity: 1;
  175. }
  176. }
  177. @keyframes hidePopup {
  178. 0% {
  179. opacity: 1;
  180. }
  181. 100% {
  182. opacity: 0;
  183. }
  184. }
  185. @keyframes showLayer {
  186. 0% {
  187. transform: translateY(0);
  188. }
  189. 100% {
  190. transform: translateY(-100%);
  191. }
  192. }
  193. @keyframes hideLayer {
  194. 0% {
  195. transform: translateY(-100%);
  196. }
  197. 100% {
  198. transform: translateY(0);
  199. }
  200. }
  201. @keyframes showAmnation {
  202. 0% {
  203. top: -12rpx;
  204. opacity: 0;
  205. }
  206. 50% {
  207. top: -60rpx;
  208. opacity: 1;
  209. }
  210. 100% {
  211. top: -100rpx;
  212. opacity: 0;
  213. }
  214. }
  215. @keyframes hideAmnation {
  216. 0% {
  217. top: -100rpx;
  218. opacity: 0;
  219. }
  220. 100% {
  221. top: -12rpx;
  222. opacity: 0;
  223. }
  224. }
  225. .popup {
  226. position: fixed;
  227. top: 0;
  228. width: 100%;
  229. height: 100%;
  230. z-index: 999;
  231. display: none;
  232. .mask{
  233. position: fixed;
  234. top: 0;
  235. width: 100%;
  236. height: 100%;
  237. z-index: 21;
  238. background-color: rgba(0, 0, 0, 0.6);
  239. }
  240. .layer {
  241. position: fixed;
  242. z-index: 22;
  243. bottom: -294rpx;
  244. width: 702rpx;
  245. padding: 24rpx 24rpx 36rpx 24rpx;
  246. height: 236rpx;
  247. border-radius: 30rpx 30rpx 0 0;
  248. background-color: #fff;
  249. display: flex;
  250. flex-wrap: wrap;
  251. align-content: space-between;
  252. .content {
  253. width: 100%;
  254. }
  255. .btn {
  256. width: 100%;
  257. height: 88rpx;
  258. display: flex;
  259. .button {
  260. width: 702rpx;
  261. height: 88rpx;
  262. color: #fff;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. font-size: $font-size-28;
  267. border-radius: 14rpx;
  268. background: $btn-confirm;
  269. }
  270. }
  271. }
  272. &.show {
  273. display: block;
  274. .mask{
  275. animation: showPopup 0.2s linear both;
  276. }
  277. .layer {
  278. animation: showLayer 0.2s linear both;
  279. }
  280. }
  281. &.hide {
  282. display: block;
  283. .mask{
  284. animation: hidePopup 0.2s linear both;
  285. }
  286. .layer {
  287. animation: hideLayer 0.2s linear both;
  288. }
  289. }
  290. &.none {
  291. display: none;
  292. }
  293. &.service {
  294. .row {
  295. margin: 30upx 0;
  296. .title {
  297. font-size: 30upx;
  298. margin: 10upx 0;
  299. }
  300. .description {
  301. font-size: 28upx;
  302. color: #999;
  303. }
  304. }
  305. }
  306. .layer-smimg{
  307. width: 114rpx;
  308. height: 114rpx;
  309. float: left;
  310. border-radius: 10rpx;
  311. margin-right: 24rpx;
  312. image{
  313. width: 114rpx;
  314. height: 114rpx;
  315. border-radius: 10rpx;
  316. }
  317. }
  318. .layer-nunbox{
  319. justify-content: space-between;
  320. align-items: center;
  321. width: 536rpx;
  322. height: 88rpx;
  323. padding: 13rpx 0 0 0;
  324. float: left;
  325. .layer-nunbox-t{
  326. width: 100%;
  327. height:44rpx;
  328. position:relative;
  329. display: flex;
  330. .layer-nunbox-text{
  331. line-height: 44rpx;
  332. font-size: $font-size-28;
  333. }
  334. .number-box{
  335. display: flex;
  336. justify-content: center;
  337. align-items: center;
  338. .iconfont{
  339. font-size: $font-size-32;
  340. padding:0 20rpx;
  341. font-size: $text-color;
  342. }
  343. .btn-input{
  344. width: 62rpx;
  345. height: 48rpx;
  346. line-height: 48rpx;
  347. background: #F8F8F8;
  348. border-radius: 4rpx;
  349. text-align: center;
  350. font-size: $font-size-28;
  351. }
  352. }
  353. .product-step{
  354. position: absolute;
  355. left: 45rpx;
  356. bottom: 0;
  357. height: 44rpx;
  358. background: #FFFFFF;
  359. }
  360. }
  361. .layer-nunbox-b{
  362. width: 100%;
  363. height:44rpx;
  364. margin-top: 13rpx;
  365. }
  366. .text{
  367. line-height: 44rpx;
  368. font-size: $font-size-28;
  369. .p{
  370. color: #FF2A2A;
  371. }
  372. .p:first-child{
  373. margin-left: 30rpx;
  374. }
  375. .p.sm{
  376. font-size: $font-size-24;
  377. }
  378. }
  379. }
  380. }
  381. </style>