addressSelection.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 { reactive } from 'vue';
  55. import sheep from '@/sheep';
  56. import { isEmpty } from 'lodash';
  57. const state = reactive({
  58. addressInfo: {}, // 选择的收货地址
  59. deliveryType: 1, // 收货方式 1 - 快递配送;2 - 门店自提
  60. isPickUp: true, // 门店自提是否开启 TODO puhui999: 默认开启,看看后端有开关的话接入
  61. pickUpInfo: {}, // 选择的自提门店信息
  62. });
  63. // 选择地址
  64. function onSelectAddress() {
  65. let emitName = 'SELECT_ADDRESS'
  66. let addressPage = '/pages/user/address/list'
  67. if (state.deliveryType === 2){
  68. emitName = 'SELECT_PICK_UP_INFO'
  69. addressPage = '/pages/user/goods_details_store/index'
  70. }
  71. uni.$once(emitName, (e) => {
  72. changeConsignee(e.addressInfo);
  73. });
  74. sheep.$router.go(addressPage);
  75. }
  76. // 更改收货人地址&计算订单信息
  77. async function changeConsignee(addressInfo = {}) {
  78. if (!isEmpty(addressInfo)) {
  79. if (state.deliveryType === 1){
  80. state.addressInfo = addressInfo;
  81. }
  82. if (state.deliveryType === 2){
  83. state.pickUpInfo = addressInfo;
  84. }
  85. }
  86. }
  87. // 收货方式切换
  88. const switchDeliveryType = (type) =>{
  89. state.deliveryType = type;
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .allAddress .font-color{
  94. color: #E93323!important
  95. }
  96. .line2{
  97. width: 504rpx;
  98. }
  99. .textR {
  100. text-align: right;
  101. }
  102. .line {
  103. width: 100%;
  104. height: 3rpx;
  105. }
  106. .line image {
  107. width: 100%;
  108. height: 100%;
  109. display: block;
  110. }
  111. .address {
  112. padding: 28rpx;
  113. background-color: #fff;
  114. box-sizing: border-box;
  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. background: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  144. // background-image: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  145. // background-image: -webkit-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  146. // background-image: -moz-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  147. //padding: 100rpx 30rpx 0 30rpx;
  148. padding-top: 100rpx;
  149. padding-bottom: 10rpx;
  150. }
  151. .allAddress .nav {
  152. width: 690rpx;
  153. margin: 0 auto;
  154. }
  155. .allAddress .nav .item {
  156. width: 334rpx;
  157. }
  158. .allAddress .nav .item.on {
  159. position: relative;
  160. width: 230rpx;
  161. }
  162. .allAddress .nav .item.on::before {
  163. position: absolute;
  164. bottom: 0;
  165. content: "快递配送";
  166. font-size: 28rpx;
  167. display: block;
  168. height: 0;
  169. width: 336rpx;
  170. border-width: 0 20rpx 80rpx 0;
  171. border-style: none solid solid;
  172. border-color: transparent transparent #fff;
  173. z-index: 2;
  174. border-radius: 14rpx 36rpx 0 0;
  175. text-align: center;
  176. line-height: 80rpx;
  177. }
  178. .allAddress .nav .item:nth-of-type(2).on::before {
  179. content: "到店自提";
  180. border-width: 0 0 80rpx 20rpx;
  181. border-radius: 36rpx 14rpx 0 0;
  182. }
  183. .allAddress .nav .item.on2 {
  184. position: relative;
  185. }
  186. .allAddress .nav .item.on2::before {
  187. position: absolute;
  188. bottom: 0;
  189. content: "到店自提";
  190. font-size: 28rpx;
  191. display: block;
  192. height: 0;
  193. width: 401rpx;
  194. border-width: 0 0 60rpx 60rpx;
  195. border-style: none solid solid;
  196. border-color: transparent transparent #f7c1bd;
  197. border-radius: 36rpx 14rpx 0 0;
  198. text-align: center;
  199. line-height: 60rpx;
  200. }
  201. .allAddress .nav .item:nth-of-type(1).on2::before {
  202. content: "快递配送";
  203. border-width: 0 60rpx 60rpx 0;
  204. border-radius: 14rpx 36rpx 0 0;
  205. }
  206. .allAddress .address {
  207. width: 690rpx;
  208. max-height: 180rpx;
  209. margin: 0 auto;
  210. }
  211. .allAddress .line {
  212. width: 100%;
  213. margin: 0 auto;
  214. }
  215. </style>