search.vue 7.9 KB

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