Login.vue 4.5 KB

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