logistics.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="选择物流路线" fixed border>
  5. <template #right v-if="checkValue">
  6. <view class="nav_right" @click.stop="submit">
  7. <trans _t="确认" />
  8. </view>
  9. </template>
  10. </Navbar>
  11. <view class="content">
  12. <up-radio-group v-model="checkValue" activeColor="var(--black)" @change="handleRadioChange">
  13. <view class="list" v-for="item, index in detail" :key="index">
  14. <logisticsList :item="item" @change="handleRadioChange" />
  15. </view>
  16. </up-radio-group>
  17. </view>
  18. </view>
  19. </Theme>
  20. </template>
  21. <script setup>
  22. import Navbar from "@/components/navbar"
  23. import { SHOP_EXPRESS_TEMPLATE } from "@/api"
  24. import { ref, nextTick, computed } from "vue";
  25. import { t } from "@/locale"
  26. import { Moneyhtml, findObjectByField } from "@/utils"
  27. import { onShow } from "@dcloudio/uni-app"
  28. import logisticsList from "./components/logistics_list"
  29. import { useShopStore } from "@/store"
  30. const detail = ref({})
  31. const checkValue = ref(null)
  32. const useShop = useShopStore()
  33. const logistics = computed(() => useShop.getLogistics)
  34. onShow(() => {
  35. checkValue.value = logistics.value.id
  36. getDetail();
  37. })
  38. const handleRadioChange = (id) => {
  39. checkValue.value = id
  40. }
  41. const getDetail = async () => {
  42. try {
  43. const res = await SHOP_EXPRESS_TEMPLATE();
  44. detail.value = res.data
  45. } catch (error) { }
  46. }
  47. const submit = () => {
  48. const findObj = detail.value.find(item => item.id === checkValue.value)
  49. useShop.setLogistics(findObj)
  50. uni.navigateBack();
  51. }
  52. </script>
  53. <style lang="less" scoped>
  54. @import url('@/style.less');
  55. .wrap {
  56. min-height: 100vh;
  57. background-color: var(--bg);
  58. .nav_right {
  59. color: var(--black);
  60. .size(24rpx);
  61. font-weight: 500;
  62. }
  63. .content {
  64. padding: 24rpx;
  65. .list {
  66. width: 100%;
  67. }
  68. }
  69. }
  70. </style>