Commit beae44494c474a9c3eaf304069efb5416c868522

Authored by lxf
1 parent 2347e509

fix: 通知

pages/goodSource/add.vue
... ... @@ -375,6 +375,29 @@ export default {
375 375 url: `/pages/goodSource/select-remark`,
376 376 });
377 377 },
  378 + // 订阅消息
  379 + subscribeMessage(afterFun) {
  380 + uni.requestSubscribeMessage({
  381 + tmplIds: ['CtqtbxU3RFUk7s1QF2RQQiAqyE8w96xHGbbJogTLZX0'],
  382 + success(res) {
  383 + uni.getSetting({
  384 + withSubscriptions: true,
  385 + success(res) {
  386 + if (!res.subscriptionsSetting) {
  387 + uni.showModal({
  388 + title: '提示',
  389 + content: '未开启小程序订阅消息接收,请前往微信设置接以接收消息!',
  390 + showCancel: false,
  391 + });
  392 + }
  393 + },
  394 + });
  395 + },
  396 + complete() {
  397 + afterFun();
  398 + },
  399 + });
  400 + },
378 401 submitAddFun() {
379 402 if (this.loading) return;
380 403 this.loading = true;
... ... @@ -396,9 +419,15 @@ export default {
396 419 uni.$u.api.freightGoodsSourceV2[opType]({ ...this.form, ...startAddressObj, ...endAddressObj })
397 420 .then(res => {
398 421 if (res.success) {
399   - // uni.showToast({ title: '成功', icon: 'none' });
400   - this.getOpenerEventChannel().emit('refreshData');
401   - setTimeout(() => uni.navigateBack(), 500);
  422 + let afterFun = () => {
  423 + this.getOpenerEventChannel().emit('refreshData');
  424 + setTimeout(() => uni.navigateBack(), 500);
  425 + };
  426 + if (opType === 'add') {
  427 + this.subscribeMessage(afterFun);
  428 + } else {
  429 + afterFun();
  430 + }
402 431 } else {
403 432 this.loading = false;
404 433 }
... ...
pages/goodSource/grab-record.vue
... ... @@ -211,33 +211,33 @@ export default {
211 211 },
212 212 // 确认-发布需求
213 213 toSubmit(item) {
214   - let form = {
215   - ...item,
216   - goodsWeight: item.biddingWeight,
217   - goodsSourceCode: item.goodsSourceCode,
218   - goodsSourceBiddingCode: item.code,
219   - loadTime: dayjs(item.biddingTime).add(3, 'hour').format('YYYY-MM-DD HH:mm:ss'),
220   - waypoints: [
221   - {
222   - cityCode: item.startCityCode,
223   - areaCode: item.startAreaCode,
224   - address: item.startAddress,
225   - lng: item.startLng,
226   - lat: item.startLat,
227   - },
228   - {
229   - cityCode: item.endCityCode,
230   - areaCode: item.endAreaCode,
231   - address: item.endAddress,
232   - lng: item.endLng,
233   - lat: item.endLat,
234   - },
235   - ],
236   - };
237 214 uni.navigateTo({
238   - url: `/pages/order/add?eventCode=${item.code}`,
  215 + url: `/pages/order/add?biddingSource=record&biddingCode=${item.code}`,
239 216 success(res) {
240   - res.eventChannel.emit('get-item', form);
  217 + res.eventChannel.emit('get-item', item);
  218 + },
  219 + });
  220 + },
  221 + // 订阅消息
  222 + subscribeMessage(afterFun) {
  223 + uni.requestSubscribeMessage({
  224 + tmplIds: ['CtqtbxU3RFUk7s1QF2RQQiAqyE8w96xHGbbJogTLZX0'],
  225 + success(res) {
  226 + uni.getSetting({
  227 + withSubscriptions: true,
  228 + success(res) {
  229 + if (!res.subscriptionsSetting) {
  230 + uni.showModal({
  231 + title: '提示',
  232 + content: '未开启小程序订阅消息接收,请前往微信设置接以接收消息!',
  233 + showCancel: false,
  234 + });
  235 + }
  236 + },
  237 + });
  238 + },
  239 + complete() {
  240 + afterFun && afterFun();
241 241 },
242 242 });
243 243 },
... ... @@ -252,6 +252,7 @@ export default {
252 252 this.loading = false;
253 253 uni.showToast({ title: '取消成功', icon: 'none' });
254 254 this.onSearch({ showLoading: true });
  255 + this.subscribeMessage();
255 256 })
256 257 .catch(() => {
257 258 this.loading = false;
... ...
pages/order/add.vue
... ... @@ -218,7 +218,8 @@ export default {
218 218 exceed: false,
219 219 exceedStr: '',
220 220 openExternalInsuranceFlag: true,
221   - eventCode: '',
  221 + biddingSource: '', // 从货源列表(record),从订阅消息(msg)
  222 + biddingCode: '', // 抢单编号
222 223 loading: false,
223 224 showModal: '',
224 225 showModal2: '',
... ... @@ -289,16 +290,30 @@ export default {
289 290 },
290 291 onLoad(option) {
291 292 // 从抢单来的数据
292   - if (option.eventCode) {
293   - this.eventCode = option.eventCode;
  293 + if (option.biddingCode) {
  294 + this.biddingCode = option.biddingCode;
  295 + this.biddingSource = option.biddingSource;
294 296 uni.setNavigationBarTitle({ title: '确定指派' });
295   - const eventChannel = this.getOpenerEventChannel();
296   - eventChannel.on('get-item', detail => {
297   - this.setFormValue(detail, ['priceType', 'weightUnitPrice', 'goodsSourceCode', 'goodsSourceBiddingCode', 'loadTime', 'paidAmount']);
298   - this.getAllowDriverSeeFreightAmount();
299   - this.clipboard(`手机号:${detail.driverMobile || ''}车牌:${detail.vehicleLicenseNum || ''}车挂:${detail.trailerLicenseNum || ''}`);
300   - this.computedService();
301   - });
  297 + if (option.biddingSource === 'record') {
  298 + const eventChannel = this.getOpenerEventChannel();
  299 + eventChannel.on('get-item', item => {
  300 + this.sourceInitForm(item);
  301 + });
  302 + } else if (option.biddingSource === 'wx_sub_msg') {
  303 + uni.$u.api.freightGoodsSourceV2
  304 + .biddingPage({
  305 + status: 'WAIT_ASSIGN',
  306 + code: option.biddingCode,
  307 + })
  308 + .then(res => {
  309 + if (res.result && res.result.length > 0) {
  310 + let item = res.result[0];
  311 + this.sourceInitForm(item);
  312 + } else {
  313 + uni.showToast({ title: '该抢单已处理,请返回', icon: 'none' });
  314 + }
  315 + });
  316 + }
302 317 } else {
303 318 if (option.code) {
304 319 this.initData(option.code);
... ... @@ -307,6 +322,35 @@ export default {
307 322 }
308 323 },
309 324 methods: {
  325 + sourceInitForm(item) {
  326 + let detail = {
  327 + ...item,
  328 + goodsWeight: item.biddingWeight,
  329 + goodsSourceCode: item.goodsSourceCode,
  330 + goodsSourceBiddingCode: item.code,
  331 + loadTime: dayjs(item.biddingTime).add(3, 'hour').format('YYYY-MM-DD HH:mm:ss'),
  332 + waypoints: [
  333 + {
  334 + cityCode: item.startCityCode,
  335 + areaCode: item.startAreaCode,
  336 + address: item.startAddress,
  337 + lng: item.startLng,
  338 + lat: item.startLat,
  339 + },
  340 + {
  341 + cityCode: item.endCityCode,
  342 + areaCode: item.endAreaCode,
  343 + address: item.endAddress,
  344 + lng: item.endLng,
  345 + lat: item.endLat,
  346 + },
  347 + ],
  348 + };
  349 + this.setFormValue(detail, ['priceType', 'weightUnitPrice', 'goodsSourceCode', 'goodsSourceBiddingCode', 'loadTime', 'paidAmount']);
  350 + this.getAllowDriverSeeFreightAmount();
  351 + this.clipboard(`手机号:${detail.driverMobile || ''}车牌:${detail.vehicleLicenseNum || ''}车挂:${detail.trailerLicenseNum || ''}`);
  352 + this.computedService();
  353 + },
310 354 setFormValue(detail, moreList = []) {
311 355 ['goodsName', 'waypoints', 'allowDriverSeeFreightAmountNode', 'projectCode', 'projectName', 'remark', 'goodsPiece', 'goodsWeight', 'goodsVolume', ...moreList].forEach(key => {
312 356 this.form[key] = detail[key];
... ... @@ -632,7 +676,7 @@ export default {
632 676 uni.$u.debounce(this.getServiceAmountInfo, 500);
633 677 },
634 678 computedPaid() {
635   - if (this.eventCode && this.form.priceType === 'TON') {
  679 + if (this.biddingCode && this.form.priceType === 'TON') {
636 680 this.form.paidAmount = Number(Number(this.form.goodsWeight) * Number(this.form.weightUnitPrice)).toFixed(2);
637 681 this.computedService();
638 682 }
... ... @@ -666,12 +710,35 @@ export default {
666 710 }
667 711 });
668 712 },
  713 + // 订阅消息
  714 + subscribeMessage(afterFun) {
  715 + uni.requestSubscribeMessage({
  716 + tmplIds: ['CtqtbxU3RFUk7s1QF2RQQiAqyE8w96xHGbbJogTLZX0'],
  717 + success(res) {
  718 + uni.getSetting({
  719 + withSubscriptions: true,
  720 + success(res) {
  721 + if (!res.subscriptionsSetting) {
  722 + uni.showModal({
  723 + title: '提示',
  724 + content: '未开启小程序订阅消息接收,请前往微信设置接以接收消息!',
  725 + showCancel: false,
  726 + });
  727 + }
  728 + },
  729 + });
  730 + },
  731 + complete() {
  732 + afterFun();
  733 + },
  734 + });
  735 + },
669 736 submitAddFun(confirmAddFlag = false) {
670 737 this.exceed = false;
671 738 if (this.loading) return;
672 739 this.loading = true;
673 740 let totalAmount = Number(this.form.paidAmount || 0) + Number(this.form.serviceAmount || 0) + Number(this.form.securityServiceAmount || 0);
674   - let addFun = this.eventCode ? uni.$u.api.freightGoodsSourceV2.addOrder : uni.$u.api.freightOrder.add;
  741 + let addFun = this.biddingCode ? uni.$u.api.freightGoodsSourceV2.addOrder : uni.$u.api.freightOrder.add;
675 742 addFun({ ...this.form, totalAmount, payeeId: this.payeeModel.driverId, confirmAddFlag })
676 743 .then(res => {
677 744 if (res.result) {
... ... @@ -680,8 +747,19 @@ export default {
680 747 this.exceed = true;
681 748 } else {
682 749 uni.showToast({ title: '下单成功', icon: 'none' });
683   - this.getOpenerEventChannel().emit('refreshData');
684   - setTimeout(() => uni.navigateBack(), 1500);
  750 + let afterFun = () => {
  751 + if (this.biddingSource === 'record') {
  752 + this.getOpenerEventChannel().emit('refreshData');
  753 + setTimeout(() => uni.navigateBack(), 1000);
  754 + } else {
  755 + uni.switchTab({ url: '/pages/goodSource/index' });
  756 + }
  757 + };
  758 + if (this.biddingCode) {
  759 + this.subscribeMessage(afterFun);
  760 + } else {
  761 + afterFun();
  762 + }
685 763 }
686 764 })
687 765 .catch(e => {
... ...