dmLogin.vue 6.5 KB

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