confirmVin.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view style="width: 100%;">
  3. <view class="confirm-text" v-if="vinImg">
  4. <view>请核对VIN识别是否正确?</view>
  5. <view>如果有误,请修改</view>
  6. </view>
  7. <view class="confirm-text" v-else>
  8. <view>请正确输入17位VIN码</view>
  9. </view>
  10. <view class="vin-img" v-if="vinImg">
  11. <u-image :src="vinImg" width="100%" height="165"></u-image>
  12. </view>
  13. <!-- <xt-verify-code v-model="verifyCode" inputType='text' size="17" @confirm="confirm"></xt-verify-code> -->
  14. <view style="padding: 30rpx 60rpx;margin-top: 20rpx;">
  15. <u-input v-model="verifyCode" :custom-style="{fontSize:'40rpx'}" type="text" height="90" :maxlength='17' input-align="center" placeholder="请输入VIN" :border="true" />
  16. </view>
  17. <view class="confirm-button">
  18. <u-button @click="submitForm" :loading="loading" :custom-style="{background:'#1283d4'}" type="primary" shape="circle">确认</u-button>
  19. </view>
  20. <view class="share-list flex align_center">
  21. <view @click="toScan">
  22. <view><u-icon name="scan" size="60" color="##d5d5d5"></u-icon></view>
  23. <view>重新扫描</view>
  24. </view>
  25. <view v-if="verifyCode.length>=17">
  26. <view>
  27. <button open-type="share"><u-icon name="chat" size="60" color="##d5d5d5"></u-icon></button>
  28. </view>
  29. <view>分享给好友</view>
  30. </view>
  31. <view @click="toCopy">
  32. <view><u-icon name="file-text" size="60" color="##d5d5d5"></u-icon></view>
  33. <view>复制VIN</view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { getVehicleInfoByVin, scanVinLog } from '@/api/car.js'
  40. export default {
  41. data() {
  42. return {
  43. loading: false,
  44. verifyCode: '',
  45. vinImg: ''
  46. }
  47. },
  48. onLoad(opts) {
  49. this.verifyCode = opts.verifyCode || ''
  50. this.vinImg = opts.filePath || ''
  51. },
  52. // 分享
  53. onShareAppMessage(e){
  54. return {
  55. title: '修配一码通车架号(VIN)分享',
  56. path: '/pages/vinIput/share?userId=123&vin='+this.verifyCode,
  57. imageUrl:'/static/share.png',
  58. type: '1',
  59. success(res){
  60. console.log(res)
  61. },
  62. fail(err){
  63. console.log(err)
  64. }
  65. }
  66. },
  67. methods: {
  68. // 重新扫描
  69. toScan(){
  70. uni.redirectTo({
  71. url: "/pages/scan-frame/scan-frame"
  72. })
  73. },
  74. // 复制
  75. toCopy(){
  76. if(this.verifyCode.length>=17){
  77. uni.setClipboardData({
  78. data: this.verifyCode,
  79. })
  80. }else{
  81. uni.showToast({
  82. icon: 'none',
  83. title: '请输入正确的VIN码'
  84. })
  85. }
  86. },
  87. // 创建扫描记录
  88. creatRecord(data){
  89. scanVinLog({
  90. vinCode: this.verifyCode.toUpperCase(),
  91. brandName: data.brand_name,
  92. brandId: data.brand_id,
  93. modelName: data.model_name,
  94. modelId:data.model_id,
  95. modelInfo: data.text,
  96. seriesId:data.series_id,
  97. seriesName:data.series_name,
  98. subId:data.sub_id,
  99. subName:data.sub_name,
  100. icon: data.icon,
  101. year: data.year
  102. }).then(res => {
  103. console.log(res)
  104. })
  105. },
  106. // 提交并匹配车型
  107. submitForm(){
  108. const _this = this
  109. const vinNo = this.verifyCode.toUpperCase()
  110. console.log(vinNo, 'vinvinvinvinvin')
  111. if(vinNo.length>=17){
  112. this.loading = true
  113. getVehicleInfoByVin({
  114. vin:vinNo
  115. }).then(res => {
  116. if (res.status == 200&&res.data) {
  117. // 生成vin记录
  118. _this.creatRecord(res.data)
  119. // 打开选择配件页面
  120. uni.redirectTo({
  121. url: "/pages/digitalShelf/choosePart?vinNumber="+vinNo+"&carList="+encodeURIComponent(JSON.stringify(res.data))
  122. })
  123. } else {
  124. uni.showModal({
  125. title: '匹配错误',
  126. content: '此VIN码没有匹配的车型,请检查VIN码是否正确',
  127. showCancel: false,
  128. confirmText: '知道了'
  129. })
  130. }
  131. this.loading = false
  132. })
  133. }else{
  134. uni.showToast({
  135. icon: 'none',
  136. title: '请输入正确的VIN码'
  137. })
  138. }
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="less">
  144. .confirm-button{
  145. padding: 50rpx;
  146. }
  147. .confirm-text{
  148. text-align: center;
  149. padding: 60rpx 30rpx 0;
  150. line-height: 45rpx;
  151. color: #999;
  152. }
  153. .vin-img{
  154. padding: 30rpx 20rpx;
  155. }
  156. .share-list{
  157. padding: 30rpx;
  158. justify-content: space-around;
  159. > view{
  160. text-align: center;
  161. >view{
  162. &:first-child{
  163. margin: 10rpx auto;
  164. border:2rpx solid #aaa;
  165. border-radius: 200rpx;
  166. width: 100rpx;
  167. height: 100rpx;
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. color: #aaa;
  172. button{
  173. background: none;
  174. border: 0;
  175. color: #aaa;
  176. line-height: normal;
  177. margin: 0;
  178. padding: 0;
  179. &:after{
  180. border: 0;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. </style>