dmLogin.vue 6.5 KB

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