freight.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template name="freight">
  2. <view class="freight-template" @click.stop="discard">
  3. <!-- 运费信息 -->
  4. <view class="invoice-freight">
  5. <view class="freight-main">
  6. <view class="freight-left">运费<text class="tips" v-if="freightData.freePostFlag == 1">运费可选择到付哟~</text></view>
  7. <view class="freight-right" >
  8. <view class="freight-text">{{freightText}}</view>
  9. <view class="select" v-if="freightData.freePostFlag == 1" @click.stop="selectFreight">
  10. <text class="select-text">{{orderPriceToFixed(freightMoney)}}</text>
  11. <text class="iconfont icon-xiayibu"></text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="freight-bean" v-if="freePostFlag == 1">
  16. <view class="bean-le">可用{{ freightMoney*100 }}采美豆抵用{{ freightMoney }}元运费</view>
  17. <view class="bean-ri">
  18. <view class="checkbox-box">
  19. <button class="checkbox iconfont"
  20. hover-class="btn-hover"
  21. @click.stop="checkedBalabce"
  22. :class="[ischecked ?'icon-yixuanze':'icon-weixuanze']"
  23. >
  24. </button>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default{
  33. name:"freight",
  34. props:{
  35. freightData:{
  36. type:Object
  37. }
  38. },
  39. data() {
  40. return{
  41. infoData:'',
  42. freightText:'',
  43. freightMoney:'',
  44. isShowOption:false,
  45. optionList:['到付'],
  46. freePostFlag:'',
  47. ischecked:false
  48. }
  49. },
  50. created(){
  51. this.initData(this.freightData)
  52. },
  53. computed: {
  54. },
  55. methods:{
  56. initData(res) {
  57. this.infoData = res;
  58. switch(res.freePostFlag){
  59. case 0:
  60. this.freightText = '包邮'
  61. this.freightData.freight = 0
  62. this.freePostFlag = res.freePostFlag
  63. break
  64. case 1:
  65. this.freightText = ''
  66. this.freightMoney = res.freight
  67. this.freePostFlag = res.freePostFlag
  68. this.optionList.unshift(this.orderPriceToFixed(this.freightMoney))
  69. break
  70. case -1:
  71. this.freightText = '到付'
  72. this.freePostFlag = res.freePostFlag
  73. this.freightData.freight = 0
  74. break
  75. }
  76. },
  77. selectFreight (){
  78. let self = this,value;
  79. uni.showActionSheet({
  80. itemList: self.optionList,
  81. success: function (res) {
  82. switch(res.tapIndex){
  83. case 0:
  84. self.freightMoney = self.infoData.freight
  85. self.freePostFlag = 1
  86. break
  87. case 1:
  88. self.freePostFlag = -1
  89. self.freightMoney ='到付'
  90. break
  91. }
  92. self.$emit('confirmFreight',self.freePostFlag);
  93. },
  94. fail: function (res) {
  95. console.log(res.errMsg);
  96. }
  97. });
  98. },
  99. checkedBalabce(){//勾选使用余额
  100. this.ischecked = !this.ischecked
  101. if(this.userMoney > 0){
  102. this.ischecked = !this.ischecked
  103. if(this.ischecked){
  104. this.balanceDeductionFlag =1
  105. this.attributePallPrice()
  106. }else{
  107. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){
  108. this.payAllPrice = this.allPrice+parseInt(this.freightData.freight)
  109. }else{
  110. this.payAllPrice = this.allPrice
  111. }
  112. this.balanceDeductionFlag = 2
  113. }
  114. }else{
  115. return
  116. }
  117. },
  118. orderPriceToFixed (value){
  119. let price ='';
  120. if(value == '到付'){
  121. price = value
  122. }else{
  123. price ='¥'+parseInt(value).toFixed(2)
  124. }
  125. return price
  126. },
  127. discard(){
  128. this.isShowOption = false
  129. this.selectClass = ''
  130. },
  131. showTip(){
  132. this.$emit('showFreightAlert');
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .freight-template{
  139. width: 100%;
  140. height: auto;
  141. background: #FFFFFF;
  142. float: left;
  143. margin-top: 24rpx;
  144. .invoice-freight{
  145. width: 100%;
  146. box-sizing: border-box;
  147. padding: 10rpx 24rpx;
  148. .freight-main{
  149. width: 100%;
  150. height: 78rpx;
  151. line-height: 78rpx;
  152. font-size: $font-size-28;
  153. color: $text-color;
  154. background: #FFFFFF;
  155. float: left;
  156. font-weight: bold;
  157. .freight-left{
  158. float: left;
  159. .tips{
  160. font-size: $font-size-24;
  161. color: $color-system;
  162. font-weight: normal;
  163. margin-left: 20rpx;
  164. }
  165. .icon-yunfeishuoming{
  166. height: 100%;
  167. padding:15rpx;
  168. color: $color-system;
  169. font-weight: normal;
  170. }
  171. }
  172. .freight-right{
  173. float: right;
  174. color: #2A81FF;
  175. position: relative;
  176. .freight-text{
  177. float: left;
  178. }
  179. .select{
  180. float: right;
  181. height: 60rpx;
  182. padding: 0 20rpx;
  183. margin-top: 14rpx;
  184. line-height: 60rpx;
  185. color: #2A81FF;
  186. font-weight: normal;
  187. position: relative;
  188. .select-text{
  189. display: inline-block;
  190. float: left;
  191. margin-right: 30rpx;
  192. }
  193. .iconfont{
  194. width: 60rpx;
  195. height: 60rpx;
  196. line-height: 60rpx;
  197. text-align: right;
  198. position: absolute;
  199. right: 0;
  200. top: 0;
  201. font-size: $font-size-28;
  202. color: #2A81FF;
  203. }
  204. }
  205. }
  206. }
  207. .freight-bean{
  208. width: 100%;
  209. height: 58rpx;
  210. line-height: 58rpx;
  211. float: left;
  212. .bean-le{
  213. float: left;
  214. color: #666666;
  215. font-size: $font-size-26;
  216. font-weight: normal;
  217. }
  218. .bean-ri{
  219. float: right;
  220. display: flex;
  221. align-items: center;
  222. .checkbox-box{
  223. display: flex;
  224. width: 60rpx;
  225. float: left;
  226. height: 100%;
  227. font-size: $font-size-26;
  228. margin-top: 8rpx;
  229. .checkbox{
  230. width: 40rpx;
  231. text-align: right;
  232. box-sizing: border-box;
  233. text-align: center;
  234. text-decoration: none;
  235. border-radius: 0;
  236. -webkit-tap-highlight-color: transparent;
  237. overflow: hidden;
  238. color: $color-system;
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. </style>