creatCustomInfo.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="pages flex flex_column">
  3. <view class="forms">
  4. <view class="forms-tits">车辆信息</view>
  5. <view class="flex align_center">
  6. <view class="labes">车辆品牌:</view>
  7. <view class="inputs">日产(东风)</view>
  8. </view>
  9. <view class="flex align_center">
  10. <view class="labes">车型:</view>
  11. <view class="inputs">轩逸</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.carNo}}</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.customerName" 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.phone" 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" @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. isvalidPhone
  57. } from '@/libs/validate.js'
  58. export default {
  59. components: {
  60. uniPopup,
  61. popupCon
  62. },
  63. data() {
  64. return {
  65. changeImg: false, // 是否重新更换图形验证码
  66. randomCode: '', // 图片验证码随机码
  67. popBtn: [], // name为操作按钮名称,color为操作按钮颜色值
  68. codeText: '获取验证码',
  69. getCodeing: false,
  70. totalTime: 60,
  71. isDisabled: false ,// 倒计时按钮是否禁用
  72. checkedXy: true,
  73. carInfo:{
  74. vinCode: '',
  75. mileage: '',
  76. carNo: ''
  77. },
  78. form:{
  79. customerName: '',
  80. phone: '',
  81. vericode: ''
  82. },
  83. uuid: [],
  84. }
  85. },
  86. onLoad() {
  87. const tempData = this.$store.state.vuex_uuidTempData
  88. this.uuid = tempData&&tempData.uuid ? tempData.uuid : [],
  89. this.carInfo = Object.assign(this.carInfo, tempData.carInfo)
  90. },
  91. methods: {
  92. toBack(){
  93. uni.redirectTo({
  94. url: "/pagesA/qualityPolicy/creatCarInfo"
  95. })
  96. },
  97. // 获取验证码
  98. getCode() {
  99. let sid = null
  100. sid = setInterval(() => {
  101. if (this.totalTime > 0) {
  102. this.totalTime = this.totalTime - 1
  103. this.codeText = '已发送' + this.totalTime + 's'
  104. if (this.totalTime < 60) {
  105. this.isDisabled = true
  106. }
  107. } else {
  108. this.isDisabled = false
  109. clearInterval(sid)
  110. this.getCodeing = false
  111. this.codeText = '获取验证码'
  112. this.totalTime = 60
  113. }
  114. }, 1000)
  115. },
  116. // 验证手机
  117. checkMobile() {
  118. if(this.isDisabled){return}
  119. if (!this.getCodeing) {
  120. if (this.form.phone) {
  121. console.log(!isvalidPhone(this.form.phone))
  122. if (!isvalidPhone(this.form.phone)) {
  123. uni.showToast({
  124. title: '请输入正确的手机号码',
  125. icon: 'none'
  126. })
  127. return false
  128. } else {
  129. this.getCodeing = true
  130. this.retsetCode()
  131. // 图文验证码
  132. this.$refs.imageTxtPopup.open()
  133. }
  134. }else{
  135. uni.showToast({
  136. title: '请输入手机号码',
  137. icon: 'none'
  138. })
  139. }
  140. }
  141. },
  142. changeModal(val) {
  143. if (val.show == false) {
  144. this.getCodeing = false
  145. }
  146. },
  147. // 验证图片验证码
  148. captchaVerify(code, nowRandomCode) {
  149. const _this = this
  150. let obj = {}
  151. obj.mobile = this.form.phone
  152. obj.random = nowRandomCode
  153. obj.code = code
  154. obj.signName = '修配易码通'
  155. obj.openid = this.$store.state.vuex_openid
  156. // 发送短信验证码
  157. sendLoginVerifyCode(obj).then(res => {
  158. console.log(JSON.stringify(res.data))
  159. if (res.status == 200) { // 验证码输入正确
  160. _this.randomCode = nowRandomCode // 图片验证码随机码
  161. // 关闭 图形验证码 弹框
  162. _this.$refs.imageTxtPopup.close()
  163. // 开启倒计时
  164. _this.getCode()
  165. uni.showToast({
  166. icon: 'none',
  167. title: '验证码发送成功'
  168. })
  169. } else { // 验证码输入错误
  170. _this.retsetCode()
  171. uni.showToast({
  172. icon: 'none',
  173. title: res.message,
  174. duration: 5000
  175. })
  176. }
  177. })
  178. },
  179. // 重新触发获取图片验证码
  180. retsetCode() {
  181. const _this = this
  182. _this.code = ''
  183. _this.randomCode = ''
  184. // 切换验证码重新校验
  185. _this.changeImg = false
  186. _this.$nextTick(function() {
  187. _this.changeImg = true
  188. })
  189. },
  190. saveForm(){
  191. if(this.form.customerName == ''){
  192. uni.showToast({
  193. icon: 'none',
  194. title: '请输入客户名称'
  195. })
  196. return
  197. }
  198. if(this.form.phone == ''){
  199. uni.showToast({
  200. icon: 'none',
  201. title: '请输入电话号码'
  202. })
  203. return
  204. }
  205. if(this.form.vericode == ''){
  206. uni.showToast({
  207. icon: 'none',
  208. title: '请输入验证码'
  209. })
  210. return
  211. }
  212. this.$store.state.vuex_uuidTempData.customerInfo = this.form
  213. uni.redirectTo({
  214. url: "/pagesA/qualityPolicy/resultOrder"
  215. })
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="less">
  221. .pages{
  222. height: 100vh;
  223. background: #f8f8f8;
  224. padding-bottom: 6rem;
  225. overflow: auto;
  226. .buttons{
  227. padding: 1rem 2rem 2rem;
  228. position: fixed;
  229. width: 100%;
  230. bottom: 0;
  231. left: 0;
  232. background: #fff;
  233. z-index: 10000;
  234. border-top: 1px solid #eee;
  235. justify-content: space-around;
  236. /deep/ .u-btn{
  237. width: 7rem;
  238. }
  239. }
  240. }
  241. .forms{
  242. background: #fff;
  243. margin-bottom: 0.5rem;
  244. .forms-tits{
  245. font-weight: bold;
  246. color: #333;
  247. }
  248. .forms-foot{
  249. padding-left: 1.5rem;
  250. color: #999;
  251. .links{
  252. color: #55aaff;
  253. }
  254. /deep/.u-checkbox__label{
  255. margin-right: 0;
  256. }
  257. }
  258. > view{
  259. border-bottom: 1px solid #eee;
  260. padding: 0.6rem 1rem;
  261. }
  262. .labes{
  263. width: 5.2rem;
  264. text{
  265. color: red;
  266. margin-right: 5px;
  267. }
  268. }
  269. .inputs{
  270. flex-grow: 1;
  271. }
  272. .btns{
  273. padding: 0 0.3rem;
  274. text-align: center;
  275. color: dodgerblue;
  276. font-size: 0.8rem;
  277. }
  278. }
  279. </style>