creatCarInfo.vue 5.9 KB

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