RelationPersonRegister.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div>
  3. <common ref="common" @asynCallBack="asynCallBack" :projectCheck="false"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content vongi-qqhm">
  6. <div class="mui-content-padded vongi-qingjiadt vongi-editme">
  7. <h5>第一步:验证手机号</h5>
  8. <form class="mui-input-group">
  9. <div class="mui-input-row">
  10. <label>姓名<i class="colorfe616c">*</i></label>
  11. <input v-model="subForm.name" type="text" class="mui-input-clear" placeholder="请输入姓名">
  12. </div>
  13. <div class="mui-input-row">
  14. <label>手机号码<i class="colorfe616c">*</i></label>
  15. <input v-model="subForm.telephone" type="text" class="mui-input-clear" placeholder="请输入手机号码">
  16. </div>
  17. <div class="mui-input-row vongi-yzm">
  18. <input v-model="subForm.verifyCode" type="text" class="mui-input-clear" placeholder="请输入验证码">
  19. <a @click="doSendMsg" class="mui-pull-right" v-text="sendMsgWz"></a>
  20. </div>
  21. </form>
  22. </div>
  23. </div>
  24. <div class="fyy-footer">
  25. <div class="bindfyy-btn" @click="nextStep"><button type="submit" class="mui-btn mui-btn-pink ">下一步</button></div>
  26. </div>
  27. <loading :visible="isLoading"></loading>
  28. </div>
  29. </template>
  30. <script>
  31. import * as API_Common from '$project/apis/common'
  32. import Common from '$project/components/Common.vue'
  33. import Loading from '$project/components/Loading.vue'
  34. import TopHeader from '$project/components/TopHeader.vue'
  35. import NavMenu from '@/components/NavMenu.vue'
  36. import {
  37. mapGetters,
  38. mapMutations
  39. } from 'vuex'
  40. import {
  41. checkPhone,
  42. } from '$project/utils'
  43. import * as types from '$project/store/mutation-types'
  44. import * as WxJsApi from '$project/utils/wxJsApi'
  45. export default {
  46. name: 'MasterUserRelationPersonRegister',
  47. components: {
  48. Common,
  49. Loading,
  50. TopHeader,
  51. NavMenu
  52. },
  53. data() {
  54. return {
  55. isLoading: false,
  56. pageTitle: '关联长者',
  57. id: this.$route.query.id,
  58. subForm: {
  59. name: '',
  60. telephone: '',
  61. verifyCode: '',
  62. },
  63. sendMsgWz: '发送验证码',
  64. isSendMsg: false,
  65. }
  66. },
  67. created() {
  68. if (this.person_data) {
  69. //如果用户存在直接调用扫码功能
  70. this.subForm.name = this.person_data.name;
  71. this.subForm.telephone = this.person_data.phone;
  72. //调用扫一扫
  73. WxJsApi.getWxConfig().then(res => {
  74. this.scanCode();
  75. });
  76. }
  77. },
  78. methods: {
  79. //微信扫二维码
  80. scanCode() {
  81. WxJsApi.scanQRCode(2);
  82. },
  83. //发送验证码
  84. sendMsg() {
  85. if (!this.isSendMsg) {
  86. this.isLoading = true;
  87. API_Common.sendMsg({
  88. personId: 0,
  89. telephone: this.subForm.telephone,
  90. }).then(response => {
  91. //倒计时
  92. this.isSendMsg = true;
  93. this.msgTimeInterval();
  94. this.isLoading = false;
  95. }).catch(error => {
  96. this.isLoading = false;
  97. mui.toast(error);
  98. })
  99. }
  100. },
  101. //倒计时
  102. msgTimeInterval() {
  103. var time = 60;
  104. var _this = this;
  105. this.timer = setInterval(() => {
  106. if (time > 0) {
  107. _this.sendMsgWz = time-- + '秒';
  108. } else {
  109. _this.isSendMsg = false;
  110. _this.sendMsgWz = '发送验证码';
  111. clearInterval(_this.timer)
  112. }
  113. }, 1000)
  114. },
  115. //表单检测
  116. checkForm() {
  117. let phoneResult = checkPhone(this.subForm.telephone);
  118. if (typeof phoneResult == 'string') {
  119. mui.toast(phoneResult);
  120. return false;
  121. } else {
  122. return true;
  123. }
  124. },
  125. //根据用户名和手机号查询人员信息
  126. doSendMsg() {
  127. if (this.checkForm()) {
  128. this.sendMsg();
  129. }
  130. },
  131. //下一步
  132. nextStep() {
  133. if (!this.subForm.verifyCode) {
  134. mui.toast('请获取并填写验证码');
  135. } else {
  136. this.isLoading = true;
  137. API_Common.validateCode({
  138. personId: 0,
  139. verifyCode: this.subForm.verifyCode,
  140. openId: this.openId,
  141. telephone: this.subForm.telephone,
  142. }).then(response => {
  143. this.set_old_relation_form_data(this.subForm);
  144. this.$router.push({
  145. name: 'MasterUserRelationPerson',
  146. id: this.id
  147. })
  148. this.isLoading = false;
  149. }).catch(error => {
  150. this.isLoading = false;
  151. mui.toast(error);
  152. })
  153. }
  154. },
  155. asynCallBack() {},
  156. ...mapMutations({
  157. set_old_relation_form_data: types.SET_OLD_RELATION_FORM_DATA,
  158. })
  159. },
  160. mounted() {
  161. },
  162. destroyed() {
  163. },
  164. computed: {
  165. ...mapGetters({
  166. openId: 'wx_openid',
  167. token: 'token',
  168. person_data: 'person_data',
  169. person_popedom: 'person_popedom',
  170. old_relation_form_data: 'old_relation_form_data'
  171. })
  172. }
  173. }
  174. </script>
  175. <style scoped src="$project/assets/css/pension.css"></style>
  176. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  177. <style src="$project/assets/css/iconfont.css"></style>
  178. <style>
  179. </style>