free_fare.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="free_fare">
  3. <view class="day">
  4. <text>白天出租出行免车费设置(07:30-20:00)</text>
  5. <view class="select_box">
  6. <view class="option" :class="currentDay == index?'select':''" v-for="(item,index) in timeList" :key="index"
  7. @click="selectDay(item,index)">
  8. {{item.value}}公里
  9. </view>
  10. </view>
  11. </view>
  12. <view class="day">
  13. <text>夜间出租出行免车费设置(20:00-07:30)</text>
  14. <view class="select_box">
  15. <view class="option" :class="currentNight == index?'select':''" v-for="(item,index) in timeList" :key="index"
  16. @click="selectNight(item,index)">
  17. {{item.value}}公里
  18. </view>
  19. </view>
  20. </view>
  21. <view class="title">
  22. 温馨提示:
  23. <text>1. 此处设置的免车费公里数是客服距离你的直线距离,直线距离的车行距离的地理位置特殊性上可能有一定误差,望大家设置距离时知晓。</text>
  24. <text>2. 设置的免出行费只针对出租车。</text>
  25. </view>
  26. <view class="btn_box">
  27. <view class="btn" @click="submit">
  28. 确 认
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. freeFare,
  36. engineDetail
  37. } from '../../api/index.js'
  38. export default {
  39. data() {
  40. return {
  41. timeList: [{
  42. value: '0'
  43. },
  44. {
  45. value: '0.5'
  46. },
  47. {
  48. value: '1'
  49. },
  50. {
  51. value: '3'
  52. },
  53. {
  54. value: '5'
  55. },
  56. {
  57. value: '7'
  58. },
  59. ],
  60. dayKm: '',
  61. nightKm: '',
  62. currentDay: null,
  63. currentNight: null,
  64. daytimeMileage: 0,
  65. nigthMileage: 0,
  66. id: '',
  67. }
  68. },
  69. methods: {
  70. selectDay(item, index) {
  71. this.currentDay = index
  72. this.daytimeMileage = item.value
  73. },
  74. selectNight(item, index) {
  75. this.currentNight = index
  76. this.nigthMileage = item.value
  77. },
  78. submit() {
  79. let data = {}
  80. data.id = this.id
  81. data.daytimeMileage = this.daytimeMileage
  82. data.nigthMileage = this.nigthMileage
  83. freeFare(data).then(res => {
  84. if (res.data.code == 200) {
  85. uni.showToast({
  86. title: '设置成功',
  87. icon: 'none'
  88. })
  89. }
  90. })
  91. },
  92. getInfo() {
  93. var openid = {
  94. cOpenId: uni.getStorageSync('wx_copenid')
  95. }
  96. engineDetail(openid).then(res => {
  97. if (res.data.data) {
  98. this.id = res.data.data.id
  99. this.daytimeMileage = res.data.data.daytimeMileage
  100. this.nigthMileage = res.data.data.nigthMileage
  101. for (let i = 0; i < this.timeList.length; i++) {
  102. if (this.timeList[i].value == this.daytimeMileage) {
  103. this.currentDay = i
  104. }
  105. if (this.timeList[i].value == this.nigthMileage) {
  106. this.currentNight = i
  107. }
  108. }
  109. }
  110. })
  111. }
  112. },
  113. onLoad() {
  114. this.getInfo()
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .free_fare {
  120. width: 100vw;
  121. height: 100vh;
  122. padding: 32rpx 40rpx;
  123. box-sizing: border-box;
  124. background: linear-gradient(152deg, #DCFFF8 0%, #F1FEFF 100%);
  125. // position: relative;
  126. .day {
  127. margin-bottom: 24rpx;
  128. padding: 24rpx;
  129. box-sizing: border-box;
  130. height: 248rpx;
  131. background: #FFFFFF;
  132. box-shadow: 0px 4rpx 12rpx 0px rgba(88, 209, 187, 0.05);
  133. border-radius: 20rpx;
  134. text {
  135. font-size: 28rpx;
  136. color: #2F3437;
  137. line-height: 33rpx;
  138. // margin-bottom: 12rpx;
  139. }
  140. .select_box {
  141. display: flex;
  142. align-items: center;
  143. justify-content: space-between;
  144. flex-wrap: wrap;
  145. margin-top: 12rpx;
  146. .option {
  147. width: 162rpx;
  148. height: 56rpx;
  149. background-color: #DCE6E6;
  150. border-radius: 5px;
  151. // margin: 8px;
  152. text-align: center;
  153. line-height: 30px;
  154. margin: 12rpx;
  155. }
  156. .select {
  157. // width: 100px;
  158. // height: 30px;
  159. background-color: #20CBC3;
  160. border-radius: 5px;
  161. // margin: 8px;
  162. text-align: center;
  163. line-height: 56rpx;
  164. }
  165. }
  166. }
  167. .title {
  168. font-size: 32rpx;
  169. font-weight: 700;
  170. // height: 268rpx;
  171. background: #FFFFFF;
  172. box-shadow: 0px 4rpx 12rpx 0px rgba(88, 209, 187, 0.1);
  173. border-radius: 20rpx;
  174. padding: 24rpx;
  175. text {
  176. display: block;
  177. font-size: 28rpx;
  178. font-weight: 400;
  179. color: #2F3437;
  180. margin-top: 16rpx;
  181. }
  182. text:nth-child(1) {
  183. margin-top: 10px;
  184. }
  185. }
  186. .btn_box {
  187. width: 100vw;
  188. height: 116rpx;
  189. background: #FFFFFF;
  190. position: fixed;
  191. bottom: 0;
  192. left: 0;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. .btn {
  197. width: 90%;
  198. height: 76rpx;
  199. background: linear-gradient( 90deg, #1AD7CE 0%, #21C9C1 100%);
  200. border-radius: 106rpx ;
  201. text-align: center;
  202. line-height: 76rpx;
  203. color: #fff;
  204. }
  205. }
  206. }
  207. </style>