search.vue 6.2 KB

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