Commit 42b352e046625c04ed86581788d4f370b43fbcbe

Authored by lxf
1 parent e65252c9

fix: 货源

common/api.js
... ... @@ -158,6 +158,21 @@ module.exports = (vm) => {
158 158 },
159 159 freightMaRecord: {
160 160 add: params => vm.$u.http.post( freightAPI + '/freightMaRecord/add', params,{custom: {toast:true}}), // 出发到达记录日志
  161 + },
  162 + // 货源管理v2版本
  163 + freightGoodsSourceV2:{
  164 + page: params => vm.$u.http.get( freightAPI + '/freightGoodsSourceV2/page', {params}),
  165 + biddingPage: params => vm.$u.http.get( freightAPI + '/freightGoodsSourceV2/biddingPage', {params}),
  166 + biddingCount: params => vm.$u.http.get( freightAPI + '/freightGoodsSourceV2/biddingCount', {params}),
  167 + count: params => vm.$u.http.get( freightAPI + '/freightGoodsSourceV2/count', {params}),
  168 + getDetail: params => vm.$u.http.get( freightAPI + '/freightGoodsSourceV2/getDetail', {params}),
  169 + add: data => vm.$u.http.post( freightAPI + '/freightGoodsSourceV2/add', data,{custom: {toast:true}}),
  170 + modify: data => vm.$u.http.post( freightAPI + '/freightGoodsSourceV2/modify', data),
  171 + complete: data => vm.$u.http.post( freightAPI + '/freightGoodsSourceV2/complete', data),
  172 + cancel: data => vm.$u.http.post( freightAPI + '/freightGoodsSourceV2/cancel', data),
  173 + cancelBidding: data => vm.$u.http.post( freightAPI + '/freightGoodsSourceV2/cancelBidding', data),
  174 + delete: data => vm.$u.http.post( freightAPI + '/freightGoodsSourceV2/delete', data),
  175 + buildMaQrcode: params => vm.$u.http.get( freightAPI + '/freightGoodsSourceV2/buildMaQrcode', {params}),
161 176 }
162 177 };
163 178 }
... ...
pages.json
... ... @@ -28,6 +28,18 @@
28 28 "navigationBarTitleText": "创建货源"
29 29 }
30 30 },{
  31 + "path": "pages/goodSource/detail",
  32 + "style": {
  33 + "navigationBarTitleText": "飞牛货源详情",
  34 + "enablePullDownRefresh": true
  35 + }
  36 + },{
  37 + "path": "pages/goodSource/grab-record",
  38 + "style": {
  39 + "navigationBarTitleText": "飞牛货源抢单记录",
  40 + "enablePullDownRefresh": true
  41 + }
  42 + },{
31 43 "path": "pages/order/index",
32 44 "style": {
33 45 "navigationBarTitleText": "订单",
... ...
pages/goodSource/add.vue
... ... @@ -8,24 +8,24 @@
8 8 </u-form-item>
9 9 <u-form-item label="开始时间" @click="showLoadTime1 = true" required>
10 10 <u-datetime-picker :show="showLoadTime1" :value="loadTimeDef1" @cancel="showLoadTime1 = false" @close="showLoadTime2 = false" @confirm="loadTimeFormat1"></u-datetime-picker>
11   - <u-input v-model="form.loadTime" border="none" suffix-icon="arrow-right" placeholder="请选择时间" disabledColor="#ffffff" disabled />
  11 + <u-input v-model="form.startTime" border="none" suffix-icon="arrow-right" placeholder="请选择时间" disabledColor="#ffffff" disabled />
12 12 </u-form-item>
13 13 <u-form-item label="结束时间" @click="showLoadTime2 = true" required>
14 14 <u-datetime-picker :show="showLoadTime2" :value="loadTimeDef2" @cancel="showLoadTime2 = false" @close="showLoadTime2 = false" @confirm="loadTimeFormat2"></u-datetime-picker>
15   - <u-input v-model="form.loadTime" border="none" suffix-icon="arrow-right" placeholder="请选择时间" disabledColor="#ffffff" disabled />
  15 + <u-input v-model="form.endTime" border="none" suffix-icon="arrow-right" placeholder="请选择时间" disabledColor="#ffffff" disabled />
16 16 </u-form-item>
17 17 </view>
18 18 <view class="card">
19 19 <u-form-item label="装货地址" required @click="() => selectAddress(0)">
20   - <u-input :value="form.waypoints[0].address" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
  20 + <u-input :value="waypoints[0].address" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
21 21 </u-form-item>
22 22 <u-form-item label="卸货地址" required @click="() => selectAddress(1)">
23   - <u-input v-model="form.waypoints[1].address" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
  23 + <u-input v-model="waypoints[1].address" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
24 24 </u-form-item>
25 25 </view>
26 26 <view class="card">
27   - <u-form-item label="货物类型" required @click="choseGoodsType">
28   - <u-input :value="form.goodsTypeName" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
  27 + <u-form-item label="货物类型" required @click="choseGoodsName">
  28 + <u-input :value="form.goodsName" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
29 29 </u-form-item>
30 30 <u-form-item label="需求车型" required @click="specificationVisible = true">
31 31 <u-input :value="formatSpecification" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
... ... @@ -36,28 +36,32 @@
36 36 </view>
37 37 <view class="card">
38 38 <u-form-item label="计价方式" @click="chosePriceType">
39   - <u-input v-model="form.priceType" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
40   - </u-form-item>
41   - <u-form-item label="货物总量" required>
42   - <u-input v-model="form.goodsValue" border="none" type="digit" placeholder="请输入">
43   - <template slot="suffix">吨</template>
44   - </u-input>
45   - </u-form-item>
46   - <u-form-item label="运输单价">
47   - <u-input v-model="form.goodsValue" border="none" type="digit" placeholder="请输入">
48   - <template slot="suffix">元/吨</template>
49   - </u-input>
50   - </u-form-item>
51   - <u-form-item label="需求车数" required>
52   - <u-input v-model="form.goodsValue" border="none" type="digit" placeholder="请输入">
53   - <template slot="suffix">吨</template>
54   - </u-input>
55   - </u-form-item>
56   - <u-form-item label="总运费">
57   - <u-input v-model="form.goodsValue" border="none" type="digit" placeholder="请输入">
58   - <template slot="suffix">元/吨</template>
59   - </u-input>
  39 + <u-input v-model="form.priceTypeName" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
60 40 </u-form-item>
  41 + <template v-if="form.priceType === 'TON'">
  42 + <u-form-item label="货物总量" required>
  43 + <u-input v-model="form.goodsWeight" border="none" type="digit" placeholder="请输入">
  44 + <template slot="suffix">吨</template>
  45 + </u-input>
  46 + </u-form-item>
  47 + <u-form-item label="运输单价">
  48 + <u-input v-model="form.weightUnitPrice" border="none" type="digit" placeholder="请输入">
  49 + <template slot="suffix">元/吨</template>
  50 + </u-input>
  51 + </u-form-item>
  52 + </template>
  53 + <template v-if="form.priceType === 'VEHICLE'">
  54 + <u-form-item label="需求车数" required>
  55 + <u-input v-model="form.vehicleNumber" border="none" type="number" placeholder="请输入">
  56 + <template slot="suffix">车</template>
  57 + </u-input>
  58 + </u-form-item>
  59 + <u-form-item label="总运费">
  60 + <u-input v-model="form.vehicleUnitPrice" border="none" type="digit" placeholder="请输入">
  61 + <template slot="suffix">元/车</template>
  62 + </u-input>
  63 + </u-form-item>
  64 + </template>
61 65 </view>
62 66 <view class="card" @tap="more = !more">
63 67 <view class="more-action">
... ... @@ -70,13 +74,13 @@
70 74 </view>
71 75 <template v-if="more">
72 76 <view class="card">
73   - <u-form-item label="订单备注" @click="selectRemark">
74   - <u-input v-model="form.remark" border="none" suffix-icon="arrow-right" placeholder="请输入,选填" disabledColor="#ffffff" disabled />
  77 + <u-form-item label="订单备注">
  78 + <u-input v-model="form.remark" border="none" suffix-icon="arrow-right" placeholder="请输入,选填" />
75 79 </u-form-item>
76 80 </view>
77 81 <view class="card">
78 82 <u-form-item label="报价联系人">
79   - <u-input v-model="form.contactName" border="none" placeholder="请输入,选填" />
  83 + <u-input v-model="form.contactUser" border="none" placeholder="请输入,选填" />
80 84 </u-form-item>
81 85 <u-form-item label="报价联系电话">
82 86 <u-input v-model="form.contactMobile" border="none" placeholder="请输入,选填" />
... ... @@ -113,6 +117,7 @@
113 117 </template>
114 118 <script>
115 119 import { urlParam } from '@/utils/param';
  120 +import { formatLngLat } from '@/utils/format-value';
116 121 import { mapGetters } from 'vuex';
117 122 import dayjs from 'dayjs';
118 123 export default {
... ... @@ -120,47 +125,42 @@ export default {
120 125 data() {
121 126 return {
122 127 loading: false,
123   - showModal: '',
124   - showModal2: '',
125   - content: '',
126   - content2: '',
127   - carNumber: '',
128 128 showLoadTime1: false,
129 129 showLoadTime2: false,
130 130 loadTimeDef1: new Date(),
131 131 loadTimeDef2: new Date(),
132   - showCar: false,
133   - typeCar: '',
134 132 more: false,
135   - radioList: [],
  133 + waypoints: [{}, {}],
136 134 form: {
  135 + code: '',
137 136 projectCode: '',
138   - loadTime: '',
139 137 projectName: '',
140   - customerOrderCode: '',
  138 + startTime: '',
  139 + endTime: '',
  140 + startCityCode: '',
  141 + startAreaCode: '',
  142 + startAddress: '',
  143 + startLng: '',
  144 + startLat: '',
  145 + endCityCode: '',
  146 + endAreaCode: '',
  147 + endAddress: '',
  148 + endLng: '',
  149 + endLat: '',
  150 + distance: '',
  151 + specification: '',
  152 + vanType: '',
141 153 goodsName: '',
142   - goodsValue: '',
143   - goodsPiece: '',
  154 + priceType: 'VEHICLE', // VEHICLE, TON
  155 + priceTypeName: '',
144 156 goodsWeight: '',
145   - goodsVolume: '',
146   - mobile: '',
147   - driverId: '',
148   - driverName: '',
149   - licenseNumber: '',
150   - trailerNumber: '',
151   - paidAmount: '',
152   - oilAmount: '',
153   - prepaidAmount: '',
154   - deliveryAmount: '',
155   - balancePaymentAmount: '',
156   - distance: '',
157   - allowDriverSeeFreightAmountNode: '',
158   - waypoints: [{}, {}],
  157 + weightUnitPrice: '',
  158 + vehicleNumber: '',
  159 + vehicleUnitPrice: '',
  160 + contactUser: '',
  161 + contactMobile: '',
159 162 remark: '',
160 163 },
161   - payeeModel: {},
162   - driverObj: {}, //司机信息
163   - currentFreight: {},
164 164 vanTypeVisible: false,
165 165 choseVanTypeList: [],
166 166 specificationVisible: false,
... ... @@ -168,7 +168,7 @@ export default {
168 168 };
169 169 },
170 170 computed: {
171   - ...mapGetters(['dictList', 'dictValue']),
  171 + ...mapGetters(['dictList', 'dictValue', 'userInfo']),
172 172 // 箱型
173 173 vanTypeList() {
174 174 return [...this.dictList('VEHICLE_COMPARTMENT_TYPE'), { valueCode: 'ALL', valueName: '不限' }];
... ... @@ -203,49 +203,54 @@ export default {
203 203 onLoad(option) {
204 204 if (option.code) {
205 205 uni.setNavigationBarTitle({ title: '修改货源' });
  206 + this.initData(option.code);
  207 + }
  208 + this.form = {
  209 + ...this.form,
  210 + contactUser: this.userInfo.name,
  211 + contactMobile: this.userInfo.mobile,
  212 + };
  213 + if (this.form.priceType) {
  214 + this.form.priceTypeName = this.dictValue('FREIGHT_GOODS_SOURCE_PRICE_TYPE', this.form.priceType);
206 215 }
207 216 },
208 217 methods: {
209 218 initData(code) {
210   - uni.$u.api.freightOrder.getDetail({ code }).then(res => {
  219 + uni.$u.api.freightGoodsSourceV2.getDetail({ code }).then(res => {
211 220 let detail = res.result || {};
212   - ['goodsName', 'waypoints', 'allowDriverSeeFreightAmountNode', 'projectCode', 'projectName', 'remark', 'goodsPiece', 'goodsWeight', 'goodsVolume'].forEach(key => {
  221 + Object.keys(this.form).forEach(key => {
213 222 this.form[key] = detail[key];
214 223 });
215   - if (detail.vehicleLicenseNum) {
216   - this.typeCar = 'licenseNumber';
217   - this.form.licenseNumber = detail.vehicleLicenseNum;
218   - this.vehicleChange(detail.vehicleLicenseNum);
219   - }
220   - if (detail.trailerLicenseNum) {
221   - setTimeout(() => {
222   - this.typeCar = 'trailerNumber';
223   - this.form.trailerNumber = detail.trailerLicenseNum;
224   - this.vehicleChange(detail.trailerLicenseNum);
225   - }, 500);
226   - }
227   - this.form.mobile = detail.driverMobile;
228   - this.form.driverId = detail.driverId;
229   - this.form.driverName = detail.driverName;
230   - this.form.driverMobile = detail.driverMobile;
231   - this.payeeModel = {
232   - driverId: detail.payeeId,
233   - dueBank: detail.dueBank,
234   - openingBank: detail.openingBank,
235   - dueBankCardNo: detail.dueBankCardNo,
  224 + let startAddressObj = {
  225 + address: detail.startAddress,
  226 + areaCode: detail.startAreaCode,
  227 + cityCode: detail.startCityCode,
  228 + lng: detail.startLng,
  229 + lat: detail.startLat,
236 230 };
237   - this.$refs.payee.setItem(this.payeeModel);
238   - this.computedDistance();
239   - });
240   - },
241   - selectRemark() {
242   - uni.$once('select-remark', remark => {
243   - this.form.remark = remark || '';
244   - });
245   - uni.navigateTo({
246   - url: `/pages/order/select-remark`,
  231 + let endAddressObj = {
  232 + address: detail.endAddress,
  233 + areaCode: detail.endAreaCode,
  234 + cityCode: detail.endCityCode,
  235 + lng: detail.endLng,
  236 + lat: detail.endLat,
  237 + };
  238 + this.waypoints = [startAddressObj, endAddressObj];
  239 + this.choseVanTypeList = detail.vanType.split(',');
  240 + this.choseSpecificationList = detail.specification.split(',');
  241 + if (this.form.priceType) {
  242 + this.form.priceTypeName = this.dictValue('FREIGHT_GOODS_SOURCE_PRICE_TYPE', this.form.priceType);
  243 + }
247 244 });
248 245 },
  246 + // selectRemark() {
  247 + // uni.$once('select-remark', remark => {
  248 + // this.form.remark = remark || '';
  249 + // });
  250 + // uni.navigateTo({
  251 + // url: `/pages/order/select-remark`,
  252 + // });
  253 + // },
249 254 choseProjectCode() {
250 255 uni.$once('select-common', option => {
251 256 this.form.projectCode = option.code;
... ... @@ -274,7 +279,7 @@ export default {
274 279 this.choseVanTypeList.push(code);
275 280 }
276 281 }
277   - this.form.vanType = this.choseVanTypeList.join('/');
  282 + this.form.vanType = this.choseVanTypeList.join(',');
278 283 },
279 284 // 选择车型
280 285 choseSpecification(code) {
... ... @@ -288,7 +293,19 @@ export default {
288 293 this.choseSpecificationList.push(code);
289 294 }
290 295 }
291   - this.form.specification = this.choseSpecificationList.join('/');
  296 + this.form.specification = this.choseSpecificationList.join(',');
  297 + },
  298 + chosePriceType() {
  299 + uni.$once('select-dict', option => {
  300 + this.form.priceType = option.valueCode;
  301 + this.form.priceTypeName = option.valueName;
  302 + });
  303 + uni.navigateTo({
  304 + url: `/pages/global/search-dict${urlParam({
  305 + title: '计价方式',
  306 + dict: 'FREIGHT_GOODS_SOURCE_PRICE_TYPE',
  307 + })}`,
  308 + });
292 309 },
293 310 choseGoodsName() {
294 311 uni.$once('select-common', option => {
... ... @@ -305,75 +322,96 @@ export default {
305 322 });
306 323 },
307 324 selectAddress(index) {
308   - uni.$once('select-detail', location => {
309   - let station = {
310   - lng: location.lng,
311   - lat: location.lat,
312   - provinceCode: location.provinceCode,
313   - provinceName: location.provinceName,
314   - cityCode: location.cityCode,
315   - cityName: location.cityName,
316   - areaCode: location.areaCode,
317   - areaName: location.areaName,
318   - address: (location.provinceName || '') + (location.cityName || '') + (location.areaName || '') + (location.address || ''),
319   - };
320   - let waypoints = index === 0 ? [station, this.form.waypoints[1]] : [this.form.waypoints[0], station];
321   - this.form = {
322   - ...this.form,
323   - waypoints,
324   - };
325   - this.computedDistance();
326   - });
327   - let type = index === 0 ? 'getStartLatestAddress' : 'getEndLatestAddress';
328   - let lat = this.form.waypoints[index].lat ? Number(this.form.waypoints[index].lat) : '';
329   - let lng = this.form.waypoints[index].lng ? Number(this.form.waypoints[index].lng) : '';
330   - uni.navigateTo({ url: `/pages/global/search-address?type=${type}&lng=${lng}&lat=${lat}` });
  325 + let lat = this.waypoints[index].lat ? Number(this.waypoints[index].lat) : '';
  326 + let lng = this.waypoints[index].lng ? Number(this.waypoints[index].lng) : '';
  327 + wx.chooseLocation({
  328 + latitude: lat ? Number(lat) : undefined,
  329 + longitude: lng ? Number(lng) : undefined,
  330 + })
  331 + .then(res => {
  332 + return formatLngLat({ lng: res.longitude, lat: res.latitude });
  333 + })
  334 + .then(location => {
  335 + let station = {
  336 + lng: location.lng,
  337 + lat: location.lat,
  338 + provinceCode: location.provinceCode,
  339 + provinceName: location.provinceName,
  340 + cityCode: location.cityCode,
  341 + cityName: location.cityName,
  342 + areaCode: location.areaCode,
  343 + areaName: location.areaName,
  344 + address: (location.provinceName || '') + (location.cityName || '') + (location.areaName || '') + (location.address || ''),
  345 + };
  346 + this.waypoints = index === 0 ? [station, this.waypoints[1]] : [this.waypoints[0], station];
  347 + this.computedDistance();
  348 + });
  349 + // uni.$once('select-detail', location => {
  350 + // let station = {
  351 + // lng: location.lng,
  352 + // lat: location.lat,
  353 + // provinceCode: location.provinceCode,
  354 + // provinceName: location.provinceName,
  355 + // cityCode: location.cityCode,
  356 + // cityName: location.cityName,
  357 + // areaCode: location.areaCode,
  358 + // areaName: location.areaName,
  359 + // address: (location.provinceName || '') + (location.cityName || '') + (location.areaName || '') + (location.address || ''),
  360 + // };
  361 + // this.waypoints = index === 0 ? [station, this.waypoints[1]] : [this.waypoints[0], station];
  362 + // });
  363 + // let type = index === 0 ? 'getStartLatestAddress' : 'getEndLatestAddress';
  364 + // let lat = this.waypoints[index].lat ? Number(this.waypoints[index].lat) : '';
  365 + // let lng = this.waypoints[index].lng ? Number(this.waypoints[index].lng) : '';
  366 + // uni.navigateTo({ url: `/pages/global/search-address?type=${type}&lng=${lng}&lat=${lat}` });
  367 + },
  368 + computedDistance() {
  369 + if (this.waypoints[0].lng && this.waypoints[1].lng) {
  370 + uni.$u.api.freightOrder
  371 + .getDistance({
  372 + startLat: this.waypoints[0].lat,
  373 + startLng: this.waypoints[0].lng,
  374 + endLat: this.waypoints[1].lat,
  375 + endLng: this.waypoints[1].lng,
  376 + })
  377 + .then(res => {
  378 + this.form.distance = res.result;
  379 + });
  380 + }
331 381 },
332   -
333 382 loadTimeFormat1({ value }) {
334   - this.form.loadTime = dayjs(value).format('YYYY-MM-DD HH:mm:ss');
  383 + this.form.startTime = dayjs(value).format('YYYY-MM-DD HH:mm:ss');
335 384 this.showLoadTime1 = false;
336 385 },
337 386 loadTimeFormat2({ value }) {
338   - this.form.loadTime = dayjs(value).format('YYYY-MM-DD HH:mm:ss');
  387 + this.form.endTime = dayjs(value).format('YYYY-MM-DD HH:mm:ss');
339 388 this.showLoadTime2 = false;
340 389 },
341   - choseGoodsType() {
342   - uni.$once('select-dict', option => {
343   - this.searchForm.goodsType = option.valueCode;
344   - this.searchForm.goodsTypeName = option.valueName;
345   - });
346   - uni.navigateTo({
347   - url: `/pages/global/search-dict${urlParam({
348   - title: '货物类型',
349   - dict: 'ONLINE_FREIGHT_ORDER_PAY_STATUS',
350   - })}`,
351   - });
352   - },
353   - chosePriceType() {
354   - uni.$once('select-dict', option => {
355   - this.searchForm.goodsType = option.valueCode;
356   - this.searchForm.goodsTypeName = option.valueName;
357   - });
358   - uni.navigateTo({
359   - url: `/pages/global/search-dict${urlParam({
360   - title: '计价方式',
361   - dict: 'ONLINE_FREIGHT_ORDER_PAY_STATUS',
362   - })}`,
363   - });
364   - },
365 390 submitAddFun() {
366 391 if (this.loading) return;
367 392 this.loading = true;
368   - let totalAmount = Number(this.form.paidAmount || 0) + Number(this.form.serviceAmount || 0) + Number(this.form.securityServiceAmount || 0);
369   - uni.$u.api.freightOrder
370   - .add({ ...this.form, totalAmount, payeeId: this.payeeModel.driverId })
  393 + let startAddressObj = {
  394 + startCityCode: this.waypoints[0].cityCode,
  395 + startAreaCode: this.waypoints[0].areaCode,
  396 + startAddress: this.waypoints[0].address,
  397 + startLng: this.waypoints[0].lng,
  398 + startLat: this.waypoints[0].lat,
  399 + };
  400 + let endAddressObj = {
  401 + endCityCode: this.waypoints[1].cityCode,
  402 + endAreaCode: this.waypoints[1].areaCode,
  403 + endAddress: this.waypoints[1].address,
  404 + endLng: this.waypoints[1].lng,
  405 + endLat: this.waypoints[1].lat,
  406 + };
  407 + let opType = this.form.code ? 'modify' : 'add';
  408 + uni.$u.api.freightGoodsSourceV2[opType]({ ...this.form, ...startAddressObj, ...endAddressObj })
371 409 .then(res => {
372 410 if (res.success) {
373 411 this.form = {};
374   - uni.showToast({ title: '下单成功', icon: 'none' });
  412 + uni.showToast({ title: '成功', icon: 'none' });
375 413 this.getOpenerEventChannel().emit('refreshData');
376   - setTimeout(() => uni.navigateBack(), 500);
  414 + setTimeout(() => uni.navigateBack(), 1000);
377 415 }
378 416 this.loading = false;
379 417 })
... ...
pages/goodSource/card.vue
... ... @@ -4,13 +4,13 @@
4 4 <view class="title">
5 5 <view class="order-no">
6 6 <field-copy :value="item.code" v-if="item.code">{{ item.code }} </field-copy>
7   - <view class="image" @click.stop="qrShow">
  7 + <view v-if="!onlyShow" class="image" @click.stop="qrShow">
8 8 <image style="height: 30upx; width: 30upx" src="/static/qr.png"></image>
9 9 </view>
10 10 </view>
11 11 <view style="display: flex; align-items: center">
12   - <render-dict v-if="item.status" class="status" :style="{ color: colorMap[item.status] }" dict="FREIGHT_ORDER_STATUS" :value="item.status"></render-dict>
13   - <u-icon name="arrow-right" size="14"></u-icon>
  12 + <render-dict v-if="item.status" class="status" :style="{ color: colorMap[item.status] }" dict="FREIGHT_GOODS_SOURCE_STATUS" :value="item.status"></render-dict>
  13 + <u-icon v-if="!onlyShow" name="arrow-right" size="14"></u-icon>
14 14 </view>
15 15 </view>
16 16 </view>
... ... @@ -24,14 +24,12 @@
24 24 <text>{{ item.customerName }}</text>
25 25 </view>
26 26 <view class="v-t">
27   - <text style="white-space: nowrap; overflow: hidden; color: #999; max-width: 50vw; text-overflow: ellipsis">
28   - {{ item.lineName }}
29   - </text>
  27 + <text style="white-space: nowrap; overflow: hidden; color: #999; max-width: 50vw; text-overflow: ellipsis"> {{ formatSpecification }}/{{ formatVanType }} </text>
30 28 </view>
31 29 </view>
32 30 <view class="info-line">
33 31 <view class="address">
34   - <view class="text">{{ item.startProvinceShortName || '' }}-{{ item.startCityShortName || '' }}</view>
  32 + <view class="text">{{ item.startProvinceName || '' }}-{{ item.startCityName || '' }}</view>
35 33 </view>
36 34 <view class="way">
37 35 <view class="w-text">{{ item.distance || 0 }}km</view>
... ... @@ -40,7 +38,7 @@
40 38 </view>
41 39 </view>
42 40 <view class="address">
43   - <view class="text">{{ item.endProvinceShortName || '' }}-{{ item.endCityShortName || '' }}</view>
  41 + <view class="text">{{ item.endProvinceName || '' }}-{{ item.endCityName || '' }}</view>
44 42 </view>
45 43 </view>
46 44 <view class="info-task">
... ... @@ -54,27 +52,34 @@
54 52 <view v-if="!onlyShow" class="info-operate">
55 53 <view class="task">
56 54 <text>
57   - 已抢单<text class="color-blue">{{ item.assignVehicleNumber }}</text> /待确认<text class="color-red">{{ item.waitConfirmNumber }}</text> /待指派<text class="color-red">{{
58   - item.waitAssignNumber
  55 + 已抢单<text class="color-blue">{{ item.biddingCount }}</text> /已指派<text class="color-green">{{ item.assignedCount }}</text> /待指派<text class="color-red">{{
  56 + item.waitAssignCount
59 57 }}</text>
60 58 </text>
61 59 </view>
62   - <view class="task-2"> 剩余{{ item.remainTonnage }}吨 </view>
  60 + <view v-if="item.priceType === 'TON'" class="task-2"> 剩余{{ item.remainGoodsWeight || item.goodsWeight }}吨 </view>
  61 + <view v-if="item.priceType === 'VEHICLE'" class="task-2"> 还需要{{ item.remainVehicleNumber || item.vehicleNumber }}车 </view>
63 62 </view>
64 63 </view>
65 64 <view v-if="!onlyShow" class="cc-operate">
66 65 <view class="price-box">
67   - <text class="com-price">{{ item.unitPrice || 200 }}</text
68   - ><text>元/吨</text>
  66 + <template v-if="item.priceType === 'TON'">
  67 + <text class="com-price">{{ item.weightUnitPrice }}</text>
  68 + 元/吨
  69 + </template>
  70 + <template v-if="item.priceType === 'VEHICLE'">
  71 + <text class="com-price">{{ item.vehicleUnitPrice }}</text>
  72 + 元
  73 + </template>
69 74 </view>
70 75 <view class="but-box">
71 76 <zb-tooltip placement="bottom" :visible="visible" @update:visible="e => (visible = e)">
72 77 <template #content>
73 78 <view class="more-action">
74   - <view @click="modifyGoodSource"> 修改货源 </view>
75   - <view @click="cancelGoodSource"> 取消货源 </view>
76   - <view @click="endGoodSource"> 结束找车 </view>
77   - <view @click="deleteGoodSource"> 删除货源 </view>
  79 + <view v-if="['MATCHING'].includes(item.status)" @click="modifyGoodSource"> 修改货源 </view>
  80 + <view v-if="['MATCHING', 'COMPLETED'].includes(item.status)" @click="cancelGoodSource"> 取消货源 </view>
  81 + <view v-if="['MATCHING'].includes(item.status)" @click="endGoodSource"> 结束找车 </view>
  82 + <view v-if="['CANCELLED'].includes(item.status)" @click="deleteGoodSource"> 删除货源 </view>
78 83 </view>
79 84 </template>
80 85 <view class="button">
... ... @@ -91,6 +96,7 @@
91 96 </view>
92 97 </template>
93 98 <script>
  99 +import { mapGetters } from 'vuex';
94 100 import FieldCopy from '@/components/field/field-copy.vue';
95 101 import ZbTooltip from '../../uni_modules/zb-tooltip/components/zb-tooltip/zb-tooltip.vue';
96 102 import page from '@/mixins/page';
... ... @@ -109,13 +115,39 @@ export default {
109 115 },
110 116 data() {
111 117 return {
112   - quoteMap: {
113   - FINDING: '#2673fb',
114   - ENDED: '#2b2a27',
115   - CANCEL: '#999999',
  118 + visible: false,
  119 + colorMap: {
  120 + MATCHING: '#2673fb',
  121 + COMPLETED: '#2b2a27',
  122 + CANCELLED: '#999999',
116 123 },
117 124 };
118 125 },
  126 + computed: {
  127 + ...mapGetters(['dictValue']),
  128 + formatVanType() {
  129 + let res = [];
  130 + for (let v of this.item.vanType.split(',')) {
  131 + if (v === 'ALL') {
  132 + res.push('不限');
  133 + } else {
  134 + res.push(this.dictValue('VEHICLE_COMPARTMENT_TYPE', v));
  135 + }
  136 + }
  137 + return res.join(',');
  138 + },
  139 + formatSpecification() {
  140 + let res = [];
  141 + for (let v of this.item.specification.split(',')) {
  142 + if (v === 'ALL') {
  143 + res.push('不限');
  144 + } else {
  145 + res.push(this.dictValue('VEHICLE_SPECIFICATION', v));
  146 + }
  147 + }
  148 + return res.join(',');
  149 + },
  150 + },
119 151 methods: {
120 152 qrShow() {
121 153 this.$emit('qrShow', this.item.code, this.item);
... ... @@ -127,7 +159,7 @@ export default {
127 159 },
128 160 // 抢单记录
129 161 toGrabPage() {
130   - uni.navigateTo({ url: `/pages/bulkOrder/bulk-order-grab-record?orderCode=${this.item.code}` });
  162 + uni.navigateTo({ url: `/pages/goodSource/grab-record?goodsSourceCode=${this.item.code}` });
131 163 },
132 164 modifyGoodSource() {
133 165 this.visible = false;
... ... @@ -170,6 +202,7 @@ export default {
170 202 flex-direction: row;
171 203 align-items: center;
172 204 justify-content: space-between;
  205 + padding: 0 16rpx;
173 206 .order-no {
174 207 display: flex;
175 208 align-items: center;
... ...
pages/goodSource/detail.vue 0 → 100644
... ... @@ -0,0 +1,431 @@
  1 +<template>
  2 + <Page name="good-source-detail" flank>
  3 + <template #content>
  4 + <card :item="form" :onlyShow="true"></card>
  5 + <view class="card">
  6 + <view class="card__item">
  7 + <view class="card__item_field">货物名称</view>
  8 + <view class="card__item_content">{{ form.goodsName || '' }}</view>
  9 + </view>
  10 + <view class="card__item" v-if="form.goodsWeight">
  11 + <view class="card__item_field">货物总量</view>
  12 + <view class="card__item_content">{{ form.goodsWeight || '' }}</view>
  13 + </view>
  14 + <view class="card__item" v-if="form.remainGoodsWeight">
  15 + <view class="card__item_field">货物剩余</view>
  16 + <view class="card__item_content">{{ form.remainGoodsWeight || '' }}</view>
  17 + </view>
  18 + <view class="card__item">
  19 + <view class="card__item_field">司机抢单</view>
  20 + <view class="card__item_content">
  21 + <text>
  22 + 已抢单<text class="color-blue">{{ form.biddingCount }}</text> /已指派<text class="color-red">{{ form.assignedCount }}</text> /待指派<text class="color-red">{{
  23 + form.waitAssignCount
  24 + }}</text>
  25 + </text>
  26 + </view>
  27 + </view>
  28 + <view class="card__item">
  29 + <view class="card__item_field">订单备注</view>
  30 + <view class="card__item_content">{{ form.remark || '' }}</view>
  31 + </view>
  32 + <view class="card__item">
  33 + <view class="card__item_field">货源联系人</view>
  34 + <view class="card__item_content">
  35 + <text>{{ form.contactUser || '' }} {{ form.contactMobile || '' }}</text>
  36 + </view>
  37 + </view>
  38 + <view class="card__item">
  39 + <view class="card__item_field">货源发布时间</view>
  40 + <view class="card__item_content">
  41 + <text>{{ form.releaseTime || '' }}</text>
  42 + </view>
  43 + </view>
  44 + </view>
  45 + <view class="card">
  46 + <view class="card__item">
  47 + <view class="card__item_field">需求车型</view>
  48 + <view class="card__item_content">{{ formatSpecification || '' }}</view>
  49 + </view>
  50 + <view class="card__item">
  51 + <view class="card__item_field">需求箱型</view>
  52 + <view class="card__item_content">{{ formatVanType || '' }}</view>
  53 + </view>
  54 + </view>
  55 + <view class="card">
  56 + <view class="card__item">
  57 + <view class="card__item_field">装货地址</view>
  58 + <view class="card__item_content"> {{ form.startProvinceName || '' }}{{ form.startCityName || '' }}{{ form.startAreaName || '' }}{{ form.startAddress || '' }} </view>
  59 + </view>
  60 + <view class="card__item">
  61 + <view class="card__item_field">司机抢单</view>
  62 + <view class="card__item_content">
  63 + <text>
  64 + 已抢单<text class="color-blue">{{ form.biddingCount }}</text> /已指派<text class="color-red">{{ form.assignedCount }}</text> /待指派<text class="color-red">{{
  65 + form.waitAssignCount
  66 + }}</text>
  67 + </text>
  68 + </view>
  69 + </view>
  70 + <view class="card__item">
  71 + <view class="card__item_field">订单备注</view>
  72 + <view class="card__item_content">{{ form.remark || '' }}</view>
  73 + </view>
  74 + <view class="card__item">
  75 + <view class="card__item_field">货源联系人</view>
  76 + <view class="card__item_content">
  77 + <text>{{ form.contactUser || '' }} {{ form.contactMobile || '' }}</text>
  78 + </view>
  79 + </view>
  80 + <view class="card__item">
  81 + <view class="card__item_field">货源发布时间</view>
  82 + <view class="card__item_content">
  83 + <text>{{ form.releaseTime || '' }}</text>
  84 + </view>
  85 + </view>
  86 + </view>
  87 + <view class="card">
  88 + <view class="card__item">
  89 + <view class="card__item_field">计价方式</view>
  90 + <view class="card__item_content">
  91 + <render-dict dict="FREIGHT_GOODS_SOURCE_PRICE_TYPE" :value="form.priceType"></render-dict>
  92 + </view>
  93 + </view>
  94 + <template v-if="form.priceType === 'VEHICLE'">
  95 + <view class="card__item">
  96 + <view class="card__item_field">需求车数</view>
  97 + <view class="card__item_content">{{ form.vehicleNumber }}车</view>
  98 + </view>
  99 + <view class="card__item">
  100 + <view class="card__item_field">总运费</view>
  101 + <view class="card__item_content">{{ form.vehicleUnitPrice }}元/车</view>
  102 + </view>
  103 + </template>
  104 + <template v-if="form.priceType === 'TON'">
  105 + <view class="card__item">
  106 + <view class="card__item_field">货物总量</view>
  107 + <view class="card__item_content">{{ form.goodsWeight }}吨</view>
  108 + </view>
  109 + <view class="card__item">
  110 + <view class="card__item_field">运输单价</view>
  111 + <view class="card__item_content">{{ form.weightUnitPrice }}元/吨</view>
  112 + </view>
  113 + </template>
  114 + </view>
  115 + </template>
  116 + </Page>
  117 +</template>
  118 +<script>
  119 +import card from './card.vue';
  120 +import { mapGetters } from 'vuex';
  121 +import FieldCopy from '@/components/field/field-copy.vue';
  122 +export default {
  123 + name: 'good-source-detail',
  124 + components: { FieldCopy, card },
  125 + data() {
  126 + return {
  127 + form: {
  128 + id: '',
  129 + code: '',
  130 + customerName: '',
  131 + goodsName: '',
  132 + goodsWeight: '',
  133 + remainGoodsWeight: '',
  134 + biddingCount: '',
  135 + assignedCount: '',
  136 + waitAssignCount: '',
  137 + contactUser: '',
  138 + contactMobile: '',
  139 + releaseTime: '',
  140 + priceType: '',
  141 + vanType: '',
  142 + specification: '',
  143 + startProvinceShortName: '',
  144 + startProvinceName: '',
  145 + startCityShortName: '',
  146 + startCityName: '',
  147 + startAreaName: '',
  148 + startAddress: '',
  149 + startAddressLat: '',
  150 + startAddressLng: '',
  151 + endProvinceName: '',
  152 + endProvinceShortName: '',
  153 + endCityName: '',
  154 + endCityShortName: '',
  155 + endAreaName: '',
  156 + endAddress: '',
  157 + endAddressLat: '',
  158 + endAddressLng: '',
  159 + remark: '',
  160 + status: '',
  161 + distance: '',
  162 + vehicleNumber: '',
  163 + vehicleUnitPrice: '',
  164 + weightUnitPrice: '',
  165 + startTime: '',
  166 + endTime: '',
  167 + },
  168 + };
  169 + },
  170 + computed: {
  171 + ...mapGetters(['userInfo', 'dictList', 'dictValue']),
  172 + formatVanType() {
  173 + if (!this.form.code) return '';
  174 + let res = [];
  175 + for (let v of this.form.vanType.split(',')) {
  176 + if (v === 'ALL') {
  177 + res.push('不限');
  178 + } else {
  179 + res.push(this.dictValue('VEHICLE_COMPARTMENT_TYPE', v));
  180 + }
  181 + }
  182 + return res.join('/');
  183 + },
  184 + formatSpecification() {
  185 + if (!this.form.code) return '';
  186 + let res = [];
  187 + for (let v of this.form.specification.split(',')) {
  188 + if (v === 'ALL') {
  189 + res.push('不限');
  190 + } else {
  191 + res.push(this.dictValue('VEHICLE_SPECIFICATION', v));
  192 + }
  193 + }
  194 + return res.join('/');
  195 + },
  196 + },
  197 + onLoad(option) {
  198 + this.initData(option.code);
  199 + },
  200 + methods: {
  201 + initData(code = '') {
  202 + uni.$u.api.freightGoodsSourceV2
  203 + .getDetail({
  204 + code,
  205 + })
  206 + .then(res => {
  207 + this.form = res.result || {};
  208 + });
  209 + },
  210 + },
  211 +};
  212 +</script>
  213 +<style lang="scss">
  214 +.page-good-source-detail {
  215 + &__content {
  216 + .card {
  217 + background-color: $color-white;
  218 + color: $color-text;
  219 + padding: $padding-sm;
  220 + margin-bottom: $padding-sm;
  221 + border-radius: $radius-md;
  222 + box-shadow: $shadow-normal;
  223 + font-size: $font-md;
  224 + &__header {
  225 + display: flex;
  226 + align-items: center;
  227 + border-bottom: 1px solid $color-border;
  228 + padding-bottom: $padding-sm;
  229 + margin-bottom: $padding-sm;
  230 + justify-content: space-between;
  231 + .title {
  232 + width: 100%;
  233 + display: flex;
  234 + flex-direction: row;
  235 + align-items: center;
  236 + justify-content: space-between;
  237 + .order-no {
  238 + display: flex;
  239 + align-items: center;
  240 + }
  241 + .status {
  242 + font-weight: bold;
  243 + }
  244 + }
  245 + }
  246 + .count-line {
  247 + padding-top: $padding-sm;
  248 + margin-top: $padding-sm;
  249 + border-top: 1px solid $color-border;
  250 + display: flex;
  251 + justify-content: space-between;
  252 + .field {
  253 + font-weight: 400;
  254 + font-size: 28upx;
  255 + color: #999999;
  256 + text-align: left;
  257 + }
  258 + .number {
  259 + font-weight: 600;
  260 + font-size: 28upx;
  261 + color: #2b2a27;
  262 + text-align: center;
  263 + font-style: normal;
  264 + }
  265 + }
  266 + &__item {
  267 + display: flex;
  268 + font-size: 26upx;
  269 + color: #999999;
  270 + align-content: baseline;
  271 + &--warning {
  272 + height: 28rpx;
  273 + color: #f52723;
  274 + font-size: 20rpx;
  275 + margin-left: 20upx;
  276 + padding-left: 10upx;
  277 + padding-right: 10upx;
  278 + border-radius: 8upx;
  279 + border: 2rpx solid #f52723;
  280 + }
  281 + &--paying {
  282 + height: 28rpx;
  283 + color: #ff9339;
  284 + font-size: 20rpx;
  285 + margin-left: 20upx;
  286 + padding-left: 10upx;
  287 + padding-right: 10upx;
  288 + border-radius: 8upx;
  289 + border: 2rpx solid #ff9339;
  290 + }
  291 + &--success {
  292 + height: 28rpx;
  293 + color: #00b87a;
  294 + font-size: 20rpx;
  295 + margin-left: 20upx;
  296 + padding-left: 10upx;
  297 + padding-right: 10upx;
  298 + border-radius: 8upx;
  299 + border: 2rpx solid #00b87a;
  300 + }
  301 + &_field {
  302 + font-weight: 400;
  303 + font-size: 28upx;
  304 + color: #999999;
  305 + width: 170upx;
  306 + text-align: left;
  307 + }
  308 + &_content {
  309 + flex: 1;
  310 + font-weight: 400;
  311 + font-size: 28upx;
  312 + color: #2b2a27;
  313 + text-align: left;
  314 + font-style: normal;
  315 + display: flex;
  316 + justify-content: space-between;
  317 + overflow-wrap: anywhere;
  318 + &_text {
  319 + font-weight: 400;
  320 + font-size: 28upx;
  321 + text-align: left;
  322 + font-style: normal;
  323 + }
  324 + &_action {
  325 + font-weight: 400;
  326 + font-size: 28upx;
  327 + color: #2673fb;
  328 + text-align: right;
  329 + font-style: normal;
  330 + }
  331 + text + text {
  332 + margin-left: 10rpx;
  333 + }
  334 + .fee-service {
  335 + font-size: 26rpx;
  336 + }
  337 + }
  338 + }
  339 + .card__item + .card__item {
  340 + margin-top: $padding-sm;
  341 + }
  342 + &__steps {
  343 + margin-top: $padding-md;
  344 + .step {
  345 + &-item {
  346 + display: flex;
  347 + align-content: space-around;
  348 + font-size: $font-md;
  349 + .icon-waypoint {
  350 + font-size: $font-sm;
  351 + margin-right: $padding-sm;
  352 + height: $padding-md * 1.2;
  353 + width: $padding-md * 1.2;
  354 + min-width: $padding-md * 1.2;
  355 + }
  356 + .city {
  357 + font-weight: 500;
  358 + font-size: 32upx;
  359 + color: #2b2a27;
  360 + text-align: left;
  361 + font-style: normal;
  362 + }
  363 + .address {
  364 + margin-top: $padding-xs;
  365 + font-weight: 400;
  366 + font-size: 24upx;
  367 + color: #999999;
  368 + text-align: left;
  369 + font-style: normal;
  370 + text + text {
  371 + margin-left: 10rpx;
  372 + }
  373 + }
  374 + .address_action {
  375 + margin-top: $padding-xs;
  376 + font-weight: 400;
  377 + font-size: 24upx;
  378 + color: #2673fb;
  379 + text-align: left;
  380 + font-style: normal;
  381 + display: flex;
  382 + justify-content: space-between;
  383 + .u-icon {
  384 + display: inline-block !important;
  385 + }
  386 + }
  387 + &:not(:first-child) {
  388 + margin-top: $padding-md;
  389 + }
  390 + }
  391 + }
  392 + }
  393 + &_label {
  394 + }
  395 + .label {
  396 + font-weight: 500;
  397 + font-size: 32rpx;
  398 + color: #2b2a27;
  399 + }
  400 + .action {
  401 + font-size: 26rpx;
  402 + color: #007aff;
  403 + }
  404 + }
  405 + .detail-card {
  406 + margin-bottom: 24rpx;
  407 + background: $color-white;
  408 + padding: 24rpx 12rpx;
  409 + .view-item {
  410 + display: flex;
  411 + .view-item__label {
  412 + padding-left: 26rpx;
  413 + color: #999999;
  414 + width: 185rpx;
  415 + }
  416 + .view-item__value {
  417 + flex: 1;
  418 + color: #2b2a27;
  419 + padding-left: 32rpx;
  420 + padding-right: 5rpx;
  421 + display: flex;
  422 + flex-wrap: wrap;
  423 + }
  424 + }
  425 + .view-item:not(:last-child) {
  426 + margin-bottom: 30rpx;
  427 + }
  428 + }
  429 + }
  430 +}
  431 +</style>
... ...
pages/goodSource/grab-record.vue 0 → 100644
... ... @@ -0,0 +1,304 @@
  1 +<template>
  2 + <Page name="grab-record" flank>
  3 + <template #header>
  4 + <u-tabs :current="currentTab" :list="navbarList" @click="onScrollCheckChange" :scrollable="false" :disabled="loading" :activeStyle="{ color: '#1E7B6B' }"> </u-tabs>
  5 + <view class="line"></view>
  6 + <view class="quick-tag">
  7 + <view class="quick-tag-group">
  8 + <view class="quick-tag-item" :class="searchForm.projectCode ? 'active' : ''" @click="selectQuickTag({ key: 'projectCode', value: searchForm.projectCode })">
  9 + <text>{{ searchForm.projectName || '车牌号' }}</text>
  10 + <view class="sx-img">
  11 + <image v-if="searchForm.projectCode" class="sx-image" :src="formatImagePath('active-down')"></image>
  12 + <image v-else class="sx-image" :src="formatImagePath('down')"></image>
  13 + </view>
  14 + <view style="position: absolute; top: 0; right: 0">
  15 + <u-icon name="close"></u-icon>
  16 + </view>
  17 + </view>
  18 + <view class="quick-tag-item" :class="searchForm.startCityCode ? 'active' : ''" @click="selectQuickTag({ key: 'startCityCode', value: searchForm.startCityCode })">
  19 + <text>{{ searchForm.startCityName || '司机姓名' }}</text>
  20 + <view class="sx-img">
  21 + <image v-if="searchForm.startCityCode" class="sx-image" :src="formatImagePath('active-down')"></image>
  22 + <image v-else class="sx-image" :src="formatImagePath('down')"></image>
  23 + </view>
  24 + </view>
  25 + <view class="quick-tag-item" :class="searchForm.endCityCode ? 'active' : ''" @click="selectQuickTag({ key: 'endCityCode', value: searchForm.endCityCode })">
  26 + <text>{{ searchForm.endCityName || '司机手机' }}</text>
  27 + <view class="sx-img">
  28 + <image v-if="searchForm.endCityCode" class="sx-image" :src="formatImagePath('active-down')"></image>
  29 + <image v-else class="sx-image" :src="formatImagePath('down')"></image>
  30 + </view>
  31 + </view>
  32 + <view>抢单时间<zui-icon name="enter"></zui-icon></view>
  33 + </view>
  34 + </view>
  35 + </template>
  36 + <template #content>
  37 + <List ref="list" v-model="list" :loading.sync="loading" :api="searchAPI">
  38 + <view v-for="(form, index) in list" :key="index">
  39 + <view class="card">
  40 + <view-item title="订单号" :value="form.code">
  41 + <view style="flex: 1; display: flex; justify-content: space-between">
  42 + <view>{{ form.code }}</view>
  43 + <view :style="{ color: statusMap[form.status], display: 'flex' }">
  44 + <render-dict :value="form.status" dict="FREIGHT_GOODS_SOURCE_BIDDING_STATUS"></render-dict>
  45 + </view>
  46 + </view>
  47 + </view-item>
  48 + <view-item title="抢单司机">
  49 + <field-call :value="form.driverMobile">
  50 + <text>{{ form.driverName || '' }}{{ form.driverMobile || '' }}</text>
  51 + </field-call>
  52 + </view-item>
  53 + <view-item title="抢单车辆">
  54 + <text>
  55 + <render-dict :value="form.specification" dict="VEHICLE_SPECIFICATION"></render-dict>
  56 + </text>
  57 + <text>
  58 + <render-dict :value="form.vanType" dict="VEHICLE_COMPARTMENT_TYPE"></render-dict>
  59 + </text>
  60 + <text>/{{ form.vehicleLicenseNum }}</text>
  61 + <text v-if="form.trailerLicenseNum">/{{ form.trailerLicenseNum }}</text>
  62 + </view-item>
  63 + <view-item title="抢单时间" :value="form.biddingTime"></view-item>
  64 + <view-item title="装卸吨位">
  65 + <text>{{ form.biddingWeight || '--' }}吨</text>
  66 + </view-item>
  67 + <view class="buts">
  68 + <view>总运费:{{ form.paidAmount }}</view>
  69 + <template v-if="form.status === 'WAIT_ASSIGN'">
  70 + <zui-button class="zui-button" @click="(cancelCode = form.code), (cancelRemark = ''), (cancelShow = true)">取消</zui-button>
  71 + <zui-button class="zui-button" type="ghost" theme="primary" @click="() => toSubmit(form)">确认</zui-button>
  72 + </template>
  73 + </view>
  74 + </view>
  75 + </view>
  76 + </List>
  77 + <u-modal :show="cancelShow" title="取消原因" @cancel="cancelShow = false" @confirm="confirmCancel" showConfirmButton>
  78 + <u-input v-model="cancelRemark" placeholder="取消原因"></u-input>
  79 + </u-modal>
  80 + <popup-platenumber v-model="platenumberVisible" :plate="searchForm.vehicleCode" @cancel="platenumberVisible = false" @confirm="onPlatenumberSelect" />
  81 + </template>
  82 + </Page>
  83 +</template>
  84 +
  85 +<script>
  86 +import MIX_ORIGIN from '@/mixins/origin';
  87 +import { mapGetters } from 'vuex';
  88 +
  89 +export default {
  90 + mixins: [MIX_ORIGIN],
  91 + data() {
  92 + return {
  93 + cancelShow: false,
  94 + cancelCode: '',
  95 + cancelRemark: '',
  96 + currentTab: 0,
  97 + loading: false,
  98 + list: [],
  99 + countMap: {
  100 + waitAssignCount: 0,
  101 + assignedCount: 0,
  102 + cancelledCount: 0,
  103 + },
  104 + orderStatus: 'WAIT_ASSIGN',
  105 + goodsSourceCode: '',
  106 + statusMap: {
  107 + WAIT_ASSIGN: '#F25643',
  108 + ASSIGNED: '#3296FA',
  109 + CANCELLED: '#999999',
  110 + },
  111 + platenumberVisible: false,
  112 + searchForm: {
  113 + vehicleCode: '',
  114 + loadFlag: '',
  115 + unloadFlag: '',
  116 + waybillCode: '',
  117 + waybillStatus: '',
  118 + },
  119 + };
  120 + },
  121 + onShow() {
  122 + this.onSearch({ showLoading: true });
  123 + },
  124 + onLoad(options) {
  125 + this.goodsSourceCode = options.goodsSourceCode;
  126 + },
  127 + computed: {
  128 + ...mapGetters(['dictList']),
  129 + navbarList() {
  130 + return [
  131 + { name: `待指派(${this.countMap.waitAssignCount || 0})`, prop: 'WAIT_ASSIGN' },
  132 + { name: `已指派(${this.countMap.assignedCount || 0})`, prop: 'ASSIGNED' },
  133 + { name: `已取消(${this.countMap.cancelledCount || 0})`, prop: 'CANCELLED' },
  134 + ];
  135 + },
  136 + },
  137 + methods: {
  138 + // 打开车牌选择
  139 + onSelectPlate() {
  140 + this.platenumberVisible = true;
  141 + },
  142 + // 选中车牌
  143 + onPlatenumberSelect(value) {
  144 + this.platenumberVisible = false;
  145 + this.searchForm.vehicleCode = value;
  146 + this.onSearch({ showLoading: true });
  147 + },
  148 + // 查询数据
  149 + searchAPI(params) {
  150 + this.getCount();
  151 + return uni.$u.api.freightGoodsSourceV2.biddingPage({
  152 + ...params,
  153 + status: this.orderStatus,
  154 + goodsSourceCode: this.goodsSourceCode,
  155 + });
  156 + },
  157 + // 获取统计数量
  158 + getCount() {
  159 + uni.$u.api.freightGoodsSourceV2.biddingCount({ goodsSourceCode: this.goodsSourceCode }).then(res => {
  160 + let result = res?.result || {};
  161 + Object.keys(this.countMap).forEach(item => {
  162 + this.countMap[item] = result[item] ? result[item] : 0;
  163 + });
  164 + });
  165 + },
  166 + onScrollCheckChange(e) {
  167 + this.currentTab = e.index;
  168 + this.orderStatus = this.navbarList[e.index].prop;
  169 + this.onSearch({ showLoading: true });
  170 + },
  171 + // 确认-发布需求
  172 + toSubmit(item) {
  173 + uni.navigateTo({
  174 + url: `/pages/order/add?eventCode=${item.code}`,
  175 + success(res) {
  176 + res.eventChannel.emit('get-item', item);
  177 + },
  178 + });
  179 + },
  180 + // 取消
  181 + confirmCancel() {
  182 + if (this.loading) return;
  183 + uni.$u.api.freightGoodsSourceV2.cancelBidding({ cancelReason: this.cancelRemark, code: this.cancelCode }).then(res => {
  184 + uni.showToast({ title: '取消成功', icon: 'none' });
  185 + this.onSearch({ showLoading: true });
  186 + });
  187 + },
  188 + },
  189 +};
  190 +</script>
  191 +
  192 +<style lang="scss">
  193 +.page-grab-record {
  194 + &__header {
  195 + padding: 0 !important;
  196 + .line {
  197 + height: 1rpx;
  198 + background: #f6f6f6;
  199 + position: relative;
  200 + top: -5rpx;
  201 + }
  202 + .quick-tag {
  203 + display: flex;
  204 + padding: 15upx 22upx;
  205 + box-sizing: border-box;
  206 + position: relative;
  207 + .quick-tag-group {
  208 + flex: 1;
  209 + display: flex;
  210 + align-items: center;
  211 + background-color: #fff;
  212 + padding-left: $padding-xs !important;
  213 + padding-right: $padding-xs !important;
  214 + overflow-y: auto;
  215 +
  216 + .quick-tag-item {
  217 + flex-shrink: 0;
  218 + min-width: 158upx;
  219 + height: 58upx;
  220 + background: #f6f6f6;
  221 + border-radius: 8upx;
  222 + font-size: 28upx;
  223 + font-weight: 400;
  224 + color: #2b2a27;
  225 + display: flex;
  226 + align-items: center;
  227 + justify-content: center;
  228 + padding: 0 10upx;
  229 + box-sizing: border-box;
  230 + position: relative;
  231 + &:not(:last-child) {
  232 + margin-right: 18upx;
  233 + }
  234 +
  235 + &.active {
  236 + background: #ffffff;
  237 + border-radius: 8upx;
  238 + border: 2upx solid #2673fb;
  239 + font-size: 28upx;
  240 + font-family:
  241 + PingFangSC,
  242 + PingFang SC;
  243 + font-weight: 400;
  244 + color: #2673fb;
  245 + }
  246 +
  247 + .sx-img {
  248 + height: 12upx;
  249 + width: 14upx;
  250 + position: relative;
  251 + margin-left: 12upx;
  252 +
  253 + .sx-image {
  254 + width: 100%;
  255 + height: 100%;
  256 + position: absolute;
  257 + top: 0;
  258 + left: 0;
  259 + }
  260 + }
  261 + }
  262 + }
  263 + }
  264 + }
  265 +
  266 + &__content {
  267 + padding: 22rpx !important;
  268 +
  269 + .card {
  270 + padding: 24rpx 12rpx 24rpx 0;
  271 + margin-bottom: 20rpx;
  272 + background: white;
  273 + border-radius: 20rpx;
  274 + .view-item {
  275 + display: flex;
  276 + .view-item__label {
  277 + padding-left: 26rpx;
  278 + color: #999999;
  279 + width: 185rpx;
  280 + }
  281 + .view-item__value {
  282 + flex: 1;
  283 + color: #2b2a27;
  284 + padding-left: 32rpx;
  285 + padding-right: 5rpx;
  286 + display: flex;
  287 + flex-wrap: wrap;
  288 + }
  289 + }
  290 + .view-item:not(:last-child) {
  291 + margin-bottom: 30rpx;
  292 + }
  293 + .buts {
  294 + display: flex;
  295 + justify-content: flex-end;
  296 +
  297 + .zui-button + .zui-button {
  298 + margin-left: 20rpx;
  299 + }
  300 + }
  301 + }
  302 + }
  303 +}
  304 +</style>
... ...
pages/goodSource/index.vue
1 1 <template>
2 2 <Page name="good-source" flank>
3 3 <template #header>
4   - <u-tabs :current="activeTab" :list="tabList" @click="onTabChange" :scrollable="true" :disabled="loading" :activeStyle="{ color: '#1E7B6B' }"> </u-tabs>
  4 + <u-tabs :current="activeTab" :list="tabList" @click="onTabChange" :scrollable="false" :disabled="loading" :activeStyle="{ color: '#1E7B6B' }"> </u-tabs>
5 5 <view class="line"></view>
6 6 <view class="quick-tag">
7 7 <view class="quick-tag-group">
... ... @@ -11,6 +11,9 @@
11 11 <image v-if="searchForm.projectCode" class="sx-image" :src="formatImagePath('active-down')"></image>
12 12 <image v-else class="sx-image" :src="formatImagePath('down')"></image>
13 13 </view>
  14 + <view style="position: absolute; top: 0; right: 0">
  15 + <u-icon name="close"></u-icon>
  16 + </view>
14 17 </view>
15 18 <view class="quick-tag-item" :class="searchForm.startCityCode ? 'active' : ''" @click="selectQuickTag({ key: 'startCityCode', value: searchForm.startCityCode })">
16 19 <text>{{ searchForm.startCityName || '始发地' }}</text>
... ... @@ -26,16 +29,17 @@
26 29 <image v-else class="sx-image" :src="formatImagePath('down')"></image>
27 30 </view>
28 31 </view>
  32 + <view>发布时间<zui-icon name="enter"></zui-icon></view>
29 33 </view>
30   - <view class="quick-screen" @click="openFilter">
31   - <image class="search-image" :src="formatImagePath('search')"></image>
32   - </view>
  34 + <!-- <view class="quick-screen" @click="openFilter">-->
  35 + <!-- <image class="search-image" :src="formatImagePath('search')"></image>-->
  36 + <!-- </view>-->
33 37 </view>
34 38 </template>
35 39 <template #content>
36 40 <List ref="list" v-model="list" :api="orderAPI" @update:loading="e => (loading = e)" :verify="true">
37 41 <template v-for="(item, index) in list">
38   - <card @modify="more" @cancel="cancelOrder" @end="deleteOrder" @delete="deleteOrder" @qrShow="qrCodeShow" :key="index" :item="item" @tap="toDetail(item.code)"></card>
  42 + <card @modify="modifySource" @cancel="cancelSource" @end="completeSource" @delete="deleteSource" @qrShow="qrCodeShow" :key="index" :item="item" @tap="toDetail(item.code)"></card>
39 43 </template>
40 44 <template #empty>
41 45 <Empty tips="暂无数据" />
... ... @@ -80,7 +84,6 @@ export default {
80 84 popValue: '',
81 85 popConfig: {
82 86 cancel: { fun: '', title: '取消原因', placeholder: '请输入取消原因,必填' },
83   - delete: { fun: '', title: '删除原因', placeholder: '请输入删除原因,必填' },
84 87 },
85 88 loading: false,
86 89 popShow: false,
... ... @@ -88,17 +91,11 @@ export default {
88 91 searchForm: {
89 92 projectCode: '',
90 93 projectName: '',
91   - code: '', //
92   - driverName: '',
93   - driverMobile: '', // 客户
94   - vehicleLicenseNum: '',
95   - unHandledExceptionFlag: '', // 存在异常
96 94 startCityCode: '',
  95 + startCityName: '',
97 96 endCityCode: '',
  97 + endCityName: '',
98 98 status: '',
99   - receiptFlag: '', // 是否已签单
100   - payStatus: '', // 支付状态
101   - payStatusName: '', //
102 99 },
103 100 activeTab: 0,
104 101 count: {},
... ... @@ -111,9 +108,9 @@ export default {
111 108 computed: {
112 109 tabList() {
113 110 let list = [
114   - { name: '找车中', value: 'TRANSFER', key: 'transfer' },
115   - { name: '已结束', value: 'COMPLETED', key: 'completed' },
116   - { name: '已取消', value: 'CANCEL', key: 'cancel' },
  111 + { name: '找车中', value: 'MATCHING', key: 'matchingCount' },
  112 + { name: '已结束', value: 'COMPLETED', key: 'completedCount' },
  113 + { name: '已取消', value: 'CANCELLED', key: 'cancelledCount' },
117 114 ];
118 115 return Object.keys(this.count).length > 0
119 116 ? list.map(item => {
... ... @@ -164,19 +161,51 @@ export default {
164 161 });
165 162 }
166 163 },
167   - // 再来一单
168   - more(code) {
  164 + // 修改货源
  165 + modifySource(code) {
169 166 this.currentCode = code;
170 167 this.toAddPage('?code=' + code);
171 168 },
172   - // 取消订单
173   - cancelOrder(code) {
  169 + // 取消货源
  170 + cancelSource(code) {
174 171 this.currentCode = code;
175 172 this.popType = 'cancel';
176 173 this.popValue = '';
177 174 this.popShow = true;
178 175 uni.hideTabBar();
179 176 },
  177 + // 删除货源
  178 + deleteSource(code) {
  179 + uni.showModal({
  180 + title: '提示',
  181 + content: '确定删除此货源吗?',
  182 + success: res => {
  183 + if (res.confirm) {
  184 + uni.$u.api.freightGoodsSourceV2.delete([code]).then(res => {
  185 + if (res.success) {
  186 + this.onSearch();
  187 + }
  188 + });
  189 + }
  190 + },
  191 + });
  192 + },
  193 + // 结束货源
  194 + completeSource(code) {
  195 + uni.showModal({
  196 + title: '提示',
  197 + content: '确定结束此货源吗?',
  198 + success: res => {
  199 + if (res.confirm) {
  200 + uni.$u.api.freightGoodsSourceV2.complete([code]).then(res => {
  201 + if (res.success) {
  202 + this.onSearch();
  203 + }
  204 + });
  205 + }
  206 + },
  207 + });
  208 + },
180 209 closePop() {
181 210 setTimeout(() => uni.showTabBar(), 300);
182 211 this.popShow = false;
... ... @@ -186,9 +215,9 @@ export default {
186 215 uni.showToast({ title: '请输入原因', icon: 'none' });
187 216 return;
188 217 }
189   - uni.$u.api.freightOrder[this.popType]({
190   - codeList: [this.currentCode],
191   - reason: this.popValue,
  218 + uni.$u.api.freightGoodsSourceV2[this.popType]({
  219 + code: this.currentCode,
  220 + cancelReason: this.popValue,
192 221 }).then(res => {
193 222 if (res.success) {
194 223 this.closePop();
... ... @@ -196,24 +225,6 @@ export default {
196 225 }
197 226 });
198 227 },
199   - // 删除订单
200   - deleteOrder(code) {
201   - this.currentCode = code;
202   - this.popType = 'delete';
203   - this.popValue = '';
204   - this.popShow = true;
205   - uni.hideTabBar();
206   - },
207   - toUploadReceipt(code) {
208   - uni.navigateTo({
209   - url: '/pages/order/upload-receipt?code=' + code,
210   - events: {
211   - refreshData: () => {
212   - this.onSearch();
213   - },
214   - },
215   - });
216   - },
217 228 toAddPage(param) {
218 229 uni.navigateTo({
219 230 url: '/pages/goodSource/add' + param,
... ... @@ -242,39 +253,19 @@ export default {
242 253 status: this.tabList[this.activeTab].value,
243 254 };
244 255 this.getAggregateType(format);
245   - return uni.$u.api.freightOrder.page({
  256 + return uni.$u.api.freightGoodsSourceV2.page({
246 257 ...format,
247 258 ...params,
248 259 });
249 260 },
250 261 // 获取聚合数量
251 262 getAggregateType(params) {
252   - uni.$u.api.freightOrder.count({ ...params, status: '' }).then(res => {
  263 + uni.$u.api.freightGoodsSourceV2.count({ ...params, status: '' }).then(res => {
253 264 this.count = res?.result || {};
254 265 });
255 266 },
256 267 toDetail(code) {
257   - uni.navigateTo({ url: '/pages/order/detail?code=' + code });
258   - },
259   - toStartCar(code) {
260   - uni.navigateTo({
261   - url: '/pages/order/start-car?code=' + code,
262   - events: {
263   - refreshData: () => {
264   - this.onSearch();
265   - },
266   - },
267   - });
268   - },
269   - toArrivalCar(code) {
270   - uni.navigateTo({
271   - url: '/pages/order/arrival-car?code=' + code,
272   - events: {
273   - refreshData: () => {
274   - this.onSearch();
275   - },
276   - },
277   - });
  268 + uni.navigateTo({ url: '/pages/goodSource/detail?code=' + code });
278 269 },
279 270 qrCodeShow(code, data) {
280 271 if (this.loading) return;
... ... @@ -308,7 +299,7 @@ export default {
308 299 <style lang="scss">
309 300 .page-good-source {
310 301 &__content {
311   - padding-bottom: 100px !important;
  302 + padding-bottom: 120px !important;
312 303 }
313 304 &__header {
314 305 padding: 0 !important;
... ... @@ -325,32 +316,6 @@ export default {
325 316 padding: 15upx 22upx;
326 317 box-sizing: border-box;
327 318 position: relative;
328   -
329   - .quick-cover {
330   - width: 25upx;
331   - height: 90upx;
332   - position: absolute;
333   - right: 122upx;
334   - top: 0;
335   -
336   - .cover-image {
337   - width: 100%;
338   - height: 100%;
339   - }
340   - }
341   -
342   - .quick-screen {
343   - width: 100upx;
344   - display: flex;
345   - align-items: center;
346   - justify-content: center;
347   -
348   - .search-image {
349   - width: 42upx;
350   - height: 42upx;
351   - }
352   - }
353   -
354 319 .quick-tag-group {
355 320 flex: 1;
356 321 display: flex;
... ... @@ -374,7 +339,7 @@ export default {
374 339 justify-content: center;
375 340 padding: 0 10upx;
376 341 box-sizing: border-box;
377   -
  342 + position: relative;
378 343 &:not(:last-child) {
379 344 margin-right: 18upx;
380 345 }
... ...
pages/order/add.vue
... ... @@ -249,9 +249,45 @@ export default {
249 249 if (option.code) {
250 250 this.initData(option.code);
251 251 }
  252 + // 从抢单来的数据
  253 + if (option.eventCode) {
  254 + const eventChannel = this.getOpenerEventChannel();
  255 + eventChannel.on('get-item', detail => {
  256 + this.setFormValue(detail);
  257 + });
  258 + }
252 259 this.initConfig();
253 260 },
254 261 methods: {
  262 + setFormValue(detail) {
  263 + ['goodsName', 'waypoints', 'allowDriverSeeFreightAmountNode', 'projectCode', 'projectName', 'remark', 'goodsPiece', 'goodsWeight', 'goodsVolume'].forEach(key => {
  264 + this.form[key] = detail[key];
  265 + });
  266 + if (detail.vehicleLicenseNum) {
  267 + this.typeCar = 'licenseNumber';
  268 + this.form.licenseNumber = detail.vehicleLicenseNum;
  269 + this.vehicleChange(detail.vehicleLicenseNum);
  270 + }
  271 + if (detail.trailerLicenseNum) {
  272 + setTimeout(() => {
  273 + this.typeCar = 'trailerNumber';
  274 + this.form.trailerNumber = detail.trailerLicenseNum;
  275 + this.vehicleChange(detail.trailerLicenseNum);
  276 + }, 500);
  277 + }
  278 + this.form.mobile = detail.driverMobile;
  279 + this.form.driverId = detail.driverId;
  280 + this.form.driverName = detail.driverName;
  281 + this.form.driverMobile = detail.driverMobile;
  282 + this.payeeModel = {
  283 + driverId: detail.payeeId,
  284 + dueBank: detail.dueBank,
  285 + openingBank: detail.openingBank,
  286 + dueBankCardNo: detail.dueBankCardNo,
  287 + };
  288 + this.$refs.payee.setItem(this.payeeModel);
  289 + this.computedDistance();
  290 + },
255 291 clipboard(data) {
256 292 if (!data) return;
257 293 let { cliMobile = '', cliVehicle = '', cliTrailer = '' } = this.getClipboardInfo(data);
... ... @@ -333,33 +369,7 @@ export default {
333 369 initData(code) {
334 370 uni.$u.api.freightOrder.getDetail({ code }).then(res => {
335 371 let detail = res.result || {};
336   - ['goodsName', 'waypoints', 'allowDriverSeeFreightAmountNode', 'projectCode', 'projectName', 'remark', 'goodsPiece', 'goodsWeight', 'goodsVolume'].forEach(key => {
337   - this.form[key] = detail[key];
338   - });
339   - if (detail.vehicleLicenseNum) {
340   - this.typeCar = 'licenseNumber';
341   - this.form.licenseNumber = detail.vehicleLicenseNum;
342   - this.vehicleChange(detail.vehicleLicenseNum);
343   - }
344   - if (detail.trailerLicenseNum) {
345   - setTimeout(() => {
346   - this.typeCar = 'trailerNumber';
347   - this.form.trailerNumber = detail.trailerLicenseNum;
348   - this.vehicleChange(detail.trailerLicenseNum);
349   - }, 500);
350   - }
351   - this.form.mobile = detail.driverMobile;
352   - this.form.driverId = detail.driverId;
353   - this.form.driverName = detail.driverName;
354   - this.form.driverMobile = detail.driverMobile;
355   - this.payeeModel = {
356   - driverId: detail.payeeId,
357   - dueBank: detail.dueBank,
358   - openingBank: detail.openingBank,
359   - dueBankCardNo: detail.dueBankCardNo,
360   - };
361   - this.$refs.payee.setItem(this.payeeModel);
362   - this.computedDistance();
  372 + this.setFormValue(detail);
363 373 });
364 374 },
365 375 selectRemark() {
... ...
store/index.js
... ... @@ -95,6 +95,10 @@ const store = new Vuex.Store({
95 95 SET_AUTHED(state, authed) {
96 96 state.authed = authed;
97 97 uni.$emit('authed', authed);
  98 + if (!authed) {
  99 + cache.put('USERINFO', {});
  100 + state.userInfo = {};
  101 + }
98 102 },
99 103 // 设置小程序来源的类型
100 104 SET_ORIGIN(state, origin) {
... ...
styles/common.scss
... ... @@ -190,6 +190,12 @@ body {
190 190 .color-red {
191 191 color: $color-red;
192 192 }
  193 +.color-blue {
  194 + color: $color-blue;
  195 +}
  196 +.color-green {
  197 + color: $color-green;
  198 +}
193 199  
194 200 .color-orange {
195 201 color: $color-zy-orange;
... ...
utils/format-value.js
1 1 export function formatValueByGapRule(gapRule, value, gap = ' ', range, isAdd = 1) {
2   - const arr = value ? value.split('') : []
3   - let showValue = ''
4   - const rule = []
  2 + const arr = value ? value.split('') : [];
  3 + let showValue = '';
  4 + const rule = [];
5 5 gapRule.split('|').some((n, j) => {
6   - rule[j] = +n + (rule[j - 1] ? +rule[j - 1] : 0)
7   - })
8   - let j = 0
  6 + rule[j] = +n + (rule[j - 1] ? +rule[j - 1] : 0);
  7 + });
  8 + let j = 0;
9 9 arr.some((n, i) => {
10 10 // Remove the excess part
11 11 if (i > rule[rule.length - 1] - 1) {
12   - return
  12 + return;
13 13 }
14 14 if (i > 0 && i === rule[j]) {
15   - showValue = showValue + gap + n
16   - j++
  15 + showValue = showValue + gap + n;
  16 + j++;
17 17 } else {
18   - showValue = showValue + '' + n
  18 + showValue = showValue + '' + n;
19 19 }
20   - })
21   - let adapt = 0
  20 + });
  21 + let adapt = 0;
22 22 rule.some((n, j) => {
23 23 if (range === +n + 1 + j) {
24   - adapt = 1 * isAdd
  24 + adapt = 1 * isAdd;
25 25 }
26   - })
27   - range = typeof range !== 'undefined' ? (range === 0 ? 0 : range + adapt) : showValue.length
28   - return {value: showValue, range: range}
  26 + });
  27 + range = typeof range !== 'undefined' ? (range === 0 ? 0 : range + adapt) : showValue.length;
  28 + return { value: showValue, range: range };
29 29 }
30 30  
31 31 export function formatValueByGapStep(step, value, gap = ' ', direction = 'right', range, isAdd = 1, oldValue = '') {
32 32 if (value.length === 0) {
33   - return {value, range}
  33 + return { value, range };
34 34 }
35 35  
36   - const arr = value && value.split('')
37   - let _range = range
38   - let showValue = ''
  36 + const arr = value && value.split('');
  37 + let _range = range;
  38 + let showValue = '';
39 39  
40 40 if (direction === 'right') {
41 41 for (let j = arr.length - 1, k = 0; j >= 0; j--, k++) {
42   - const m = arr[j]
43   - showValue = k > 0 && k % step === 0 ? m + gap + showValue : m + '' + showValue
  42 + const m = arr[j];
  43 + showValue = k > 0 && k % step === 0 ? m + gap + showValue : m + '' + showValue;
44 44 }
45 45 if (isAdd === 1) {
46 46 // 在添加的情况下,如果添加前字符串的长度减去新的字符串的长度为2,说明多了一个间隔符,需要调整range
47 47 if (oldValue.length - showValue.length === -2) {
48   - _range = range + 1
  48 + _range = range + 1;
49 49 }
50 50 } else {
51 51 // 在删除情况下,如果删除前字符串的长度减去新的字符串的长度为2,说明少了一个间隔符,需要调整range
52 52 if (oldValue.length - showValue.length === 2) {
53   - _range = range - 1
  53 + _range = range - 1;
54 54 }
55 55 // 删除到最开始,range 保持 0
56 56 if (_range <= 0) {
57   - _range = 0
  57 + _range = 0;
58 58 }
59 59 }
60 60 } else {
61 61 arr.some((n, i) => {
62   - showValue = i > 0 && i % step === 0 ? showValue + gap + n : showValue + '' + n
63   - })
64   - const adapt = range % (step + 1) === 0 ? 1 * isAdd : 0
65   - _range = typeof range !== 'undefined' ? (range === 0 ? 0 : range + adapt) : showValue.length
  62 + showValue = i > 0 && i % step === 0 ? showValue + gap + n : showValue + '' + n;
  63 + });
  64 + const adapt = range % (step + 1) === 0 ? 1 * isAdd : 0;
  65 + _range = typeof range !== 'undefined' ? (range === 0 ? 0 : range + adapt) : showValue.length;
66 66 }
67 67  
68   - return {value: showValue, range: _range}
  68 + return { value: showValue, range: _range };
69 69 }
70 70  
71 71 export function trimValue(value, gap = ' ') {
72   - value = typeof value === 'undefined' ? '' : value
73   - const reg = new RegExp(gap, 'g')
74   - value = value.toString().replace(reg, '')
75   - return value
  72 + value = typeof value === 'undefined' ? '' : value;
  73 + const reg = new RegExp(gap, 'g');
  74 + value = value.toString().replace(reg, '');
  75 + return value;
  76 +}
  77 +
  78 +function getAddress(geo) {
  79 + const { regeocode = {} } = geo || {};
  80 + const { addressComponent = {} } = regeocode || {};
  81 + const { province, city, district, township, streetNumber } = addressComponent || {};
  82 + const { street, number } = streetNumber || {};
  83 + const formattedAddress = regeocode.formatted_address || regeocode.formattedAddress || '';
  84 + let amapAddress = formattedAddress.replace(province, '');
  85 + amapAddress = amapAddress.replace(city, '');
  86 + amapAddress = amapAddress.replace(district, '');
  87 + amapAddress = amapAddress.replace(township, '');
  88 + amapAddress = amapAddress.replace(street, '');
  89 + amapAddress = amapAddress.replace(number, '');
  90 + return {
  91 + formattedAddress,
  92 + fullAddress: `${province}${city}${district}${township}${street}${number}`,
  93 + address: `${township}${street}${number}${amapAddress}`,
  94 + amapAddress,
  95 + adcode: addressComponent.adcode,
  96 + township,
  97 + };
  98 +}
  99 +
  100 +export function formatLngLat({ lat, lng }) {
  101 + if (!lat || !lng) {
  102 + return Promise.resolve({});
  103 + }
  104 + return new Promise(resolve => {
  105 + uni.request({
  106 + url: 'https://restapi.amap.com/v3/geocode/regeo', //逆地理编码接口地址。
  107 + data: {
  108 + key: '1b987a62e5685a58cda5933e1bc66044',
  109 + location: lng + ',' + lat,
  110 + },
  111 + success: response => {
  112 + const regeocode = response?.data?.regeocode || {};
  113 + const addressComponent = regeocode?.addressComponent || {};
  114 + const addressInfo = getAddress(response?.data);
  115 + let location = {
  116 + lng: lng || '',
  117 + lat: lat || '',
  118 + provinceCode: addressComponent.adcode ? addressComponent.adcode.substring(0, 2) + '0000' : '',
  119 + cityCode: addressComponent.adcode ? addressComponent.adcode.substring(0, 4) + '00' : '',
  120 + areaCode: addressComponent.adcode,
  121 + provinceName: addressComponent.province,
  122 + areaName: addressComponent.district,
  123 + address: addressInfo.address,
  124 + formattedAddress: addressInfo.formattedAddress,
  125 + };
  126 + resolve(location);
  127 + },
  128 + fail() {
  129 + resolve({});
  130 + },
  131 + });
  132 + });
76 133 }
... ...