freight.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template name="freight">
  2. <view class="freight-template" @click.stop="discard">
  3. <!-- 运费信息 -->
  4. <view class="invoice-freight">
  5. <view class="freight-left">运费<text class="tips" v-if="freightData.freePostFlag == 1">运费可选择到付哟~</text></view>
  6. <view class="freight-right" >
  7. <view class="freight-text">{{freightText}}</view>
  8. <view class="select" v-if="freightData.freePostFlag == 1" @click.stop="selectFreight">
  9. <text class="select-text">{{orderPriceToFixed(freightMoney)}}</text>
  10. <text class="iconfont icon-chakangengduo"></text>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default{
  18. name:"freight",
  19. props:{
  20. freightData:{
  21. type:Object
  22. }
  23. },
  24. data() {
  25. return{
  26. infoData:'',
  27. freightText:'',
  28. freightMoney:'',
  29. isShowOption:false,
  30. optionList:['到付'],
  31. freePostFlag:'',
  32. }
  33. },
  34. created(){
  35. this.initData(this.freightData)
  36. },
  37. computed: {
  38. },
  39. methods:{
  40. initData(res) {
  41. this.infoData = res;
  42. switch(res.freePostFlag){
  43. case 0:
  44. this.freightText = '包邮'
  45. this.freightData.freight = 0
  46. break
  47. case 1:
  48. this.freightText = ''
  49. this.freightMoney = res.freight
  50. this.optionList.unshift(this.orderPriceToFixed(this.freightMoney))
  51. break
  52. case -1:
  53. this.freightText = '到付'
  54. this.freightData.freight = 0
  55. break
  56. }
  57. },
  58. selectFreight (){
  59. let self = this,value;
  60. uni.showActionSheet({
  61. itemList: self.optionList,
  62. success: function (res) {
  63. switch(res.tapIndex){
  64. case 0:
  65. self.freightMoney = self.infoData.freight
  66. self.freePostFlag = 1
  67. break
  68. case 1:
  69. self.freePostFlag = -1
  70. self.freightMoney ='到付'
  71. break
  72. }
  73. self.$emit('confirmFreight',self.freePostFlag);
  74. },
  75. fail: function (res) {
  76. console.log(res.errMsg);
  77. }
  78. });
  79. },
  80. orderPriceToFixed (value){
  81. let price ='';
  82. if(value == '到付'){
  83. price = value
  84. }else{
  85. price ='¥'+parseInt(value).toFixed(2)
  86. }
  87. return price
  88. },
  89. discard(){
  90. this.isShowOption = false
  91. this.selectClass = ''
  92. },
  93. showTip(){
  94. this.$emit('showFreightAlert');
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. .freight-template{
  101. width: 100%;
  102. height: auto;
  103. background: #FFFFFF;
  104. float: left;
  105. margin-top: 24rpx;
  106. .invoice-freight{
  107. width: 702rpx;
  108. padding: 0 24rpx;
  109. height: 86rpx;
  110. line-height: 86rpx;
  111. font-size: $font-size-28;
  112. color: $text-color;
  113. background: #FFFFFF;
  114. float: left;
  115. font-weight: bold;
  116. .freight-left{
  117. float: left;
  118. .tips{
  119. font-size: $font-size-24;
  120. color: $color-system;
  121. font-weight: normal;
  122. margin-left: 20rpx;
  123. }
  124. .icon-yunfeishuoming{
  125. height: 100%;
  126. padding:15rpx;
  127. color: $color-system;
  128. font-weight: normal;
  129. }
  130. }
  131. .freight-right{
  132. float: right;
  133. color: #2A81FF;
  134. position: relative;
  135. .freight-text{
  136. float: left;
  137. }
  138. .select{
  139. float: right;
  140. height: 60rpx;
  141. padding: 0 20rpx;
  142. margin-top: 14rpx;
  143. line-height: 60rpx;
  144. color: #2A81FF;
  145. font-weight: normal;
  146. position: relative;
  147. .select-text{
  148. display: inline-block;
  149. float: left;
  150. margin-right: 30rpx;
  151. }
  152. .iconfont{
  153. width: 60rpx;
  154. height: 60rpx;
  155. line-height: 60rpx;
  156. text-align: right;
  157. position: absolute;
  158. right: 0;
  159. top: 0;
  160. font-size: $font-size-28;
  161. color: #2A81FF;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. </style>