1
0

add.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="main">
  3. <view class="form">
  4. <view class="form_group">
  5. <view class="lable">绑定方式</view>
  6. <picker :range="bindType" @change="picker($event, 'type')">
  7. <input placeholder="请选择" :value="bindType[item.type]" :disabled="true" />
  8. <view class="icon more">&#xe62b;</view>
  9. </picker>
  10. </view>
  11. <view class="form_group">
  12. <view class="lable">姓名</view>
  13. <input v-model="item.name" placeholder="请输入姓名" />
  14. </view>
  15. <view class="form_group">
  16. <view class="lable">{{ item.type == 0 ? '手机号' : '身份证号' }}</view>
  17. <input type="tel" v-model="item.value" placeholder="请输入手机号" v-if="item.type == 0" />
  18. <input type="idcard" v-model="item.value" placeholder="请输入身份证" v-else />
  19. </view>
  20. <view class="form_group">
  21. <view class="lable">就诊人关系</view>
  22. <picker :range="relationship" range-key="dictLabel" @change="picker($event, 'relationship')">
  23. <input placeholder="请选择" v-model="item.relationship" :disabled="true" />
  24. <view class="icon more">&#xe62b;</view>
  25. </picker>
  26. </view>
  27. </view>
  28. <button class="btn" @click="add()">确认</button>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. item: { type: 0, relationship: '自己' },
  36. bindType: ['手机号', '身份证'],
  37. relationship: []
  38. };
  39. },
  40. onLoad() {
  41. this.getRelationship();
  42. },
  43. methods: {
  44. picker(e, tag) {
  45. if (tag == 'type') {
  46. this.item.type = e.detail.value;
  47. }
  48. if (tag == 'relationship') {
  49. this.item.relationship = this.relationship[e.detail.value].dictLabel;
  50. }
  51. this.$forceUpdate();
  52. },
  53. getRelationship() {
  54. this.http.request({
  55. url: '/app/common/type/nk_kinship',
  56. loading: 'false',
  57. success: (res) => {
  58. this.relationship = res.data.data;
  59. }
  60. });
  61. },
  62. add() {
  63. let rule = [
  64. { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
  65. { name: 'value', checkType: 'notnull', errorMsg: this.item.type == 0 ? '请输入手机号' : '请输入身份证' }
  66. ];
  67. if (!this.verify.check(this.item, rule)) {
  68. uni.showModal({ content: this.verify.error, showCancel: false });
  69. return false;
  70. }
  71. //通知模板订阅消息
  72. uni.requestSubscribeMessage({
  73. tmplIds: ['1Jvx8F22na-tG2Q6HFX_3vRtbiv7zZko6NwX8ICIFXc', 'S6JARkInVBjID8QMpgZdSHNyxeMDZQq7lur8YrNK0oY'],
  74. complete: (c) => {
  75. this.http.request({
  76. url: '/app/user/bind',
  77. method: 'POST',
  78. data: this.item,
  79. success: (res) => {
  80. uni.showModal({
  81. title: '提示',
  82. content: '绑定成功',
  83. showCancel: false,
  84. success: (res) => {
  85. uni.$emit('bind');
  86. uni.navigateBack();
  87. }
  88. });
  89. }
  90. });
  91. }
  92. });
  93. }
  94. }
  95. };
  96. </script>
  97. <style lang="scss"></style>