immediately.vue 8.9 KB

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