sellerFreight.vue 10 KB

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