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

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