dmLogin.vue 6.4 KB

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