creatCarInfo.vue 5.5 KB

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