Login.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle" :leftShow="false"></top-header>
  5. <div class="mui-content">
  6. <div class="mui-content-padded">
  7. <div class="vongi-login-logo">
  8. <img src="~$project/assets/img/logo_xiaopengguanjia.png" />
  9. <h2>小鹏管家</h2>
  10. </div>
  11. <form class="mui-input-group vongi-login-form">
  12. <div class="mui-input-row">
  13. <input name="name" v-model="subForm.name" type="text" class="mui-input-clear" placeholder="请填写您的姓名">
  14. </div>
  15. <div class="mui-input-row">
  16. <input name="phone" v-model="subForm.phone" type="text" class="mui-input-clear" placeholder="请输入手机号码">
  17. </div>
  18. <div class="mui-input-row">
  19. <input v-model="verifyCode" type="text" class="mui-input-clear" placeholder="请输入验证码">
  20. <a @click="findByNameAndPhone" v-html="sendMsgWz"></a>
  21. </div>
  22. </form>
  23. <form class="mui-input-group vongi-xieyi">
  24. <div class="mui-input-row mui-radio mui-left">
  25. <label class="mui-h6">我已阅读并同意<span class="color4fc5f7">《用户使用协议》</span></label>
  26. <input name="radio1" type="radio">
  27. </div>
  28. </form>
  29. </div>
  30. <div class="vongi-btn vongi-login-btn">
  31. <button class="mui-btn mui-btn-primary" @click="nextStep">
  32. 登录
  33. </button>
  34. <button type="button" class="mui-btn mui-btn-primary mui-btn-outlined">
  35. 申请加入
  36. </button>
  37. </div>
  38. </div>
  39. <loading :visible="isLoading"></loading>
  40. </div>
  41. </template>
  42. <script>
  43. import * as API_Person from '@/apis/person'
  44. import * as API_Common from '@/apis/common'
  45. import Common from '$project/components/Common.vue'
  46. import Loading from '$project/components/Loading.vue'
  47. import TopHeader from '$project/components/TopHeader.vue'
  48. import {
  49. mapGetters,
  50. mapMutations
  51. } from 'vuex'
  52. import {
  53. checkPhone,
  54. } from '$project/utils'
  55. import * as types from '$project/store/mutation-types'
  56. export default {
  57. name: 'Home',
  58. components: {
  59. Common,
  60. Loading,
  61. TopHeader
  62. },
  63. data() {
  64. return {
  65. pageTitle: '登录账号',
  66. subForm: {
  67. name: '',
  68. phone: '',
  69. },
  70. personId: '',
  71. verifyCode: '',
  72. sendMsgWz: '发送验证码',
  73. isLoading: false,
  74. }
  75. },
  76. created() {
  77. },
  78. methods: {
  79. //表单检测
  80. checkForm() {
  81. let phoneResult = checkPhone(this.subForm.phone);
  82. if (!this.subForm.name) {
  83. mui.toast('请输入您的姓名');
  84. return false;
  85. } else if (typeof phoneResult == 'string') {
  86. mui.toast(phoneResult);
  87. return false;
  88. } else {
  89. return true;
  90. }
  91. },
  92. //根据用户名和手机号查询人员信息
  93. findByNameAndPhone() {
  94. if (this.checkForm()) {
  95. this.isLoading = true;
  96. API_Person.findByNameAndPhone(this.subForm).then(response => {
  97. this.personId = response;
  98. this.isLoading = false;
  99. this.sendMsg();
  100. }).catch(error => {
  101. this.isLoading = false;
  102. mui.toast(error);
  103. })
  104. }
  105. },
  106. //发送验证码
  107. sendMsg() {
  108. this.isLoading = true;
  109. API_Common.sendMsg({
  110. personId: this.personId
  111. }).then(response => {
  112. //倒计时
  113. this.msgTimeInterval();
  114. this.isLoading = false;
  115. }).catch(error => {
  116. this.isLoading = false;
  117. mui.toast(error);
  118. })
  119. },
  120. //倒计时
  121. msgTimeInterval() {
  122. var time = 60;
  123. var _this = this;
  124. this.timer = setInterval(() => {
  125. if (time > 0) {
  126. _this.sendMsgWz = time-- + '秒';
  127. } else {
  128. _this.isSendMsg = true;
  129. _this.sendMsgWz = '发送验证码';
  130. clearInterval(_this.timer)
  131. }
  132. }, 1000)
  133. },
  134. //下一步
  135. nextStep() {
  136. if (!this.verifyCode || !this.personId) {
  137. mui.toast('请获取并填写验证码');
  138. } else {
  139. this.isLoading = true;
  140. API_Person.validateCode({
  141. personId: this.personId,
  142. verifyCode: this.verifyCode,
  143. openId: this.openId
  144. }).then(response => {
  145. this.set_token(response);
  146. //上传头像
  147. this.$router.push({
  148. name: 'UploadPhoto',
  149. query: {
  150. personId: this.personId,
  151. project: this.$route.query.project
  152. }
  153. })
  154. this.isLoading = false;
  155. }).catch(error => {
  156. this.isLoading = false;
  157. mui.toast(error);
  158. })
  159. }
  160. },
  161. asynCallBack() {
  162. },
  163. ...mapMutations({
  164. set_token: types.SET_TOKEN,
  165. })
  166. },
  167. mounted() {
  168. document.body.style.backgroundColor = '#fff';
  169. },
  170. destroyed() {
  171. },
  172. computed: {
  173. ...mapGetters({
  174. openId: 'wx_openid',
  175. token: 'token',
  176. person_data: 'person_data',
  177. company_data: 'company_data',
  178. vister_scene: 'vister_scene',
  179. })
  180. }
  181. }
  182. </script>
  183. <style src="$project/assets/css/iconfont.css"></style>
  184. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  185. <style scoped>
  186. </style>