Address.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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
  8. @click="handleQux"
  9. type="error"
  10. :plain="true"
  11. :hairline="true"
  12. text="取消"
  13. :customStyle="hadlClickEdit"
  14. ></up-button>
  15. <up-button
  16. type="error"
  17. text="确定"
  18. @click="handlOk(item)"
  19. :customStyle="hadlClickEdit"
  20. ></up-button>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, reactive } from 'vue'
  26. import { useraDdressData } from '@/api/userSettings.js'
  27. import pickerAddress from '@/pages_home/components/pickerAddress/pickerAddress.vue' // 地区选择器组件
  28. import addComponent from '@/pages_home/components/setupUserCopy/Add.vue'
  29. const addComponentRef = ref(null)
  30. const addInfoArr = ref([{}])
  31. function handleAdd() {
  32. if (addInfoArr.value.length < 4) addInfoArr.value.push({})
  33. }
  34. const handlOk = async (item) => {
  35. const params = []
  36. const paramsData = {
  37. volunteerId: item.volunteerId, // 获取 volunteerId
  38. serviceCategory: item.serviceCategory, // 获取 serviceCategory
  39. businessManagementId: item.businessManagementId, //获取 businessManagementId
  40. }
  41. const data = encodeURIComponent(JSON.stringify(paramsData))
  42. addInfoArr.value.forEach((item, index) => {
  43. params.push(addComponentRef.value[index].modelForm)
  44. })
  45. params.forEach(async (obj) => {
  46. const res = await useraDdressData(obj)
  47. if (res.code == 200) {
  48. uni.showToast({
  49. title: '新增成功',
  50. icon: 'success', // 或者 'none'
  51. duration: 1500, // 显示时间,单位毫秒,默认1500
  52. mask: true, // 是否显示透明蒙层,防止触摸穿透,默认false
  53. })
  54. setTimeout(() => {
  55. // uni.navigateBack({
  56. // delta: 2
  57. // })
  58. wx.reLaunch({
  59. url: `/pages_home/pages/Volunteerside/goodsDetails?paramsData=${data}`,
  60. })
  61. }, 1500)
  62. }
  63. })
  64. }
  65. const handleQux = () => {
  66. uni.navigateBack({
  67. delta: 2,
  68. })
  69. }
  70. const hadlClickEdit = {
  71. width: '240rpx',
  72. marginTop: '30rpx',
  73. }
  74. </script>
  75. <style scoped lang="scss">
  76. .address-inp {
  77. color: #929292;
  78. }
  79. .Wrapper-Btn {
  80. display: flex;
  81. justify-content: center;
  82. align-items: center;
  83. }
  84. </style>