123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <template name="freight">
- <view class="freight-template" @click.stop="discard">
- <!-- 运费信息 -->
- <view class="invoice-freight">
- <view class="freight-main">
- <view class="freight-left">运费<text class="tips" v-if="freightData.postageFlag == 1 && vipFlag!=1">运费可选择到付哟~</text></view>
- <view class="freight-right" >
- <view class="freight-text">{{freightText}}</view>
- <view class="select" v-if="freightData.postageFlag == 1" @click.stop="selectFreight">
- <text class="select-text">{{orderPriceToFixed(freightMoney)}}</text>
- <text class="iconfont icon-xiangyou"></text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default{
- name:'freight',
- props:{
- freightData:{
- type:Object
- }
- },
- data() {
- return{
- infoData:{},
- freightText:'',
- freightMoney:'',
- isShowOption:false,
- optionList:['到付'],
- postageFlag:0,
- ischecked:false,
- isBeansShow:false,
- userBeans:0,
- deductionBeans:0,
- freightBeansMoney:0,
- vipFlag:0
- }
- },
- created(){
- this.initData(this.freightData)
- },
- computed: {
- },
- methods:{
- async initData(res) {
- const userInfo = await this.$api.getStorage()
- this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
- this.infoData = res
- switch(res.postageFlag){
- case 0:
- this.freightText = '包邮'
- this.freightData.freight = 0
- this.postageFlag = res.postageFlag
- this.isBeansShow = false
- break
- case 1:
- this.freightText = ''
- this.freightMoney = this.freightBeansMoney = res.postage
- this.userBeans = res.userBeans
- this.postageFlag = res.postageFlag
- this.optionList.unshift(this.orderPriceToFixed(this.freightMoney))
- if( res.userBeans > 0 ){
- this.isBeansShow = true
- }else{
- this.isBeansShow = false
- }
- if(res.userBeans >= this.freightBeansMoney*100){
- this.deductionBeans = this.freightBeansMoney*100
- }else{
- this.deductionBeans = res.userBeans
- }
- break
- case -1:
- this.freightText = '到付'
- this.freightMoney = '到付'
- this.userBeans = res.userBeans
- this.postageFlag = res.postageFlag
- this.freightData.freight = 0
- this.freightBeansMoney = 30
- if( res.userBeans >0 ){
- this.isBeansShow = true
- }else{
- this.isBeansShow = false
- }
- if(res.userBeans >= this.freightBeansMoney*100){
- this.deductionBeans = this.freightBeansMoney*100
- }else{
- this.deductionBeans = res.userBeans
- }
- break
- }
- },
- selectFreight (){//切换运费
- if(this.vipFlag==1){ return }
- let self = this
- uni.showActionSheet({
- itemList: self.optionList,
- success: function (res) {
- switch(res.tapIndex){
- case 0:
- self.freightMoney = self.infoData.postage
- self.postageFlag = 1
- if( self.userBeans > 0 ){
- self.isBeansShow = true
- self.freightBeansMoney = self.freightMoney
- if(self.userBeans >= self.freightBeansMoney*100){
- self.deductionBeans = self.freightBeansMoney*100
- }else{
- self.deductionBeans = self.userBeans
- }
- }else{
- self.isBeansShow = false
- self.freightBeansMoney = 0
- }
- break
- case 1:
- self.postageFlag = -1
- self.freightMoney = '到付'
- if( self.userBeans > 0 ){
- self.freightBeansMoney = 30
- self.isBeansShow = true
- if(self.userBeans >= self.freightBeansMoney*100){
- self.deductionBeans = self.freightBeansMoney*100
- }else{
- self.deductionBeans = self.userBeans
- }
- }else{
- self.freightBeansMoney = 0
- self.isBeansShow = false
- }
- break
- }
- let obj = {
- postageFlag :self.postageFlag,
- freightBeansMoney: self.freightBeansMoney
- }
- self.$emit('confirmFreight',obj)
- },
- fail: function (res) {
- console.log(res.errMsg)
- }
- })
- },
- orderPriceToFixed (value){
- let price =''
- if(value == '到付'){
- price = value
- }else{
- price ='¥'+parseInt(value).toFixed(2)
- }
- return price
- },
- discard(){
- this.isShowOption = false
- this.selectClass = ''
- },
- showTip(){
- this.$emit('showFreightAlert')
- },
- }
- }
- </script>
- <style lang="scss">
- .freight-template{
- width: 100%;
- height: auto;
- background: #FFFFFF;
- float: left;
- margin-top: 24rpx;
- .invoice-freight{
- width: 100%;
- box-sizing: border-box;
- padding: 10rpx 24rpx;
- .freight-main{
- width: 100%;
- height: 78rpx;
- line-height: 78rpx;
- font-size: $font-size-28;
- color: $text-color;
- background: #FFFFFF;
- float: left;
- font-weight: bold;
- .freight-left{
- float: left;
- .tips{
- font-size: $font-size-24;
- color: $color-system;
- font-weight: normal;
- margin-left: 20rpx;
- }
- .icon-yunfeishuoming{
- height: 100%;
- padding:15rpx;
- color: $color-system;
- font-weight: normal;
- }
- }
- .freight-right{
- float: right;
- color: #2A81FF;
- position: relative;
- .freight-text{
- float: left;
- }
- .select{
- float: right;
- height: 60rpx;
- padding: 0 20rpx;
- margin-top: 14rpx;
- line-height: 60rpx;
- color: #2A81FF;
- font-weight: normal;
- position: relative;
- .select-text{
- display: inline-block;
- float: left;
- margin-right: 30rpx;
- }
- .iconfont{
- width: 60rpx;
- height: 60rpx;
- line-height: 60rpx;
- text-align: right;
- position: absolute;
- right: 0;
- top: 0;
- font-size: $font-size-28;
- color: #2A81FF;
- }
- }
- }
- }
- }
- }
- </style>
|