addressSelection.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!-- 下单界面,收货地址 or 自提门店的选择组件 -->
  2. <template>
  3. <v-card class="allAddress" elevation="1" :style="state.isPickUp ? '' : 'padding-top:10rpx;'">
  4. <!-- 情况一:收货地址的选择 -->
  5. <div
  6. class="address"
  7. @click="onSelectAddress"
  8. v-if="state.deliveryType === 1"
  9. :style="state.isPickUp ? '' : 'border-top-left-radius: 14rpx;border-top-right-radius: 14rpx;'"
  10. >
  11. <div class="addressCon" v-if="state.addressInfo.name">
  12. <div class="name d-flex"
  13. >{{ state.addressInfo.name }}
  14. <div class="phone ml-3">{{ state.addressInfo.mobile }}</div>
  15. </div>
  16. <div class="d-flex mt-1">
  17. <div class="default font-color" v-if="state.addressInfo.defaultStatus">[默认]</div>
  18. <div class="line2 ml-3">
  19. {{ state.addressInfo.areaName }} {{ state.addressInfo.detailAddress }}
  20. </div>
  21. </div>
  22. </div>
  23. <div class="addressCon" v-else>
  24. <div class="setaddress">设置收货地址</div>
  25. </div>
  26. <div class="iconfont">
  27. <div class="ss-rest-button">
  28. <div class="_icon-forward" />
  29. </div>
  30. </div>
  31. </div>
  32. </v-card>
  33. </template>
  34. <script setup>
  35. import { computed } from 'vue';
  36. import { isEmpty1 } from '@/utils/is'
  37. // import Snackbar from '@/plugins/snackbar'
  38. const props = defineProps({
  39. modelValue: {
  40. type: Object,
  41. default() {},
  42. },
  43. });
  44. const emits = defineEmits(['update:modelValue']);
  45. // computed 解决父子组件双向数据同步
  46. const state = computed({
  47. get() {
  48. return new Proxy(props.modelValue, {
  49. set(obj, name, val) {
  50. emits('update:modelValue', {
  51. ...obj,
  52. [name]: val,
  53. });
  54. return true;
  55. },
  56. });
  57. },
  58. set(val) {
  59. emits('update:modelValue', val);
  60. },
  61. });
  62. // 选择地址
  63. function onSelectAddress() {
  64. // let emitName = 'SELECT_ADDRESS';
  65. // let addressPage = '/pages/user/address/list?type=select';
  66. // if (state.value.deliveryType === 2) {
  67. // emitName = 'SELECT_PICK_UP_INFO';
  68. // addressPage = '/pages/user/goods_details_store/index';
  69. // }
  70. // uni.$once(emitName, (e) => {
  71. // changeConsignee(e.addressInfo);
  72. // });
  73. // sheep.$router.go(addressPage);
  74. }
  75. // 更改收货人地址&计算订单信息
  76. async function changeConsignee(addressInfo = {}) {
  77. if (!isEmpty1(addressInfo)) {
  78. if (state.value.deliveryType === 1) {
  79. state.value.addressInfo = addressInfo;
  80. }
  81. if (state.value.deliveryType === 2) {
  82. state.value.pickUpInfo = addressInfo;
  83. }
  84. }
  85. }
  86. // 收货方式切换
  87. const switchDeliveryType = (type) => {
  88. state.value.deliveryType = type;
  89. };
  90. </script>
  91. <style scoped lang="scss">
  92. .allAddress .font-color {
  93. color: #e93323 !important;
  94. }
  95. .line2 {
  96. width: 504rpx;
  97. }
  98. .textR {
  99. text-align: right;
  100. }
  101. .line {
  102. width: 100%;
  103. height: 3rpx;
  104. }
  105. .line image {
  106. width: 100%;
  107. height: 100%;
  108. display: block;
  109. }
  110. .address {
  111. background-color: #fff;
  112. box-sizing: border-box;
  113. padding: 12px;
  114. border-radius: 10px;
  115. }
  116. .address .addressCon {
  117. width: 596rpx;
  118. font-size: 26rpx;
  119. color: #666;
  120. }
  121. .address .addressCon .name {
  122. font-size: 30rpx;
  123. color: #282828;
  124. font-weight: bold;
  125. margin-bottom: 10rpx;
  126. }
  127. .address .addressCon .name .phone {
  128. margin-left: 50rpx;
  129. }
  130. .address .addressCon .default {
  131. margin-right: 12rpx;
  132. }
  133. .address .addressCon .setaddress {
  134. color: #333;
  135. font-size: 28rpx;
  136. }
  137. .address .iconfont {
  138. font-size: 35rpx;
  139. color: #707070;
  140. }
  141. .allAddress {
  142. width: 100%;
  143. padding-top: 100rpx;
  144. padding-bottom: 10rpx;
  145. }
  146. .allAddress .nav {
  147. width: 690rpx;
  148. margin: 0 auto;
  149. }
  150. .allAddress .nav .item {
  151. width: 334rpx;
  152. }
  153. .allAddress .nav .item.on {
  154. position: relative;
  155. width: 230rpx;
  156. }
  157. .allAddress .nav .item.on::before {
  158. position: absolute;
  159. bottom: 0;
  160. content: '快递配送';
  161. font-size: 28rpx;
  162. display: block;
  163. height: 0;
  164. width: 336rpx;
  165. border-width: 0 20rpx 80rpx 0;
  166. border-style: none solid solid;
  167. border-color: transparent transparent #fff;
  168. z-index: 2;
  169. border-radius: 14rpx 36rpx 0 0;
  170. text-align: center;
  171. line-height: 80rpx;
  172. }
  173. .allAddress .nav .item:nth-of-type(2).on::before {
  174. content: '到店自提';
  175. border-width: 0 0 80rpx 20rpx;
  176. border-radius: 36rpx 14rpx 0 0;
  177. }
  178. .allAddress .nav .item.on2 {
  179. position: relative;
  180. }
  181. .allAddress .nav .item.on2::before {
  182. position: absolute;
  183. bottom: 0;
  184. content: '到店自提';
  185. font-size: 28rpx;
  186. display: block;
  187. height: 0;
  188. width: 401rpx;
  189. border-width: 0 0 60rpx 60rpx;
  190. border-style: none solid solid;
  191. border-color: transparent transparent #f7c1bd;
  192. border-radius: 36rpx 14rpx 0 0;
  193. text-align: center;
  194. line-height: 60rpx;
  195. }
  196. .allAddress .nav .item:nth-of-type(1).on2::before {
  197. content: '快递配送';
  198. border-width: 0 60rpx 60rpx 0;
  199. border-radius: 14rpx 36rpx 0 0;
  200. }
  201. .allAddress .address {
  202. width: 690rpx;
  203. max-height: 180rpx;
  204. margin: 0 auto;
  205. }
  206. .allAddress .line {
  207. width: 100%;
  208. margin: 0 auto;
  209. }
  210. </style>