addAddress.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <view>
  4. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
  5. :background="background" title-width="300" :title="i18n('addConsignee')"></u-navbar>
  6. </view>
  7. <view style="background: #fff;box-sizing:border-box;padding: 20rpx;">
  8. <u-form :model="form" ref="uForm">
  9. <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '姓名:' : 'Name:'">
  10. <u-input maxlength="20" :placeholder="$i18n.locale == 'zh'? '请输入姓名': 'Please enter your name'"
  11. type="text" :border="border" v-model="form.name" />
  12. </u-form-item>
  13. <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '手机号码:' : 'Phone:'">
  14. <u-input :placeholder="$i18n.locale == 'zh'? '请输入手机号码': 'Please enter your phone'" type="text"
  15. :border="border" v-model="form.phone" />
  16. </u-form-item>
  17. <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '邮政编码:' : 'Code:'">
  18. <u-input :placeholder="$i18n.locale == 'zh'? '请输入邮政编码': 'Please enter your post code'" type="text"
  19. :border="border" v-model="form.postCode" />
  20. </u-form-item>
  21. <u-form-item v-if="$i18n.locale == 'zh'" label-width="140rpx"
  22. :label="$i18n.locale == 'zh' ?'所在区域:':'Areas:'">
  23. <u-input :disabled='info' :placeholder="$i18n.locale == 'zh'?'请选择地区':'Please select a region'"
  24. :border="border" v-model="this.form.division" @tap='cancelInfo'></u-input>
  25. <u-select v-model="show" mode="muitl-column-auto" child-name="child" value-name="id"
  26. label-name="name" :list="sysAreaList" @confirm="confirm">
  27. </u-select>
  28. <u-picker mode="region" v-model="show" :area-code='["11", "1101", "110101"]' @confirm="confirm">
  29. </u-picker>
  30. </u-form-item>
  31. <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '详细地址:' : 'Detail:'">
  32. <u-input :placeholder="$i18n.locale == 'zh'? '请输入详细地址': 'Please enter detail address'" type="text"
  33. :border="border" v-model="form.address" />
  34. </u-form-item>
  35. <u-form-item>
  36. <u-checkbox-group>
  37. <u-checkbox v-model="form.status" shape="circle">
  38. {{$i18n.locale=='zh'?'设为默认地址':'Set as default address'}}
  39. </u-checkbox>
  40. </u-checkbox-group>
  41. </u-form-item>
  42. </u-form>
  43. <view>
  44. <u-button @tap="save" shape="circle" type="primary">
  45. <text style="margin-left:20rpx">{{$i18n.locale=='zh'?'保存':'Save'}}</text>
  46. </u-button>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. addUmsUserCommodityAddresss
  54. } from "@/api/address"
  55. export default {
  56. data() {
  57. return {
  58. info: true,
  59. background: {
  60. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  61. },
  62. backStyle: {
  63. color: '#FFFFFF',
  64. },
  65. name: "name",
  66. id: "id",
  67. child: "child",
  68. test: [],
  69. form: {
  70. name: '',
  71. phone: '',
  72. postCode: '',
  73. division: "",
  74. address: "",
  75. status: false,
  76. },
  77. border: true,
  78. show: false,
  79. userId: null,
  80. sysAreaList: [],
  81. }
  82. },
  83. onShow() {
  84. // this.getSysAreaList()
  85. },
  86. methods: {
  87. cancelInfo() {
  88. uni.hideKeyboard()
  89. this.show = true
  90. },
  91. navTo(route) {
  92. this.$mRouter.push({
  93. route
  94. });
  95. },
  96. i18n(data) {
  97. return this.$t('common.' + data);
  98. },
  99. async save() {
  100. this.userId = JSON.parse(uni.getStorageSync("user")) || ''
  101. let params = {
  102. // id: this.addressForm.id,
  103. userId: this.userId.id,
  104. consignee: this.form.name,
  105. mobile: this.form.phone,
  106. province: this.test[0],
  107. city: this.test[1],
  108. area: this.test[2],
  109. address: this.form.address,
  110. postalCode: this.form.postCode,
  111. status: this.form.status ? '1' : '0',
  112. };
  113. const tokendata = await this.$myRequest({
  114. url: '/sys/token',
  115. method: 'get'
  116. });
  117. // console.log('---------++++++>>>>>>', tokendata.data);
  118. addUmsUserCommodityAddresss(params, tokendata.data).then((res) => {
  119. if (res.status == '200') {
  120. this.navTo('/pages/profile/personIntegrate/userAddress')
  121. }
  122. });
  123. },
  124. confirm(e) {
  125. console.log(e)
  126. this.form.division = e.province.label + '/' + e.city.label + '/' + e.area.label;
  127. let str = e.province.label + '/' + e.city.label + '/' + e.area.label;
  128. this.test = str.split('/')
  129. }
  130. }
  131. }
  132. </script>
  133. <style>
  134. </style>