freight.vue 6.3 KB

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