creatCarInfo.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="pages flex flex_column" :style="{paddingBottom:showCarKeyborde?'40vh':'6rem'}">
  3. <uniNavBar title="创建质保单-车辆信息" statusBar :shadow="false" @click-left="toBack"></uniNavBar>
  4. <u-read-more toggle close-text="展开全部">
  5. <view class="uuid-list">
  6. <view class="flex align_center" v-for="item in uuid" :key="item.id">
  7. <view class="uuid-info">
  8. <view>产品名称:{{item.productName}}</view>
  9. <view>产品编码:{{item.productCode}}</view>
  10. <view class="uuid" style="margin-top: 0.2rem;">唯一码:{{item.traceCode}}</view>
  11. </view>
  12. <view v-if="item.productMsg" class="uuid-img" @click="viewImg(item.productMsg)">
  13. <image :src="item.productMsg"></image>
  14. </view>
  15. </view>
  16. </view>
  17. </u-read-more>
  18. <view class="forms">
  19. <view class="forms-tits">车辆信息</view>
  20. <view class="flex align_center">
  21. <view class="labes"><text>*</text>扫描VIN码:</view>
  22. <view class="inputs"><image style="width: 100%;height: 35px;background: #eaeaea;" :src="tempImg"></image></view>
  23. <view class="btns" @click="openCamera"><image src="../../static/tab/tab_scan_normal.png"></image></view>
  24. </view>
  25. <view class="flex align_center">
  26. <view class="labes"><text>*</text>识别VIN码:</view>
  27. <view class="inputs"><u-input :focus="focusInput" @blur="getCarInfo" v-model="form.vin" maxlength="17" border clearable type="text" placeholder="请输入VIN码"></u-input></view>
  28. </view>
  29. <view class="flex align_center">
  30. <view class="labes" style="width: 4.5rem;"><text>*</text>里程数:</view>
  31. <view class="inputs"><u-input v-model="form.mileage" type="number" border maxlength="99999999" clearable placeholder="请输入里程数"></u-input></view>
  32. <view class="btns">KM</view>
  33. </view>
  34. <view class="flex align_center">
  35. <view class="labes" style="width: 4.5rem;">车牌号:</view>
  36. <view class="inputs">
  37. <car-number-input @numberInputResult="vehicleNumberResult" @show="showCarInput" :defaultStr="form.vehicleNumber"></car-number-input>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="buttons flex align_center">
  42. <u-button type="default" @click="toBack">上一步</u-button>
  43. <u-button type="primary" :loading="loading" @click="saveForm">下一步</u-button>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { getVehicleInfoByVin } from '@/api/car'
  49. import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  50. export default {
  51. components: {
  52. uniNavBar
  53. },
  54. data() {
  55. return {
  56. tempImg: '',
  57. form:{
  58. vin: '',
  59. mileage: '',
  60. vehicleNumber: '',
  61. carBrand: '',
  62. carModel: '',
  63. // icon:'',
  64. // year:'',
  65. // text:''
  66. },
  67. uuid: [],
  68. focusInput: false,
  69. loading: false,
  70. showCarKeyborde: false
  71. }
  72. },
  73. onUnload() {
  74. this.$store.state.vuex_uuidTempData.carInfo = this.form
  75. },
  76. onLoad() {
  77. const tempData = this.$store.state.vuex_uuidTempData
  78. this.uuid = tempData&&tempData.traceCodeList ? tempData.traceCodeList : []
  79. this.form = Object.assign(this.form,tempData&&tempData.carInfo ? tempData.carInfo : {})
  80. },
  81. onShow() {
  82. const ret = this.$store.state.vuex_tempData
  83. if(ret&&ret.retCode){
  84. this.tempImg = ret.filePath
  85. this.form.vin = ret.retCode
  86. if(ret.retCode){
  87. this.getCarInfo()
  88. }
  89. }
  90. this.focusInput = ret&&ret=="inputCode"
  91. },
  92. onHide() {
  93. this.tempImg = ''
  94. this.$store.state.vuex_tempData = null
  95. },
  96. methods: {
  97. toBack(){
  98. uni.redirectTo({
  99. url: "/pagesA/qualityPolicy/creatOrder"
  100. })
  101. },
  102. viewImg(img){
  103. uni.previewImage({
  104. urls: [img]
  105. })
  106. },
  107. showCarInput(v){
  108. this.showCarKeyborde = v
  109. },
  110. vehicleNumberResult(e){
  111. this.form.vehicleNumber = e
  112. },
  113. openCamera(){
  114. uni.navigateTo({
  115. url: "/pages/scan-frame/scan-frame?pageType=UUID"
  116. })
  117. },
  118. //获取车辆信息
  119. async getCarInfo(){
  120. this.loading = true
  121. const ret = await getVehicleInfoByVin({vin: this.form.vin})
  122. if(ret.data){
  123. this.form.carBrand = ret.data.brand_name
  124. this.form.carModel = ret.data.model_name
  125. // this.form.icon = ret.data.icon
  126. // this.form.year = ret.data.year
  127. // this.form.text = ret.data.text
  128. }else{
  129. uni.showToast({
  130. icon: 'none',
  131. title: ret.message
  132. })
  133. }
  134. this.loading = false
  135. },
  136. saveForm(){
  137. if(this.form.vin == ''){
  138. uni.showToast({
  139. icon: 'none',
  140. title: '请扫描或手动输入VIN码'
  141. })
  142. return
  143. }
  144. if(this.form.mileage == ''){
  145. uni.showToast({
  146. icon: 'none',
  147. title: '请输入里程数'
  148. })
  149. return
  150. }
  151. if(this.form.vehicleNumber.length>0 && this.form.vehicleNumber.length < 7){
  152. uni.showToast({
  153. icon: 'none',
  154. title: '请输入正确的车牌号码'
  155. })
  156. return
  157. }
  158. this.$store.state.vuex_uuidTempData.carInfo = this.form
  159. uni.redirectTo({
  160. url: "/pagesA/qualityPolicy/creatCustomInfo"
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="less">
  167. .pages{
  168. height: 100vh;
  169. background: #f8f8f8;
  170. padding-bottom: 6rem;
  171. overflow: auto;
  172. .uuid-list{
  173. background: #fff;
  174. text-indent: 0;
  175. line-height: normal;
  176. font-size: 28rpx;
  177. > view{
  178. justify-content: space-between;
  179. border-bottom: 1px solid #eee;
  180. padding: 0.6rem 1rem;
  181. }
  182. color: #666;
  183. .uuid-info{
  184. flex-grow: 1;
  185. line-height: 1.5rem;
  186. width: 50%;
  187. .uuid{
  188. color: #333;
  189. }
  190. > view{
  191. padding: 0.3rem 0;
  192. }
  193. }
  194. .uuid-img{
  195. width: 6rem;
  196. height: 6rem;
  197. border: 1px solid #eee;
  198. overflow: hidden;
  199. display: flex;
  200. align-items: center;
  201. margin-left: 0.5rem;
  202. image {
  203. max-width: 100%;
  204. max-height: 100%;
  205. background: #eaeaea;
  206. }
  207. }
  208. margin-bottom: 0.5rem;
  209. }
  210. .buttons{
  211. padding: 1rem 2rem 2rem;
  212. position: fixed;
  213. width: 100%;
  214. bottom: 0;
  215. left: 0;
  216. background: #fff;
  217. z-index: 900;
  218. border-top: 1px solid #eee;
  219. justify-content: space-around;
  220. /deep/ .u-btn{
  221. width: 7rem;
  222. }
  223. }
  224. }
  225. .forms{
  226. background: #fff;
  227. .forms-tits{
  228. font-weight: bold;
  229. color: #333;
  230. }
  231. > view{
  232. border-bottom: 1px solid #eee;
  233. padding: 0.6rem 1rem;
  234. }
  235. .labes{
  236. width: 6rem;
  237. text-align: right;
  238. padding-right: 0.6rem;
  239. text{
  240. color: red;
  241. margin-right: 5px;
  242. }
  243. }
  244. .inputs{
  245. flex-grow: 1;
  246. }
  247. .btns{
  248. width: 3rem;
  249. text-align: center;
  250. image{
  251. width: 1.6rem;
  252. height: 1.6rem;
  253. }
  254. }
  255. }
  256. </style>