dmLogin.vue 6.8 KB

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