index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <u-notice-bar :text="text"></u-notice-bar>
  5. </view>
  6. <view class="two">
  7. <view class="two_1">
  8. <view class="table_column">
  9. <view class="left">
  10. 商品编号
  11. </view>
  12. <view class="right">
  13. {{info._id||'暂无'}}
  14. </view>
  15. </view>
  16. <view class="table_column">
  17. <view class="left">
  18. 商品名称
  19. </view>
  20. <view class="right">
  21. {{info.series||'暂无'}} {{info.year||'暂无'}}款
  22. {{info.style||'暂无'}}
  23. </view>
  24. </view>
  25. <view class="table_column">
  26. <view class="left">
  27. 车辆识别号(VIN)
  28. </view>
  29. <view class="right">
  30. {{info.vin||'暂无'}}
  31. </view>
  32. </view>
  33. </view>
  34. <view class="text">档案手续</view>
  35. <view class="two_2">
  36. <view class="table_column">
  37. <view class="left">
  38. 表显里程
  39. </view>
  40. <view class="right">
  41. {{info.mileage||'暂无'}}
  42. </view>
  43. </view>
  44. <view class="table_column">
  45. <view class="left">
  46. 排放标准
  47. </view>
  48. <view class="right">
  49. {{getDict(info.emission, 'emission')}}
  50. </view>
  51. </view>
  52. <view class="table_column">
  53. <view class="left">
  54. 首次上牌
  55. </view>
  56. <view class="right">
  57. {{info.f_time||'暂无'}}
  58. </view>
  59. </view>
  60. <view class="table_column">
  61. <view class="left">
  62. 过户次数
  63. </view>
  64. <view class="right">
  65. {{info.number||'0'}}次
  66. </view>
  67. </view>
  68. <view class="table_column">
  69. <view class="left">
  70. 车源地
  71. </view>
  72. <view class="right">
  73. {{info.place||'暂无'}}
  74. </view>
  75. </view>
  76. <view class="table_column">
  77. <view class="left">
  78. 车牌地
  79. </view>
  80. <view class="right">
  81. {{info.license||'暂无'}}
  82. </view>
  83. </view>
  84. <view class="table_column">
  85. <view class="left">
  86. 外观颜色
  87. </view>
  88. <view class="right">
  89. {{info.out_color||'暂无'}}
  90. </view>
  91. </view>
  92. <view class="table_column">
  93. <view class="left">
  94. 内饰颜色
  95. </view>
  96. <view class="right">
  97. {{info.in_color||'暂无'}}
  98. </view>
  99. </view>
  100. <view class="table_column">
  101. <view class="left">
  102. 车辆使用性质
  103. </view>
  104. <view class="right">
  105. {{getDict(info.use_type, 'use_type')}}
  106. </view>
  107. </view>
  108. </view>
  109. <view class="text">功能配置</view>
  110. <view class="two_2">
  111. <view class="table_column">
  112. <view class="left">
  113. 能源类型
  114. </view>
  115. <view class="right">
  116. {{getDict(info.energy, 'energy')}}
  117. </view>
  118. </view>
  119. <view class="table_column">
  120. <view class="left">
  121. 排量
  122. </view>
  123. <view class="right">
  124. {{getDict(info.displacement, 'displacement')}}
  125. </view>
  126. </view>
  127. <view class="table_column">
  128. <view class="left">
  129. 级别
  130. </view>
  131. <view class="right">
  132. {{getDict(info.level, 'level')}}
  133. </view>
  134. </view>
  135. <view class="table_column">
  136. <view class="left">
  137. 变速箱
  138. </view>
  139. <view class="right">
  140. {{getDict(info.type, 'type')}}
  141. </view>
  142. </view>
  143. <view class="table_column">
  144. <view class="left">
  145. 驱动方式
  146. </view>
  147. <view class="right">
  148. {{getDict(info.drive, 'drive')}}
  149. </view>
  150. </view>
  151. <view class="table_column">
  152. <view class="left">
  153. 座位数
  154. </view>
  155. <view class="right">
  156. {{getDict(info.set, 'set')}}
  157. </view>
  158. </view>
  159. </view>
  160. <u-divider text="以上为全部内容"></u-divider>
  161. </view>
  162. </view>
  163. </template>
  164. <script setup lang="ts">
  165. import { getCurrentInstance, computed, ref } from 'vue';
  166. //该依赖已内置不需要单独安装
  167. import { onLoad } from "@dcloudio/uni-app";
  168. // 请求接口
  169. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  170. // openid
  171. const openid = computed(() => {
  172. return uni.getStorageSync('openid');
  173. })
  174. // 基本信息
  175. const config = ref({});
  176. const id = ref('');
  177. const text = ref('以下内容为商家填写 购车前请谨慎核对,以实际情况为准');
  178. const info = ref({});
  179. // 字典表
  180. const useTypeList = ref([]);
  181. const boxTypeList = ref([]);
  182. const structureList = ref([]);
  183. const emissionList = ref([]);
  184. const energyList = ref([]);
  185. const displacementList = ref([]);
  186. const setList = ref([]);
  187. const levelList = ref([]);
  188. const driveList = ref([]);
  189. onLoad(async (options) => {
  190. id.value = options && options.id
  191. await searchConfig();
  192. await searchOther();
  193. await search();
  194. })
  195. // 查询其他信息
  196. const searchOther = async () => {
  197. let res;
  198. // 车辆使用性质
  199. res = await $api(`dictData`, 'GET', { code: 'useType', is_use: '0' });
  200. if (res.errcode === 0) useTypeList.value = res.data;
  201. // 变速箱
  202. res = await $api(`dictData`, 'GET', { code: 'boxType', is_use: '0' });
  203. if (res.errcode === 0) boxTypeList.value = res.data;
  204. // 车身结构
  205. res = await $api(`dictData`, 'GET', { code: 'structure', is_use: '0' });
  206. if (res.errcode === 0) structureList.value = res.data;
  207. // 排放标准
  208. res = await $api(`dictData`, 'GET', { code: 'emission', is_use: '0' });
  209. if (res.errcode === 0) emissionList.value = res.data;
  210. // 能源类型
  211. res = await $api(`dictData`, 'GET', { code: 'energy', is_use: '0' });
  212. if (res.errcode === 0) energyList.value = res.data;
  213. // 排量
  214. res = await $api(`dictData`, 'GET', { code: 'displacement', is_use: '0' });
  215. if (res.errcode === 0) displacementList.value = res.data;
  216. // 座椅
  217. res = await $api(`dictData`, 'GET', { code: 'set', is_use: '0' });
  218. if (res.errcode === 0) setList.value = res.data;
  219. // 车辆级别
  220. res = await $api(`dictData`, 'GET', { code: 'level', is_use: '0' });
  221. if (res.errcode === 0) levelList.value = res.data;
  222. // 驱动方式
  223. res = await $api(`dictData`, 'GET', { code: 'drive', is_use: '0' });
  224. if (res.errcode === 0) driveList.value = res.data;
  225. };
  226. // config信息
  227. const searchConfig = async () => {
  228. config.value = uni.getStorageSync('config');
  229. };
  230. // 查询
  231. const search = async () => {
  232. if (id.value) {
  233. const res = await $api(`car/${id.value}`, 'GET', {});
  234. if (res.errcode === 0) {
  235. info.value = res.data
  236. } else {
  237. uni.showToast({
  238. title: res.errmsg || '',
  239. icon: 'error',
  240. });
  241. }
  242. }
  243. };
  244. // 数据处理
  245. const getDict = (data, model) => {
  246. let list;
  247. switch (model) {
  248. case 'use_type':
  249. list = useTypeList.value;
  250. break;
  251. case 'type':
  252. list = boxTypeList.value;
  253. break;
  254. case 'structure':
  255. list = structureList.value;
  256. break;
  257. case 'emission':
  258. list = emissionList.value;
  259. break;
  260. case 'energy':
  261. list = energyList.value;
  262. break;
  263. case 'displacement':
  264. list = displacementList.value;
  265. break;
  266. case 'set':
  267. list = setList.value;
  268. break;
  269. case 'level':
  270. list = levelList.value;
  271. break;
  272. case 'drive':
  273. list = driveList.value;
  274. break;
  275. default:
  276. break;
  277. }
  278. if (!list) return;
  279. const res = list.find((f) => f.value == data);
  280. return res?.label || '暂无';
  281. };
  282. </script>
  283. <style lang="scss" scoped>
  284. .content {
  285. display: flex;
  286. flex-direction: column;
  287. width: 100vw;
  288. height: 100vh;
  289. .two {
  290. padding: 2vw;
  291. .two_1 {
  292. margin: 2vw;
  293. .table_column {
  294. display: flex;
  295. font-size: var(--font12Size);
  296. .left {
  297. width: 25vw;
  298. text-align: center;
  299. padding: 2vw;
  300. border: 1px solid #e7e6e4;
  301. }
  302. .right {
  303. width: 65vw;
  304. padding: 2vw;
  305. border: 1px solid #e7e6e4;
  306. background-color: #f4f4f5;
  307. }
  308. }
  309. }
  310. .text {
  311. margin: 2vw;
  312. font-size: var(--font16Size);
  313. font-weight: bold;
  314. }
  315. .two_2 {
  316. margin: 2vw;
  317. display: flex;
  318. flex-wrap: wrap;
  319. .table_column {
  320. display: flex;
  321. font-size: var(--font12Size);
  322. width: 46vw;
  323. .left {
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. padding: 2vw;
  328. border: 1px solid #e7e6e4;
  329. width: 20vw;
  330. }
  331. .right {
  332. padding: 2vw;
  333. border: 1px solid #e7e6e4;
  334. background-color: #f4f4f5;
  335. width: 24vw;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. </style>