sellerFreight.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. float: left;
  189. margin: 24rpx 0 34rpx 0;
  190. .invoice-freight{
  191. width: 702rpx;
  192. padding: 0 24rpx;
  193. height: 88rpx;
  194. line-height: 88rpx;
  195. font-size: $font-size-28;
  196. color: $text-color;
  197. background: #FFFFFF;
  198. float: left;
  199. font-weight: bold;
  200. .freight-left{
  201. float: left;
  202. .icon-yunfeishuoming{
  203. height: 100%;
  204. padding:15rpx;
  205. color: $color-system;
  206. font-weight: normal;
  207. }
  208. }
  209. .freight-right{
  210. float: right;
  211. color: #2A81FF;
  212. .text-l{
  213. margin-right: 20rpx;
  214. }
  215. .text{
  216. line-height: 88rpx;
  217. color: #ff0000;
  218. margin:0 20rpx;
  219. font-weight: normal;
  220. }
  221. .icon-chakangengduo{
  222. line-height: 88rpx;
  223. color: #999999;
  224. font-weight: normal;
  225. }
  226. }
  227. }
  228. }
  229. .freight-ltitle{
  230. width: 100%;
  231. line-height: 60rpx;
  232. height: 60rpx;
  233. font-size: $font-size-28;
  234. color: #333333;
  235. }
  236. .freight-radio{
  237. width: 100%;
  238. height: 88rpx;
  239. line-height: 88rpx;
  240. display: flex;
  241. border-bottom: 1px solid #EBEBEB;
  242. .row-group{
  243. flex:1;
  244. display: flex;
  245. }
  246. .row-input{
  247. flex: 1;
  248. height: 88rpx;
  249. line-height: 88rpx;
  250. }
  251. .row-radio{
  252. float: left;
  253. transform: scale(0.6);
  254. }
  255. .row-text{
  256. font-size: $font-size-24;
  257. color: $text-color;
  258. }
  259. }
  260. .freight-group{
  261. width: 100%;
  262. height: 88rpx;
  263. display: flex;
  264. border-bottom: 1px solid #FFFFFF;
  265. flex-direction: row;
  266. .text{
  267. display: block;
  268. flex: 1;
  269. line-height: 88rpx;
  270. font-size: $font-size-24;
  271. color: #999999;
  272. text-align: left;
  273. padding-left: 10rpx;
  274. }
  275. .group-from{
  276. flex: 1;
  277. height: 40rpx;
  278. padding: 20rpx;
  279. line-height: 40rpx;
  280. align-items: flex-start;
  281. font-size: $font-size-24;
  282. color: $text-color;
  283. background: #F7F7F7;
  284. border-radius: 14rpx;
  285. margin-bottom: 20rpx;
  286. margin-top: 10rpx;
  287. .form-input{
  288. height: 40rpx;
  289. line-height: 40rpx;
  290. flex-grow: 1;
  291. }
  292. }
  293. }
  294. /* 加入购物模态层*/
  295. @keyframes showPopup {
  296. 0% {
  297. opacity: 0;
  298. }
  299. 100% {
  300. opacity: 1;
  301. }
  302. }
  303. @keyframes hidePopup {
  304. 0% {
  305. opacity: 1;
  306. }
  307. 100% {
  308. opacity: 0;
  309. }
  310. }
  311. @keyframes showLayer {
  312. 0% {
  313. transform: translateY(0);
  314. }
  315. 100% {
  316. transform: translateY(-100%);
  317. }
  318. }
  319. @keyframes hideLayer {
  320. 0% {
  321. transform: translateY(-100%);
  322. }
  323. 100% {
  324. transform: translateY(0);
  325. }
  326. }
  327. @keyframes showAmnation {
  328. 0% {
  329. top: -12rpx;
  330. opacity: 0;
  331. }
  332. 50% {
  333. top: -60rpx;
  334. opacity: 1;
  335. }
  336. 100% {
  337. top: -100rpx;
  338. opacity: 0;
  339. }
  340. }
  341. @keyframes hideAmnation {
  342. 0% {
  343. top: -100rpx;
  344. opacity: 0;
  345. }
  346. 100% {
  347. top: -12rpx;
  348. opacity: 0;
  349. }
  350. }
  351. .popup {
  352. position: fixed;
  353. top: 0;
  354. width: 100%;
  355. height: 100%;
  356. z-index: 999;
  357. display: none;
  358. .mask{
  359. position: fixed;
  360. top: 0;
  361. width: 100%;
  362. height: 100%;
  363. z-index: 21;
  364. background-color: rgba(0, 0, 0, 0.6);
  365. }
  366. .layer {
  367. position: fixed;
  368. z-index: 22;
  369. bottom: -460rpx;
  370. width: 702rpx;
  371. padding: 24rpx 24rpx 36rpx 24rpx;
  372. height: 400rpx;
  373. border-radius: 20rpx 20rpx 0 0;
  374. background-color: #fff;
  375. display: flex;
  376. flex-wrap: wrap;
  377. align-content: space-between;
  378. .content {
  379. width: 100%;
  380. }
  381. .btn {
  382. width: 100%;
  383. height: 88rpx;
  384. display: flex;
  385. .button {
  386. width: 702rpx;
  387. height: 88rpx;
  388. color: #fff;
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. font-size: $font-size-28;
  393. border-radius: 44rpx;
  394. background: $btn-confirm;
  395. }
  396. }
  397. }
  398. &.show {
  399. display: block;
  400. .mask{
  401. animation: showPopup 0.2s linear both;
  402. }
  403. .layer {
  404. animation: showLayer 0.2s linear both;
  405. }
  406. }
  407. &.hide {
  408. display: block;
  409. .mask{
  410. animation: hidePopup 0.2s linear both;
  411. }
  412. .layer {
  413. animation: hideLayer 0.2s linear both;
  414. }
  415. }
  416. &.none {
  417. display: none;
  418. }
  419. &.service {
  420. .row {
  421. margin: 30upx 0;
  422. .title {
  423. font-size: 30upx;
  424. margin: 10upx 0;
  425. }
  426. .description {
  427. font-size: 28upx;
  428. color: #999;
  429. }
  430. }
  431. }
  432. .layer-smimg{
  433. width: 114rpx;
  434. height: 114rpx;
  435. float: left;
  436. border-radius: 10rpx;
  437. margin-right: 24rpx;
  438. image{
  439. width: 114rpx;
  440. height: 114rpx;
  441. border-radius: 10rpx;
  442. }
  443. }
  444. .layer-nunbox{
  445. justify-content: space-between;
  446. align-items: center;
  447. width: 536rpx;
  448. height: 88rpx;
  449. padding: 13rpx 0 0 0;
  450. float: left;
  451. .layer-nunbox-t{
  452. width: 100%;
  453. height:44rpx;
  454. position:relative;
  455. display: flex;
  456. .layer-nunbox-text{
  457. line-height: 44rpx;
  458. font-size: $font-size-28;
  459. }
  460. .number-box{
  461. display: flex;
  462. justify-content: center;
  463. align-items: center;
  464. .iconfont{
  465. font-size: $font-size-32;
  466. padding:0 18rpx;
  467. font-size: $text-color;
  468. }
  469. .btn-input{
  470. width: 62rpx;
  471. height: 48rpx;
  472. line-height: 48rpx;
  473. background: #F8F8F8;
  474. border-radius: 4rpx;
  475. text-align: center;
  476. font-size: $font-size-28;
  477. }
  478. }
  479. .product-step{
  480. position: absolute;
  481. left: 45rpx;
  482. bottom: 0;
  483. height: 44rpx;
  484. background: #FFFFFF;
  485. }
  486. }
  487. .layer-nunbox-b{
  488. width: 100%;
  489. height:44rpx;
  490. margin-top: 13rpx;
  491. }
  492. .text{
  493. line-height: 44rpx;
  494. font-size: $font-size-28;
  495. .p{
  496. color: #FF2A2A;
  497. }
  498. .p:first-child{
  499. margin-left: 30rpx;
  500. }
  501. .p.sm{
  502. font-size: $font-size-24;
  503. }
  504. }
  505. }
  506. }
  507. </style>