dmLogin.vue 6.4 KB

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