dmLogin.vue 6.5 KB

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