freight.vue 6.3 KB

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