sellerFreight.vue 10 KB

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