freight.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template name="freight">
  2. <view class="freight-template">
  3. <!-- 运费信息 -->
  4. <view class="invoice-freight">
  5. <view class="freight-main" v-if="infoData.designatedFlag === 2">
  6. <view class="freight-left">运费</view>
  7. <view class="freight-right">
  8. <view class="freight-text">{{ freightText }}</view>
  9. </view>
  10. </view>
  11. <template v-else>
  12. <view class="freight-main">
  13. <view class="freight-left">运费</view>
  14. <view class="freight-right">
  15. <view class="freight-text">{{ totalFreight }}</view>
  16. </view>
  17. </view>
  18. <view class="freight-bean">
  19. <view class="bean-le">冷链运输费</view>
  20. <view class="bean-ri">
  21. <text>¥{{ coldChain | NumFormat }}</text>
  22. <view class="checkbox-box" v-if="coldChain > 0">
  23. <button
  24. class="checkbox iconfont"
  25. hover-class="btn-hover"
  26. @click.stop="checkedBalabce"
  27. :class="[ischecked ? 'icon-yixuanze' : 'icon-weixuanze']"
  28. ></button>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="freight-bean" v-if="infoData.designatedFlag === 3">
  33. <view class="bean-le">其他运费</view>
  34. <view class="bean-ri">
  35. <view>{{ freightText }}</view>
  36. </view>
  37. </view>
  38. </template>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. name: 'freight',
  45. props: {
  46. coldChain: {
  47. type: Number
  48. },
  49. freightData: {
  50. type: Object
  51. }
  52. },
  53. data() {
  54. return {
  55. infoData: {},
  56. freightText: '',
  57. postageFlag: 0,
  58. ischecked: true,
  59. totalFreight: 0
  60. }
  61. },
  62. created() {
  63. this.initData(this.freightData)
  64. },
  65. filters: {
  66. NumFormat(value) {
  67. //处理金额
  68. if (value && value > 0) {
  69. return Number(value).toFixed(2)
  70. } else {
  71. return '0.00'
  72. }
  73. }
  74. },
  75. methods: {
  76. async initData(data) {
  77. this.infoData = data
  78. /**
  79. * 1.如果designatedFlag === 1 且 冷链费 大于 0 勾选冷链费 运费为 冷链费
  80. * 2.如果designatedFlag === 1 且 冷链费 等于 0 运费为0
  81. * 3.如果designatedFlag === 2 只有其他供应商商品 运费按采美规则
  82. * 4.如果designatedFlag === 3 且 冷链费 大于 0 其他供应商商品不包邮有运费 勾选冷链费 运费为 冷链费 + 采美规则运费
  83. * 5.如果designatedFlag === 3 且 冷链费 大于 0 其他供应商商品到付 勾选冷链费 运费为 冷链费
  84. * 5.如果designatedFlag === 3 且 冷链费 大于 0 其他供应商商品包邮 勾选冷链费 运费为 冷链费
  85. * */
  86. if (data.designatedFlag === 1) {
  87. this.freightText = '¥' + data.postage.toFixed(2)
  88. this.totalFreight = '¥' + this.coldChain.toFixed(2)
  89. } else if (data.designatedFlag === 2) {
  90. this.infoFreightText(data)
  91. } else if (data.designatedFlag === 3) {
  92. if (this.coldChain === 0) { this.ischecked = false }
  93. if (data.postageFlag === 1) {
  94. this.freightText = '¥' + data.postage.toFixed(2)
  95. this.totalFreight = '¥' + (this.coldChain+data.postage).toFixed(2)
  96. } else {
  97. this.freightText = data.postageFlag === 0 ? '包邮' : '到付'
  98. this.totalFreight = this.ischecked ? '¥' + this.coldChain.toFixed(2) : this.freightText
  99. }
  100. }
  101. },
  102. infoFreightText(data) {
  103. //仅其他供应商商品设置运费
  104. switch (data.postageFlag) {
  105. case 0:
  106. this.freightText = '包邮'
  107. this.freightData.freight = 0
  108. this.postageFlag = data.postageFlag
  109. break
  110. case 1:
  111. this.freightText = '¥'+ data.postage.toFixed(2)
  112. this.postageFlag = data.postageFlag
  113. break
  114. case -1:
  115. this.freightText = '到付'
  116. this.postageFlag = data.postageFlag
  117. this.freightData.freight = 0
  118. break
  119. }
  120. },
  121. checkedBalabce() {
  122. //勾选是否使用冷链运输费
  123. this.ischecked = !this.ischecked
  124. if (this.ischecked) {
  125. this.setTotalFreight(this.infoData)
  126. } else {
  127. this.totalFreight = this.freightText
  128. }
  129. this.$emit('confirmFreight', this.ischecked)
  130. },
  131. setTotalFreight(data){// 勾选冷链费
  132. if (data.designatedFlag === 1) {
  133. this.totalFreight ='¥'+ this.coldChain.toFixed(2)
  134. } else {
  135. if (data.postageFlag === 1) {
  136. this.totalFreight = '¥' + (this.coldChain+data.postage).toFixed(2)
  137. } else {
  138. this.freightText = data.postageFlag === 0 ? '包邮' : '到付'
  139. this.totalFreight = '¥' + this.coldChain.toFixed(2)
  140. }
  141. }
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. .freight-template {
  148. width: 100%;
  149. height: auto;
  150. background: #ffffff;
  151. float: left;
  152. margin-top: 24rpx;
  153. .invoice-freight {
  154. width: 100%;
  155. box-sizing: border-box;
  156. padding: 10rpx 24rpx;
  157. float: left;
  158. .freight-main {
  159. width: 100%;
  160. height: 78rpx;
  161. line-height: 78rpx;
  162. font-size: $font-size-28;
  163. color: $text-color;
  164. background: #ffffff;
  165. float: left;
  166. .freight-left {
  167. float: left;
  168. font-weight: bold;
  169. }
  170. .freight-right {
  171. float: right;
  172. position: relative;
  173. .freight-text {
  174. float: left;
  175. color:#F85050;
  176. }
  177. }
  178. }
  179. .freight-bean {
  180. width: 100%;
  181. height: 58rpx;
  182. line-height: 58rpx;
  183. float: left;
  184. .bean-le {
  185. float: left;
  186. color: $text-color;
  187. font-size: $font-size-26;
  188. }
  189. .bean-ri {
  190. float: right;
  191. display: flex;
  192. align-items: center;
  193. font-size: $font-size-28;
  194. .checkbox-box {
  195. display: flex;
  196. width: 60rpx;
  197. float: left;
  198. height: 100%;
  199. font-size: $font-size-26;
  200. margin-left: 20rpx;
  201. .checkbox {
  202. width: 40rpx;
  203. text-align: right;
  204. box-sizing: border-box;
  205. text-align: center;
  206. text-decoration: none;
  207. border-radius: 0;
  208. -webkit-tap-highlight-color: transparent;
  209. overflow: hidden;
  210. color: $color-system;
  211. }
  212. .iconfont {
  213. font-size: 34rpx;
  214. }
  215. }
  216. }
  217. }
  218. }
  219. }
  220. </style>