activation.vue 7.2 KB

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