Address.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view>
  3. <template v-for="(item, index) in addInfoArr" :key="index">
  4. <add-component ref="addComponentRef"></add-component>
  5. </template>
  6. <view class="Wrapper-Btn">
  7. <up-button @click="handleQux" type="error" :plain="true" :hairline="true" text="取消" :customStyle="hadlClickEdit"></up-button>
  8. <up-button type="error" text="确定" @click="handlOk" :customStyle="hadlClickEdit"></up-button>
  9. </view>
  10. </view>
  11. </template>
  12. <script setup>
  13. import {
  14. ref,
  15. reactive
  16. } from 'vue';
  17. import {
  18. useraDdressData
  19. } from "@/api/userSettings.js"
  20. import pickerAddress from '@/pages_mine/components/pickerAddress/pickerAddress.vue' // 地区选择器组件
  21. import addComponent from '@/pages_mine/components/setupUser/Add.vue'
  22. const addComponentRef = ref(null)
  23. const addInfoArr = ref([{}])
  24. function handleAdd() {
  25. if (addInfoArr.value.length < 4) addInfoArr.value.push({})
  26. }
  27. const handlOk = async () => {
  28. const params = []
  29. addInfoArr.value.forEach((item, index) => {
  30. params.push(addComponentRef.value[index].modelForm)
  31. })
  32. params.forEach(async (obj) => {
  33. const res = await useraDdressData(obj)
  34. if (res.code == 200) {
  35. uni.showToast({
  36. title: '新增成功',
  37. icon: 'success', // 或者 'none'
  38. duration: 1500, // 显示时间,单位毫秒,默认1500
  39. mask: true, // 是否显示透明蒙层,防止触摸穿透,默认false
  40. });
  41. setTimeout(() => {
  42. uni.navigateBack({
  43. delta: 2
  44. })
  45. }, 1500)
  46. }
  47. })
  48. }
  49. const handleQux = () =>{
  50. uni.navigateBack({
  51. delta:-1
  52. })
  53. }
  54. const hadlClickEdit = {
  55. width: '240rpx',
  56. marginTop: '30rpx'
  57. }
  58. </script>
  59. <style scoped lang="scss">
  60. .address-inp {
  61. color: #929292;
  62. }
  63. .Wrapper-Btn{
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. }
  68. </style>