dmLogin.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <dmDialog ref='popView' :isShowTitle="true" title="登陆" :isShowClose="true" :isShowConfirm="false" >
  3. <view class="content">
  4. <view class="user_item">
  5. <text class="item_name">手机号</text>
  6. <view class="user_line">
  7. </view>
  8. <view class="item_right">
  9. <input placeholder-class="item_right_name_placeholder" type='number' maxlength="11" class="item_right_name" :value="mobile" placeholder="请输入" @blur='inputMobile' @confirm='inputMobile'/>
  10. </view>
  11. </view>
  12. <view class="user_item">
  13. <text class="item_name">验证码</text>
  14. <view class="user_line">
  15. </view>
  16. <view class="item_right">
  17. <input placeholder-class="item_right_name_placeholder" class="item_right_name" type="text" :value="verifity" placeholder="请输入" @blur='inputVerifity' @confirm='inputVerifity'/>
  18. <view class="veritify" @click="getVeritify">
  19. {{veritifyTxt}}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="agreement" @click="agreeXieYI">
  24. <image class="icon_agree" v-if="agree" src="../../static/icons/icon_yezhu_selected.png" mode=""></image>
  25. <image class="icon_agree" v-else src="../../static/icons/icon_yezhu_unselected.png" mode=""></image>
  26. 我已阅读并同意
  27. <text class="agreement_" @click="yonghuxy">《用户使用协议》</text>
  28. <text class="agreement_" @click="ysxieyi">《隐私政策》</text>
  29. </view>
  30. <view class="confirm" @click="toLogin">
  31. 确认
  32. </view>
  33. </view>
  34. </dmDialog>
  35. </template>
  36. <script>
  37. let app = getApp();
  38. import dmDialog from "./dmDialog.vue"
  39. export default{
  40. data(){
  41. return {
  42. mobile:"",
  43. veritifyTxt:"发送验证码",
  44. verifity:"",
  45. timer:null,
  46. countdownTimes:120,
  47. agree:false,
  48. userId:"",
  49. }
  50. },
  51. methods:{
  52. yonghuxy(){},
  53. ysxieyi(){},
  54. agreeXieYI(){
  55. this.agree = !this.agree
  56. },
  57. show() {
  58. this.$refs.popView.show()
  59. },
  60. knowAction(){
  61. if(this.timer){
  62. clearInterval(this.timer);
  63. this.timer = null;
  64. }
  65. this.$refs.popView.hide()
  66. },
  67. inputMobile(e){
  68. this.mobile = e.detail.value
  69. },
  70. inputVerifity(e){
  71. this.verifity = e.detail.value
  72. },
  73. async getVeritify(){
  74. if(!this.mobile){
  75. uni.showToast({
  76. icon:"none",
  77. title:"请输入手机号"
  78. })
  79. return
  80. }
  81. var phone = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
  82. if (!phone.test(this.mobile)) {
  83. uni.showToast({
  84. icon:"none",
  85. title:"请输入正确的手机号"
  86. })
  87. return
  88. }
  89. this.showInputVerifity = true;
  90. if(this.timer&&this.countdownTimes>=0){
  91. return
  92. }
  93. let ret = await this.$myRequest({
  94. url: "/sms/sendSmsVerifyCode",
  95. data: {
  96. "phone": this.mobile,
  97. },
  98. method:"GET"
  99. })
  100. this.houseList = [];
  101. if (ret.data.success) {
  102. this.countdown();
  103. }
  104. },
  105. countdown(){
  106. this.timer = setInterval(()=>{
  107. this.countdownTimes--;
  108. this.veritifyTxt = this.countdownTimes+"s"
  109. if(this.countdownTimes<=0){
  110. clearInterval(this.timer);
  111. this.timer = null;
  112. this.veritifyTxt = '获取验证码';
  113. this.countdownTimes = 120;
  114. }
  115. },1000)
  116. },
  117. async toLogin(){
  118. if(!this.mobile){
  119. uni.showToast({
  120. icon:"none",
  121. title:"请输入手机号"
  122. })
  123. return
  124. }
  125. if(!this.verifity){
  126. uni.showToast({
  127. icon:"none",
  128. title:"请输入验证码"
  129. })
  130. return
  131. }
  132. if(!this.agree){
  133. uni.showToast({
  134. icon:"none",
  135. title:"请阅读并同意《入住协议》"
  136. })
  137. return
  138. }
  139. let ret = await this.$myRequest({
  140. url: "/authorizedPhone",
  141. data: {
  142. "code": this.verifity,
  143. "phone": this.mobile,
  144. "userId": this.userId
  145. }
  146. });
  147. if(ret.data.success){
  148. uni.$emit('request');
  149. this.knowAction();
  150. uni.showToast({
  151. icon:"none",
  152. title:"登录成功"
  153. });
  154. let token = ret.data.single;
  155. this.$cache.set('_token_owner_union', token);
  156. app.globalData.token = token;
  157. }else{
  158. uni.showToast({
  159. icon:"none",
  160. title:ret.data.message
  161. });
  162. }
  163. }
  164. },
  165. mounted() {
  166. this.userId = this.$cache.get('_user_id')
  167. uni.$on('login',()=>{
  168. this.show();
  169. })
  170. },
  171. components:{
  172. dmDialog
  173. }
  174. }
  175. </script>
  176. <style scoped lang="scss">
  177. .content{
  178. width: 100%;
  179. height: 430rpx;
  180. margin-top: 30rpx;
  181. display: flex;
  182. flex-direction: column;
  183. align-items: center;
  184. .user_item{
  185. width: 630rpx;
  186. height: 84rpx;
  187. min-height: 84rpx;
  188. background: #f5f6f7;
  189. border-radius: 16rpx;
  190. display: flex;
  191. align-items: center;
  192. margin-bottom: 12rpx;
  193. .item_name{
  194. width: 90rpx;
  195. min-width: 90rpx;
  196. font-size: 28rpx;
  197. font-family: Verdana, Verdana-Regular;
  198. font-weight: 400;
  199. color: #b1b1b1;
  200. padding-left: 40rpx;
  201. }
  202. .item_right{
  203. font-size: 28rpx;
  204. font-family: Verdana, Verdana-Regular;
  205. font-weight: 400;
  206. color: #262626;
  207. display: flex;
  208. align-items: center;
  209. .item_right_name{
  210. width: 100%;
  211. }
  212. .item_right_name_placeholder{
  213. font-size: 26rpx;
  214. font-family: Verdana, Verdana-Regular;
  215. font-weight: 400;
  216. color: #b1b1b1;
  217. }
  218. .icon_right{
  219. width: 10rpx;
  220. height: 22rpx;
  221. margin-left: 19rpx;
  222. }
  223. .veritify{
  224. width: 150rpx;
  225. min-width: 150rpx;
  226. height: 50rpx;
  227. margin-left: 10rpx;
  228. margin-right: 60rpx;
  229. line-height: 50rpx;
  230. font-size: 20rpx;
  231. font-family: Verdana, Verdana-Regular;
  232. font-weight: 400;
  233. text-align: center;
  234. color: #f07423;
  235. }
  236. }
  237. }
  238. .user_line{
  239. width: 2rpx;
  240. min-width: 2rpx;
  241. height: 20rpx;
  242. min-height: 20rpx;
  243. background: rgba(177,177,177,1);
  244. margin-left: 18rpx;
  245. margin-right: 20rpx;
  246. }
  247. .confirm{
  248. width: 410rpx;
  249. height: 80rpx;
  250. line-height: 80rpx;
  251. background: #f07423;
  252. border-radius: 40rpx;
  253. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(240,116,35,0.37);
  254. font-size: 28rpx;
  255. font-family: Verdana, Verdana-Bold;
  256. font-weight: 700;
  257. text-align: center;
  258. color: #ffffff;
  259. margin-top: 70rpx;
  260. }
  261. }
  262. .agreement{
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. font-size: 24rpx;
  267. font-family: Verdana, Verdana-Regular;
  268. font-weight: 400;
  269. text-align: left;
  270. color: #b1b1b1;
  271. margin-top: 30rpx;
  272. .icon_agree{
  273. width: 24rpx;
  274. height: 24rpx;
  275. margin-right: 10rpx;
  276. }
  277. .agreement_{
  278. color: rgba(240,116,35,1);
  279. }
  280. }
  281. </style>