info.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="ysec">
  3. <uni-forms ref="form" :value="user" >
  4. <view class="yttit">信息开门</view>
  5. <view class="ysecbox">
  6. <uni-forms-item name="username" label="姓名">
  7. <uni-easyinput :inputBorder="false" v-model="username" placeholder="请输入姓名" />
  8. </uni-forms-item>
  9. <uni-forms-item name="phonenumber" label="手机号码">
  10. <uni-easyinput :inputBorder="false" type="number" v-model="phonenumber" placeholder="请输入手机号码" />
  11. </uni-forms-item>
  12. <uni-forms-item name="code" label="验证码">
  13. <uni-easyinput :inputBorder="false" v-model="code" placeholder="请输入验证码" />
  14. <view class="line flex0"></view>
  15. <view v-if="timefalg" class="code act">{{time}}秒</view>
  16. <view v-else @click="getCode" class="code">获取验证码</view>
  17. </uni-forms-item>
  18. </view>
  19. <view class="rbtn" @click="submit">开门</view>
  20. </uni-forms>
  21. </view>
  22. </template>
  23. <script>
  24. import * as base64 from "base-64"
  25. import { getOpenDzFn,sendSmskmFn } from "@/api/mine/order.js"
  26. export default {
  27. components:{},
  28. data() {
  29. return {
  30. timefalg:false,
  31. time:'',
  32. username:'',
  33. phonenumber:'',
  34. code:'',
  35. user:{},
  36. equipmentName:"",//设备id,
  37. }
  38. },
  39. onReady() {
  40. },
  41. onLoad:function(e){
  42. var type=e.adr;
  43. if(type==1){
  44. this.equipmentName='后门抓拍一体机1';
  45. }
  46. // this.equipmentName=e.adr;
  47. },
  48. methods: {
  49. submit() {
  50. var that = this;
  51. if (!this.username) {
  52. that.$toast("请输入姓名")
  53. return
  54. }
  55. if (!this.phonenumber) {
  56. that.$toast("请输入手机号")
  57. return
  58. }
  59. if (!this.code) {
  60. that.$toast("请输入验证码")
  61. return
  62. }
  63. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  64. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  65. that.$toast("请输入正确的手机号")
  66. return
  67. }
  68. that.timefalg=false;
  69. that.time=60;
  70. clearInterval(that.timer)
  71. var params={
  72. "equipmentName":this.equipmentName,
  73. "loginName":this.username,
  74. "phoneNumber":this.phonenumber,
  75. "code": this.code
  76. }
  77. getOpenDzFn(params).then(res=>{
  78. if(res.code==200){
  79. that.$toast('已开门');
  80. that.code='';
  81. }
  82. })
  83. },
  84. // getDetail(data){
  85. // var s=base64.encode(data)
  86. // this.$tab.navigateTo('/a/code?id='+s)
  87. // },
  88. getCode(){
  89. var that=this;
  90. if (!this.phonenumber) {
  91. that.$toast("请输入手机号")
  92. return
  93. }
  94. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  95. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  96. that.$toast("请输入正确的手机号")
  97. return
  98. }
  99. var params={
  100. username:this.phonenumber
  101. }
  102. sendSmskmFn(params).then(res=>{
  103. if (res.code == 200) {
  104. // 发送验证码
  105. that.$toast("发送成功")
  106. that.time=60;
  107. that.timefalg=true;
  108. that.setTimein()
  109. } else {
  110. that.$toast(res.msg)
  111. }
  112. // 判断是不是对等的
  113. // that.getCodesend(that.phonenumber)
  114. })
  115. },
  116. // 验证码倒计时
  117. setTimein(){
  118. var that=this;
  119. clearInterval(that.timer)
  120. that.timer=setInterval(()=>{
  121. if(that.time<=1){
  122. that.timefalg=false;
  123. that.time=60;
  124. clearInterval(that.timer)
  125. }
  126. that.time=that.time-1;
  127. },1000)
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss">
  133. // page {
  134. // background-color: #f5f5f5;
  135. // }
  136. .ysec{padding-top: 10rpx;
  137. .rbtn{width: 680rpx;height: 90rpx;background: $com-cd3;border-radius: 42rpx;text-align: center;line-height: 90rpx;font-size: 28rpx;font-weight: bold;color: #FFFEFE;margin: 70rpx auto 0;}
  138. .yttit{font-size: 28rpx;font-weight: bold;background-color: #f1f1f1;color: $com-cd3;min-height: 72rpx;display: flex;align-items: center;padding: 0rpx 60rpx;box-sizing: border-box;position: relative;
  139. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 34rpx;}
  140. }
  141. .ysecbox{padding:0 34rpx;background: #ffffff;}
  142. }
  143. .searchlist{
  144. padding: 0 30rpx;margin-top: 30rpx;
  145. }
  146. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 24rpx;}
  147. .code{font-size: 26rpx;color: $com-cd3;font-weight: 500;
  148. &.act{color: #666666;}
  149. }
  150. .ysec /deep/ .uni-forms .uni-forms-item{padding: 20rpx 16rpx 20rpx;border-bottom: 2rpx solid #E6E6E6;margin-bottom: 0;}
  151. .ysec /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 28rpx;font-weight: bold;position: relative;color: #343434;}
  152. .ysec /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  153. .ysec /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  154. .ysec /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  155. .ysec /deep/ .uni-easyinput{flex: 1;text-align: right;}
  156. .ysec /deep/ .uni-forms-item:last-child{border-bottom: none;}
  157. .ysec /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  158. .ysec /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  159. </style>