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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <image class='bg-image' mode="widthFix"
  4. src="https://qtzl.etcjz.cn/default-bucket/20240324/3eba2095f5204798a1f8101b_beijing.jpg"></image>
  5. <view class="content-re">
  6. <custom-header :back="false" title="邮寄"></custom-header>
  7. <view style="padding-top: 20rpx" v-if="isShow">
  8. <form-builder-vue :formData="formData" :config="config" @radioChange="radioChange"
  9. @submit="submit"></form-builder-vue>
  10. </view>
  11. </view>
  12. </view>
  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. let { commitInterface, jumpPage } = config.value;
  69. uni.navigateTo({
  70. url: '/' + jumpPage,
  71. animationType: 'pop-in',
  72. animationDuration: 500
  73. });
  74. return
  75. // qdorder数据
  76. let { userType, vanType, vehicleColor, vehiclePlate, qdOrderNo } =
  77. qdOrderVal.value;
  78. // 客货类型
  79. qdOrderVal.value.type = vanType;
  80. const data = {
  81. userType,
  82. qdOrderNo,
  83. vehiclePlate,
  84. vehiclePlateColor: vehicleColor,
  85. type: vanType,
  86. orderSource: 'H5',
  87. ...e
  88. };
  89. // let { commitInterface, jumpPage } = config.value;
  90. console.log('邮件请求数据', data, e);
  91. // return;
  92. request(commitInterface || '3dc2df0ba7004fffbd97192cbaa66b6f', {
  93. data,
  94. showTitle: '正在提交订单...'
  95. }).then((res) => {
  96. if (res.statusCode === 0) {
  97. // 通过orderId关联产品
  98. relatedProducts(
  99. qdOrderVal.value.productCode || qdOrderVal.value.promoteId,
  100. JSON.parse(res.bizContent).orderId
  101. );
  102. }
  103. });
  104. }
  105. /**
  106. * 关联产品
  107. * */
  108. function relatedProducts(promoteId : string, orderId : string) {
  109. const data = {
  110. promoteId,
  111. orderId
  112. };
  113. let { commitInterface, jumpPage } = config.value;
  114. request('198172b1858d474fa8e35225d65014d7', {
  115. data,
  116. }).then((res) => {
  117. console.log('关联成功', res);
  118. if (res.statusCode === 0) {
  119. relatedEquity(orderId);
  120. uni.navigateTo({
  121. url: '/' + jumpPage,
  122. animationType: 'pop-in',
  123. animationDuration: 500
  124. });
  125. }
  126. }).catch(err => {
  127. console.log(err, 'err');
  128. if (err.errMsg === 'request:fail timeout') {
  129. relatedProducts(promoteId, orderId)
  130. }
  131. });
  132. }
  133. /**
  134. * 关联权益
  135. * */
  136. function relatedEquity(orderId : string) {
  137. if (!qdOrderVal.value.equityId) {
  138. return
  139. }
  140. const data = {
  141. equityId: qdOrderVal.value.equityId, //权益编号
  142. orderId, //订单id
  143. isRepeatPurchase: 1 //是否重复加购权益
  144. };
  145. console.log(data, '关联权益');
  146. request('10414819633f46db98158fc7b4e8475e', {
  147. showLoading: true,
  148. data
  149. }).then((res) => {
  150. if (res.statusCode === 0) {
  151. console.log('关联权益成功', res);
  152. }
  153. });
  154. }
  155. </script>
  156. <style lang="scss" scoped></style>