creatCustomInfo.vue 7.9 KB

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