freight.vue 6.6 KB

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