dmLogin.vue 6.7 KB

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