freight.vue 7.0 KB

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