freight.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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="freePostFlag == 1">可用{{ deductionBeans }}采美豆抵用{{ freightMoney }}元运费</view>
  17. <view class="bean-le" v-if="freePostFlag == -1">可用{{ deductionBeans }}采美豆抵用{{ freightMoney }}运费</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.freightMoney = '到付'
  90. this.userBeans = res.userBeans
  91. this.freePostFlag = res.freePostFlag
  92. this.freightData.freight = 0
  93. this.freightBeansMoney = 30
  94. if( res.userBeans >0 ){
  95. this.isBeansShow = true
  96. }else{
  97. this.isBeansShow = false
  98. }
  99. if(res.userBeans >= this.freightBeansMoney*100){
  100. this.deductionBeans = this.freightBeansMoney*100
  101. }else{
  102. this.deductionBeans = res.userBeans
  103. }
  104. break
  105. }
  106. },
  107. selectFreight (){//切换运费
  108. let self = this,value;
  109. uni.showActionSheet({
  110. itemList: self.optionList,
  111. success: function (res) {
  112. switch(res.tapIndex){
  113. case 0:
  114. self.freightMoney = self.infoData.freight
  115. self.freePostFlag = 1
  116. if( self.userBeans > 0 ){
  117. self.isBeansShow = true
  118. self.freightBeansMoney = self.freightMoney
  119. if(self.userBeans >= self.freightBeansMoney*100){
  120. self.deductionBeans = self.freightBeansMoney*100
  121. }else{
  122. self.deductionBeans = self.userBeans
  123. }
  124. }else{
  125. self.isBeansShow = false
  126. self.freightBeansMoney = 0
  127. }
  128. break
  129. case 1:
  130. self.freePostFlag = -1
  131. self.freightMoney = '到付'
  132. if( self.userBeans > 0 ){
  133. self.freightBeansMoney = 30
  134. self.isBeansShow = true
  135. if(self.userBeans >= self.freightBeansMoney*100){
  136. self.deductionBeans = self.freightBeansMoney*100
  137. }else{
  138. self.deductionBeans = self.userBeans
  139. }
  140. }else{
  141. self.freightBeansMoney = 0
  142. self.isBeansShow = false
  143. }
  144. break
  145. }
  146. let obj = {
  147. freePostFlag :self.freePostFlag,
  148. freightBeansMoney: self.freightBeansMoney
  149. }
  150. self.$emit('confirmFreight',obj);
  151. },
  152. fail: function (res) {
  153. console.log(res.errMsg);
  154. }
  155. });
  156. },
  157. checkedBalabce(){//勾选使用采美豆抵扣
  158. this.ischecked = !this.ischecked
  159. this.$emit('confirmFreightBeans',this.ischecked);
  160. },
  161. orderPriceToFixed (value){
  162. let price ='';
  163. if(value == '到付'){
  164. price = value
  165. }else{
  166. price ='¥'+parseInt(value).toFixed(2)
  167. }
  168. return price
  169. },
  170. discard(){
  171. this.isShowOption = false
  172. this.selectClass = ''
  173. },
  174. showTip(){
  175. this.$emit('showFreightAlert');
  176. },
  177. }
  178. }
  179. </script>
  180. <style lang="scss">
  181. .freight-template{
  182. width: 100%;
  183. height: auto;
  184. background: #FFFFFF;
  185. float: left;
  186. margin-top: 24rpx;
  187. .invoice-freight{
  188. width: 100%;
  189. box-sizing: border-box;
  190. padding: 10rpx 24rpx;
  191. .freight-main{
  192. width: 100%;
  193. height: 78rpx;
  194. line-height: 78rpx;
  195. font-size: $font-size-28;
  196. color: $text-color;
  197. background: #FFFFFF;
  198. float: left;
  199. font-weight: bold;
  200. .freight-left{
  201. float: left;
  202. .tips{
  203. font-size: $font-size-24;
  204. color: $color-system;
  205. font-weight: normal;
  206. margin-left: 20rpx;
  207. }
  208. .icon-yunfeishuoming{
  209. height: 100%;
  210. padding:15rpx;
  211. color: $color-system;
  212. font-weight: normal;
  213. }
  214. }
  215. .freight-right{
  216. float: right;
  217. color: #2A81FF;
  218. position: relative;
  219. .freight-text{
  220. float: left;
  221. }
  222. .select{
  223. float: right;
  224. height: 60rpx;
  225. padding: 0 20rpx;
  226. margin-top: 14rpx;
  227. line-height: 60rpx;
  228. color: #2A81FF;
  229. font-weight: normal;
  230. position: relative;
  231. .select-text{
  232. display: inline-block;
  233. float: left;
  234. margin-right: 30rpx;
  235. }
  236. .iconfont{
  237. width: 60rpx;
  238. height: 60rpx;
  239. line-height: 60rpx;
  240. text-align: right;
  241. position: absolute;
  242. right: 0;
  243. top: 0;
  244. font-size: $font-size-28;
  245. color: #2A81FF;
  246. }
  247. }
  248. }
  249. }
  250. .freight-bean{
  251. width: 100%;
  252. height: 58rpx;
  253. line-height: 58rpx;
  254. float: left;
  255. .bean-le{
  256. float: left;
  257. color: #666666;
  258. font-size: $font-size-26;
  259. font-weight: normal;
  260. }
  261. .bean-ri{
  262. float: right;
  263. display: flex;
  264. align-items: center;
  265. .checkbox-box{
  266. display: flex;
  267. width: 60rpx;
  268. float: left;
  269. height: 100%;
  270. font-size: $font-size-26;
  271. margin-top: 8rpx;
  272. .checkbox{
  273. width: 40rpx;
  274. text-align: right;
  275. box-sizing: border-box;
  276. text-align: center;
  277. text-decoration: none;
  278. border-radius: 0;
  279. -webkit-tap-highlight-color: transparent;
  280. overflow: hidden;
  281. color: $color-system;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>