creatCustomInfo.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="pages flex flex_column">
  3. <uniNavBar title="创建质保单-客户信息" statusBar :shadow="false" @click-left="toBack"></uniNavBar>
  4. <view class="forms" v-if="carInfo">
  5. <view class="forms-tits">车辆信息</view>
  6. <view class="flex align_center">
  7. <view class="labes">车辆品牌:</view>
  8. <view class="inputs">{{carInfo.carBrand}}</view>
  9. </view>
  10. <view class="flex align_center">
  11. <view class="labes">车型:</view>
  12. <view class="inputs">{{carInfo.carModel}}</view>
  13. </view>
  14. <view class="flex align_center">
  15. <view class="labes">里程数:</view>
  16. <view class="inputs">{{carInfo.mileage}}KM</view>
  17. </view>
  18. <view class="flex align_center">
  19. <view class="labes">车牌号:</view>
  20. <view class="inputs">{{carInfo.vehicleNumber||'--'}}</view>
  21. </view>
  22. </view>
  23. <view class="forms">
  24. <view class="forms-tits">客户联系方式</view>
  25. <view class="flex align_center">
  26. <view class="labes"><text>*</text>客户姓名:</view>
  27. <view class="inputs"><u-input :focus="focusInput" v-model="form.customName" maxlength="30" border clearable type="text" placeholder="请输入客户姓名"></u-input></view>
  28. </view>
  29. <view class="flex align_center">
  30. <view class="labes"><text>*</text>手机号码:</view>
  31. <view class="inputs"><u-input v-model="form.customMobile" type="number" maxlength="11" border clearable placeholder="请输入手机号码"></u-input></view>
  32. </view>
  33. <view class="flex align_center">
  34. <view class="labes"><text>*</text>验证码:</view>
  35. <view class="inputs"><u-input v-model="form.vericode" type="number" maxlength="6" border clearable placeholder="请输入验证码"></u-input></view>
  36. <view class="btns" @click="checkMobile()" >{{codeText}}</view>
  37. </view>
  38. <view class="forms-foot flex align_center">
  39. <u-checkbox v-model="checkedXy">您已知晓</u-checkbox>
  40. <text class="links" @click="readXy()">《箭冠轮胎质保法律条款》</text>
  41. </view>
  42. </view>
  43. <view class="buttons flex align_center">
  44. <u-button type="default" @click="toBack">上一步</u-button>
  45. <u-button type="primary" :loading="loading" @click="saveForm">确定</u-button>
  46. </view>
  47. <!-- 图文验证码 -->
  48. <uni-popup @change="changeModal" ref="imageTxtPopup" type="center">
  49. <popup-con title="图文验证码" :popBtn="popBtn" :changeImg="changeImg" @captchaImg="captchaVerify"></popup-con>
  50. </uni-popup>
  51. </view>
  52. </template>
  53. <script>
  54. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  55. import popupCon from '@/components/uni-popup/popup-con.vue'
  56. import {
  57. sendPhoneVerifyCode,
  58. verifyPhoneCode
  59. } from '@/api/data.js'
  60. import {
  61. isvalidPhone
  62. } from '@/libs/validate.js'
  63. import{ traceWarrantySave, getTraceCodeQueryList } from '@/api/trace.js'
  64. import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  65. export default {
  66. components: {
  67. uniPopup,
  68. popupCon,
  69. uniNavBar
  70. },
  71. data() {
  72. return {
  73. changeImg: false, // 是否重新更换图形验证码
  74. randomCode: '', // 图片验证码随机码
  75. popBtn: [], // name为操作按钮名称,color为操作按钮颜色值
  76. codeText: '获取验证码',
  77. getCodeing: false,
  78. totalTime: 60,
  79. isDisabled: false ,// 倒计时按钮是否禁用
  80. checkedXy: false,
  81. carInfo:{
  82. vin: '',
  83. mileage: '',
  84. vehicleNumber: '',
  85. carBrand: '',
  86. carModel: '',
  87. },
  88. form:{
  89. customName: '',
  90. customMobile: '',
  91. vericode: ''
  92. },
  93. uuid: [],
  94. loading: false
  95. }
  96. },
  97. onLoad() {
  98. const tempData = this.$store.state.vuex_uuidTempData
  99. this.uuid = tempData&&tempData.traceCodeList ? tempData.traceCodeList : [],
  100. this.carInfo = Object.assign(this.carInfo, tempData.carInfo)
  101. this.form = Object.assign(this.form,tempData&&tempData.customerInfo ? tempData.customerInfo : {})
  102. this.form.vericode = ''
  103. },
  104. onUnload() {
  105. this.$store.state.vuex_uuidTempData.customerInfo = this.form
  106. },
  107. methods: {
  108. toBack(){
  109. uni.redirectTo({
  110. url: "/pagesA/qualityPolicy/creatCarInfo"
  111. })
  112. },
  113. readXy(){
  114. const baseUrl = getApp().globalData.baseUrl
  115. uni.navigateTo({
  116. url: "/pagesA/h5Page/index?src="+baseUrl.replace('/saas/clz/','/')+'zbd/clause.html'
  117. })
  118. },
  119. // 获取验证码
  120. getCode() {
  121. let sid = null
  122. sid = setInterval(() => {
  123. if (this.totalTime > 0) {
  124. this.totalTime = this.totalTime - 1
  125. this.codeText = '已发送' + this.totalTime + 's'
  126. if (this.totalTime < 60) {
  127. this.isDisabled = true
  128. }
  129. } else {
  130. this.isDisabled = false
  131. clearInterval(sid)
  132. this.getCodeing = false
  133. this.codeText = '获取验证码'
  134. this.totalTime = 60
  135. }
  136. }, 1000)
  137. },
  138. // 验证手机
  139. checkMobile() {
  140. if(this.isDisabled){return}
  141. if (!this.getCodeing) {
  142. if (this.form.customMobile) {
  143. console.log(!isvalidPhone(this.form.customMobile))
  144. if (!isvalidPhone(this.form.customMobile)) {
  145. uni.showToast({
  146. title: '请输入正确的手机号码',
  147. icon: 'none'
  148. })
  149. return false
  150. } else {
  151. this.getCodeing = true
  152. this.retsetCode()
  153. // 图文验证码
  154. this.$refs.imageTxtPopup.open()
  155. }
  156. }else{
  157. uni.showToast({
  158. title: '请输入手机号码',
  159. icon: 'none'
  160. })
  161. }
  162. }
  163. },
  164. changeModal(val) {
  165. if (val.show == false) {
  166. this.getCodeing = false
  167. }
  168. },
  169. // 验证图片验证码
  170. captchaVerify(code, nowRandomCode) {
  171. const _this = this
  172. let obj = {}
  173. obj.mobile = this.form.customMobile
  174. obj.random = nowRandomCode
  175. obj.code = code
  176. obj.signName = '修配易码通'
  177. // 发送短信验证码
  178. sendPhoneVerifyCode(obj).then(res => {
  179. console.log(JSON.stringify(res.data))
  180. if (res.status == 200) { // 验证码输入正确
  181. _this.randomCode = nowRandomCode // 图片验证码随机码
  182. // 关闭 图形验证码 弹框
  183. _this.$refs.imageTxtPopup.close()
  184. // 开启倒计时
  185. _this.getCode()
  186. uni.showToast({
  187. icon: 'none',
  188. title: '验证码发送成功'
  189. })
  190. } else { // 验证码输入错误
  191. _this.retsetCode()
  192. uni.showToast({
  193. icon: 'none',
  194. title: res.message,
  195. duration: 5000
  196. })
  197. }
  198. })
  199. },
  200. // 重新触发获取图片验证码
  201. retsetCode() {
  202. const _this = this
  203. _this.code = ''
  204. _this.randomCode = ''
  205. // 切换验证码重新校验
  206. _this.changeImg = false
  207. _this.$nextTick(function() {
  208. _this.changeImg = true
  209. })
  210. },
  211. async saveForm(){
  212. if(this.form.customName == ''){
  213. uni.showToast({
  214. icon: 'none',
  215. title: '请输入客户名称'
  216. })
  217. return
  218. }
  219. if(this.form.customMobile == ''){
  220. uni.showToast({
  221. icon: 'none',
  222. title: '请输入电话号码'
  223. })
  224. return
  225. }
  226. if(this.form.vericode == ''){
  227. uni.showToast({
  228. icon: 'none',
  229. title: '请输入验证码'
  230. })
  231. return
  232. }
  233. if(!this.checkedXy){
  234. uni.showToast({
  235. icon: 'none',
  236. title: '请勾选已知晓并阅读《箭冠轮胎质保法律条款》'
  237. })
  238. return
  239. }
  240. this.$store.state.vuex_uuidTempData.customerInfo = this.form
  241. const formData = this.$store.state.vuex_uuidTempData
  242. console.log(formData)
  243. // 验证验证码是否正确
  244. const phoneCodeIsOk = await verifyPhoneCode({mobile: this.form.customMobile, code: this.form.vericode })
  245. if(phoneCodeIsOk.status == 200){
  246. const params = {...formData.carInfo,...formData.customerInfo}
  247. const uuidList = []
  248. formData.traceCodeList.map(item => {
  249. uuidList.push(item.traceCode)
  250. })
  251. params.traceCodeList = uuidList
  252. params.clientFlag = 'applet'
  253. console.log(params)
  254. // 保存数据
  255. this.loading = true
  256. const res = await traceWarrantySave(params)
  257. uni.showToast({
  258. icon: 'none',
  259. title: res.message
  260. })
  261. if(res.status == 200){
  262. uni.redirectTo({
  263. url: "/pagesA/qualityPolicy/resultOrder"
  264. })
  265. }
  266. this.loading = false
  267. }else{
  268. uni.showToast({
  269. icon: 'none',
  270. title: '验证码不正确'
  271. })
  272. this.form.vericode = ''
  273. }
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="less">
  279. .pages{
  280. height: 100vh;
  281. background: #f8f8f8;
  282. padding-bottom: 6rem;
  283. overflow: auto;
  284. .buttons{
  285. padding: 1rem 2rem 2rem;
  286. position: fixed;
  287. width: 100%;
  288. bottom: 0;
  289. left: 0;
  290. background: #fff;
  291. z-index: 10000;
  292. border-top: 1px solid #eee;
  293. justify-content: space-around;
  294. /deep/ .u-btn{
  295. width: 7rem;
  296. }
  297. }
  298. }
  299. .forms{
  300. background: #fff;
  301. margin-bottom: 0.5rem;
  302. .forms-tits{
  303. font-weight: bold;
  304. color: #333;
  305. }
  306. .forms-foot{
  307. padding-left: 1.5rem;
  308. color: #999;
  309. .links{
  310. color: #55aaff;
  311. }
  312. /deep/.u-checkbox__label{
  313. margin-right: 0;
  314. }
  315. }
  316. > view{
  317. border-bottom: 1px solid #eee;
  318. padding: 0.6rem 1rem;
  319. }
  320. .labes{
  321. width: 5.2rem;
  322. text{
  323. color: red;
  324. margin-right: 5px;
  325. }
  326. }
  327. .inputs{
  328. flex-grow: 1;
  329. }
  330. .btns{
  331. padding: 0 0.3rem;
  332. text-align: center;
  333. color: dodgerblue;
  334. font-size: 0.8rem;
  335. width: 5rem;
  336. }
  337. }
  338. </style>