sellerFreight.vue 10 KB

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