景徳镇旅游微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
4.8 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <uv-popup round="40rpx" ref="addressPopup" :customStyle="{ height: 'auto' , width : '100%' , padding : '20rpx'}">
  3. <view class="redact-address">
  4. <view class="redact-address-title">{{title}}</view>
  5. <uv-form label-width="210rpx" :model="addressDetail" ref="form">
  6. <uv-form-item label="联系人" prop="name">
  7. <uv-input v-model="addressDetail.name" placeholder="请输入联系人姓名" border="none">
  8. </uv-input>
  9. </uv-form-item>
  10. <uv-form-item label="手机号" prop="phone">
  11. <uv-input v-model="addressDetail.phone" placeholder="请输入手机号" border="none">
  12. </uv-input>
  13. </uv-form-item>
  14. <uv-form-item label="所在地区" prop="address">
  15. <uv-input v-model="addressDetail.address" placeholder="请选择所在地区" border="none">
  16. </uv-input>
  17. <template #right>
  18. <view style="padding-right: 40rpx;color: #FBAB32;" @click.stop="selectAddr">
  19. <image src="../../static/address/selectIcon.png" mode="aspectFit"></image>定位
  20. </view>
  21. </template>
  22. </uv-form-item>
  23. <uv-form-item label="详细地址" prop="addressDetail">
  24. <uv-input v-model="addressDetail.addressDetail" placeholder="请输入详细地址" border="none">
  25. </uv-input>
  26. </uv-form-item>
  27. </uv-form>
  28. <view @click="onSubmit" class="save">{{ addressDetail.id ? '修改地址' : '新增地址'}}</view>
  29. </view>
  30. </uv-popup>
  31. </template>
  32. <script>
  33. import Position from '@/utils/position.js'
  34. export default {
  35. data() {
  36. return {
  37. addressDetail: {}
  38. }
  39. },
  40. props: {
  41. title: {
  42. type: String,
  43. default: '新增地址'
  44. }
  45. },
  46. methods: {
  47. open(addressDetail) {
  48. this.addressDetail = addressDetail
  49. this.$refs.addressPopup.open('bottom')
  50. },
  51. close(){
  52. this.$refs.addressPopup.close()
  53. },
  54. //新增和修改地址
  55. onSubmit() {
  56. let isOk = this.parameterVerification(this.addressDetail)
  57. if (isOk && !isOk.auth) {
  58. return uni.showToast({
  59. icon: 'none',
  60. title: isOk.title,
  61. 'zIndex': 10000
  62. })
  63. }
  64. this.$emit('saveOrUpdate', this.addressDetail)
  65. },
  66. //验证用户参数合法性
  67. parameterVerification(addressDetaila) {
  68. let {
  69. name,
  70. phone,
  71. address,
  72. addressDetail
  73. } = addressDetaila
  74. if (name.trim() == '') {
  75. return {
  76. title: '请填写联系人',
  77. auth: false
  78. }
  79. } else if (phone.trim() == '') {
  80. return {
  81. title: '请填写手机号',
  82. auth: false
  83. }
  84. } else if (address.trim() == '') {
  85. return {
  86. title: '请填写所在地区',
  87. auth: false
  88. }
  89. } else if (addressDetail.trim() == '') {
  90. return {
  91. title: '请填写详细地址',
  92. auth: false
  93. }
  94. } else if (phone.trim() != '') {
  95. if (!this.$utils.verificationPhone(phone)) {
  96. return {
  97. title: '手机号格式不合法',
  98. auth: false
  99. }
  100. }
  101. }
  102. return {
  103. title: '验证通过',
  104. auth: true
  105. }
  106. },
  107. //地图上选择地址
  108. selectAddr() {
  109. Position.getLocation(res => {
  110. Position.selectAddress(res.longitude, res.latitude, success => {
  111. this.setAddress(success)
  112. })
  113. })
  114. },
  115. //提取用户选择的地址信息复制给表单数据
  116. setAddress(res) {
  117. //经纬度信息
  118. this.addressDetail.latitude = res.latitude
  119. this.addressDetail.longitude = res.longitude
  120. if (!res.address && res.name) { //用户直接选择城市的逻辑
  121. return this.addressDetail.address = res.name
  122. }
  123. if (res.address || res.name) {
  124. return this.addressDetail.address = res.address + res.name
  125. }
  126. this.addressDetail.address = '' //用户啥都没选就点击勾选
  127. },
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .redact-address {
  133. box-sizing: border-box;
  134. .redact-address-title {
  135. height: 80rpx;
  136. line-height: 80rpx;
  137. font-size: 30rpx;
  138. color: #333333;
  139. font-weight: 600;
  140. }
  141. .save {
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. width: 90%;
  146. height: 80rpx;
  147. border-radius: 40rpx;
  148. color: white;
  149. font-size: 28rpx;
  150. margin: 0rpx auto;
  151. background: $uni-color;
  152. margin-top: 150rpx;
  153. }
  154. image {
  155. width: 25rpx;
  156. height: 25rpx;
  157. }
  158. //修改组件默认样式
  159. .uv-form {
  160. padding: 30rpx 0rpx;
  161. }
  162. &::v-deep .uv-cell {
  163. padding: 0rpx 0rpx;
  164. font-size: 26rpx;
  165. &::after {
  166. border: none !important;
  167. }
  168. .uv-field__label {
  169. display: flex;
  170. align-items: center;
  171. height: 80rpx;
  172. }
  173. .uv-field__control,
  174. .uv-field__right-icon {
  175. height: 80rpx;
  176. font-size: 26rpx;
  177. border-bottom: 2rpx solid #cbc8c8;
  178. }
  179. .uv-field__right-icon {
  180. display: flex;
  181. align-items: center;
  182. height: 78rpx;
  183. color: #5FCC9F;
  184. }
  185. .uv-cell__value {
  186. height: 120rpx;
  187. }
  188. }
  189. &::v-deep .uv-field__error-message {
  190. color: #5AC796;
  191. font-size: 20rpx;
  192. margin-top: 10rpx;
  193. }
  194. }
  195. </style>