Liuyi
2024-10-16 7cbda90b02e31447122f1d22c9797b423d7bd9fc
pages/addCard/index.vue
@@ -1,15 +1,50 @@
<script setup>
import { onMounted,ref} from 'vue';
import{ creatUserArchive } from '../../api/index.js'
const form = ref({
   id:JSON.parse(uni.getStorageSync('userInfo')).id,
    waterCardNumber:'',
    userName:'',
    userPhone:'',
    address:'',
    remark:'',
})
function submit(){
   console('res')
function toScan(){
   // 调用二维码扫描接口
   uni.scanCode({
      scanType: ['qrCode'],
      success: function (res) {
         console.log('条码内容:' + res.result);
         let data = res.result.split('&id=')
         form.value.waterCardNumber = data[1]
         console.log('form.value.waterCardNumber',form.value.waterCardNumber)
      }
   });
}
async function submit(){
   await creatUserArchive(form.value).then((res) =>{
      if(res.code == 200){
         uni.showToast({
            title: '添加成功!',
            image: '../../static/images/other/success.svg',
            duration:2000
         }).then(() =>{
            uni.navigateBack()
         })
      }else if(res.code == 300){
         uni.showToast({
            title: res.msg,
            duration:2000,
            icon:'none'
         })
      }else{
         uni.showToast({
            title:'绑卡失败',
            duration:2000,
            icon:'none'
         })
      }
   })
}
onMounted(() =>{
})
@@ -23,28 +58,20 @@
            <view class="form">
               <view class="form-item card-item">
                  <text>卡号:</text>
                  <input v-model="form.cardNumber" placeholder="请输入卡号"/>
                  <image src="../../static/images/addCard/code.png" alt=""></image>
                  <input v-model="form.waterCardNumber" placeholder="请输入卡号"/>
                  <image @click="toScan()" src="../../static/images/addCard/code.png" alt=""></image>
               </view>
               <view class="form-item">
                  <text>姓名:</text>
                  <input v-model="form.cardNumber" placeholder="请输入姓名"/>
                  <input v-model="form.userName" placeholder="请输入姓名"/>
               </view>
               <view class="form-item">
                  <text>联系方式:</text>
                  <input v-model="form.cardNumber" placeholder="请输入手机号"/>
               </view>
               <view class="form-item">
                  <text>区域:</text>
                  <input v-model="form.cardNumber" placeholder="请选择区域"/>
               </view>
               <view class="form-item">
                  <text>地址:</text>
                  <input v-model="form.cardNumber" placeholder="请输入地址"/>
                  <input v-model="form.userPhone" placeholder="请输入手机号"/>
               </view>
               <view class="form-item">
                  <text>备注:</text>
                  <input v-model="form.cardNumber" placeholder="请输入内容"/>
                  <input v-model="form.remark" placeholder="请输入内容"/>
               </view>
            </view>
            <view class="tips">
@@ -64,27 +91,6 @@
         .content{
            width:100%;
            height:100vh;
            .navbar{
               width:100%;
               height:176rpx;
               background: linear-gradient(to bottom,#5EA1FA,#8BC1FC);
               display: flex;
               align-items: flex-end;
               padding-bottom:24rpx;
               box-sizing: border-box;
               image{
                  width:20rpx;
                  height:40rpx;
                  margin-left:32rpx;
               }
               text{
                  font-weight: 400;
                  font-size: 36rpx;
                  color: #000000;
                  margin-left: 234rpx;
               }
            }
         .main{
            width:100%;
            height: calc(100vh - 176rpx);