app-form-send1.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view>
  3. <tui-list-cell class="line-cell" :hover="false" :arrow="true" >
  4. <view class="tui-title">配送方</view>
  5. <picker mode="selector" :value="sendSideIndex" :range="deliveryList" :range-key="'name'" @change="selectSideEvent" class="tui-input">
  6. <view v-if="formData.sendSide" class="tui-input">
  7. {{ deliveryList[sendSideIndex].name }}
  8. </view>
  9. <view v-else class="tui-placeholder">请选择快递公司</view>
  10. <input name="sendSide" hidden />
  11. </picker>
  12. </tui-list-cell>
  13. <!-- 门店送或快递送需要设置地址 -->
  14. <appAddressGroup :customId="customId" cityTitle="配送城市" @selectAdress="selectAdress" ></appAddressGroup>
  15. <!-- <appSendTime @alterTime="selectAdress('')" :sendDate.sync="formData.sendDate" :sendTime.sync="formData.sendTime"></appSendTime> -->
  16. <appTimer :sendTime="formData.sendTime" @confirm="onConfirm"></appTimer>
  17. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  18. <view class="tui-title">运费</view>
  19. <view v-if="formData.sendCost" class="tui-input">
  20. {{ formData.sendCost }}
  21. </view>
  22. <view v-else class="tui-placeholder">留空表示免运费</view>
  23. <input name="sendCost" hidden />
  24. </tui-list-cell>
  25. </view>
  26. </template>
  27. <script>
  28. import TuiListCell from "@/components/plugin/list-cell";
  29. import { freight } from "@/api/order";
  30. import appFormRadioBtn from "@/components/app-formRadio-btn";
  31. import appAddressGroup from "@/components/app-address-group";
  32. import appSendTime from "@/components/app-send-time";
  33. import appTimer from "@/components/app-timer";
  34. import {mapGetters} from "vuex";
  35. export default {
  36. components: {
  37. TuiListCell,
  38. appFormRadioBtn,
  39. appAddressGroup,
  40. appSendTime,
  41. appTimer
  42. },
  43. props: {
  44. customId:'',
  45. orderid:'',
  46. form: {
  47. type: Object
  48. }
  49. },
  50. data() {
  51. return {
  52. formData: {
  53. sendCost: "",
  54. customName: "",
  55. customMobile: "",
  56. receiveProvince: "",
  57. receiveCity: "",
  58. receiveFloor: "",
  59. receiveAddress: "",
  60. receiveLong: "",
  61. receiveLat: "",
  62. sendSide: "",
  63. sendType: "3", //1自取 2本店送 3快递送
  64. sendDate: "",
  65. sendTime: ""
  66. },
  67. userLong:'',
  68. userLat:'',
  69. sendSideIndex:0,
  70. deliveryList: []
  71. };
  72. },
  73. created() {
  74. this.initData();
  75. },
  76. computed: {
  77. ...mapGetters(["getDictionariesInfo"]),
  78. getCurSideName() {
  79. let name = "";
  80. if (this.formData.sendSide) {
  81. const curItem = this.deliveryList.find(ele => {
  82. return ele.value == this.formData.sendSide;
  83. });
  84. if (curItem) {
  85. name = curItem.name;
  86. }
  87. }
  88. return name;
  89. }
  90. },
  91. methods: {
  92. initData() {
  93. for (const key in this.formData) {
  94. if (Object.hasOwnProperty.call(this.formData, key)) {
  95. const element = this.form[key];
  96. this.formData[key] = element;
  97. }
  98. }
  99. //配送方-列表
  100. let list = this.getDictionariesInfo.expressList;
  101. for (let i=0;i<list.length;i++){
  102. this.deliveryList.push({name:list[i].deliveryName,value:list[i].deliveryId,id:list[i].id})
  103. }
  104. console.log(list);
  105. this.formData.sendSide = list[0].id;
  106. },
  107. selectAdress(info) {
  108. if(info){
  109. this.formData.receiveProvince = info.province;
  110. this.formData.receiveCity = info.city;
  111. this.formData.receiveFloor = info.floor;
  112. this.formData.receiveAddress = info.address;
  113. this.formData.receiveLong = info.longitude;
  114. this.formData.receiveLat = info.latitude;
  115. this.formData.customName = info.customName;
  116. this.formData.customMobile = info.customMobile;
  117. }
  118. console.log('this.formData',this.formData)
  119. this.$nextTick(() => {
  120. let params = {
  121. id: this.orderid,
  122. customName: this.formData.customName,
  123. customMobile: this.formData.customMobile,
  124. province: this.formData.receiveProvince,
  125. city:this.formData.receiveCity,
  126. address:this.formData.receiveAddress,
  127. floor:this.formData.receiveFloor,
  128. expressId: this.formData.sendSide,
  129. // orderId: this.orderid,
  130. long: this.formData.receiveLong,
  131. lat: this.formData.receiveLat,
  132. sendTime: this.formData.sendTime,
  133. };
  134. this.freightCount(params);
  135. });
  136. },
  137. onConfirm(val) {
  138. this.formData.sendTime = val
  139. this.selectAdress('')
  140. },
  141. // 计算运费
  142. freightCount(option) {
  143. freight(option).then(res => {
  144. this.formData.sendCost = res.data.sedCost;
  145. });
  146. },
  147. selectSideEvent(event) {
  148. // console.log(event);
  149. // console.log(event.detail.value);
  150. const {detail: { value }} = event;
  151. this.sendSideIndex = value;
  152. this.formData.sendSide = this.deliveryList[value].id;
  153. console.log(this.formData.sendSide);
  154. }
  155. },
  156. watch: {
  157. formData: {
  158. handler(val) {
  159. if (val) {
  160. let info = { ...this.form, ...val };
  161. if (this.formData.sendTime) {
  162. // info.sendTime = `${this.formData.sendDate} ${this.formData.sendTime}`;
  163. info.sendTime = this.formData.sendTime;
  164. }
  165. this.$emit("update:form", info);
  166. }
  167. },
  168. deep: true
  169. },
  170. ["formData.sendType"](val) {
  171. if (val != "3") {
  172. //不是快递配送不包含运费
  173. this.formData.sendCost = "";
  174. }
  175. }
  176. }
  177. };
  178. </script>
  179. <style></style>