addressSelection.vue 6.5 KB

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