sellerFreight.vue 10 KB

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