addressMgt.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="u-page">
  3. <view class="u-demo-block">
  4. <view class="u-demo-block__content">
  5. <u--form labelPosition="left" :model="form" ref="form">
  6. <u-form-item label="姓名" prop="userName" labelWidth="80" borderBottom>
  7. <view class="content">
  8. <u--input placeholder="姓名" v-model="form.userName" count></u--input>
  9. </view>
  10. </u-form-item>
  11. <u-form-item label="手机号" prop="phone" labelWidth="80" borderBottom>
  12. <view class="content">
  13. <u--input placeholder="手机号" v-model="form.phone" count></u--input>
  14. </view>
  15. </u-form-item>
  16. <u-form-item label="省市区" prop="provinces" labelWidth="80" borderBottom>
  17. <view class="content">
  18. <pickerAddress @change="change">
  19. <view v-if="form.provinces">
  20. {{form.provinces}}
  21. </view>
  22. <view v-else style="color: #c4c4c4;">
  23. 选择地址
  24. </view>
  25. </pickerAddress>
  26. </view>
  27. </u-form-item>
  28. <u-form-item label="详细地址" prop="detailedAddress" labelWidth="80" borderBottom>
  29. <u--textarea v-model="form.detailedAddress"></u--textarea>
  30. </u-form-item>
  31. </u--form>
  32. <u-button :disabled="isDisabled" color="rgb(55,186,189)" text="提交" shape="circle" size="large"
  33. @click="submit" customStyle="margin-top: 50px">
  34. </u-button>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import pickerAddress from '../address/pickerAddress.vue'
  41. export default {
  42. components: {
  43. pickerAddress
  44. },
  45. data() {
  46. return {
  47. isDisabled: false,
  48. form: {
  49. userCode: uni.getStorageSync("setUserName"),
  50. userName: '',
  51. phone: '',
  52. detailedAddress: '',
  53. provinces: ''
  54. }
  55. }
  56. },
  57. onLoad() {},
  58. onShow() {
  59. if (uni.getStorageSync("addressData")) {
  60. this.form = uni.getStorageSync("addressData")
  61. }
  62. },
  63. methods: {
  64. change(data) {
  65. this.form.provinces = data.data.join('')
  66. },
  67. async submit() {
  68. if (!this.form.userName) {
  69. this.$showModal('请输入姓名')
  70. return
  71. }
  72. if (!this.form.phone) {
  73. this.$showModal('请输入手机号')
  74. return
  75. }
  76. if (!this.form.provinces) {
  77. this.$showModal('选择省市区')
  78. return
  79. }
  80. if (!this.form.detailedAddress) {
  81. this.$showModal('请输入详细地址')
  82. return
  83. }
  84. const {
  85. data: res
  86. } = await this.$httpRequest({
  87. url: '/app/saveAds',
  88. method: 'post',
  89. urlType: 2,
  90. data: this.form
  91. });
  92. if (res.code === 200) {
  93. uni.showModal({
  94. content: "保存成功",
  95. showCancel: false,
  96. success() {
  97. uni.navigateBack()
  98. }
  99. })
  100. } else {
  101. uni.showToast({
  102. duration: 2500,
  103. title: res.msg,
  104. icon: 'error',
  105. });
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. </style>