activation.vue 7.0 KB

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