dmLogin.vue 6.6 KB

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