info.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. this.equipmentName=e.adr;
  43. },
  44. methods: {
  45. submit() {
  46. var that = this;
  47. if (!this.username) {
  48. that.$toast("请输入姓名")
  49. return
  50. }
  51. if (!this.phonenumber) {
  52. that.$toast("请输入手机号")
  53. return
  54. }
  55. if (!this.code) {
  56. that.$toast("请输入验证码")
  57. return
  58. }
  59. 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}$/
  60. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  61. that.$toast("请输入正确的手机号")
  62. return
  63. }
  64. that.timefalg=false;
  65. that.time=60;
  66. clearInterval(that.timer)
  67. var params={
  68. "equipmentName":this.equipmentName,
  69. "loginName":this.username,
  70. "phoneNumber":this.phonenumber,
  71. "code": this.code
  72. }
  73. getOpenDzFn(params).then(res=>{
  74. if(res.code==200){
  75. that.$toast('已开门');
  76. that.code='';
  77. }
  78. })
  79. },
  80. // getDetail(data){
  81. // var s=base64.encode(data)
  82. // this.$tab.navigateTo('/a/code?id='+s)
  83. // },
  84. getCode(){
  85. var that=this;
  86. if (!this.phonenumber) {
  87. that.$toast("请输入手机号")
  88. return
  89. }
  90. 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}$/
  91. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  92. that.$toast("请输入正确的手机号")
  93. return
  94. }
  95. var params={
  96. username:this.phonenumber
  97. }
  98. sendSmskmFn(params).then(res=>{
  99. if (res.code == 200) {
  100. // 发送验证码
  101. that.$toast("发送成功")
  102. that.time=60;
  103. that.timefalg=true;
  104. that.setTimein()
  105. } else {
  106. that.$toast(res.msg)
  107. }
  108. // 判断是不是对等的
  109. // that.getCodesend(that.phonenumber)
  110. })
  111. },
  112. // 验证码倒计时
  113. setTimein(){
  114. var that=this;
  115. clearInterval(that.timer)
  116. that.timer=setInterval(()=>{
  117. if(that.time<=1){
  118. that.timefalg=false;
  119. that.time=60;
  120. clearInterval(that.timer)
  121. }
  122. that.time=that.time-1;
  123. },1000)
  124. },
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. // page {
  130. // background-color: #f5f5f5;
  131. // }
  132. .ysec{padding-top: 10rpx;
  133. .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;}
  134. .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;
  135. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 34rpx;}
  136. }
  137. .ysecbox{padding:0 34rpx;background: #ffffff;}
  138. }
  139. .searchlist{
  140. padding: 0 30rpx;margin-top: 30rpx;
  141. }
  142. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 24rpx;}
  143. .code{font-size: 26rpx;color: $com-cd3;font-weight: 500;
  144. &.act{color: #666666;}
  145. }
  146. .ysec /deep/ .uni-forms .uni-forms-item{padding: 20rpx 16rpx 20rpx;border-bottom: 2rpx solid #E6E6E6;margin-bottom: 0;}
  147. .ysec /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 28rpx;font-weight: bold;position: relative;color: #343434;}
  148. .ysec /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  149. .ysec /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  150. .ysec /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  151. .ysec /deep/ .uni-easyinput{flex: 1;text-align: right;}
  152. .ysec /deep/ .uni-forms-item:last-child{border-bottom: none;}
  153. .ysec /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  154. .ysec /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  155. </style>