You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div>
  3. <custom-header :back="false" title="邮寄"></custom-header>
  4. <div style="padding-top: 20rpx" v-if="isShow">
  5. <form-builder-vue
  6. :formData="formData"
  7. :config="config"
  8. @radioChange="radioChange"
  9. @submit="submit"
  10. ></form-builder-vue>
  11. </div>
  12. </div>
  13. </template>
  14. <script setup lang="ts">
  15. import { unifyTemplate } from '@/hooks/unifyTemplate';
  16. import { TypeData, Index } from '@/components/form-builder/tools';
  17. import { ref } from 'vue';
  18. import { onLoad } from '@dcloudio/uni-app';
  19. import { request } from '@/utils/network/request';
  20. import fromData from './fromData.js';
  21. let config = ref<any>({
  22. submitName: '提交',
  23. titleWidth: 160
  24. });
  25. let formData = ref(fromData);
  26. const {
  27. formBuilderVue, //组件
  28. CustomHeader, //头部组件
  29. initData, //初始化数据
  30. isShow, //是否展示formBuilderVue组件
  31. qdOrderVal //qdOrder中数据 ref
  32. } = unifyTemplate(); //初始化数据
  33. //获取页面配置
  34. onLoad((opin) => {
  35. initData(opin, 0).then((data) => {
  36. // formData.value = JSON.parse(data.config.tableConfig)
  37. // console.log(formData.value,data);
  38. // isShow.value = true
  39. delete data.config.tableConfig;
  40. config.value = Object.assign(data.config, config.value);
  41. submit({
  42. whetherToMail: 1
  43. });
  44. });
  45. });
  46. //单项选择器
  47. function radioChange(e: any, item: TypeData) {
  48. if (item.title === '是否邮寄') {
  49. if (parseInt(e.detail.value) == 1) {
  50. formData.value[Index('收件人', formData.value)].show = true;
  51. formData.value[Index('收件人手机号', formData.value)].show = true;
  52. formData.value[Index('省市区', formData.value)].show = true;
  53. formData.value[Index('详细地址', formData.value)].show = true;
  54. formData.value[Index('邮政编码', formData.value)].show = true;
  55. } else {
  56. formData.value[Index('收件人', formData.value)].show = false;
  57. formData.value[Index('收件人手机号', formData.value)].show = false;
  58. formData.value[Index('省市区', formData.value)].show = false;
  59. formData.value[Index('详细地址', formData.value)].show = false;
  60. formData.value[Index('邮政编码', formData.value)].show = false;
  61. }
  62. }
  63. }
  64. /**
  65. * 请求函数,e为处理后的value
  66. * */
  67. function submit(e: any) {
  68. // qdorder数据
  69. let { userType, vanType, vehicleColor, vehiclePlate, qdOrderNo } =
  70. qdOrderVal.value;
  71. // 客货类型
  72. qdOrderVal.value.type = vanType > 3 ? 2 : vanType;
  73. const data = {
  74. userType,
  75. qdOrderNo,
  76. vehiclePlate,
  77. vehiclePlateColor: vehicleColor,
  78. type: vanType > 3 ? 2 : vanType,
  79. orderSource: 'H5',
  80. ...e
  81. };
  82. let { commitInterface, jumpPage } = config.value;
  83. console.log('邮件请求数据', data,e);
  84. // return;
  85. request(commitInterface || '3dc2df0ba7004fffbd97192cbaa66b6f', {
  86. data,
  87. showTitle: '正在提交订单...'
  88. }).then((res) => {
  89. if (res.statusCode === 0) {
  90. // 通过orderId关联产品
  91. relatedProducts(
  92. qdOrderVal.value.productCode || qdOrderVal.value.promoteId,
  93. JSON.parse(res.bizContent).orderId
  94. );
  95. uni.navigateTo({
  96. url: '/' + jumpPage,
  97. animationType: 'pop-in',
  98. animationDuration: 500
  99. });
  100. }
  101. });
  102. }
  103. /**
  104. * 关联产品
  105. * */
  106. function relatedProducts(promoteId: string, orderId: string) {
  107. const data = {
  108. promoteId,
  109. orderId
  110. };
  111. request('198172b1858d474fa8e35225d65014d7', {
  112. showLoading: true,
  113. data
  114. }).then((res) => {
  115. console.log('关联成功', res);
  116. });
  117. }
  118. </script>
  119. <style lang="scss" scoped></style>