index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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?.title}}</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?.name||'请选择'}}</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="toCity">{{form.place?.name||'请选择'}}</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, 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({ phone: "" });
  107. const rules = ref({
  108. phone: [
  109. {
  110. required: true,
  111. message: '请输入手机号',
  112. trigger: ['blur', 'change']
  113. }
  114. ]
  115. });
  116. // 字典表
  117. const courseList = ref([{ value: '1', label: '1万公里' }, { value: '2', label: '2万公里' }, { value: '3', label: '3万公里' }, { value: '4', label: '4万公里' }, { value: '5', label: '5万公里' }]);
  118. onLoad(async () => {
  119. await searchConfig();
  120. })
  121. onShow(() => {
  122. uni.$on('toRoute', function (data) {
  123. form.value.brand = data
  124. })
  125. uni.$on('toCity', function (data) {
  126. form.value.city = data
  127. })
  128. })
  129. // config信息
  130. const searchConfig = async () => {
  131. config.value = uni.getStorageSync('config');
  132. };
  133. // 上牌日期
  134. const dateChange = (e) => {
  135. form.value.start = e.target.value;
  136. };
  137. // 行驶里程
  138. const courseChange = (e) => {
  139. const data = courseList.value[e.detail.value]
  140. if (data) form.value.course = data.label
  141. };
  142. // 选择上牌城市
  143. const toCity = () => {
  144. uni.navigateTo({
  145. url: `/pagesHome/city/index`,
  146. })
  147. };
  148. // 选择估值城市
  149. const toPlace = () => {
  150. uni.navigateTo({
  151. url: `/pagesHome/city/index`,
  152. })
  153. };
  154. // 选择品牌
  155. const toSelect = () => {
  156. uni.navigateTo({
  157. url: `/pagesHome/brand/index`,
  158. })
  159. };
  160. // 估价
  161. const toEvaluate = async () => {
  162. if (agree.value) {
  163. $refs.form.validate().then(res => {
  164. uni.$u.toast('校验通过')
  165. }).catch(errors => {
  166. uni.$u.toast('校验失败')
  167. })
  168. } else {
  169. uni.showToast({
  170. title: '请阅读并同意用户协议和隐私政策',
  171. icon: 'none'
  172. })
  173. }
  174. };
  175. // 查看隐私协议
  176. const toAgree = () => {
  177. uni.navigateTo({
  178. url: `/pagesHome/agree/index`
  179. })
  180. };
  181. // 同意隐私协议
  182. const changeAgree = () => {
  183. agree.value = !agree.value;
  184. };
  185. </script>
  186. <style lang="scss" scoped>
  187. .content {
  188. display: flex;
  189. flex-direction: column;
  190. width: 100vw;
  191. height: 100vh;
  192. .info {
  193. position: relative;
  194. flex-grow: 1;
  195. background-color: var(--f1Color);
  196. .one {
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. height: 25vh;
  201. background: linear-gradient(to bottom, #ffbc00, #f1f1f1);
  202. .text {
  203. 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%);
  204. -webkit-text-fill-color: transparent;
  205. -webkit-background-clip: text;
  206. -webkit-background-size: 200% 100%;
  207. -webkit-animation: masked-animation 4s linear infinite;
  208. font-size: 30px;
  209. font-weight: bold;
  210. }
  211. @keyframes masked-animation {
  212. 0% {
  213. background-position: 0 0;
  214. }
  215. 100% {
  216. background-position: -100% 0;
  217. }
  218. }
  219. }
  220. .two {
  221. background-color: var(--mainColor);
  222. margin: 0 3vw 2vw 3vw;
  223. padding: 2vw;
  224. border-radius: 10px;
  225. .text {
  226. font-size: var(--font16Size);
  227. font-weight: bold;
  228. padding: 2vw;
  229. }
  230. .two_1 {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. background-color: var(--f1Color);
  235. padding: 6vw 2vw;
  236. text {
  237. font-size: var(--font16Size);
  238. margin: 0 0 0 1vw;
  239. }
  240. }
  241. .two_2 {
  242. display: flex;
  243. align-items: center;
  244. color: #323233;
  245. padding: 2vw 0;
  246. font-size: var(--font16Size);
  247. border-bottom: 1px solid var(--f5Color);
  248. .image {
  249. width: 60px;
  250. height: 60px;
  251. border-radius: 60px;
  252. }
  253. .title {
  254. width: 75%;
  255. margin: 0 0 0 2vw;
  256. }
  257. }
  258. .form {
  259. .picker {
  260. padding: 2vw;
  261. }
  262. .input {
  263. padding: 2vw;
  264. }
  265. }
  266. }
  267. }
  268. .foot {
  269. padding: 2vw;
  270. .foot_1 {
  271. .btn {
  272. background-color: var(--fFFColor);
  273. font-size: var(--font16Size);
  274. }
  275. }
  276. .foot_2 {
  277. font-size: var(--font12Size);
  278. color: var(--f85Color);
  279. margin: 1vw;
  280. }
  281. }
  282. }
  283. .scroll-view {
  284. position: absolute;
  285. top: 0;
  286. left: 0;
  287. right: 0;
  288. bottom: 0;
  289. .list-scroll-view {
  290. display: flex;
  291. flex-direction: column;
  292. }
  293. }
  294. </style>