1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <template>
- <view class="main">
- <view class="form">
- <view class="form_group">
- <view class="lable">绑定方式</view>
- <picker :range="bindType" @change="picker">
- <input placeholder="请选择" :value="bindType[item.type]" :disabled="true" />
- <view class="icon more"></view>
- </picker>
- </view>
- <view class="form_group">
- <view class="lable">姓名</view>
- <input v-model="item.name" placeholder="请输入姓名" />
- </view>
- <view class="form_group">
- <view class="lable">{{ item.type == 0 ? '手机号' : '身份证号' }}</view>
- <input type="tel" v-model="item.value" placeholder="请输入手机号" v-if="item.type == 0" />
- <input type="idcard" v-model="item.value" placeholder="请输入身份证" v-else />
- </view>
- </view>
- <button class="btn" @click="add()">确认</button>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- item: { type: 0 },
- bindType: ['手机号', '身份证']
- };
- },
- methods: {
- picker(e) {
- this.item.type = e.detail.value;
- this.$forceUpdate();
- },
- add() {
- let rule = [
- { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
- { name: 'value', checkType: 'notnull', errorMsg: this.item.type == 0 ? '请输入手机号' : '请输入身份证' }
- ];
- if (!this.verify.check(this.item, rule)) {
- uni.showModal({ content: this.verify.error, showCancel: false });
- return false;
- }
- this.http.request({
- url: '/app/user/bind',
- method: 'POST',
- data: this.item,
- success: (res) => {
- uni.showModal({
- title: '提示',
- content: '绑定成功',
- showCancel: false,
- success: (res) => {
- uni.$emit('bind');
- uni.navigateBack();
- }
- });
- }
- });
- }
- }
- };
- </script>
- <style lang="scss"></style>
|