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

392 lines
8.2 KiB

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