index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="content">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <view class="one">
  7. <view class="text">
  8. 免费估值 精准报价
  9. </view>
  10. </view>
  11. <view class="two">
  12. <view class="text">为爱车估值</view>
  13. <view class="two_1" @tap="toSelect" v-if="!form.brand&&!form.brand?.title">
  14. <u-icon name="plus-circle-fill" size="20" color="#ffbc00"></u-icon>
  15. <text>请选择车辆品牌</text>
  16. </view>
  17. <view class="two_2" @tap="toSelect" v-else>
  18. <image class="image"
  19. :src="form.brand?.url&&form.brand?.url.length>0?form.brand?.url[0].url:'/static/logo.png'">
  20. </image>
  21. <view class="title">{{form.brand}}</view>
  22. <u-icon name="arrow-right"></u-icon>
  23. </view>
  24. <u--form class="form" :model="form" ref="uForm" :rules="rules" labelWidth="65"
  25. :border-bottom="true">
  26. <u-form-item label="车辆车系" prop="bank">
  27. <input class="input" v-model="form.bank" placeholder="填写车辆车系" />
  28. <template #right>
  29. <u-icon name="arrow-right"></u-icon>
  30. </template>
  31. </u-form-item>
  32. <u-form-item label="车辆车型" prop="type">
  33. <input class="input" v-model="form.type" placeholder="填写车辆车型" />
  34. <template #right>
  35. <u-icon name="arrow-right"></u-icon>
  36. </template>
  37. </u-form-item>
  38. <u-form-item label="上牌日期" prop="start">
  39. <picker name="date" @change="dateChange" mode="date">
  40. <view class="picker">{{form.start||'请选择'}}</view>
  41. </picker>
  42. <template #right>
  43. <u-icon name="arrow-right"></u-icon>
  44. </template>
  45. </u-form-item>
  46. <u-form-item label="行驶里程" prop="course">
  47. <picker name="course" @change="courseChange" :value="index" :range="courseList"
  48. range-key="label">
  49. <view class="picker">{{form.course||'请选择'}}</view>
  50. </picker>
  51. <template #right>
  52. <u-icon name="arrow-right"></u-icon>
  53. </template>
  54. </u-form-item>
  55. <u-form-item label="上牌城市" prop="city">
  56. <text class="picker" @tap="toCity">{{form.city||'请选择'}}</text>
  57. <template #right>
  58. <u-icon name="arrow-right"></u-icon>
  59. </template>
  60. </u-form-item>
  61. <u-form-item label="估值地区" prop="place">
  62. <text class="picker" @tap="toPlace">{{form.place||'请选择'}}</text>
  63. <template #right>
  64. <u-icon name="arrow-right"></u-icon>
  65. </template>
  66. </u-form-item>
  67. <u-form-item label="联系人" prop="contacts">
  68. <input class="input" v-model="form.contacts" placeholder="填写联系人" />
  69. </u-form-item>
  70. <u-form-item label="联系电话" prop="tel">
  71. <input class="input" v-model="form.tel" placeholder="填写常用手机号" />
  72. </u-form-item>
  73. </u--form>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. <view class="foot">
  79. <view class="foot_1">
  80. <button class="btn" @click="toEvaluate">免费估价</button>
  81. </view>
  82. <view class="foot_2">
  83. <checkbox-group @change="changeAgree">
  84. <label>
  85. <checkbox color="#ffbc00" style="transform:scale(0.7)" :checked="agree" />
  86. <text @tap.stop="toAgree">已阅读并同意 《个人信息保护声明》,提交后将会有1-3家服务商为您提供报价服务</text>
  87. </label>
  88. </checkbox-group>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script setup lang="ts">
  94. import { getCurrentInstance, computed, ref } from 'vue';
  95. //该依赖已内置不需要单独安装
  96. import { onLoad, onShow } from "@dcloudio/uni-app";
  97. // 请求接口
  98. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  99. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  100. // 基本信息
  101. const config = ref({});
  102. // 用户协议
  103. const agree = ref(false);
  104. // 用户信息
  105. const user = ref({});
  106. const form = ref({ brand: '', bank: '', type: '', start: '', course: '', place: '', city: '', tel: '' });
  107. const rules = {
  108. 'bank': {
  109. type: 'string',
  110. required: true,
  111. message: '请输入车辆车系',
  112. trigger: ['blur', 'change'],
  113. },
  114. 'type': {
  115. type: 'string',
  116. required: true,
  117. message: '请输入车辆车型',
  118. trigger: ['blur', 'change'],
  119. },
  120. 'start': {
  121. type: 'string',
  122. required: true,
  123. message: '请选择上牌日期',
  124. trigger: ['blur', 'change'],
  125. },
  126. 'course': {
  127. type: 'string',
  128. required: true,
  129. message: '请选择行驶里程',
  130. trigger: ['blur', 'change'],
  131. },
  132. 'tel': {
  133. type: 'string',
  134. required: true,
  135. message: '请输入手机号',
  136. trigger: ['blur', 'change'],
  137. }
  138. }
  139. const uForm = ref(null);
  140. // openid
  141. const openid = computed(() => {
  142. return uni.getStorageSync('openid');
  143. })
  144. // 字典表
  145. const courseList = ref([{ value: '1', label: '1万公里' }, { value: '2', label: '2万公里' }, { value: '3', label: '3万公里' }, { value: '4', label: '4万公里' }, { value: '5', label: '5万公里' }]);
  146. onLoad(async () => {
  147. await searchConfig();
  148. })
  149. onShow(() => {
  150. uni.$on('toRoute', function (data) {
  151. form.value.brand = data.name
  152. })
  153. uni.$on('toCity', function (data) {
  154. form.value[data.field] = data.name
  155. })
  156. })
  157. // config信息
  158. const searchConfig = async () => {
  159. config.value = uni.getStorageSync('config');
  160. };
  161. // 上牌日期
  162. const dateChange = (e) => {
  163. form.value.start = e.target.value;
  164. };
  165. // 行驶里程
  166. const courseChange = (e) => {
  167. const data = courseList.value[e.detail.value]
  168. if (data) form.value.course = data.label
  169. };
  170. // 选择上牌城市
  171. const toCity = () => {
  172. uni.navigateTo({
  173. url: `/pagesHome/city/index?field=${'city'}`,
  174. })
  175. };
  176. // 选择估值城市
  177. const toPlace = () => {
  178. uni.navigateTo({
  179. url: `/pagesHome/city/index?field=${'place'}`,
  180. })
  181. };
  182. // 选择品牌
  183. const toSelect = () => {
  184. uni.navigateTo({
  185. url: `/pagesHome/brand/index`,
  186. })
  187. };
  188. // 估价
  189. const toEvaluate = async () => {
  190. if (agree.value) {
  191. if (openid.value) {
  192. uForm.value.validate().then(async res => {
  193. if (form.value.place || form.value.city) {
  194. form.value.openid = openid.value
  195. const res = await $api(`estimate`, 'POST', form.value);
  196. if (res.errcode == 0) {
  197. uni.showToast({
  198. title: '免费估价申请成功',
  199. icon: 'none'
  200. })
  201. uni.navigateBack({
  202. delta: 1
  203. })
  204. } else {
  205. uni.showToast({
  206. title: res.errmsg,
  207. icon: 'none'
  208. })
  209. }
  210. } else {
  211. uni.showToast({
  212. title: '缺少城市信息',
  213. icon: 'none'
  214. })
  215. }
  216. }).catch(err => {
  217. console.log(err, '校验失败');
  218. })
  219. } else {
  220. uni.showToast({
  221. title: '系统更新中,请稍后再试!',
  222. icon: 'none'
  223. })
  224. }
  225. } else {
  226. uni.showToast({
  227. title: '请阅读并同意用户协议和隐私政策',
  228. icon: 'none'
  229. })
  230. }
  231. };
  232. // 查看隐私协议
  233. const toAgree = () => {
  234. uni.navigateTo({
  235. url: `/pagesHome/agree/index`
  236. })
  237. };
  238. // 同意隐私协议
  239. const changeAgree = () => {
  240. agree.value = !agree.value;
  241. };
  242. </script>
  243. <style lang="scss" scoped>
  244. .content {
  245. display: flex;
  246. flex-direction: column;
  247. width: 100vw;
  248. height: 100vh;
  249. .info {
  250. position: relative;
  251. flex-grow: 1;
  252. background-color: var(--f1Color);
  253. .one {
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. height: 25vh;
  258. background: linear-gradient(to bottom, #ffbc00, #f1f1f1);
  259. .text {
  260. background-image: -webkit-linear-gradient(left, #000, #ffbc00 10%, #ffbc00 20%, #ffbc00 30%, #ffbc00 40%, #ffbc00 50%, #ffbc00 60%, #ffbc00 70%, #ffbc00 80%, #ffbc00 90%, #000 100%);
  261. -webkit-text-fill-color: transparent;
  262. -webkit-background-clip: text;
  263. -webkit-background-size: 200% 100%;
  264. -webkit-animation: masked-animation 4s linear infinite;
  265. font-size: 30px;
  266. font-weight: bold;
  267. }
  268. @keyframes masked-animation {
  269. 0% {
  270. background-position: 0 0;
  271. }
  272. 100% {
  273. background-position: -100% 0;
  274. }
  275. }
  276. }
  277. .two {
  278. background-color: var(--mainColor);
  279. margin: 0 3vw 2vw 3vw;
  280. padding: 2vw;
  281. border-radius: 10px;
  282. .text {
  283. font-size: var(--font16Size);
  284. font-weight: bold;
  285. padding: 2vw;
  286. }
  287. .two_1 {
  288. display: flex;
  289. align-items: center;
  290. justify-content: center;
  291. background-color: var(--f1Color);
  292. padding: 6vw 2vw;
  293. text {
  294. font-size: var(--font16Size);
  295. margin: 0 0 0 1vw;
  296. }
  297. }
  298. .two_2 {
  299. display: flex;
  300. align-items: center;
  301. color: #323233;
  302. padding: 2vw 0;
  303. font-size: var(--font16Size);
  304. border-bottom: 1px solid var(--f5Color);
  305. .image {
  306. width: 60px;
  307. height: 60px;
  308. border-radius: 60px;
  309. }
  310. .title {
  311. width: 75%;
  312. margin: 0 0 0 2vw;
  313. }
  314. }
  315. .form {
  316. .picker {
  317. padding: 2vw;
  318. }
  319. .input {
  320. padding: 2vw;
  321. }
  322. }
  323. }
  324. }
  325. .foot {
  326. padding: 2vw;
  327. .foot_1 {
  328. .btn {
  329. background-color: var(--fFFColor);
  330. font-size: var(--font16Size);
  331. }
  332. }
  333. .foot_2 {
  334. font-size: var(--font12Size);
  335. color: var(--f85Color);
  336. margin: 1vw;
  337. }
  338. }
  339. }
  340. .scroll-view {
  341. position: absolute;
  342. top: 0;
  343. left: 0;
  344. right: 0;
  345. bottom: 0;
  346. .list-scroll-view {
  347. display: flex;
  348. flex-direction: column;
  349. }
  350. }
  351. </style>