freight.vue 6.1 KB

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