info.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. <!-- 列表 -->
  22. <view class="searchlist" v-if="listflag">
  23. <y-list :datalist="list" :wtdt="wtdt" :type="type" @getDetail='getDetail'></y-list>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import * as base64 from "base-64"
  29. import { getReservatList } from "@/api/mine/order.js"
  30. import {sendSmsFn} from "@/api/login.js"
  31. import yList from "@/components/order/list.vue"
  32. export default {
  33. components:{yList},
  34. data() {
  35. return {
  36. timefalg:false,
  37. time:'',
  38. username:'',
  39. phonenumber:'17856919066',
  40. code:'',
  41. newcode:'',//验证码1419
  42. user:{},
  43. list:[],
  44. type:'1',
  45. pageSize: 10,
  46. pageNum: 1,
  47. reachflag: true,
  48. wtdt:'',
  49. listflag:false,
  50. backflag:false
  51. }
  52. },
  53. onReady() {
  54. },
  55. onLoad:function(){
  56. // uni.$on('refreshrelist',(e) => {
  57. // this.reachflag=true;
  58. // this.pageNum=1;
  59. // this.list=[];
  60. // this.backflag=true;
  61. // this.getDataFn();
  62. // })
  63. },
  64. onUnload() {
  65. uni.$off('refreshrelist')
  66. },
  67. // 上拉触底加载更多触发事件
  68. onReachBottom() {
  69. // if (this.reachflag) {
  70. // this.pageNum++
  71. // this.getDataFn()
  72. // }
  73. },
  74. methods: {
  75. submit() {
  76. var that = this;
  77. if (!this.username) {
  78. that.$toast("请输入姓名")
  79. return
  80. }
  81. if (!this.phonenumber ) {
  82. that.$toast("请输入手机号")
  83. return
  84. }
  85. if (!this.code) {
  86. that.$toast("请输入验证码")
  87. return
  88. }
  89. // if(this.code!=this.newcode){
  90. // that.$toast("验证码错误,请重新输入")
  91. // return
  92. // }
  93. 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}$/
  94. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  95. that.$toast("请输入正确的手机号")
  96. return
  97. }
  98. that.timefalg=false;
  99. that.time=60;
  100. clearInterval(that.timer)
  101. // this.getDataFn()
  102. },
  103. // getDetail(data){
  104. // var s=base64.encode(data)
  105. // this.$tab.navigateTo('/a/code?id='+s)
  106. // },
  107. getCode(){
  108. var that=this;
  109. if (!this.phonenumber ) {
  110. that.$toast("请输入手机号")
  111. return
  112. }
  113. 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}$/
  114. if (this.phonenumber && !regphone.test(this.phonenumber)) {
  115. that.$toast("请输入正确的手机号")
  116. return
  117. }
  118. that.$toast("发送成功")
  119. that.newcode='1234'
  120. that.time=60;
  121. that.timefalg=true;
  122. that.setTimein()
  123. return
  124. sendSmsFn(this.phonenumber).then(res=>{
  125. if (res.code == 200) {
  126. // 发送验证码
  127. that.$toast("发送成功")
  128. that.newcode=res.msg
  129. that.time=60;
  130. that.timefalg=true;
  131. that.setTimein()
  132. } else {
  133. that.$toast(res.msg)
  134. }
  135. // 判断是不是对等的
  136. // that.getCodesend(that.phonenumber)
  137. })
  138. },
  139. // 验证码倒计时
  140. setTimein(){
  141. var that=this;
  142. clearInterval(that.timer)
  143. that.timer=setInterval(()=>{
  144. if(that.time<=1){
  145. that.timefalg=false;
  146. that.time=60;
  147. clearInterval(that.timer)
  148. }
  149. that.time=that.time-1;
  150. },1000)
  151. },
  152. // getDataFn(){
  153. // var params={
  154. // visitPhone:this.phonenumber,
  155. // pageSize:this.pageSize,
  156. // pageNum: this.pageNum,
  157. // }
  158. // getReservatList(params).then(res=>{
  159. // if(res.code==200){
  160. // var list=res.rows;
  161. // this.listflag=true;
  162. // if(list&&list.length){
  163. // var len=list.length;
  164. // if(len==1&&!this.backflag&&this.pageNum==1){
  165. // var id=list[0].reservatId
  166. // this.$tab.navigateTo('/pages/order/comedetail?id='+base64.encode(id))
  167. // }else{
  168. // if (res.rows.length < this.pageSize) {
  169. // this.reachflag = false
  170. // this.wtdt = '到底了~';
  171. // } else {
  172. // var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  173. // if (num < res.total) {
  174. // this.reachflag = true
  175. // this.wtdt = '上拉加载更多'
  176. // } else {
  177. // this.reachflag = false
  178. // this.wtdt = '到底了~';
  179. // }
  180. // }
  181. // if (this.pageNum == 1) {
  182. // this.list = res.rows;
  183. // } else {
  184. // this.list = this.list.concat(res.rows)
  185. // }
  186. // }
  187. // }else{
  188. // this.$toast('暂无预约信息')
  189. // }
  190. // }else{
  191. // this.$toast(res.msg)
  192. // }
  193. // })
  194. // },
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. // page {
  200. // background-color: #f5f5f5;
  201. // }
  202. .ysec{padding-top: 10rpx;
  203. .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;}
  204. .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;
  205. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 34rpx;}
  206. }
  207. .ysecbox{padding:0 34rpx;background: #ffffff;}
  208. }
  209. .searchlist{
  210. padding: 0 30rpx;margin-top: 30rpx;
  211. }
  212. .line{width: 2rpx;height: 24rpx;background: #CDCDCD;margin: 0 24rpx;}
  213. .code{font-size: 26rpx;color: $com-cd3;font-weight: 500;
  214. &.act{color: #666666;}
  215. }
  216. .ysec /deep/ .uni-forms .uni-forms-item{padding: 20rpx 16rpx 20rpx;border-bottom: 2rpx solid #E6E6E6;margin-bottom: 0;}
  217. .ysec /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 28rpx;font-weight: bold;position: relative;color: #343434;}
  218. .ysec /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  219. .ysec /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  220. .ysec /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  221. .ysec /deep/ .uni-easyinput{flex: 1;text-align: right;}
  222. .ysec /deep/ .uni-forms-item:last-child{border-bottom: none;}
  223. .ysec /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  224. .ysec /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  225. </style>