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

326 lines
6.9 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page bg-fff">
  3. <view class="size-22 color-ffb flex-rowl tip">
  4. <image class="icon" :src="configList.my_information_statement.paramValueImage"></image>
  5. <view>
  6. <up-parse :content="configList.my_information_statement.paramValueArea" containerStyle="{
  7. color: '#FFBF60',
  8. fontSize: '22rpx',
  9. lineHeight: '40rpx',
  10. }"></up-parse>
  11. </view>
  12. </view>
  13. <view class="info">
  14. <view class="title mt24">
  15. 基本资料
  16. </view>
  17. <view class="flex-colc">
  18. <button class="btn-avatar" :plain="true" :hairline="false" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  19. <view class="flex-colc">
  20. <image class="head" :src="form.headImage" mode="widthFix"></image>
  21. <text class="size-28 color-999 mt10">点击更换头像</text>
  22. </view>
  23. </button>
  24. </view>
  25. <view class="form">
  26. <DForm ref="baseInfoRef" :list="state.baseInfoList" @input="fetchUpdate"></DForm>
  27. </view>
  28. </view>
  29. <view class="info">
  30. <view class="title mt24 flex-rowl">
  31. 展示信息
  32. <text class="size-22 color-ffb fw700">(重要)</text>
  33. </view>
  34. <view class="form">
  35. <DForm ref="displayInfoRef" :list="state.displayInfoList" @input="fetchUpdate">
  36. <!-- 服务记录 -->
  37. <template v-slot:jilu>
  38. <view class="flex-rowr" @click="jumpToServeRecord">
  39. <text>{{ `${0}` }}</text>
  40. <up-icon name="arrow-right" color="#999999" size="32rpx"></up-icon>
  41. </view>
  42. </template>
  43. </DForm>
  44. </view>
  45. </view>
  46. <view class="info">
  47. <view class="title mt24 flex-rowl">
  48. 服务资料
  49. </view>
  50. <view class="form">
  51. <DForm ref="serveInfoRef" :list="state.serveInfoList" @input="fetchUpdate">
  52. <!-- 服务宠物类型 -->
  53. <template v-slot:type>
  54. <view class="flex-rowr" @click="openTypeSelectPopup">
  55. <text>{{ typeDesc }}</text>
  56. <up-icon name="arrow-right" color="#999999" size="32rpx"></up-icon>
  57. </view>
  58. </template>
  59. <!-- 增值服务 -->
  60. <template v-slot:zenz>
  61. <view class="flex-rowr" @click="openServeSelectPopup">
  62. <text>{{ serveDesc }}</text>
  63. <up-icon name="arrow-right" color="#999999" size="32rpx"></up-icon>
  64. </view>
  65. </template>
  66. </DForm>
  67. </view>
  68. </view>
  69. <view class="size-24 color-ffb flex-rowc mt32 pb28">
  70. 伴宠师查看服务酬劳服务时长等规则
  71. </view>
  72. <popupTypeSelect ref="popupTypeSelectRef" v-model="form.type" @confirm="fetchUpdate" ></popupTypeSelect>
  73. <popupServeSelect ref="popupServeSelectRef" v-model="form.serve" @confirm="fetchUpdate" ></popupServeSelect>
  74. </view>
  75. </template>
  76. <script setup>
  77. import { ref, reactive, computed, onMounted } from "vue";
  78. import { useStore } from 'vuex'
  79. import { onShow } from '@dcloudio/uni-app'
  80. import { ossUpload } from '@/utils/oss-upload/oss/index.js'
  81. import DForm from "@/components/dForm/index.vue"
  82. import popupTypeSelect from "./popupTypeSelect.vue";
  83. import popupServeSelect from "./popupServeSelect.vue";
  84. const store = useStore()
  85. const configList = computed(() => {
  86. return store.getters.configList
  87. })
  88. const fetchUpdate = (data) => {
  89. // todo
  90. console.log(data);
  91. for(let key in data){
  92. state.baseInfoList[key] = data[key]
  93. }
  94. console.log(state.baseInfoList);
  95. }
  96. const form = reactive({
  97. headImage: null,
  98. type: [],
  99. serve: [],
  100. })
  101. const onChooseAvatar = (res) => {
  102. ossUpload(res.target.avatarUrl)
  103. .then(url => {
  104. form.headImage = url
  105. fetchUpdate()
  106. })
  107. }
  108. const baseInfoRef = ref()
  109. const displayInfoRef = ref()
  110. const serveInfoRef = ref()
  111. const state = reactive({
  112. baseInfoList: [{
  113. type: "input",
  114. label: "昵称",
  115. key: "name",
  116. placeholder: "请输入",
  117. },
  118. {
  119. type: "input",
  120. label: "手机号",
  121. key: "idCard",
  122. placeholder: "请输入",
  123. },
  124. {
  125. type: "select",
  126. label: "性别",
  127. key: "sex",
  128. placeholder: "请选择",
  129. options: [{
  130. name: "男"
  131. },
  132. {
  133. name: "女"
  134. }
  135. ]
  136. }
  137. ],
  138. displayInfoList: [{
  139. type: "input",
  140. label: "个人简介",
  141. key: "jianjie",
  142. placeholder: "请输入",
  143. },
  144. {
  145. type: "input",
  146. label: "养宠经验",
  147. unit: "年",
  148. key: "jingyan",
  149. placeholder: "请输入",
  150. },
  151. {
  152. type: "custom",
  153. label: "服务记录",
  154. key: "jilu",
  155. placeholder: "请选择",
  156. options: [{
  157. name: "男"
  158. },
  159. {
  160. name: "女"
  161. }
  162. ]
  163. }
  164. ],
  165. serveInfoList: [{
  166. type: "custom",
  167. label: "服务宠物类型",
  168. key: "type",
  169. placeholder: "请选择",
  170. },
  171. {
  172. type: "input",
  173. label: "基础服务",
  174. key: "base",
  175. placeholder: "宠物喂养上门遛狗",
  176. },
  177. {
  178. type: "custom",
  179. label: "增值服务",
  180. key: "zenz",
  181. placeholder: "请选择",
  182. }
  183. ],
  184. })
  185. const jumpToServeRecord = () => {
  186. uni.navigateTo({
  187. url: "/otherPages/authentication/serve/record"
  188. })
  189. }
  190. const popupTypeSelectRef = ref()
  191. const openTypeSelectPopup = () => {
  192. popupTypeSelectRef.value.open()
  193. }
  194. const petTypeOptions = computed(() => {
  195. return store.getters.petTypeOptions
  196. })
  197. const typeDesc = computed(() => {
  198. const typeIds = form.type
  199. if (!typeIds.length) {
  200. return '请选择'
  201. }
  202. let descArr = typeIds.map(typeId => {
  203. return petTypeOptions.value.find(item => item.id === typeId).title
  204. })
  205. return descArr.join('、')
  206. })
  207. const popupServeSelectRef = ref()
  208. const increaseServiceOptions = computed(() => {
  209. return store.getters.increaseServiceOptions
  210. })
  211. const openServeSelectPopup = () => {
  212. popupServeSelectRef.value.open()
  213. }
  214. const serveDesc = computed(() => {
  215. const serveIds = form.serve
  216. if (!serveIds.length) {
  217. return '请选择'
  218. }
  219. let descArr = serveIds.map(serveId => {
  220. return increaseServiceOptions.value.find(option => option.id === serveId)?.title
  221. })
  222. return descArr.join('、')
  223. })
  224. onShow(() => {
  225. store.dispatch('fetchPetTypeOptions')
  226. store.dispatch('fetchIncreaseServiceOptions')
  227. })
  228. onMounted(()=> {
  229. // todo: fetch data and init data
  230. serveInfoRef.value.setDataByKey('base', configList.value.pet_basic_services.paramValueText)
  231. })
  232. </script>
  233. <style lang="scss" scoped>
  234. .page {
  235. padding-top: 16rpx;
  236. .tip {
  237. background-color: rgba($color: #FFBF60, $alpha: 0.16);
  238. padding: 13rpx 22rpx;
  239. margin: 0 28rpx 37rpx 28rpx;
  240. .icon {
  241. width: 36rpx;
  242. height: 36rpx;
  243. margin-right: 15rpx;
  244. }
  245. }
  246. }
  247. .info {
  248. & + & {
  249. margin-top: 50rpx;
  250. }
  251. }
  252. .head {
  253. width: 165rpx;
  254. height: auto;
  255. margin-top: 28rpx;
  256. }
  257. .btn-avatar {
  258. border: none;
  259. padding: 0;
  260. }
  261. .title {
  262. font-size: 30rpx;
  263. font-weight: 700;
  264. display: flex;
  265. align-items: center;
  266. padding: 0 40rpx;
  267. &:before {
  268. display: inline-block;
  269. content: "";
  270. width: 10rpx;
  271. border-radius: 5rpx;
  272. height: 33rpx;
  273. background-color: #FFBF60;
  274. margin-right: 7rpx;
  275. }
  276. }
  277. .form {
  278. padding: 0 22rpx;
  279. :deep(.form-item){
  280. padding-left: 24rpx;
  281. padding-right: 30rpx;
  282. box-sizing: border-box;
  283. }
  284. }
  285. </style>