sellerFreight.vue 10 KB

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