dmLogin.vue 6.4 KB

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