sellerFreight.vue 11 KB

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