immediately.vue 8.2 KB

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