sellerFreight.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template name="freight">
  2. <view class="freight-template">
  3. <!-- 运费信息 -->
  4. <view class="invoice-freight" @tap.stop="hanldOperationConfim">
  5. <view class="freight-left">运费</view>
  6. <view class="freight-right">
  7. <text class="text-l">{{freightText}}</text>
  8. <text class="text" v-if="freightData.postageFlag == 1">¥{{orderPriceToFixed(freightMoney)}}</text>
  9. <text class="iconfont icon-xiayibu"></text>
  10. </view>
  11. </view>
  12. <!--底部选择模态层弹窗组件 -->
  13. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @click="freightConfim">
  14. <!-- 遮罩层 -->
  15. <view class="mask"></view>
  16. <view class="layer" @tap.stop="discard">
  17. <view class="content">
  18. <view class="freight-ltitle">选择运费</view>
  19. <view class="freight-radio">
  20. <radio-group class="row-group" @change="radioChange">
  21. <label class="row-input" v-for="(item, index) in freightList" :key="item.value">
  22. <radio class="row-radio" :value="item.value" :checked="index === current" color="#E15616"/>
  23. <view class="row-text">{{item.name}}</view>
  24. </label>
  25. </radio-group>
  26. </view>
  27. <view class="freight-group" v-if="freightData.postageFlag == 1">
  28. <view class="group-from">
  29. <input class="form-input" type="text" v-model="hanldFreight" @input="setFreightMoney" placeholder="请填写运费" maxlength="20">
  30. </view>
  31. </view>
  32. <view class="freight-group" v-if="freightData.postageFlag == 0">
  33. <text class="text">{{freightText}}</text>
  34. </view>
  35. <view class="freight-group" v-if="freightData.postageFlag == -1">
  36. <text class="text">{{freightText}}</text>
  37. </view>
  38. </view>
  39. <view class="btn">
  40. <view class="button add" @click="freightConfim">完成</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default{
  48. name:'freight',
  49. props:{
  50. freightDatas:{
  51. type:Object
  52. }
  53. },
  54. data() {
  55. return{
  56. freightText:'不包邮',
  57. freightMoney:0,
  58. specClass: '',//规格弹窗css类,控制开关动画
  59. freightList:[
  60. {value:1,name:'不包邮'},
  61. {value:0,name:'包邮'},
  62. {value:-1,name:'到付'},
  63. ],
  64. current:0,
  65. hanldFreight:0,
  66. freightData:{
  67. postageFlag:1,
  68. postage:0
  69. }
  70. }
  71. },
  72. created(){
  73. console.log('this.freightDatas',this.freightDatas)
  74. this.infoData(this.freightDatas)
  75. },
  76. methods:{
  77. infoData(data){//初始化运费
  78. console.log(data)
  79. switch(data.postageFlag){
  80. case 1:
  81. this.current = 0
  82. this.freightData.postageFlag = data.postageFlag
  83. if(data.freight == 0){
  84. this.hanldFreight = ''
  85. }else{
  86. this.hanldFreight = data.postage
  87. }
  88. this.freightData.postage = data.postage
  89. this.freightMoney = this.hanldFreight
  90. this.freightText = ''
  91. console.log('11111111111')
  92. break
  93. case 0:
  94. this.current = 1
  95. this.freightData.postageFlag = data.postageFlag
  96. this.freightText = '包邮'
  97. console.log('000000000000')
  98. break
  99. case -1:
  100. this.current = 2
  101. this.freightData.postageFlag = data.postageFlag
  102. this.freightText = '到付'
  103. console.log('-=1-1-1-1-1-1-')
  104. break
  105. }
  106. },
  107. freightConfim(){//提交完成运费选择
  108. switch(this.freightData.postageFlag){
  109. case 1:
  110. this.choiceaFreightFirst(this.freightData.postageFlag)
  111. break
  112. case 0:
  113. this.choiceaFreightFirst(this.freightData.postageFlag)
  114. break
  115. case -1:
  116. this.choiceaFreightFirst(this.freightData.postageFlag)
  117. break
  118. }
  119. },
  120. choiceaFreightFirst(index){//校验运费形式及运费价
  121. if(index == 1){
  122. if(this.hanldFreight == 0 || this.hanldFreight== ''){
  123. this.$util.msg('请填写运费',2000)
  124. return
  125. }
  126. this.freightData.postage = this.hanldFreight
  127. this.$emit('handleChoiceaFreight',this.freightData)
  128. }else{
  129. this.freightData.postage = 0
  130. this.$emit('handleChoiceaFreight',this.freightData)
  131. }
  132. this.hideSpec()
  133. },
  134. showTip(){//显示运费弹窗
  135. this.$emit('showFreightAlert')
  136. },
  137. hideSpec() {//关闭选择数量确认弹窗
  138. this.specClass = 'hide'
  139. setTimeout(() => {
  140. this.specClass = 'none'
  141. }, 200)
  142. },
  143. hanldOperationConfim(data){//显示选择数量确认弹窗
  144. this.specClass = 'show'
  145. this.freightMoney = this.hanldFreight
  146. },
  147. radioChange(e) {//运费选择切换
  148. this.freightData.postageFlag = parseInt(e.target.value)
  149. switch(this.freightData.postageFlag){
  150. case 1:
  151. this.freightText = '不包邮'
  152. break
  153. case 0:
  154. this.freightText = '包邮'
  155. break
  156. case -1:
  157. this.freightText = '到付'
  158. break
  159. }
  160. for (let i = 0; i < this.freightList.length; i++) {
  161. if (this.freightList[i].value === this.postageFlag) {
  162. this.current = i
  163. break
  164. }
  165. }
  166. },
  167. setFreightMoney(e){//处理邮费显示
  168. if(e.detail.value == ''){
  169. this.freightMoney=0
  170. this.freightData.postage=0
  171. }else{
  172. this.freightData.postage = e.detail.value
  173. this.freightMoney = this.orderPriceToFixed(e.detail.value)
  174. }
  175. },
  176. orderPriceToFixed (num){
  177. let price =''
  178. price = parseInt(num).toFixed(2)
  179. return price
  180. },
  181. discard(){
  182. //丢弃
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss">
  188. .freight-template{
  189. width: 100%;
  190. height: auto;
  191. background: #FFFFFF;
  192. float: left;
  193. margin-top: 24rpx;
  194. .invoice-freight{
  195. width: 702rpx;
  196. padding: 0 24rpx;
  197. height: 88rpx;
  198. line-height: 88rpx;
  199. font-size: $font-size-28;
  200. color: $text-color;
  201. background: #FFFFFF;
  202. float: left;
  203. font-weight: bold;
  204. .freight-left{
  205. float: left;
  206. .icon-yunfeishuoming{
  207. height: 100%;
  208. padding:15rpx;
  209. color: $color-system;
  210. font-weight: normal;
  211. }
  212. }
  213. .freight-right{
  214. float: right;
  215. color: #2A81FF;
  216. .text-l{
  217. margin-right: 20rpx;
  218. }
  219. .text{
  220. line-height: 88rpx;
  221. color: #ff0000;
  222. margin:0 20rpx;
  223. font-weight: normal;
  224. }
  225. .icon-xiayibu{
  226. line-height: 88rpx;
  227. color: #999999;
  228. font-weight: normal;
  229. }
  230. }
  231. }
  232. }
  233. .freight-ltitle{
  234. width: 100%;
  235. line-height: 60rpx;
  236. height: 60rpx;
  237. font-size: $font-size-28;
  238. color: #333333;
  239. }
  240. .freight-radio{
  241. width: 100%;
  242. height: 88rpx;
  243. line-height: 88rpx;
  244. display: flex;
  245. border-bottom: 1px solid #EBEBEB;
  246. .row-group{
  247. flex:1;
  248. display: flex;
  249. }
  250. .row-input{
  251. flex: 1;
  252. height: 88rpx;
  253. line-height: 88rpx;
  254. }
  255. .row-radio{
  256. float: left;
  257. transform: scale(0.6);
  258. }
  259. .row-text{
  260. font-size: $font-size-24;
  261. color: $text-color;
  262. }
  263. }
  264. .freight-group{
  265. width: 100%;
  266. height: 88rpx;
  267. display: flex;
  268. border-bottom: 1px solid #FFFFFF;
  269. flex-direction: row;
  270. .text{
  271. display: block;
  272. flex: 1;
  273. line-height: 88rpx;
  274. font-size: $font-size-24;
  275. color: #999999;
  276. text-align: left;
  277. padding-left: 10rpx;
  278. }
  279. .group-from{
  280. flex: 1;
  281. height: 40rpx;
  282. padding: 20rpx;
  283. line-height: 40rpx;
  284. align-items: flex-start;
  285. font-size: $font-size-24;
  286. color: $text-color;
  287. background: #F7F7F7;
  288. border-radius: 14rpx;
  289. margin-bottom: 20rpx;
  290. margin-top: 10rpx;
  291. .form-input{
  292. height: 40rpx;
  293. line-height: 40rpx;
  294. flex-grow: 1;
  295. }
  296. }
  297. }
  298. /* 加入购物模态层*/
  299. @keyframes showPopup {
  300. 0% {
  301. opacity: 0;
  302. }
  303. 100% {
  304. opacity: 1;
  305. }
  306. }
  307. @keyframes hidePopup {
  308. 0% {
  309. opacity: 1;
  310. }
  311. 100% {
  312. opacity: 0;
  313. }
  314. }
  315. @keyframes showLayer {
  316. 0% {
  317. transform: translateY(0);
  318. }
  319. 100% {
  320. transform: translateY(-100%);
  321. }
  322. }
  323. @keyframes hideLayer {
  324. 0% {
  325. transform: translateY(-100%);
  326. }
  327. 100% {
  328. transform: translateY(0);
  329. }
  330. }
  331. @keyframes showAmnation {
  332. 0% {
  333. top: -12rpx;
  334. opacity: 0;
  335. }
  336. 50% {
  337. top: -60rpx;
  338. opacity: 1;
  339. }
  340. 100% {
  341. top: -100rpx;
  342. opacity: 0;
  343. }
  344. }
  345. @keyframes hideAmnation {
  346. 0% {
  347. top: -100rpx;
  348. opacity: 0;
  349. }
  350. 100% {
  351. top: -12rpx;
  352. opacity: 0;
  353. }
  354. }
  355. .popup {
  356. position: fixed;
  357. top: 0;
  358. width: 100%;
  359. height: 100%;
  360. z-index: 999;
  361. display: none;
  362. .mask{
  363. position: fixed;
  364. top: 0;
  365. width: 100%;
  366. height: 100%;
  367. z-index: 21;
  368. background-color: rgba(0, 0, 0, 0.6);
  369. }
  370. .layer {
  371. position: fixed;
  372. z-index: 22;
  373. bottom: -460rpx;
  374. width: 702rpx;
  375. padding: 24rpx 24rpx 36rpx 24rpx;
  376. height: 400rpx;
  377. border-radius: 20rpx 20rpx 0 0;
  378. background-color: #fff;
  379. display: flex;
  380. flex-wrap: wrap;
  381. align-content: space-between;
  382. .content {
  383. width: 100%;
  384. }
  385. .btn {
  386. width: 100%;
  387. height: 88rpx;
  388. display: flex;
  389. .button {
  390. width: 702rpx;
  391. height: 88rpx;
  392. color: #fff;
  393. display: flex;
  394. align-items: center;
  395. justify-content: center;
  396. font-size: $font-size-28;
  397. border-radius: 44rpx;
  398. background: $btn-confirm;
  399. }
  400. }
  401. }
  402. &.show {
  403. display: block;
  404. .mask{
  405. animation: showPopup 0.2s linear both;
  406. }
  407. .layer {
  408. animation: showLayer 0.2s linear both;
  409. }
  410. }
  411. &.hide {
  412. display: block;
  413. .mask{
  414. animation: hidePopup 0.2s linear both;
  415. }
  416. .layer {
  417. animation: hideLayer 0.2s linear both;
  418. }
  419. }
  420. &.none {
  421. display: none;
  422. }
  423. &.service {
  424. .row {
  425. margin: 30upx 0;
  426. .title {
  427. font-size: 30upx;
  428. margin: 10upx 0;
  429. }
  430. .description {
  431. font-size: 28upx;
  432. color: #999;
  433. }
  434. }
  435. }
  436. .layer-smimg{
  437. width: 114rpx;
  438. height: 114rpx;
  439. float: left;
  440. border-radius: 10rpx;
  441. margin-right: 24rpx;
  442. image{
  443. width: 114rpx;
  444. height: 114rpx;
  445. border-radius: 10rpx;
  446. }
  447. }
  448. .layer-nunbox{
  449. justify-content: space-between;
  450. align-items: center;
  451. width: 536rpx;
  452. height: 88rpx;
  453. padding: 13rpx 0 0 0;
  454. float: left;
  455. .layer-nunbox-t{
  456. width: 100%;
  457. height:44rpx;
  458. position:relative;
  459. display: flex;
  460. .layer-nunbox-text{
  461. line-height: 44rpx;
  462. font-size: $font-size-28;
  463. }
  464. .number-box{
  465. display: flex;
  466. justify-content: center;
  467. align-items: center;
  468. .iconfont{
  469. font-size: $font-size-32;
  470. padding:0 18rpx;
  471. font-size: $text-color;
  472. }
  473. .btn-input{
  474. width: 62rpx;
  475. height: 48rpx;
  476. line-height: 48rpx;
  477. background: #F8F8F8;
  478. border-radius: 4rpx;
  479. text-align: center;
  480. font-size: $font-size-28;
  481. }
  482. }
  483. .product-step{
  484. position: absolute;
  485. left: 45rpx;
  486. bottom: 0;
  487. height: 44rpx;
  488. background: #FFFFFF;
  489. }
  490. }
  491. .layer-nunbox-b{
  492. width: 100%;
  493. height:44rpx;
  494. margin-top: 13rpx;
  495. }
  496. .text{
  497. line-height: 44rpx;
  498. font-size: $font-size-28;
  499. .p{
  500. color: #FF2A2A;
  501. }
  502. .p:first-child{
  503. margin-left: 30rpx;
  504. }
  505. .p.sm{
  506. font-size: $font-size-24;
  507. }
  508. }
  509. }
  510. }
  511. </style>