search.vue 7.0 KB

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