猫妈狗爸伴宠师小程序前端代码
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.

160 lines
3.8 KiB

  1. <template>
  2. <view class="page">
  3. <up-form
  4. ref="formRef"
  5. :model="form"
  6. :rules="rules"
  7. labelPosition="left"
  8. labelWidth="150rpx"
  9. >
  10. <view class="info">
  11. <view class="info-header">地址信息</view>
  12. <view class="info-content">
  13. <up-form-item label="接单地址" prop="area">
  14. <view plain class="flex-rowr" @click="selectAddr">
  15. <text v-if="form.area"></text>
  16. <text v-else class="placeholder">请定位选择小区或商城等</text>
  17. <up-icon style="margin-left: 22rpx;" name="arrow-down" color="#7F7F7F" size="21rpx"></up-icon>
  18. </view>
  19. </up-form-item>
  20. <up-form-item label="接单地址" prop="address" labelPosition="top">
  21. <view class="textarea">
  22. <textarea
  23. v-model="form.address"
  24. placeholder="如街道、门牌号、小区、乡镇、村等"
  25. :row="3"
  26. ></textarea>
  27. </view>
  28. </up-form-item>
  29. </view>
  30. </view>
  31. <view class="info">
  32. <view class="info-header">接单信息</view>
  33. <view class="info-content">
  34. <up-form-item label="接单状态" prop="status">
  35. <view class="flex-rowr">
  36. <switch :checked="!!form.status" @change="onSwitch" color="#FFBF60" style="transform: scale(0.6);"/>
  37. <text>{{ !!form.status ? '开启' : '关闭' }}</text>
  38. </view>
  39. </up-form-item>
  40. <up-form-item label="接单范围" prop="distance">
  41. <up-input
  42. v-model="form.distance"
  43. placeholder="请输入内容"
  44. inputAlign="right"
  45. border="none"
  46. >
  47. <template #suffix>
  48. <text>Km</text>
  49. </template>
  50. </up-input>
  51. </up-form-item>
  52. <up-form-item label="不接单日期(选填)" prop="disabledDate" labelWidth="300rpx">
  53. <!-- todo -->
  54. </up-form-item>
  55. </view>
  56. </view>
  57. </up-form>
  58. <view>
  59. <up-parse class="size-28"
  60. :content="configList.pet_km_text.paramValueArea"
  61. :containerStyle="{
  62. color: '#707070',
  63. fontSize: '22rpx',
  64. lineHeight: '35rpx',
  65. }"
  66. ></up-parse>
  67. </view>
  68. <view class="footer-btn">
  69. <view class="btn" @click="onSave">
  70. 保存
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script setup>
  76. import { ref } from 'vue'
  77. import { store } from '@/store'
  78. const configList = store.state.system.configList
  79. const formRef = ref()
  80. const form = ref({
  81. area: null,
  82. latitude: null,
  83. longitude: null,
  84. address: null,
  85. status: true,
  86. distance: null,
  87. disabledDate: [],
  88. })
  89. // todo: set rules
  90. const rules = ref({})
  91. const setAddress = (res) => {
  92. //经纬度信息
  93. form.value.latitude = res.latitude
  94. form.value.longitude = res.longitude
  95. if (!res.address && res.name) { //用户直接选择城市的逻辑
  96. return form.value.area = res.name
  97. }
  98. if (res.address || res.name) {
  99. return form.value.area = res.address + res.name
  100. }
  101. form.value.area = '' //用户啥都没选就点击勾选
  102. }
  103. const selectAddr = () => {
  104. uni.chooseLocation({
  105. success: function(res) {
  106. setAddress(res)
  107. }
  108. })
  109. }
  110. const onSwitch = (e) => {
  111. form.value.status = e.detail.value
  112. }
  113. const onSave = () => {
  114. // todo: fetch save data
  115. uni.navigateBack()
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .page {
  120. padding: 35rpx 37rpx 144rpx 37rpx;
  121. }
  122. .info {
  123. color: #707070;
  124. font-size: 30rpx;
  125. line-height: 40rpx;
  126. &-header {
  127. color: #000000;
  128. }
  129. .placeholder {
  130. color: #707070;
  131. }
  132. .textarea {
  133. margin-top: 16rpx;
  134. background-color: #F3F3F3;
  135. padding: 26rpx 8rpx;
  136. border-radius: 15rpx;
  137. }
  138. :deep(.u-form-item__body__left__content__label) {
  139. color: #707070;
  140. }
  141. }
  142. </style>