普兆健康管家前端代码仓库
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.

248 lines
5.8 KiB

  1. <template>
  2. <view>
  3. <uv-popup ref="popup" mode="bottom" bgColor="none" >
  4. <view class="popup__view">
  5. <view class="flex header">
  6. <view class="title">新建地址</view>
  7. <button class="btn" @click="close">关闭</button>
  8. </view>
  9. <view class="form">
  10. <uv-form
  11. ref="form"
  12. :model="form"
  13. :rules="rules"
  14. errorType="toast"
  15. >
  16. <view class="form-item">
  17. <uv-form-item prop="name" :customStyle="formItemStyle">
  18. <view class="form-item-label">联系人</view>
  19. <view class="form-item-content">
  20. <formInput v-model="form.name"></formInput>
  21. </view>
  22. </uv-form-item>
  23. </view>
  24. <view class="form-item">
  25. <uv-form-item prop="phone" :customStyle="formItemStyle">
  26. <view class="form-item-label">手机号</view>
  27. <view class="form-item-content">
  28. <formInput v-model="form.phone"></formInput>
  29. </view>
  30. </uv-form-item>
  31. </view>
  32. <view class="form-item">
  33. <uv-form-item prop="phone" :customStyle="formItemStyle">
  34. <view class="form-item-label">所在地区</view>
  35. <view class="form-item-content">
  36. <picker mode="region" @change="onAreaChange" :value="form.area">
  37. <view class="flex region">
  38. <view v-if="form.area">{{ form.area.join('') }}</view>
  39. <view v-else class="placeholder">选择省市区街道</view>
  40. </view>
  41. </picker>
  42. <!-- <formInput v-model="form.phone"></formInput> -->
  43. </view>
  44. </uv-form-item>
  45. </view>
  46. <view class="form-item">
  47. <uv-form-item prop="address" :customStyle="formItemStyle">
  48. <view class="form-item-label">详细地址</view>
  49. <view class="form-item-content">
  50. <formInput v-model="form.address" placeholder="小区楼栋、门牌号、村等"></formInput>
  51. </view>
  52. </uv-form-item>
  53. </view>
  54. </uv-form>
  55. </view>
  56. <view class="footer">
  57. <button class="flex btn" @click="onSave">保存</button>
  58. </view>
  59. </view>
  60. </uv-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import formInput from '@/pages_order/components/formInput.vue'
  65. export default {
  66. components: {
  67. formInput,
  68. },
  69. data() {
  70. return {
  71. form: {
  72. name: null,
  73. phone: null,
  74. area: null,
  75. address: null,
  76. },
  77. rules: {
  78. 'name': {
  79. type: 'string',
  80. required: true,
  81. message: '请输入联系人',
  82. },
  83. 'phone': {
  84. type: 'string',
  85. required: true,
  86. message: '请输入手机号',
  87. },
  88. 'area': {
  89. type: 'array',
  90. required: true,
  91. message: '请选择省市区',
  92. },
  93. 'address': {
  94. type: 'string',
  95. required: true,
  96. message: '请输入详细地址',
  97. },
  98. },
  99. formItemStyle: { padding: 0 },
  100. }
  101. },
  102. methods: {
  103. open(data) {
  104. if (data) {
  105. const {
  106. name,
  107. phone,
  108. area,
  109. address,
  110. } = data
  111. this.form = {
  112. name,
  113. phone,
  114. area,
  115. address,
  116. }
  117. }
  118. this.$refs.popup.open()
  119. },
  120. close() {
  121. this.$refs.popup.close()
  122. },
  123. onAreaChange(e) {
  124. this.form.area = e.detail.value
  125. },
  126. async onSave() {
  127. try {
  128. const res = await this.$refs.form.validate()
  129. console.log('onSave res', res)
  130. // todo: save
  131. this.$emit('submitted')
  132. this.close()
  133. } catch (err) {
  134. console.log('onSave err', err)
  135. }
  136. },
  137. },
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .popup__view {
  142. width: 100vw;
  143. display: flex;
  144. flex-direction: column;
  145. box-sizing: border-box;
  146. background: #FFFFFF;
  147. border-top-left-radius: 32rpx;
  148. border-top-right-radius: 32rpx;
  149. }
  150. .header {
  151. position: relative;
  152. width: 100%;
  153. padding: 24rpx 0;
  154. box-sizing: border-box;
  155. border-bottom: 2rpx solid #EEEEEE;
  156. .title {
  157. font-family: PingFang SC;
  158. font-weight: 500;
  159. font-size: 34rpx;
  160. line-height: 1.4;
  161. color: #181818;
  162. }
  163. .btn {
  164. font-family: PingFang SC;
  165. font-weight: 500;
  166. font-size: 32rpx;
  167. line-height: 1.4;
  168. color: #8B8B8B;
  169. position: absolute;
  170. top: 26rpx;
  171. left: 40rpx;
  172. }
  173. }
  174. .form {
  175. padding: 32rpx 40rpx;
  176. &-item {
  177. padding: 8rpx 0 6rpx 0;
  178. & + & {
  179. padding-top: 24rpx;
  180. border-top: 2rpx solid #EEEEEE;
  181. }
  182. &-label {
  183. margin-bottom: 14rpx;
  184. font-family: PingFang SC;
  185. font-weight: 400;
  186. font-size: 26rpx;
  187. line-height: 1.4;
  188. color: #181818;
  189. }
  190. &-content {
  191. .placeholder {
  192. color: #C6C6C6;
  193. font-size: 32rpx;
  194. font-weight: 400;
  195. }
  196. .region {
  197. min-height: 44rpx;
  198. justify-content: flex-start;
  199. }
  200. }
  201. }
  202. }
  203. .footer {
  204. width: 100%;
  205. // todo:check
  206. // height: 214rpx;
  207. padding: 32rpx 40rpx;
  208. box-sizing: border-box;
  209. border-top: 2rpx solid #F1F1F1;
  210. .btn {
  211. width: 100%;
  212. padding: 16rpx 0;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. font-size: 36rpx;
  216. line-height: 1.4;
  217. color: #FFFFFF;
  218. background-image: linear-gradient(to right, #4B348F, #845CFA);
  219. border-radius: 41rpx;
  220. }
  221. }
  222. </style>