confirmVin.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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" :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 } from '@/api/car.js'
  40. export default {
  41. data() {
  42. return {
  43. verifyCode: '',
  44. vinImg: ''
  45. }
  46. },
  47. onLoad(opts) {
  48. this.verifyCode = opts.verifyCode || ''
  49. this.vinImg = opts.filePath || ''
  50. },
  51. // 分享
  52. onShareAppMessage(e){
  53. return {
  54. title: '修配一码通车架号(VIN)分享',
  55. path: '/pages/vinIput/share?userId=123&vin='+this.verifyCode,
  56. imageUrl:'/static/share.png',
  57. type: '1',
  58. success(res){
  59. console.log(res)
  60. },
  61. fail(err){
  62. console.log(err)
  63. }
  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. // confirm(code){
  87. // this.verifyCode = code
  88. // },
  89. // 提交并匹配车型
  90. submitForm(){
  91. const _this = this
  92. const vinNo = this.verifyCode.toUpperCase()
  93. console.log(vinNo, 'vinvinvinvinvin')
  94. if(vinNo.length>=17){
  95. getVehicleInfoByVin({
  96. vin:vinNo
  97. }).then(res => {
  98. console.log(res, 'vinvinvinvinvin')
  99. if (res.status == 200&&res.data) {
  100. // 打开选择配件页面
  101. uni.redirectTo({
  102. url: "/pages/digitalShelf/choosePart?vinNumber="+vinNo+"&carList="+encodeURIComponent(JSON.stringify(res.data))
  103. })
  104. } else {
  105. uni.showModal({
  106. title: '匹配错误',
  107. content: '此VIN码没有匹配的车型,请检查VIN码是否正确',
  108. showCancel: false,
  109. confirmText: '知道了'
  110. })
  111. }
  112. })
  113. }else{
  114. uni.showToast({
  115. icon: 'none',
  116. title: '请输入正确的VIN码'
  117. })
  118. }
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="less">
  124. .confirm-button{
  125. padding: 50rpx;
  126. }
  127. .confirm-text{
  128. text-align: center;
  129. padding: 60rpx 30rpx 0;
  130. line-height: 45rpx;
  131. color: #999;
  132. }
  133. .vin-img{
  134. padding: 30rpx 20rpx;
  135. }
  136. .share-list{
  137. padding: 30rpx;
  138. justify-content: space-around;
  139. > view{
  140. text-align: center;
  141. >view{
  142. &:first-child{
  143. margin: 10rpx auto;
  144. border:2rpx solid #aaa;
  145. border-radius: 200rpx;
  146. width: 100rpx;
  147. height: 100rpx;
  148. display: flex;
  149. align-items: center;
  150. justify-content: center;
  151. color: #aaa;
  152. button{
  153. background: none;
  154. border: 0;
  155. color: #aaa;
  156. line-height: normal;
  157. margin: 0;
  158. padding: 0;
  159. &:after{
  160. border: 0;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. </style>