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

352 lines
6.5 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="containers po-r">
  3. <image src="" mode="" class="mainBg"></image>
  4. <view class="w-100 po-a content">
  5. <stepProgress :step="1"></stepProgress>
  6. <view class="bg-fff mt22 form ">
  7. <view class="title fw700 size-30 flex-rowl">
  8. 基本信息
  9. </view>
  10. <dForm ref="formRef" :list="state.list" labelWidth="220rpx" :isFooter="false" @input="onFormInput"></dForm>
  11. </view>
  12. <view class="license__view" v-if="form.license">
  13. <view class="license">
  14. <up-checkbox-group
  15. v-model="licenseData.selected"
  16. shape="circle"
  17. activeColor="#FFBF60"
  18. labelColor="#000000"
  19. labelSize="26rpx"
  20. >
  21. <view class="license-options">
  22. <up-checkbox
  23. v-for="item in licenseOptions"
  24. :key="`license-${item.id}`"
  25. :label="item.title"
  26. :name="item.id"
  27. >
  28. </up-checkbox>
  29. </view>
  30. </up-checkbox-group>
  31. <view class="tips">
  32. {{ configList.pet_news.paramValueText }}
  33. </view>
  34. <up-upload
  35. :fileList="licenseData.fileList"
  36. @afterRead="afterRead"
  37. @delete="deletePic"
  38. multiple
  39. >
  40. <image src="../static/list/icon-upload.png" style="width: 144rpx;height: 144rpx;"></image>
  41. </up-upload>
  42. </view>
  43. </view>
  44. <view class="bg-fff mt22 form bt120">
  45. <view class="title fw700 size-30 flex-rowl">
  46. 个人宠物类型
  47. </view>
  48. <view class="flex-between wrap mt32">
  49. <view class="type" v-for="item in petTypeOptions" :key="`petType-${item.id}`">
  50. <image :src="item.imageNo" mode="widthFix" @click="onSelectPetType(item.id)"></image>
  51. <template v-if="petType === item.id">
  52. <image class="active" :src="item.image" mode="widthFix"></image>
  53. <view class="active-icon">
  54. <up-icon name="checkmark-circle" color="#FFBF60" size="32rpx"></up-icon>
  55. </view>
  56. </template>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="footer-btn" @click="toNext">
  61. <view class="btn">
  62. 下一步
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script setup>
  69. import { ref, reactive } from "vue";
  70. import { onShow } from '@dcloudio/uni-app'
  71. import { ossUpload } from '@/utils/oss-upload/oss/index.js'
  72. import { getLicenseList, getPetTypeList } from '@/api/examination'
  73. import { insertUser } from '@/api/userTeacher'
  74. import { store } from '@/store'
  75. import dForm from "@/components/dForm/index.vue"
  76. import stepProgress from '../components/stepProgress.vue';
  77. const configList = store.state.system.configList
  78. const state = reactive({
  79. list: [{
  80. type: "input",
  81. label: "姓名",
  82. key: "name",
  83. placeholder: "请输入您的真实姓名",
  84. },
  85. {
  86. type: "input",
  87. label: "身份证号",
  88. key: "idCard",
  89. placeholder: "请输入您的真实身份证号",
  90. },
  91. {
  92. type: "radio",
  93. label: "性别",
  94. key: "sex",
  95. options: [{
  96. name: "男",
  97. value: 0,
  98. },
  99. {
  100. name: "女",
  101. value: 1,
  102. }
  103. ]
  104. },
  105. {
  106. type: "input",
  107. label: "年龄",
  108. key: "age",
  109. placeholder: "请输入您的年龄",
  110. },
  111. {
  112. type: "input",
  113. label: "养宠经验",
  114. key: "experience",
  115. placeholder: "请输入您的养宠年限",
  116. unit: "年"
  117. },
  118. {
  119. type: "radio",
  120. label: "是否有专业执照",
  121. key: "license",
  122. placeholder: "请选择",
  123. options: [{
  124. name: "是",
  125. value: 1,
  126. }, {
  127. name: "没有",
  128. value: 0,
  129. }]
  130. },
  131. ]
  132. })
  133. const formRef = ref()
  134. const form = ref({})
  135. const onFormInput = (e) => {
  136. form.value = e
  137. }
  138. const licenseData = reactive({
  139. selected: [],
  140. fileList: []
  141. })
  142. const licenseOptions = ref([])
  143. const fetchLicenseOptions = async () => {
  144. try {
  145. licenseOptions.value = await getLicenseList()
  146. } catch (err) {
  147. }
  148. }
  149. const afterRead = (event) => {
  150. event.file.forEach(n => {
  151. ossUpload(n.url)
  152. .then(url => {
  153. licenseData.fileList.push({
  154. url
  155. })
  156. })
  157. })
  158. };
  159. const deletePic = (event) => {
  160. licenseData.fileList.splice(event.index, 1);
  161. };
  162. const petType = ref()
  163. const petTypeOptions = ref([])
  164. const onSelectPetType = (type) => {
  165. petType.value = type
  166. }
  167. const fetchPetTypeOptions = async () => {
  168. try {
  169. petTypeOptions.value = await getPetTypeList()
  170. } catch (err) {
  171. }
  172. }
  173. const toNext = async () => {
  174. try {
  175. const {
  176. name,
  177. idCard,
  178. sex,
  179. age,
  180. experience,
  181. license,
  182. } = form.value
  183. const data = {
  184. name,
  185. idCard,
  186. sex,
  187. age,
  188. experience,
  189. petType: petType.value,
  190. }
  191. if (license) {
  192. const { selected, fileList } = licenseData
  193. data.license = selected.join(';')
  194. data.images = fileList.join(';')
  195. }
  196. await insertUser(data)
  197. uni.setStorageSync('petTypeData', petTypeOptions.value.find(item => item.id === petType.value))
  198. uni.navigateTo({
  199. url: "/otherPages/authentication/examination/start"
  200. })
  201. } catch (err) {
  202. }
  203. }
  204. onShow(() => {
  205. fetchPetTypeOptions()
  206. fetchLicenseOptions()
  207. })
  208. </script>
  209. <style lang="scss" scoped>
  210. .bt120 {
  211. margin-bottom: 120rpx;
  212. width: 716rpx;
  213. box-sizing: border-box;
  214. }
  215. .footer-btn {
  216. width: 100vw;
  217. height: 144rpx;
  218. background-color: #fff;
  219. display: flex;
  220. justify-content: center;
  221. position: fixed;
  222. bottom: 0;
  223. left: 0;
  224. align-items: center;
  225. .btn {
  226. font-size: 30rpx;
  227. color: #fff;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. width: 574rpx;
  232. height: 94rpx;
  233. border-radius: 94rpx;
  234. background-color: #FFBF60;
  235. }
  236. }
  237. .type {
  238. width: 190rpx;
  239. margin-bottom: 74rpx;
  240. position: relative;
  241. image {
  242. width: 100%;
  243. }
  244. .active {
  245. position: absolute;
  246. top: 0;
  247. left: 0;
  248. &-icon {
  249. position: absolute;
  250. top: 14rpx;
  251. right: 18rpx;
  252. }
  253. }
  254. }
  255. .form {
  256. padding: 40rpx 32rpx;
  257. box-sizing: border-box;
  258. width: 716rpx;
  259. }
  260. .title {
  261. &::before {
  262. content: "";
  263. display: block;
  264. width: 9rpx;
  265. height: 33rpx;
  266. background-color: #FFBF60;
  267. margin-right: 7rpx;
  268. }
  269. }
  270. .mb6 {
  271. margin-bottom: 6rpx;
  272. }
  273. .containers {
  274. .mainBg {
  275. width: 100vw;
  276. height: 442rpx;
  277. background-image: linear-gradient(to bottom, #FFBF60, #f5f5f5);
  278. }
  279. .content {
  280. top: 0;
  281. left: 0;
  282. padding: 16rpx;
  283. }
  284. }
  285. .license__view {
  286. width: 716rpx;
  287. padding-bottom: 40rpx;
  288. box-sizing: border-box;
  289. background-color: #FFFFFF;
  290. .license {
  291. width: 100%;
  292. padding: 13rpx 16rpx;
  293. box-sizing: border-box;
  294. background-color: #FFFCF1;
  295. &-options {
  296. display: grid;
  297. grid-template-columns: repeat(2, 1fr);
  298. }
  299. }
  300. .tips {
  301. margin: 22rpx 0 24rpx 0;
  302. color: #FFBF60;
  303. font-size: 22rpx;
  304. width: 100%;
  305. word-break: break-all;
  306. }
  307. }
  308. </style>