index.vue 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="cnt_wrapper">
  3. <view class="add_wrap">
  4. <form @submit="formSubmit">
  5. <view class="uni-form-item uni-column">
  6. <view class="title required">关系</view>
  7. <view class="uni-list-cell-db">
  8. <picker @change="bindPickerChange" :value="index" :range="array">
  9. <view class="uni-input">{{array[index]}}
  10. <van-icon name="arrow-down" />
  11. </view>
  12. </picker>
  13. </view>
  14. </view>
  15. <view class="uni-form-item uni-column">
  16. <view class="title required">身份证号</view>
  17. <view class="uni-form-item uni-column">
  18. <input class="uni-input" type="idcard" required='required' maxlength="18" v-model="standing_ID" name="input" placeholder="请输入就诊人身份证卡号" />
  19. </view>
  20. </view>
  21. <view class="uni-form-item uni-column">
  22. <view class="title required">姓名</view>
  23. <view class="uni-form-item uni-column">
  24. <input class="uni-input" required='required' v-model='client_name' name="input" placeholder="请输入就诊人姓名" />
  25. </view>
  26. </view>
  27. <view class="uni-form-item uni-column">
  28. <view class="title">住址</view>
  29. <view class="uni-form-item uni-column">
  30. <input class="uni-input" v-model='address' @ch name="input" placeholder="请输入住址" />
  31. </view>
  32. </view>
  33. <view class="divedeline"></view>
  34. <view class="uni-form-item uni-column" style="padding-right: 0px;width: 652rpx;">
  35. <view class="title">手机号码</view>
  36. <view class="uni-form-item uni-column" style="padding: 0rpx;">
  37. <input class="uni-input" v-model="mobile" name="input" placeholder="请输入您的手机号码" />
  38. <view class="getCode" @click="getcode" >获取验证码</view>
  39. </view>
  40. </view>
  41. <view class="uni-form-item uni-column">
  42. <view class="title">验证码</view>
  43. <!-- <van-field :value="code" placeholder="请输入短信验证码" clearable @change="codeInput" use-button-slot>
  44. <button slot="button" :disabled="disabled" class="send" @click="send">{{ text }}</button>
  45. </van-field> -->
  46. <view class="uni-form-item uni-column">
  47. <input class="uni-input" v-model='code' name="input" placeholder="请输入验证码" />
  48. </view>
  49. </view>
  50. <view class="divedeline"></view>
  51. <view class="uni-btn-v">
  52. <button form-type="submit">立即绑定</button>
  53. </view>
  54. </form>
  55. </view>
  56. <view class="">
  57. </view>
  58. <van-toast id="van-toast" />
  59. </view>
  60. </template>
  61. <script>
  62. import VanIcon from '@/wxcomponents/vant/icon/index'
  63. import Toast from '@/wxcomponents/vant/toast/toast';
  64. import { getCode, login, sendCode, bindMobile, getFieldConfig, getDataConfig } from '@/api/api.js';
  65. import {mapGetters,mapMutations} from 'vuex'
  66. export default {
  67. data() {
  68. return {
  69. array: ['请选择', '父子', '母子','兄弟','父女','母女'],
  70. index: 0,
  71. standing_ID:'',
  72. client_name:'',
  73. mobile:'',
  74. code:'',
  75. address:''
  76. }
  77. },
  78. onLoad(){
  79. this.getCode()
  80. },
  81. methods: {
  82. ...mapMutations(['setIsBand','setConfigList', 'setFiledList', 'setOrg']),
  83. bindPickerChange: function(e) {
  84. console.log('picker发送选择改变,携带值为', e.detail.value)
  85. this.index = e.detail.value
  86. },
  87. numberInput(event){
  88. this.mobile = event.detail
  89. },
  90. codeInput(event){
  91. this.code = event.detail
  92. },
  93. getcode() {
  94. if (!this.mobile) return Toast('请填写手机号码');
  95. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) return Toast('请输入正确的手机号码')
  96. this.sendCodes()
  97. },
  98. async getCode(){
  99. let res = await getCode({}, true)
  100. // console.log(res,'res')
  101. this.aespass = res.data.data.aespass
  102. },
  103. async sendCodes(){
  104. let mobile = this.mobile
  105. let aespass = this.aespass
  106. let params = {
  107. phone: mobile.toString(),
  108. aespass: aespass
  109. }
  110. // this.sendCode()
  111. let res = await sendCode(params, true)
  112. console.log(res,'oop')
  113. },
  114. async formSubmit(){
  115. let _IDRe18 = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  116. // let _IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
  117. if(this.index==0){
  118. return Toast('关系选项未选择');
  119. }
  120. if(this.standing_ID.length==0 ){
  121. console.log('111111',this.standing_ID);
  122. return Toast('请输入身份证号');
  123. }
  124. if( this.standing_ID.length!=0 && (_IDRe18.test(this.standing_ID)== false)){
  125. console.log('222222',this.standing_ID);
  126. return Toast('身份证号输入有误,请重新输入');
  127. }
  128. if(this.client_name ==''){
  129. return Toast('请输入姓名');
  130. }
  131. if(this.mobile==''){
  132. return Toast('请输入手机号码');
  133. }else if(!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)){
  134. return Toast('请输入正确的手机号码');
  135. }
  136. if (!this.code) return Toast('请填写验证码');
  137. let params = {
  138. name: this.client_name,
  139. id_card_no:this.standing_ID,
  140. mobile:this.mobile,
  141. code:this.code,
  142. openid:'opE6O5ODuaN9U6viDrAlGH87h6yM',
  143. // relationship:'父子'
  144. relationship:this.index
  145. }
  146. let res = await bindMobile(params ,true)
  147. console.log('res',res)
  148. if(res.data.data.result){
  149. Toast('验证码错误')
  150. }else{
  151. if(res.data.data.is_bind == true){
  152. let data = {
  153. is_bind:true,
  154. userInfo:res.data.data.patient
  155. }
  156. this.setIsBand(data)
  157. // if(res.data.data.patient.id > 0){
  158. // this.getDataConfig(res.data.data.patient.id)
  159. // this.getFieldConfig(res.data.data.patient.id)
  160. // }
  161. if(res.data.data.role.patient_id > 0){
  162. this.getDataConfig(res.data.data.role.patient_id)
  163. this.getFieldConfig(res.data.data.role.patient_id)
  164. }
  165. // if(res.data.data.template_id.id > 0){
  166. // let data = {
  167. // org: res.data.data.template_id
  168. // }
  169. // this.setOrg(data)
  170. // }
  171. Toast('绑定成功')
  172. console.log()
  173. setTimeout(() => {
  174. uni.navigateBack()
  175. },1000)
  176. }else{
  177. Toast(res.data.data.msg)
  178. }
  179. }
  180. // // return
  181. },
  182. async getFieldConfig(patient_id){
  183. let params = {
  184. patient_id: patient_id
  185. }
  186. let res = await getFieldConfig(params)
  187. let data = {
  188. filedList:res.data.data
  189. }
  190. this.setFiledList(data)
  191. },
  192. async getDataConfig(patient_id){
  193. let params = {
  194. patient_id: patient_id
  195. }
  196. let res = await getDataConfig(params)
  197. let data = {
  198. configList:res.data.data.list
  199. }
  200. this.setConfigList(data)
  201. },
  202. }
  203. }
  204. </script>
  205. <style>
  206. page {
  207. height: 100%;
  208. background-color: #f3f3f9;
  209. }
  210. .cnt_wrapper {
  211. margin: 0;
  212. padding: 0;
  213. }
  214. .add_wrap {
  215. background: #fff;
  216. width: 93vw;
  217. margin: 10px auto;
  218. border-radius: 15rpx;
  219. }
  220. .uni-form-item {
  221. height: 100rpx;
  222. width: 570rpx;
  223. padding: 0 40rpx;
  224. display: flex;
  225. justify-content: space-between;
  226. align-items: center;
  227. }
  228. .title {
  229. width: 220rpx;
  230. white-space: nowrap;
  231. }
  232. .required:after{
  233. content: '*';
  234. color: red;
  235. }
  236. .uni-list-cell-db {
  237. width: 570rpx;
  238. padding: 0 40rpx;
  239. }
  240. .getCode {
  241. font-size: 24rpx;
  242. width: 155rpx;
  243. color: #00c4b3;
  244. border: 1px solid;
  245. border-radius: 20rpx;
  246. text-align: center;
  247. }
  248. .divedeline {
  249. height: 20rpx;
  250. background-color: #f3f3f9;
  251. }
  252. .uni-btn-v button {
  253. background: #00c4b3;
  254. color: #fff;
  255. }
  256. </style>
  257. <style lang="scss" scoped>
  258. /deep/ .van-icon-arrow-down {
  259. top: 5rpx;
  260. }
  261. </style>