activation.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="container-view">
  3. <view class="return-info">
  4. <view class="h5">车辆信息</view>
  5. <view v-if="overdueMoney" class="return-top flex-row flex-between">
  6. <view style="align-items: baseline;" class="flex-row">逾期费用:<allPrice :amount="(overdueMoney/100)"/></view>
  7. </view>
  8. <view class="return-top flex-row flex-between">
  9. <view>车辆编号:{{car_sn}}</view>
  10. </view>
  11. <view class="return-top flex-row flex-between">
  12. <view>车辆名称:{{carInfoData.car_name}}</view>
  13. </view>
  14. <view class="return-top flex-row flex-between">
  15. <view>车型:{{carInfoData.model_name}}</view>
  16. </view>
  17. <view class="return-top flex-row flex-between">
  18. <view>续航:{{carInfoData.endurance}}m</view>
  19. </view>
  20. <view class="return-top flex-row flex-between">
  21. <view>重量:{{carInfoData.weight}}kg</view>
  22. </view>
  23. <view class="return-top flex-row ">
  24. <view>照片:</view>
  25. <image class="img" :src="carInfoData.model_images" mode="aspectFill"></image>
  26. </view>
  27. </view>
  28. <view v-if="shopInfo.shop_name" class="return-info">
  29. <view class="h5">门店信息</view>
  30. <view class="return-top flex-row flex-between">
  31. <view>门店名称:{{shopInfo.shop_name}}</view>
  32. </view>
  33. <view class="return-top flex-row flex-between">
  34. <view>门店地址:{{shopInfo.address}}</view>
  35. </view>
  36. </view>
  37. <view class="pictures-info">
  38. <view>车辆照片</view>
  39. <!-- <view>这里是关于激活车辆照片的文案描述,这里是关于激活车辆照片的文案描述</view> -->
  40. <uploaders :max="shopList.flk_hire_car_img_num" :car_info="car_imgs" @update-car-images="handleCarImagesUpdate"></uploaders>
  41. <view v-if="isReturnCar" @tap="submitReturn" class="pictures-btn">归还车辆</view>
  42. <view v-else @tap="submitEnabled" class="pictures-btn">激活车辆</view>
  43. </view>
  44. <PayTypeModel @closeShow="()=>isShowToBuy=false" @payToOrder="payToOrder" :free_price="totalPrice"
  45. :isShowToBuy="isShowToBuy" />
  46. </view>
  47. </template>
  48. <script>
  49. import uploaders from '@/component/uploaders/uploaders';
  50. const http = require('@/common/http.js');
  51. const request = require('../../common/request');
  52. const config = require('@/common/config.js');
  53. const config_gyq = require('@/common/config_gyq.js');
  54. const common = require('@/common/common.js');
  55. import PayTypeModel from '@/component/payTypeModel/payTypeModel';
  56. import allPrice from '@/component/allPrice/allPrice';
  57. export default {
  58. components: {
  59. uploaders,
  60. PayTypeModel,
  61. allPrice
  62. },
  63. data() {
  64. return {
  65. totalPrice:0,
  66. isShowToBuy:false,
  67. myLocation:{},
  68. shopInfo:{},
  69. isReturnCar:"",
  70. overdueTimes:'',
  71. model_id:"",
  72. car_sn:"",
  73. shopList:{},
  74. carInfoData:{},
  75. carInfo: {},
  76. overdueMoney:0,
  77. overdueTime:0,
  78. sub_sn: '',
  79. model_image: '3',
  80. car_model: '',
  81. return_imgs: [],
  82. car_imgs: [],
  83. model_image_list: '',
  84. _image_list:[]
  85. };
  86. },
  87. /**
  88. * 生命周期函数--监听页面加载
  89. */
  90. onLoad: function(options) {
  91. console.log(options,'options');
  92. this.isReturnCar = options.isReturnCar
  93. if(options.isReturnCar){
  94. uni.setNavigationBarTitle({
  95. title:'归还车辆'
  96. })
  97. this.shopInfoFn()
  98. }
  99. this.sub_sn = options.sub_sn || ''
  100. this.model_id = options.model_id || ''
  101. this.car_sn = options.car_sn || ''
  102. this.overdueMoney = options.overdueMoney || ''
  103. this.overdueTime = options.overdueTime || ''
  104. this.totalPrice = Number(this.overdueMoney) || 0
  105. this.carDetFn()
  106. this.shopSettingFn()
  107. },
  108. // API_FLK_CAR_DETAIL
  109. /**
  110. * 生命周期函数--监听页面显示
  111. */
  112. onShow: function() {
  113. },
  114. onUnload: function () {
  115. },
  116. methods: {
  117. async payToOrder(pay_type){
  118. let milliseconds = new Date().getTime();
  119. const current_time = this.overdueTime ? this.overdueTime : parseInt(milliseconds / 1000);
  120. let {data} = await request.postApi(config_gyq.API_FLK_CAR_RETURN_CAR,{
  121. latitude: this.myLocation.latitude,
  122. longitude: this.myLocation.longitude,
  123. shop_id:this.shopInfo.id,
  124. car_sn:this.car_sn,
  125. image_list:this._image_list.join(','),
  126. pay_type,
  127. price:this.totalPrice,
  128. current_time
  129. })
  130. if(data.code == 200){
  131. common.simpleToast('还车成功!')
  132. setTimeout(()=> {
  133. uni.switchTab({
  134. url: `/pages/index/index?plate_number=${this.car_sn}`,
  135. });
  136. }, 800)
  137. }else{
  138. common.simpleToast(data.msg)
  139. }
  140. },
  141. async locationFn() {
  142. let res = await uni.getLocation()
  143. if (res[1]) {
  144. this.myLocation = {
  145. latitude: res[1].latitude,
  146. longitude: res[1].longitude,
  147. }
  148. this.shopInfoFn()
  149. }
  150. },
  151. //还车
  152. async submitReturn(){
  153. this._image_list = this.car_imgs.map(item => item.img_url)
  154. if (this._image_list.length < 1) return common.simpleToast('请上传车辆照片')
  155. this.isShowToBuy = true
  156. },
  157. async shopInfoFn(){
  158. let res = await uni.getLocation()
  159. let {data} = await request.postApi(config.API_NEAR_SHOP_LIST,
  160. {
  161. limit:1,
  162. latitude: this.myLocation.latitude,
  163. longitude: this.myLocation.longitude,
  164. }
  165. )
  166. if(data.code == 200){
  167. if(data.data.list.length > 0){
  168. this.shopInfo = data.data.list[0]
  169. }else{
  170. common.simpleToast('未获取到门店位置!')
  171. }
  172. }else{
  173. common.simpleToast(data.msg)
  174. }
  175. },
  176. async shopSettingFn(){
  177. let {data} = await request.postApi(config_gyq.API_FLK_INDEX_SHOP_SETTING,{model_id:this.model_id})
  178. if(data.code == 200){
  179. this.shopList = data.data
  180. }else{
  181. common.simpleToast(data.msg)
  182. }
  183. },
  184. async carDetFn(){
  185. let {data} = await request.postApi(config.API_FLK_CAR_DETAIL,{car_sn:this.car_sn})
  186. if(data.code == 200){
  187. this.carInfoData = data.data
  188. }else{
  189. common.simpleToast(data.msg)
  190. }
  191. },
  192. handleCarImagesUpdate(updatedImages) {
  193. // 这里会接收到子组件传来的更新后的图片URL数组
  194. this.car_imgs = updatedImages
  195. },
  196. submitEnabled() {
  197. const me = this
  198. const _image_list = this.car_imgs.map(item => item.img_url)
  199. if (_image_list.length < 1) return common.simpleToast('请上传车辆照片')
  200. const pData = {
  201. car_sn: this.car_sn,
  202. sub_sn: this.sub_sn,
  203. image_list: _image_list.join(',')
  204. }
  205. http.postApi(config.API_FLK_CAR_ASSIGNMENT, pData, (resp) => {
  206. if (resp.data.code === 200) {
  207. common.simpleToast('车辆激活成功')
  208. setTimeout(function() {
  209. uni.switchTab({
  210. url: `/pages/index/index?plate_number=${me.car_sn}`,
  211. });
  212. }, 800)
  213. } else {
  214. common.simpleToast(resp.data.msg)
  215. }
  216. })
  217. }
  218. }
  219. };
  220. </script>
  221. <style>
  222. @import './activation.css';
  223. </style>