sellerFreight.vue 10 KB

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