sellerFreight.vue 10 KB

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