edit.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="container">
  3. <!-- 物品信息 -->
  4. <view class="form-card">
  5. <view class="form-item">
  6. <view class="item-label">
  7. <input class="input-field" placeholder="姓名" placeholder-class="placeholder" v-model="formInfo" />
  8. </view>
  9. <view class="item-control">
  10. <input class="input-field" placeholder="电话" placeholder-class="placeholder" v-model="formInfo" />
  11. </view>
  12. </view>
  13. <view class="form-item" @click="showTimePicker = true">
  14. <text class="time-value placeholder">省市区</text>
  15. <text class="time-value value">{{ selectedTime }}</text>
  16. <u-icon class="arrow" name='arrow-right' size="18"></u-icon>
  17. </view>
  18. <view class="form-item">
  19. <view class="item-control">
  20. <input class="input-field" placeholder="详细地址" placeholder-class="placeholder" v-model="formInfo" />
  21. </view>
  22. </view>
  23. <view class="form-item">
  24. <!-- 设置默认和清空 -->
  25. <view class="form-actions">
  26. <view class="action-left">
  27. <switch color="#007AFF" @change="onDefaultChange" />
  28. <text class="action-text">设为默认寄件地址</text>
  29. </view>
  30. <view class="action-right" @click="clearForm">
  31. <text class="clear-text">清空</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="section-title">最近使用地址</view>
  37. <!-- 最近使用地址 -->
  38. <view class="recent-address">
  39. <!-- 地址项1 -->
  40. <view class="address-item" @tap="selectAddress(0)">
  41. <AddressInfo v-if="addressSend.id" :address="addressSend" />
  42. <view class="address-info">
  43. <view class="address-name">袁添昊 13344642161</view>
  44. <view class="address-detail">湖北省荆州市新石南路747号</view>
  45. </view>
  46. <!-- <view class="address-select">
  47. </view> -->
  48. </view>
  49. <!-- 地址项2 -->
  50. <view class="address-item" @tap="selectAddress(1)">
  51. <view class="address-info">
  52. <view class="address-name">袁添昊 13344642161</view>
  53. <view class="address-detail">湖北省荆州市新石南路747号</view>
  54. </view>
  55. <!-- <view class="address-select">
  56. </view> -->
  57. </view>
  58. </view>
  59. <!-- 下单按钮 -->
  60. <view class="submit-btn" @click="onConfirm">
  61. 确定
  62. </view>
  63. <!-- 安全区域占位 -->
  64. <view class="safe-area"></view>
  65. </view>
  66. </template>
  67. <script setup>
  68. import {
  69. ref,
  70. reactive
  71. } from 'vue'
  72. import {onLoad} from '@dcloudio/uni-app'
  73. import AddressInfo from '@/components/AddressInfo.vue'
  74. const addType = ref('1') //1 表示从创建订单过来 2 表示编辑 3表示创建
  75. // 表单数据
  76. const formData = reactive({
  77. name: '',
  78. phone: '',
  79. region: [],
  80. address: '',
  81. isDefault: false
  82. })
  83. // 最近地址列表
  84. const recentAddresses = ref([{
  85. name: '袁添昊',
  86. phone: '13344642161',
  87. address: '湖北省荆州市新石南路747号'
  88. },
  89. {
  90. name: '袁添昊',
  91. phone: '13344642161',
  92. address: '湖北省荆州市新石南路747号'
  93. }
  94. ])
  95. onLoad((option)=>{
  96. })
  97. // 省市区选择
  98. const onRegionChange = (e) => {
  99. formData.region = e.detail.value
  100. }
  101. // 默认地址切换
  102. const onDefaultChange = (e) => {
  103. formData.isDefault = e.detail.value
  104. }
  105. // 清空表单
  106. const clearForm = () => {
  107. formData.name = ''
  108. formData.phone = ''
  109. formData.region = []
  110. formData.address = ''
  111. formData.isDefault = false
  112. }
  113. // 选择地址
  114. const selectAddress = (index) => {
  115. const address = recentAddresses.value[index]
  116. formData.name = address.name
  117. formData.phone = address.phone
  118. formData.address = address.address
  119. }
  120. // 确定提交
  121. const onConfirm = () => {
  122. // 这里可以添加表单验证
  123. if (!formData.name || !formData.phone || !formData.address) {
  124. uni.showToast({
  125. title: '请填写完整信息',
  126. icon: 'none'
  127. })
  128. return
  129. }
  130. // 提交逻辑
  131. console.log('提交数据:', formData)
  132. uni.showToast({
  133. title: '提交成功',
  134. icon: 'success'
  135. })
  136. // 返回上一页或执行其他操作
  137. // uni.navigateBack()
  138. }
  139. </script>
  140. <style scoped lang="less">
  141. .container {
  142. background-color: #F5F7FA;
  143. min-height: 100vh;
  144. padding: 20rpx 20rpx 30rpx 20rpx;
  145. }
  146. .form-card {
  147. background-color: #fff;
  148. border-radius: 32rpx;
  149. padding: 0rpx 20rpx;
  150. }
  151. .form-title {
  152. font-size: 32rpx;
  153. font-weight: 600;
  154. color: #333;
  155. margin-bottom: 32rpx;
  156. }
  157. .form-item {
  158. display: flex;
  159. justify-content: space-between;
  160. align-items: center;
  161. height: 100rpx;
  162. border-bottom: 1rpx solid #F1F3F8;
  163. &:last-child {
  164. border-bottom: none;
  165. margin-bottom: 0;
  166. }
  167. .item-label {
  168. font-size: 28rpx;
  169. color: #666;
  170. font-weight: 400;
  171. &.required::before {
  172. content: '*';
  173. color: #ff4444;
  174. margin-right: 8rpx;
  175. }
  176. }
  177. .item-control {
  178. display: flex;
  179. align-items: center;
  180. &.btn {
  181. background: #fff;
  182. border: 1rpx solid #dcdfe6;
  183. border-radius: 5rpx;
  184. height: 59rpx;
  185. width: 266rpx;
  186. box-sizing: border-box;
  187. }
  188. }
  189. .input-field {
  190. width: 100%;
  191. height: 100rpx;
  192. line-height: 100rpx;
  193. padding: 0 24rpx;
  194. font-size: 28rpx;
  195. color: #333;
  196. text-align: left;
  197. &::placeholder {
  198. color: #999;
  199. }
  200. }
  201. .time-value {
  202. display: flex;
  203. align-items: center;
  204. font-size: 28rpx;
  205. color: #333;
  206. line-height: 88rpx;
  207. height: 88rpx;
  208. padding: 0 24rpx;
  209. &.placeholder {
  210. color: #999;
  211. }
  212. .value {
  213. margin-right: 16rpx;
  214. }
  215. .arrow {
  216. margin-left: 32rpx;
  217. color: #999;
  218. font-size: 28rpx;
  219. font-weight: bold;
  220. }
  221. }
  222. }
  223. /* 寄件标识 */
  224. .send-tag {
  225. padding: 40rpx 30rpx 20rpx;
  226. background-color: #fff;
  227. }
  228. .send-circle {
  229. width: 60rpx;
  230. height: 60rpx;
  231. border-radius: 50%;
  232. background-color: #007AFF;
  233. color: #fff;
  234. display: flex;
  235. align-items: center;
  236. justify-content: center;
  237. font-size: 28rpx;
  238. font-weight: bold;
  239. }
  240. /* 表单区域 */
  241. .form-container {
  242. background-color: #fff;
  243. padding: 0 30rpx;
  244. margin-bottom: 20rpx;
  245. }
  246. .form-title {
  247. font-size: 18px;
  248. font-weight: 500;
  249. color: #333;
  250. padding: 30rpx 0 20rpx;
  251. border-bottom: 1rpx solid #eee;
  252. }
  253. .form-item {
  254. width: 100%;
  255. padding: 30rpx 0;
  256. border-bottom: 1rpx solid #eee;
  257. }
  258. .form-input {
  259. font-size: 16px;
  260. height: 40rpx;
  261. line-height: 40rpx;
  262. color: #333;
  263. }
  264. .form-input::placeholder {
  265. color: #999;
  266. }
  267. .picker-placeholder {
  268. font-size: 16px;
  269. height: 40rpx;
  270. line-height: 40rpx;
  271. color: #999;
  272. }
  273. .picker-placeholder.has-value {
  274. color: #333;
  275. }
  276. /* 表单操作 */
  277. .form-actions {
  278. width: 100%;
  279. display: flex;
  280. justify-content: space-between;
  281. align-items: center;
  282. padding: 30rpx 0;
  283. }
  284. .action-left {
  285. display: flex;
  286. align-items: center;
  287. }
  288. .action-text {
  289. font-size: 28rpx;
  290. color: #333;
  291. margin-left: 10rpx;
  292. }
  293. .action-right {
  294. padding: 10rpx 20rpx;
  295. }
  296. .clear-text {
  297. height: 44rpx;
  298. font-weight: 400;
  299. font-size: 28rpx;
  300. color: #1B64F0;
  301. line-height: 44rpx;
  302. }
  303. /* 最近地址 */
  304. .recent-address {
  305. background-color: #fff;
  306. padding: 0 30rpx;
  307. }
  308. .section-title {
  309. height: 48rpx;
  310. font-size: 32rpx;
  311. color: #333333;
  312. line-height: 48rpx;
  313. margin: 20rpx 0rpx;
  314. font-weight: bold;
  315. }
  316. .address-item {
  317. display: flex;
  318. justify-content: space-between;
  319. align-items: center;
  320. padding: 30rpx 0;
  321. border-bottom: 1rpx solid #eee;
  322. }
  323. .address-info {
  324. flex: 1;
  325. }
  326. .address-name {
  327. font-size: 16px;
  328. color: #333;
  329. margin-bottom: 10rpx;
  330. }
  331. .address-detail {
  332. font-size: 14px;
  333. color: #666;
  334. line-height: 1.4;
  335. }
  336. .address-select {
  337. width: 40rpx;
  338. height: 40rpx;
  339. border: 1rpx solid #007AFF;
  340. border-radius: 50%;
  341. margin-left: 20rpx;
  342. }
  343. .safe-area {
  344. height: 140rpx;
  345. }
  346. .submit-btn {
  347. position: fixed;
  348. bottom: 40rpx;
  349. left: 30rpx;
  350. right: 30rpx;
  351. width: 686rpx;
  352. height: 88rpx;
  353. background: #1B64F0;
  354. border-radius: 44rpx;
  355. display: flex;
  356. justify-content: center;
  357. align-items: center;
  358. font-size: 32rpx;
  359. color: #FFFFFF;
  360. line-height: 88rpx;
  361. text-align: center;
  362. z-index: 10;
  363. }
  364. </style>