freight.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. console.log(data.postageFlag)
  105. switch (data.postageFlag) {
  106. case 0:
  107. this.freightText = '包邮'
  108. this.freightData.freight = 0
  109. this.postageFlag = data.postageFlag
  110. break
  111. case 1:
  112. this.freightText = '¥'+ data.postage.toFixed(2)
  113. this.postageFlag = data.postageFlag
  114. break
  115. case 2:
  116. this.freightText = '到付'
  117. this.postageFlag = data.postageFlag
  118. this.freightData.freight = 0
  119. break
  120. }
  121. console.log('freightText', this.freightText)
  122. },
  123. checkedBalabce() {
  124. //勾选是否使用冷链运输费
  125. this.ischecked = !this.ischecked
  126. if (this.ischecked) {
  127. this.setTotalFreight(this.infoData)
  128. } else {
  129. this.totalFreight = this.freightText
  130. }
  131. this.$emit('confirmFreight', this.ischecked)
  132. },
  133. setTotalFreight(data){// 勾选冷链费
  134. if (data.designatedFlag === 1) {
  135. this.totalFreight ='¥'+ this.coldChain.toFixed(2)
  136. } else {
  137. if (data.postageFlag === 1) {
  138. this.totalFreight = '¥' + (this.coldChain+data.postage).toFixed(2)
  139. } else {
  140. this.freightText = data.postageFlag === 0 ? '包邮' : '到付'
  141. this.totalFreight = '¥' + this.coldChain.toFixed(2)
  142. }
  143. }
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss">
  149. .freight-template {
  150. width: 100%;
  151. height: auto;
  152. background: #ffffff;
  153. float: left;
  154. margin-top: 24rpx;
  155. .invoice-freight {
  156. width: 100%;
  157. box-sizing: border-box;
  158. padding: 10rpx 24rpx;
  159. float: left;
  160. .freight-main {
  161. width: 100%;
  162. height: 78rpx;
  163. line-height: 78rpx;
  164. font-size: $font-size-28;
  165. color: $text-color;
  166. background: #ffffff;
  167. float: left;
  168. .freight-left {
  169. float: left;
  170. font-weight: bold;
  171. }
  172. .freight-right {
  173. float: right;
  174. position: relative;
  175. .freight-text {
  176. float: left;
  177. color:#F85050;
  178. }
  179. }
  180. }
  181. .freight-bean {
  182. width: 100%;
  183. height: 58rpx;
  184. line-height: 58rpx;
  185. float: left;
  186. .bean-le {
  187. float: left;
  188. color: $text-color;
  189. font-size: $font-size-26;
  190. }
  191. .bean-ri {
  192. float: right;
  193. display: flex;
  194. align-items: center;
  195. font-size: $font-size-28;
  196. .checkbox-box {
  197. display: flex;
  198. width: 60rpx;
  199. float: left;
  200. height: 100%;
  201. font-size: $font-size-26;
  202. margin-left: 20rpx;
  203. .checkbox {
  204. width: 40rpx;
  205. text-align: right;
  206. box-sizing: border-box;
  207. text-align: center;
  208. text-decoration: none;
  209. border-radius: 0;
  210. -webkit-tap-highlight-color: transparent;
  211. overflow: hidden;
  212. color: $color-system;
  213. }
  214. .iconfont {
  215. font-size: 34rpx;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. </style>