activation.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. uni.removeStorageSync('car_info')
  147. common.simpleToast('还车成功!')
  148. setTimeout(() => {
  149. uni.switchTab({
  150. url: `/pages/index/index?plate_number=${this.car_sn}`,
  151. });
  152. }, 800)
  153. } else {
  154. common.simpleToast(data.msg)
  155. }
  156. },
  157. async locationFn() {
  158. let _this = this
  159. uni.getLocation({
  160. success(res) {
  161. _this.myLocation = {
  162. latitude: res.latitude,
  163. longitude: res.longitude,
  164. }
  165. }
  166. })
  167. },
  168. //还车
  169. async submitReturn() {
  170. this._image_list = this.car_imgs.map(item => {
  171. return item.url
  172. })
  173. if (this._image_list.length < 1) return common.simpleToast('请上传车辆照片')
  174. if (this.totalPrice > 0) {
  175. this.isShowToBuy = true
  176. } else {
  177. this.payToOrder(1)
  178. }
  179. },
  180. async shopInfoFn() {
  181. let res = await uni.getLocation()
  182. let {
  183. data
  184. } = await request.postApi(config.API_NEAR_SHOP_LIST, {
  185. limit: 1,
  186. latitude: this.myLocation.latitude,
  187. longitude: this.myLocation.longitude,
  188. })
  189. if (data.code == 200) {
  190. if (data.data.list.length > 0) {
  191. this.shopInfo = data.data.list[0]
  192. } else {
  193. common.simpleToast('未获取到门店位置!')
  194. }
  195. } else {
  196. common.simpleToast(data.msg)
  197. }
  198. },
  199. async shopSettingFn() {
  200. let {
  201. data
  202. } = await request.postApi(config_gyq.API_FLK_INDEX_SHOP_SETTING, {
  203. model_id: this.model_id
  204. })
  205. if (data.code == 200) {
  206. this.shopList = data.data
  207. } else {
  208. common.simpleToast(data.msg)
  209. }
  210. },
  211. async carDetFn() {
  212. let {
  213. data
  214. } = await request.postApi(config.API_FLK_CAR_DETAIL, {
  215. car_sn: this.car_sn
  216. })
  217. if (data.code == 200) {
  218. this.carInfoData = data.data
  219. } else {
  220. common.simpleToast(data.msg)
  221. }
  222. },
  223. handleCarImagesUpdate(updatedImages) {
  224. // 这里会接收到子组件传来的更新后的图片URL数组
  225. this.car_imgs = updatedImages
  226. },
  227. submitEnabled() {
  228. const me = this
  229. console.log(this.car_imgs)
  230. const _image_list = this.car_imgs.map(item => item.url)
  231. if (_image_list.length < 1) return common.simpleToast('请上传车辆照片')
  232. const pData = {
  233. car_sn: this.car_sn,
  234. sub_sn: this.sub_sn,
  235. image_list: _image_list.join(',')
  236. }
  237. http.postApi(config.API_FLK_CAR_ASSIGNMENT, pData, (resp) => {
  238. if (resp.data.code === 200) {
  239. common.simpleToast('车辆激活成功')
  240. setTimeout(function() {
  241. uni.switchTab({
  242. url: `/pages/index/index?plate_number=${me.car_sn}`,
  243. });
  244. }, 800)
  245. } else {
  246. common.simpleToast(resp.data.msg)
  247. }
  248. })
  249. }
  250. }
  251. };
  252. </script>
  253. <style>
  254. @import './activation.css';
  255. </style>