creatCarInfo.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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>产品名称:{{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" @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. height: 100vh;
  172. background: #f8f8f8;
  173. padding-bottom: 6rem;
  174. overflow: auto;
  175. .uuid-list{
  176. background: #fff;
  177. text-indent: 0;
  178. line-height: normal;
  179. font-size: 28rpx;
  180. > view{
  181. justify-content: space-between;
  182. border-bottom: 1px solid #eee;
  183. padding: 0.6rem 1rem;
  184. }
  185. color: #666;
  186. .uuid-info{
  187. flex-grow: 1;
  188. line-height: 1.5rem;
  189. width: 50%;
  190. .uuid{
  191. color: #333;
  192. }
  193. > view{
  194. padding: 0.3rem 0;
  195. }
  196. }
  197. .uuid-img{
  198. width: 6rem;
  199. height: 6rem;
  200. border: 1px solid #eee;
  201. overflow: hidden;
  202. display: flex;
  203. align-items: center;
  204. margin-left: 0.5rem;
  205. image {
  206. max-width: 100%;
  207. max-height: 100%;
  208. background: #eaeaea;
  209. }
  210. }
  211. margin-bottom: 0.5rem;
  212. }
  213. .buttons{
  214. padding: 1rem 2rem 2rem;
  215. position: fixed;
  216. width: 100%;
  217. bottom: 0;
  218. left: 0;
  219. background: #fff;
  220. z-index: 900;
  221. border-top: 1px solid #eee;
  222. justify-content: space-around;
  223. /deep/ .u-btn{
  224. width: 7rem;
  225. }
  226. }
  227. }
  228. .forms{
  229. background: #fff;
  230. .forms-tits{
  231. font-weight: bold;
  232. color: #333;
  233. }
  234. > view{
  235. border-bottom: 1px solid #eee;
  236. padding: 0.6rem 1rem;
  237. }
  238. .labes{
  239. width: 6rem;
  240. text-align: right;
  241. padding-right: 0.6rem;
  242. text{
  243. color: red;
  244. margin-right: 5px;
  245. }
  246. }
  247. .inputs{
  248. flex-grow: 1;
  249. }
  250. .btns{
  251. width: 3rem;
  252. text-align: center;
  253. image{
  254. width: 1.6rem;
  255. height: 1.6rem;
  256. }
  257. }
  258. }
  259. </style>