creatCarInfo.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="pages flex flex_column" :style="{paddingBottom:showCarKeyborde?'40vh':'6rem'}">
  3. <uniNavBar title="创建质保单-车辆信息" statusBar :shadow="false" fixed @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><text>产品名称:</text>{{item.productName}}</view>
  9. <view><text>产品编码:</text>{{item.productCode}}</view>
  10. <view class="uuid" style="margin-top: 0.2rem;"><text>唯一码:</text>{{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" @focus="hideCarinput" @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" @focus="hideCarinput" 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 ref="carInput" @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. hideCarinput(){
  108. this.$refs.carInput.showOrHidePop(-1)
  109. },
  110. showCarInput(v){
  111. this.showCarKeyborde = v
  112. },
  113. vehicleNumberResult(e){
  114. this.form.vehicleNumber = e
  115. },
  116. openCamera(){
  117. uni.navigateTo({
  118. url: "/pages/scan-frame/scan-frame?pageType=UUID"
  119. })
  120. },
  121. //获取车辆信息
  122. async getCarInfo(){
  123. this.loading = true
  124. const ret = await getVehicleInfoByVin({vin: this.form.vin})
  125. if(ret.data){
  126. this.form.carBrand = ret.data.brand_name
  127. this.form.carModel = ret.data.model_name
  128. // this.form.icon = ret.data.icon
  129. // this.form.year = ret.data.year
  130. // this.form.text = ret.data.text
  131. }else{
  132. uni.showToast({
  133. icon: 'none',
  134. title: ret.message
  135. })
  136. }
  137. this.loading = false
  138. },
  139. saveForm(){
  140. if(this.form.vin == ''){
  141. uni.showToast({
  142. icon: 'none',
  143. title: '请扫描或手动输入VIN码'
  144. })
  145. return
  146. }
  147. if(this.form.mileage == ''){
  148. uni.showToast({
  149. icon: 'none',
  150. title: '请输入里程数'
  151. })
  152. return
  153. }
  154. if(this.form.vehicleNumber.length>0 && this.form.vehicleNumber.length < 7){
  155. uni.showToast({
  156. icon: 'none',
  157. title: '请输入正确的车牌号码'
  158. })
  159. return
  160. }
  161. this.$store.state.vuex_uuidTempData.carInfo = this.form
  162. uni.redirectTo({
  163. url: "/pagesA/qualityPolicy/creatCustomInfo"
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="less">
  170. .pages{
  171. background: #f8f8f8;
  172. padding-bottom: 6rem;
  173. overflow: auto;
  174. .uuid-list{
  175. background: #fff;
  176. text-indent: 0;
  177. line-height: normal;
  178. font-size: 28rpx;
  179. > view{
  180. justify-content: space-between;
  181. border-bottom: 1px solid #eee;
  182. padding: 0.6rem 1rem;
  183. }
  184. color: #666;
  185. .uuid-info{
  186. flex-grow: 1;
  187. line-height: 1.5rem;
  188. width: 50%;
  189. > view{
  190. color: #666;
  191. text{
  192. color: #000;
  193. width: 70px;
  194. float: left;
  195. }
  196. }
  197. }
  198. .uuid-img{
  199. width: 6rem;
  200. height: 6rem;
  201. border: 1px solid #eee;
  202. overflow: hidden;
  203. display: flex;
  204. align-items: center;
  205. margin-left: 0.5rem;
  206. image {
  207. max-width: 100%;
  208. max-height: 100%;
  209. background: #eaeaea;
  210. }
  211. }
  212. margin-bottom: 0.5rem;
  213. }
  214. .buttons{
  215. padding: 1rem 2rem 2rem;
  216. position: fixed;
  217. width: 100%;
  218. bottom: 0;
  219. left: 0;
  220. background: #fff;
  221. z-index: 90;
  222. border-top: 1px solid #eee;
  223. justify-content: space-around;
  224. /deep/ .u-btn{
  225. width: 7rem;
  226. }
  227. }
  228. }
  229. .forms{
  230. background: #fff;
  231. .forms-tits{
  232. font-weight: bold;
  233. color: #333;
  234. }
  235. > view{
  236. border-bottom: 1px solid #eee;
  237. padding: 0.6rem 1rem;
  238. }
  239. .labes{
  240. width: 6rem;
  241. text-align: right;
  242. padding-right: 0.6rem;
  243. text{
  244. color: red;
  245. margin-right: 5px;
  246. }
  247. }
  248. .inputs{
  249. flex-grow: 1;
  250. }
  251. .btns{
  252. width: 3rem;
  253. text-align: center;
  254. image{
  255. width: 1.6rem;
  256. height: 1.6rem;
  257. }
  258. }
  259. }
  260. </style>