activation.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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.brand_name}}</view>
  17. </view>
  18. <view class="return-top flex-row flex-between">
  19. <view>车辆颜色:{{carInfoData.color_name}}</view>
  20. </view>
  21. <view v-if="carInfoData.license_plate_number" class="return-top flex-row flex-between">
  22. <view>车牌号:{{carInfoData.license_plate_number}}</view>
  23. </view>
  24. <view class="return-top flex-row flex-between">
  25. <view>车辆名称:{{carInfoData.car_name}}</view>
  26. </view>
  27. <view class="return-top flex-row flex-between">
  28. <view>车型:{{carInfoData.model_name}}</view>
  29. </view>
  30. <view class="return-top flex-row flex-between">
  31. <view>续航:{{(carInfoData.endurance / 1000).toFixed(2)}}km</view>
  32. </view>
  33. <view class="return-top flex-row flex-between">
  34. <view>重量:{{(carInfoData.weight / 1000).toFixed(2)}}kg</view>
  35. </view>
  36. <view class="return-top flex-row ">
  37. <view>照片:</view>
  38. <view style="display: flex;align-items: center;" class="">
  39. <image style="margin-right: 10rpx;" v-for="(item,index) of carInfoData.model_images"
  40. :key="index" class="img" :src="item" mode="aspectFill"></image>
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="shopInfo.shop_name" class="return-info">
  45. <view class="h5">门店信息</view>
  46. <view class="return-top flex-row flex-between">
  47. <view>门店名称:{{shopInfo.shop_name}}</view>
  48. </view>
  49. <view class="return-top flex-row flex-between">
  50. <view>门店地址:{{shopInfo.address}}</view>
  51. </view>
  52. </view>
  53. <view class="pictures-info">
  54. <view>上传照片</view>
  55. <!-- <view>这里是关于激活车辆照片的文案描述,这里是关于激活车辆照片的文案描述</view> -->
  56. <!-- <uploaders :max="Number(shopList.flk_hire_car_img_num)" :car_info="car_imgs"
  57. @update-car-images="handleCarImagesUpdate"></uploaders> -->
  58. <view class="list-group">
  59. <view class="list-item" @click="bindUpImg(index)" @longpress="bindDelImage(index)" :data-idx="index" v-for="(item, index) in shopList.flk_hire_return_car_img"
  60. :key="item.unique">
  61. <image v-if="!item.imgUrl" class="img-item-demo" :src="item.url"></image>
  62. <image v-else class="img-item" :src="item.imgUrl" mode="aspectFill"></image>
  63. <view class="img_text">{{ item.title? item.title : '车辆照片'}}</view>
  64. <view v-if="!item.imgUrl" class="empity-item">+</view>
  65. </view>
  66. </view>
  67. <view v-if="isReturnCar" @tap="submitReturn" class="pictures-btn">归还车辆</view>
  68. <view v-else @tap="submitEnabled" class="pictures-btn">激活车辆</view>
  69. </view>
  70. <PayTypeModel @closeShow="()=>isShowToBuy=false" @payToOrder="payToOrder" :free_price="totalPrice"
  71. :isShowToBuy="isShowToBuy" />
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import uploaders from '@/component/uploaders/uploaders';
  77. const http = require('@/common/http.js');
  78. const request = require('../../common/request');
  79. const config = require('@/common/config.js');
  80. const config_gyq = require('@/common/config_gyq.js');
  81. const common = require('@/common/common.js');
  82. import PayTypeModel from '@/component/payTypeModel/payTypeModel';
  83. import allPrice from '@/component/allPrice/allPrice';
  84. import upload from '@//component/uploaders/upload.js.js';
  85. export default {
  86. components: {
  87. uploaders,
  88. PayTypeModel,
  89. allPrice
  90. },
  91. data() {
  92. return {
  93. imgList:[],
  94. totalPrice: 0,
  95. isShowToBuy: false,
  96. myLocation: {},
  97. shopInfo: {},
  98. isReturnCar: "",
  99. overdueTimes: '',
  100. model_id: "",
  101. car_sn: "",
  102. shopList: {},
  103. carInfoData: {},
  104. carInfo: {},
  105. overdueMoney: 0,
  106. overdueTime: 0,
  107. sub_sn: '',
  108. model_image: '3',
  109. car_model: '',
  110. return_imgs: [],
  111. car_imgs: [],
  112. model_image_list: '',
  113. _image_list: []
  114. };
  115. },
  116. /**
  117. * 生命周期函数--监听页面加载
  118. */
  119. onLoad: function(options) {
  120. this.locationFn()
  121. this.isReturnCar = options.isReturnCar
  122. if (options.isReturnCar) {
  123. uni.setNavigationBarTitle({
  124. title: '归还车辆'
  125. })
  126. this.shopInfoFn()
  127. }
  128. this.sub_sn = options.sub_sn || ''
  129. this.model_id = options.model_id || ''
  130. this.car_sn = options.car_sn || ''
  131. if (options.overdueMoney == 'undefined' || !options.overdueMoney) {
  132. this.overdueMoney = 0
  133. } else {
  134. this.overdueTime = Number(options.overdueMoney)
  135. }
  136. if (options.overdueTime == 'undefined' || !options.overdueTime == 'undefined') {
  137. this.overdueTime = ''
  138. } else {
  139. this.overdueTime = options.overdueTime
  140. }
  141. this.totalPrice = Number(this.overdueMoney) || 0
  142. this.carDetFn()
  143. this.shopSettingFn()
  144. },
  145. // API_FLK_CAR_DETAIL
  146. /**
  147. * 生命周期函数--监听页面显示
  148. */
  149. onShow: function() {},
  150. onUnload: function() {},
  151. methods: {
  152. async bindDelImage(index){
  153. let res = await uni.showModal({
  154. title: '提示',
  155. content: '你确定要删除吗?',
  156. showCancel: true,
  157. })
  158. if (res[1].confirm) {
  159. this.shopList.flk_hire_return_car_img[index].imgUrl = ''
  160. this.$forceUpdate()
  161. }
  162. },
  163. async bindUpImg(index) {
  164. let res = await uni.chooseImage({
  165. count: 1,
  166. })
  167. if(res[1]){
  168. const imgList = res[1].tempFilePaths
  169. let data = await upload.uploadFile(imgList)
  170. this.shopList.flk_hire_return_car_img[index].imgUrl = data[0].url
  171. this.$forceUpdate()
  172. // this.imgList = this.imgList.concat(data)
  173. // this.updateImages(this.imgList)
  174. }
  175. },
  176. async payToOrder(pay_type) {
  177. let milliseconds = new Date().getTime();
  178. const current_time = this.overdueTime ? this.overdueTime : parseInt(milliseconds / 1000);
  179. let {
  180. data
  181. } = await request.postApi(config_gyq.API_FLK_CAR_RETURN_CAR, {
  182. latitude: this.myLocation.latitude,
  183. longitude: this.myLocation.longitude,
  184. shop_id: this.shopInfo.id,
  185. car_sn: this.car_sn,
  186. image_list: this._image_list.join(','),
  187. pay_type,
  188. price: this.totalPrice,
  189. current_time
  190. })
  191. if (data.code == 200) {
  192. uni.removeStorageSync('car_info')
  193. common.simpleToast('还车成功!')
  194. setTimeout(() => {
  195. uni.switchTab({
  196. url: `/pages/index/index`,
  197. });
  198. }, 800)
  199. } else {
  200. common.simpleToast(data.msg)
  201. }
  202. },
  203. async locationFn() {
  204. let _this = this
  205. uni.getLocation({
  206. success(res) {
  207. _this.myLocation = {
  208. latitude: res.latitude,
  209. longitude: res.longitude,
  210. }
  211. }
  212. })
  213. },
  214. //还车
  215. async submitReturn() {
  216. this._image_list = this.shopList.flk_hire_return_car_img.map(item => {
  217. return item.imgUrl
  218. })
  219. this._image_list = this._image_list.filter(item=> {
  220. if(item){
  221. return item
  222. }
  223. })
  224. if (this._image_list.length < this.shopList.flk_hire_return_car_img.length) return common.simpleToast('请上传车辆照片')
  225. if (this.totalPrice > 0) {
  226. this.isShowToBuy = true
  227. } else {
  228. this.payToOrder(1)
  229. }
  230. },
  231. async shopInfoFn() {
  232. let res = await uni.getLocation()
  233. let {
  234. data
  235. } = await request.postApi(config.API_NEAR_SHOP_LIST, {
  236. limit: 1,
  237. latitude: this.myLocation.latitude,
  238. longitude: this.myLocation.longitude,
  239. })
  240. if (data.code == 200) {
  241. if (data.data.list.length > 0) {
  242. this.shopInfo = data.data.list[0]
  243. } else {
  244. common.simpleToast('未获取到门店位置!')
  245. }
  246. } else {
  247. common.simpleToast(data.msg)
  248. }
  249. },
  250. async shopSettingFn() {
  251. let {
  252. data
  253. } = await request.postApi(config_gyq.API_FLK_INDEX_SHOP_SETTING, {
  254. model_id: this.model_id
  255. })
  256. if (data.code == 200) {
  257. this.shopList = data.data
  258. if(this.shopList.flk_hire_return_car_img.length < this.shopList.share_car_max_user_num){
  259. let num = this.shopList.share_car_max_user_num - this.shopList.flk_hire_return_car_img.length
  260. for (let i = 0; i < num; i++) {
  261. this.shopList.flk_hire_return_car_img.push({
  262. url:"",
  263. imgUrl:'',
  264. title:''
  265. })
  266. }
  267. }
  268. if(this.shopList.flk_hire_return_car_img.length > this.shopList.share_car_max_user_num){
  269. let flk_hire_return_car_img = []
  270. for (let i = 0; i < this.shopList.share_car_max_user_num; i++) {
  271. let item = this.shopList.flk_hire_return_car_img[i]
  272. this.shopList.flk_hire_return_car_img.push(item)
  273. }
  274. }
  275. } else {
  276. common.simpleToast(data.msg)
  277. }
  278. },
  279. async carDetFn() {
  280. let {
  281. data
  282. } = await request.postApi(config.API_FLK_CAR_DETAIL, {
  283. car_sn: this.car_sn
  284. })
  285. if (data.code == 200) {
  286. data.data.model_images = data.data.model_images.split(',') || []
  287. this.carInfoData = data.data
  288. } else {
  289. common.simpleToast(data.msg)
  290. }
  291. },
  292. handleCarImagesUpdate(updatedImages) {
  293. // 这里会接收到子组件传来的更新后的图片URL数组
  294. this.car_imgs = updatedImages
  295. },
  296. submitEnabled() {
  297. const me = this
  298. let _image_list =this.shopList.flk_hire_return_car_img.map(item => item.imgUrl)
  299. _image_list = _image_list.filter(item=> {
  300. if(item){
  301. return item
  302. }
  303. })
  304. if (_image_list.length < this.shopList.flk_hire_return_car_img.length) return common.simpleToast('请上传车辆照片')
  305. const pData = {
  306. car_sn: this.car_sn,
  307. sub_sn: this.sub_sn,
  308. image_list: _image_list.join(',')
  309. }
  310. http.postApi(config.API_FLK_CAR_ASSIGNMENT, pData, (resp) => {
  311. if (resp.data.code === 200) {
  312. common.simpleToast('车辆激活成功')
  313. setTimeout(function() {
  314. uni.switchTab({
  315. url: `/pages/index/index?plate_number=${me.car_sn}`,
  316. });
  317. }, 800)
  318. } else {
  319. common.simpleToast(resp.data.msg)
  320. }
  321. })
  322. }
  323. }
  324. };
  325. </script>
  326. <style scoped>
  327. @import './activation.css';
  328. .list-group {
  329. display: flex;
  330. flex-direction: row;
  331. justify-content: flex-start;
  332. flex-wrap: wrap;
  333. }
  334. .list-item {
  335. width: 200rpx;
  336. height: 200rpx;
  337. background-color: #F4F5F6;
  338. border-radius: 16rpx;
  339. display: flex;
  340. flex-direction: column;
  341. margin-right: 9rpx;
  342. margin-bottom: 10rpx;
  343. position: relative;
  344. align-items: center;
  345. }
  346. .img-item {
  347. width: 200rpx;
  348. height: 200rpx;
  349. background-color: #fff;
  350. border-radius: 16rpx;
  351. }
  352. .img-item-demo {
  353. width: 200rpx;
  354. height: 200rpx;
  355. background-color: #fff;
  356. border-radius: 16rpx;
  357. /* 翻转图片的颜色 */
  358. filter: invert(30%);
  359. opacity: 0.8;
  360. }
  361. .empity-item {
  362. position: absolute;
  363. /* #ifdef MP-ALIPAY */
  364. top: 0.7rem;
  365. left: 0.5rem;
  366. /* #endif */
  367. /* #ifdef MP-WEIXIN */
  368. top: 10rpx;
  369. left: 48rpx;
  370. /* #endif */
  371. color: #e6e6e6;
  372. font-size: 120rpx;
  373. text-align: center;
  374. }
  375. .img_text {
  376. font-family: PingFangSC, PingFang SC;
  377. font-weight: 500;
  378. font-size: 24rpx;
  379. color: #fff;
  380. line-height: 24rpx;
  381. /* text-align: center; */
  382. font-style: normal;
  383. /* text-align: center; */
  384. position: absolute;
  385. bottom: 17rpx;
  386. /* left: 73rpx; */
  387. }
  388. </style>