index.vue 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="userBinding">
  3. <view class="cInputBox">
  4. <input class="cInput" v-model="name" type="text" placeholder="请输入就诊人姓名">
  5. </view>
  6. <view class="cInputBox">
  7. <input class="cInput" v-model="idCard" type="idcard" placeholder="请输入就诊人身份证号码">
  8. </view>
  9. <view class="marginTop">
  10. <view class="cInputBox">
  11. <input class="cInput" v-model="mobile" type="tel" placeholder="请输入绑定人手机号码">
  12. </view>
  13. <van-field :value="code" placeholder="请输入短信验证码" clearable @change="codeInput" use-button-slot>
  14. <button slot="button" :disabled="disabled" class="send" @click="send">{{ text }}</button>
  15. </van-field>
  16. </view>
  17. <!-- <van-field :value="name" placeholder="请输入就诊人姓名" clearable @change="nameInput" />
  18. <van-field :value="idCard" type="idcard" placeholder="请输入就诊人身份证号码" clearable @change="userIdInput" />
  19. <view class="marginTop">
  20. <van-field :value="mobile" type="number" placeholder="请输入就诊人手机号码" clearable @change="numberInput" />
  21. <van-field :value="code" placeholder="请输入短信验证码" clearable @change="codeInput" use-button-slot>
  22. <button slot="button" :disabled="disabled" class="send" @click="send">{{ text }}</button>
  23. </van-field>
  24. </view> -->
  25. <view class="bind bindActive" @click="bind">绑定</view>
  26. <van-toast id="van-toast" />
  27. </view>
  28. </template>
  29. <script>
  30. import IdentityCodeValid from '@/utils/validateIdent'
  31. import Toast from '@/wxcomponents/vant/toast/toast';
  32. import sendVerifyCode from "@/mixins/SendVerifyCode";
  33. import { getCode, login, sendCode, bindMobile, getFieldConfig, getDataConfig } from '@/api/api.js';
  34. import {mapGetters,mapMutations} from 'vuex'
  35. export default {
  36. mixins:[sendVerifyCode],
  37. data(){
  38. return{
  39. name:'',
  40. idCard:'',
  41. mobile:'',
  42. code:'',
  43. aespass:''
  44. }
  45. },
  46. onLoad(){
  47. this.getCode()
  48. },
  49. methods:{
  50. ...mapMutations(['setIsBand','setConfigList', 'setFiledList', 'setOrg']),
  51. nameInput(event){
  52. this.name = event.detail
  53. },
  54. userIdInput(event){
  55. this.idCard = event.detail
  56. },
  57. numberInput(event){
  58. this.mobile = event.detail
  59. },
  60. codeInput(event){
  61. this.code = event.detail
  62. },
  63. send(){
  64. if (!this.mobile) return Toast('请填写手机号码');
  65. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) return Toast('请输入正确的手机号码')
  66. this.sendCodes()
  67. },
  68. // 获取验证码前获取密钥
  69. async getCode(){
  70. let res = await getCode({}, true)
  71. // console.log(res,'res')
  72. this.aespass = res.data.data.aespass
  73. },
  74. async sendCodes(){
  75. let mobile = this.mobile
  76. let aespass = this.aespass
  77. let params = {
  78. phone: mobile.toString(),
  79. aespass: aespass
  80. }
  81. this.sendCode()
  82. let res = await sendCode(params, true)
  83. console.log(res,'oop')
  84. },
  85. async bind(){
  86. if (!this.name) return Toast('请填写患者姓名');
  87. let data = this.idCard.toUpperCase() //转换成大写
  88. // if(!IdentityCodeValid( data )){
  89. // Toast('请输入正确的身份证号')
  90. // return
  91. // }
  92. if (!this.mobile) return Toast('请填写手机号码');
  93. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) return Toast('请输入正确的手机号码')
  94. if (!this.code) return Toast('请填写验证码');
  95. let params = {
  96. name: this.name,
  97. id_card_no:this.idCard,
  98. mobile:this.mobile,
  99. code:this.code,
  100. openid:'opE6O5ODuaN9U6viDrAlGH87h6yM',
  101. relationship:'父子'
  102. }
  103. let res = await bindMobile(params ,true)
  104. console.log('res',res)
  105. if(res.data.data.result){
  106. Toast('验证码错误')
  107. }else{
  108. if(res.data.data.is_bind == true){
  109. let data = {
  110. is_bind:true,
  111. userInfo:res.data.data.patient
  112. }
  113. this.setIsBand(data)
  114. // if(res.data.data.patient.id > 0){
  115. // this.getDataConfig(res.data.data.patient.id)
  116. // this.getFieldConfig(res.data.data.patient.id)
  117. // }
  118. if(res.data.data.role.patient_id > 0){
  119. this.getDataConfig(res.data.data.role.patient_id)
  120. this.getFieldConfig(res.data.data.role.patient_id)
  121. }
  122. // if(res.data.data.template_id.id > 0){
  123. // let data = {
  124. // org: res.data.data.template_id
  125. // }
  126. // this.setOrg(data)
  127. // }
  128. Toast('绑定成功')
  129. console.log()
  130. setTimeout(() => {
  131. uni.navigateBack()
  132. },1000)
  133. }else{
  134. Toast(res.data.data.msg)
  135. }
  136. }
  137. },
  138. async getFieldConfig(patient_id){
  139. let params = {
  140. patient_id: patient_id
  141. }
  142. let res = await getFieldConfig(params)
  143. let data = {
  144. filedList:res.data.data
  145. }
  146. this.setFiledList(data)
  147. },
  148. async getDataConfig(patient_id){
  149. let params = {
  150. patient_id: patient_id
  151. }
  152. let res = await getDataConfig(params)
  153. let data = {
  154. configList:res.data.data.list
  155. }
  156. this.setConfigList(data)
  157. },
  158. }
  159. }
  160. </script>
  161. <style>
  162. page{
  163. height: 100%;
  164. }
  165. .cInputBox{
  166. padding: 20rpx 30rpx;
  167. box-sizing: border-box;
  168. width: 100%;
  169. background-color: #fff;
  170. }
  171. .cInput{
  172. height: 48rpx;
  173. line-height: 48rpx;
  174. font-size: 28rpx;
  175. color: #333;
  176. background-color: #fff;
  177. }
  178. .userBinding{
  179. height: 100%;
  180. background: #f7f7f7;
  181. }
  182. .marginTop{
  183. margin-top: 20rpx;
  184. }
  185. .send{
  186. color: #01BD5D;
  187. font-size: 30rpx;
  188. background: #FFFFFF;
  189. }
  190. button::after {
  191. border: none;
  192. }
  193. .bind{
  194. width: 690rpx;
  195. height: 90rpx;
  196. background: #D8D8D8;
  197. box-shadow: 0px 0px 24rpx 0px rgba(216, 216, 216, 0.4);
  198. border-radius: 45rpx;
  199. line-height: 90rpx;
  200. text-align: center;
  201. font-size: 36rpx;
  202. color: #FFFFFF;
  203. margin: 80rpx auto 0;
  204. }
  205. .bindActive{
  206. background: linear-gradient(-90deg, #01BD5D, #28D87D);
  207. }
  208. </style>