dmLogin.vue 6.2 KB

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