creatCarInfo.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="pages flex flex_column">
  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">唯一码:{{item.traceCode}}</view>
  11. </view>
  12. <view v-if="item.productMsg" class="uuid-img" @click="viewImg(item.productMsg)">
  13. <image style="width: 100%;height: 80px;background: #eaeaea;" :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" :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. }
  71. },
  72. onUnload() {
  73. this.$store.state.vuex_uuidTempData.carInfo = this.form
  74. },
  75. onLoad() {
  76. const tempData = this.$store.state.vuex_uuidTempData
  77. this.uuid = tempData&&tempData.traceCodeList ? tempData.traceCodeList : []
  78. this.form = Object.assign(this.form,tempData&&tempData.carInfo ? tempData.carInfo : {})
  79. },
  80. onShow() {
  81. const ret = this.$store.state.vuex_tempData
  82. if(ret&&ret.retCode){
  83. this.tempImg = ret.filePath
  84. this.form.vin = ret.retCode
  85. if(ret.retCode){
  86. this.getCarInfo()
  87. }
  88. }
  89. this.focusInput = ret&&ret=="inputCode"
  90. },
  91. onHide() {
  92. this.tempImg = ''
  93. this.$store.state.vuex_tempData = null
  94. },
  95. methods: {
  96. toBack(){
  97. uni.redirectTo({
  98. url: "/pagesA/qualityPolicy/creatOrder"
  99. })
  100. },
  101. viewImg(img){
  102. uni.previewImage({
  103. urls: [img]
  104. })
  105. },
  106. vehicleNumberResult(e){
  107. this.form.vehicleNumber = e
  108. },
  109. openCamera(){
  110. uni.navigateTo({
  111. url: "/pages/scan-frame/scan-frame?pageType=UUID"
  112. })
  113. },
  114. //获取车辆信息
  115. async getCarInfo(){
  116. this.loading = true
  117. const ret = await getVehicleInfoByVin({vin: this.form.vin})
  118. if(ret.data){
  119. this.form.carBrand = ret.data.brand_name
  120. this.form.carModel = ret.data.model_name
  121. // this.form.icon = ret.data.icon
  122. // this.form.year = ret.data.year
  123. // this.form.text = ret.data.text
  124. }else{
  125. uni.showToast({
  126. icon: 'none',
  127. title: ret.message
  128. })
  129. }
  130. this.loading = false
  131. },
  132. saveForm(){
  133. if(this.form.vin == ''){
  134. uni.showToast({
  135. icon: 'none',
  136. title: '请扫描或手动输入VIN码'
  137. })
  138. return
  139. }
  140. if(this.form.mileage == ''){
  141. uni.showToast({
  142. icon: 'none',
  143. title: '请输入里程数'
  144. })
  145. return
  146. }
  147. if(this.form.vehicleNumber.length>0 && this.form.vehicleNumber.length < 7){
  148. uni.showToast({
  149. icon: 'none',
  150. title: '请输入正确的车牌号码'
  151. })
  152. return
  153. }
  154. this.$store.state.vuex_uuidTempData.carInfo = this.form
  155. uni.redirectTo({
  156. url: "/pagesA/qualityPolicy/creatCustomInfo"
  157. })
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="less">
  163. .pages{
  164. height: 100vh;
  165. background: #f8f8f8;
  166. padding-bottom: 6rem;
  167. overflow: auto;
  168. .uuid-list{
  169. background: #fff;
  170. text-indent: 0;
  171. line-height: normal;
  172. font-size: 28rpx;
  173. > view{
  174. justify-content: space-between;
  175. border-bottom: 1px solid #eee;
  176. padding: 0.6rem 1rem;
  177. }
  178. color: #666;
  179. .uuid-info{
  180. flex-grow: 1;
  181. padding-right: 1rem;
  182. .uuid{
  183. color: #333;
  184. }
  185. > view{
  186. padding: 0.3rem 0;
  187. }
  188. }
  189. .uuid-img{
  190. width: 7rem;
  191. border: 1px solid #eee;
  192. }
  193. margin-bottom: 0.5rem;
  194. }
  195. .buttons{
  196. padding: 1rem 2rem 2rem;
  197. position: fixed;
  198. width: 100%;
  199. bottom: 0;
  200. left: 0;
  201. background: #fff;
  202. z-index: 900;
  203. border-top: 1px solid #eee;
  204. justify-content: space-around;
  205. /deep/ .u-btn{
  206. width: 7rem;
  207. }
  208. }
  209. }
  210. .forms{
  211. background: #fff;
  212. .forms-tits{
  213. font-weight: bold;
  214. color: #333;
  215. }
  216. > view{
  217. border-bottom: 1px solid #eee;
  218. padding: 0.6rem 1rem;
  219. }
  220. .labes{
  221. width: 6rem;
  222. text-align: right;
  223. padding-right: 0.6rem;
  224. text{
  225. color: red;
  226. margin-right: 5px;
  227. }
  228. }
  229. .inputs{
  230. flex-grow: 1;
  231. }
  232. .btns{
  233. width: 3rem;
  234. text-align: center;
  235. image{
  236. width: 1.6rem;
  237. height: 1.6rem;
  238. }
  239. }
  240. }
  241. </style>