1
0

add.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="main">
  3. <view class="bgm">
  4. <view class="form_group">
  5. <view class="lable">绑定方式</view>
  6. <picker :range="bindType" @change="picker">
  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>
  21. <button class="btn" @click="add()">确认</button>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. item: { type: 0 },
  29. bindType: ['手机号', '身份证']
  30. };
  31. },
  32. methods: {
  33. picker(e) {
  34. this.item.type = e.detail.value;
  35. this.$forceUpdate();
  36. },
  37. add() {
  38. let rule = [
  39. { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
  40. { name: 'value', checkType: 'notnull', errorMsg: this.item.type == 0 ? '请输入手机号' : '请输入身份证' }
  41. ];
  42. if (!this.verify.check(this.item, rule)) {
  43. uni.showModal({ content: this.verify.error, showCancel: false });
  44. return false;
  45. }
  46. this.http.request({
  47. url: '/app/user/bind',
  48. method: 'POST',
  49. data: this.item,
  50. success: (res) => {
  51. uni.showModal({
  52. title: '提示',
  53. content: '绑定成功',
  54. showCancel: false,
  55. success: (res) => {
  56. uni.$emit('bind');
  57. uni.navigateBack();
  58. }
  59. });
  60. }
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. .bgm {
  68. border-radius: 5px;
  69. overflow: hidden;
  70. }
  71. .btn {
  72. margin-top: 35px;
  73. }
  74. </style>