confirmVin.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. computed: {
  49. userInfo(){
  50. return this.$store.state.vuex_userInfo
  51. }
  52. },
  53. onLoad(opts) {
  54. this.verifyCode = opts.verifyCode || ''
  55. this.vinImg = opts.filePath || ''
  56. },
  57. // 分享
  58. onShareAppMessage(e){
  59. return {
  60. title: '修配一码通车架号(VIN)分享',
  61. path: '/pages/vinIput/share?userName='+this.userInfo.userNameCN+'&vinNo='+this.verifyCode,
  62. imageUrl:'/static/share.png',
  63. type: '2',
  64. }
  65. },
  66. methods: {
  67. // 重新扫描
  68. toScan(){
  69. uni.redirectTo({
  70. url: "/pages/scan-frame/scan-frame"
  71. })
  72. },
  73. // 复制
  74. toCopy(){
  75. if(this.verifyCode.length>=17){
  76. uni.setClipboardData({
  77. data: this.verifyCode,
  78. })
  79. }else{
  80. uni.showToast({
  81. icon: 'none',
  82. title: '请输入正确的VIN码'
  83. })
  84. }
  85. },
  86. // 创建扫描记录
  87. creatRecord(data){
  88. scanVinLog({
  89. vinCode: this.verifyCode.toUpperCase(),
  90. brandName: data.brand_name,
  91. brandId: data.brand_id,
  92. modelName: data.model_name,
  93. modelId:data.model_id,
  94. modelInfo: data.text,
  95. seriesId:data.series_id,
  96. seriesName:data.series_name,
  97. subId:data.sub_id,
  98. subName:data.sub_name,
  99. icon: data.icon,
  100. year: data.year
  101. }).then(res => {
  102. console.log(res)
  103. })
  104. },
  105. // 提交并匹配车型
  106. submitForm(){
  107. const _this = this
  108. const vinNo = this.verifyCode.toUpperCase()
  109. console.log(vinNo, 'vinvinvinvinvin')
  110. if(vinNo.length>=17){
  111. this.loading = true
  112. getVehicleInfoByVin({
  113. vin:vinNo
  114. }).then(res => {
  115. if (res.status == 200&&res.data) {
  116. // 生成vin记录
  117. _this.creatRecord(res.data)
  118. // 打开选择配件页面
  119. uni.redirectTo({
  120. url: "/pages/digitalShelf/choosePart?vinNumber="+vinNo+"&carList="+encodeURIComponent(JSON.stringify(res.data))
  121. })
  122. } else {
  123. uni.showModal({
  124. title: '匹配错误',
  125. content: '此VIN码没有匹配的车型,请检查VIN码是否正确',
  126. showCancel: false,
  127. confirmText: '知道了'
  128. })
  129. }
  130. this.loading = false
  131. })
  132. }else{
  133. uni.showToast({
  134. icon: 'none',
  135. title: '请输入正确的VIN码'
  136. })
  137. }
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="less">
  143. .confirm-button{
  144. padding: 50rpx;
  145. }
  146. .confirm-text{
  147. text-align: center;
  148. padding: 60rpx 30rpx 0;
  149. line-height: 45rpx;
  150. color: #999;
  151. }
  152. .vin-img{
  153. padding: 30rpx 20rpx;
  154. }
  155. .share-list{
  156. padding: 30rpx;
  157. justify-content: space-around;
  158. > view{
  159. text-align: center;
  160. >view{
  161. &:first-child{
  162. margin: 10rpx auto;
  163. border:2rpx solid #aaa;
  164. border-radius: 200rpx;
  165. width: 100rpx;
  166. height: 100rpx;
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. color: #aaa;
  171. button{
  172. background: none;
  173. border: 0;
  174. color: #aaa;
  175. line-height: normal;
  176. margin: 0;
  177. padding: 0;
  178. &:after{
  179. border: 0;
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. </style>