receivingAddress.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="address-list-page">
  3. <view class="custom-navbar">
  4. <view class="navbar-left" @click="goBack">
  5. <text class="fa fa-angle-left"></text>
  6. </view>
  7. <view class="navbar-center"> 收货地址 </view>
  8. <view class="navbar-right">
  9. <view class="add-btn blick-btn-animation" @click="goAdd">新增</view>
  10. </view>
  11. </view>
  12. <view class="address-card" v-for="item in addressList" :key="item.id" @click="selectAddress(item)" :style="isSelectAddress && selectedAddress && selectedAddress.id === item.id ? 'border-color: #000000;' : ''">
  13. <view class="left">
  14. <view class="row">
  15. <text class="name">{{ item.realname }}</text>
  16. <text class="mobile">{{ item.mobile }}</text>
  17. <text class="default" v-if="item.isDefault">默认</text>
  18. <!-- <image class="edit" src="@/static/icon/edit.png" @click="goEdit(item)" /> -->
  19. </view>
  20. <view class="address two-omit">{{ item.area }}</view>
  21. </view>
  22. <view class="right" @click.stop="goEdit(item)">
  23. <image src="@/static/icon/sy_icon_fabiao.png" />
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. addressList: [ ],
  33. isSelectAddress: false,
  34. selectedAddress: null,
  35. selectedSpec:null,
  36. detail:null
  37. };
  38. },
  39. onLoad(options) {
  40. if (options.isSelectAddress == true || options.isSelectAddress == 'true') {
  41. this.isSelectAddress = true;
  42. const eventChannel = this.getOpenerEventChannel();
  43. eventChannel.on('acceptDataFromOpener', (data) => {
  44. this.selectedSpec = data.selectedSpec;
  45. this.detail = data.detail;
  46. console.log('接收到的数据:', this.selectedSpec, this.detail);
  47. });
  48. }
  49. },
  50. onShow() {
  51. this.getAddressList();
  52. },
  53. methods: {
  54. goBack() {
  55. uni.navigateBack();
  56. },
  57. goAdd() {
  58. uni.navigateTo({ url: "/pages/crowdFunding/addressEdit" });
  59. },
  60. goEdit(item) {
  61. uni.navigateTo({ url: "/pages/crowdFunding/addressEdit?id=" + item.id });
  62. },
  63. selectAddress(item) {
  64. if (this.isSelectAddress) {
  65. this.selectedAddress = item;
  66. uni.navigateTo({
  67. url: '/pages/crowdFunding/orderConfirm',
  68. success: function(res) {
  69. // 通过 eventChannel 向被打开页面传送数据
  70. res.eventChannel.emit('acceptDataFromOpener', { selectedSpec: this.selectedSpec, detail: this.detail });
  71. res.eventChannel.emit('acceptAddress', item);
  72. }.bind(this)
  73. });
  74. }
  75. },
  76. getAddressList() {
  77. uni.request({
  78. url: this.$apiHost + '/Address/getlist',
  79. method: 'GET',
  80. data: {
  81. id: this.projectId,
  82. uuid: getApp().globalData.uuid,
  83. skey: getApp().globalData.skey
  84. },
  85. success: (res) => {
  86. if (res.data ) {
  87. this.addressList = res.data.list;
  88. console.log(this.addressList,"地址列表");
  89. // 可根据接口返回字段设置isFavorite等
  90. }
  91. }
  92. });
  93. },
  94. },
  95. };
  96. </script>
  97. <style lang="scss">
  98. .address-list-page {
  99. min-height: 100vh;
  100. background: #f6faf6;
  101. /* 自定义导航栏样式 */
  102. .custom-navbar {
  103. display: flex;
  104. align-items: center;
  105. justify-content: space-between;
  106. width: 100%;
  107. height: calc(90rpx + var(--status-bar-height));
  108. padding: 0 20rpx;
  109. padding-top: var(--status-bar-height);
  110. background-color: #ffffff;
  111. position: sticky;
  112. top: 0;
  113. z-index: 100;
  114. .navbar-left {
  115. width: 80rpx;
  116. height: 80rpx;
  117. display: flex;
  118. align-items: center;
  119. justify-content: center;
  120. .fa-angle-left {
  121. font-size: 48rpx;
  122. color: #333;
  123. }
  124. }
  125. .navbar-center {
  126. flex: 1;
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. font-size: 28rpx;
  131. font-weight: bold;
  132. color: #1f1f1f;
  133. }
  134. .navbar-right {
  135. .add-btn {
  136. background: #1f1f1f;
  137. color: #acf934;
  138. border-radius: 32rpx;
  139. padding: 6rpx 32rpx;
  140. display: flex;
  141. align-items: center;
  142. font-size: 28rpx;
  143. }
  144. }
  145. }
  146. .address-card {
  147. background: #fff;
  148. border-radius: 18rpx;
  149. margin: 16rpx 20rpx;
  150. padding: 32rpx;
  151. padding-right: 0;
  152. display: flex;
  153. align-items: center;
  154. justify-content: space-between;
  155. border: 2rpx solid transparent;
  156. .left{
  157. height: 100%;
  158. .row {
  159. display: flex;
  160. align-items: center;
  161. margin-bottom: 12rpx;
  162. .name {
  163. font-size: 32rpx;
  164. font-weight: bold;
  165. margin-right: 18rpx;
  166. }
  167. .mobile {
  168. font-size: 32rpx;
  169. margin-right: 18rpx;
  170. }
  171. .default {
  172. font-size: 22rpx;
  173. color: #fff;
  174. background: #1f1f1f;
  175. border-radius: 8rpx;
  176. padding: 2rpx 12rpx;
  177. margin-right: 12rpx;
  178. }
  179. .edit {
  180. width: 32rpx;
  181. height: 32rpx;
  182. margin-left: auto;
  183. }
  184. }
  185. .address {
  186. font-size: 26rpx;
  187. color: #666;
  188. }
  189. }
  190. .right{
  191. width: 100rpx;
  192. height: 90rpx;
  193. flex-shrink: 0;
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. image{
  198. width: 32rpx;
  199. height: 32rpx;
  200. }
  201. }
  202. }
  203. }
  204. </style>