dmLogin.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. uni.$on('request',()=>{
  181. this.hide();
  182. })
  183. },
  184. components:{
  185. dmDialog
  186. }
  187. }
  188. </script>
  189. <style scoped lang="scss">
  190. .content{
  191. width: 100%;
  192. height: 430rpx;
  193. margin-top: 30rpx;
  194. display: flex;
  195. flex-direction: column;
  196. align-items: center;
  197. .user_item{
  198. width: 630rpx;
  199. height: 84rpx;
  200. min-height: 84rpx;
  201. background: #f5f6f7;
  202. border-radius: 16rpx;
  203. display: flex;
  204. align-items: center;
  205. margin-bottom: 12rpx;
  206. .item_name{
  207. width: 90rpx;
  208. min-width: 90rpx;
  209. font-size: 28rpx;
  210. font-family: Verdana, Verdana-Regular;
  211. font-weight: 400;
  212. color: #b1b1b1;
  213. padding-left: 40rpx;
  214. }
  215. .item_right{
  216. font-size: 28rpx;
  217. font-family: Verdana, Verdana-Regular;
  218. font-weight: 400;
  219. color: #262626;
  220. display: flex;
  221. align-items: center;
  222. .item_right_name{
  223. width: 100%;
  224. }
  225. .item_right_name_placeholder{
  226. font-size: 26rpx;
  227. font-family: Verdana, Verdana-Regular;
  228. font-weight: 400;
  229. color: #b1b1b1;
  230. }
  231. .icon_right{
  232. width: 10rpx;
  233. height: 22rpx;
  234. margin-left: 19rpx;
  235. }
  236. .veritify{
  237. width: 150rpx;
  238. min-width: 150rpx;
  239. height: 50rpx;
  240. margin-left: 10rpx;
  241. margin-right: 60rpx;
  242. line-height: 50rpx;
  243. font-size: 20rpx;
  244. font-family: Verdana, Verdana-Regular;
  245. font-weight: 400;
  246. text-align: center;
  247. color: #f07423;
  248. }
  249. }
  250. }
  251. .user_line{
  252. width: 2rpx;
  253. min-width: 2rpx;
  254. height: 20rpx;
  255. min-height: 20rpx;
  256. background: rgba(177,177,177,1);
  257. margin-left: 18rpx;
  258. margin-right: 20rpx;
  259. }
  260. .confirm{
  261. width: 410rpx;
  262. height: 80rpx;
  263. line-height: 80rpx;
  264. background: #f07423;
  265. border-radius: 40rpx;
  266. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(240,116,35,0.37);
  267. font-size: 28rpx;
  268. font-family: Verdana, Verdana-Bold;
  269. font-weight: 700;
  270. text-align: center;
  271. color: #ffffff;
  272. margin-top: 70rpx;
  273. }
  274. }
  275. .agreement{
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. font-size: 24rpx;
  280. font-family: Verdana, Verdana-Regular;
  281. font-weight: 400;
  282. text-align: left;
  283. color: #b1b1b1;
  284. margin-top: 30rpx;
  285. .icon_agree{
  286. width: 24rpx;
  287. height: 24rpx;
  288. margin-right: 10rpx;
  289. }
  290. .agreement_{
  291. color: rgba(240,116,35,1);
  292. }
  293. }
  294. </style>