球星卡微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
3.6 KiB

  1. <template>
  2. <view style="flex-direction: column;">
  3. <scroll-view class="scroll-view" :scroll-y="true">
  4. <view class="addressItem" v-for="(item, index) in addressList" :key="item.id" @click="selectAddress(item)">
  5. <view class="addressItemTop">
  6. <text class="addrName">{{ item.name }}</text>
  7. <text class="addrTel">{{ item.phone }}</text>
  8. </view>
  9. <text class="addr">{{ item.address }}</text>
  10. <view class="line"></view>
  11. <view class="optionsPanel">
  12. <radio-group @change="radioChange" @click.stop>
  13. <label>
  14. <radio :value="item.id" :checked="item.isDefault" color="#e7a23f"></radio>
  15. <text>设置为默认地址</text>
  16. </label>
  17. </radio-group>
  18. <view class="rightPanel">
  19. <image class="optionsBtn" src="../../static/删除.png" @click.stop="remove"></image>
  20. <image class="optionsBtnEdit" src="../../static/编辑.png" @click.stop="$url('/packages/addAddress/addAddress?id='+ item.id)"></image>
  21. </view>
  22. </view>
  23. <view style="height: 30rpx;background-color: #F6F6F6;"></view>
  24. </view>
  25. </scroll-view>
  26. <view class="addNewAddr" @click="$url('/packages/addAddress/addAddress')">
  27. <text>+ 新增收获地址</text>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. addressList: [{
  36. id: '1',
  37. name: '邓平艺',
  38. phone: '18454545455',
  39. address: '北京北京市海淀区钻石大厦C座',
  40. isDefault: true
  41. },{
  42. id: '2',
  43. name: '邓艺平',
  44. phone: '18454545455',
  45. address: '北京北京市海淀区钻石大厦C座',
  46. isDefault: false
  47. },{
  48. id: '3',
  49. name: '洛阳',
  50. phone: '18454545455',
  51. address: '北京北京市海淀区钻石大厦C座',
  52. isDefault: false
  53. }],
  54. is_select: false
  55. }
  56. },
  57. onLoad(options){
  58. this.is_select = Boolean(Number(options.is_select || '0'));
  59. },
  60. methods: {
  61. radioChange(event){
  62. let id = event.detail.value;
  63. this.addressList.forEach(item => {
  64. if(item.id === id){
  65. item.isDefault = true;
  66. }else{
  67. item.isDefault = false;
  68. }
  69. });
  70. },
  71. remove(){
  72. this.$msg('删除')
  73. },
  74. selectAddress(item){
  75. if(!this.is_select) return;
  76. let pages = getCurrentPages();
  77. let page = pages[pages.length - 2]; // 访问上一个页面
  78. page.$vm.address = item; // 将选中的地址赋值回去
  79. this.$toBack();
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped class="scss">
  85. /deep/view{
  86. display: flex;
  87. background-color: #FFFFFF;
  88. }
  89. .scroll-view{
  90. height: calc(100vh - 200rpx);
  91. }
  92. .checkBtn{
  93. width: 44rpx;
  94. height: 44rpx;
  95. margin-right: 14rpx;
  96. }
  97. .addressItemTop{
  98. align-items: center;
  99. margin-top: 20rpx;
  100. margin-bottom: 20rpx;
  101. }
  102. .addressItem{
  103. flex-direction: column;
  104. }
  105. .line{
  106. height: 1rpx;
  107. background-color: #D8D8D8;
  108. margin-left: 32rpx;
  109. margin-right: 32rpx;
  110. margin-top: 20rpx;
  111. margin-bottom: 20rpx;
  112. }
  113. .addrName{
  114. margin-left: 32rpx;
  115. font-size: 36rpx;
  116. font-weight: bold;
  117. margin-right: 40rpx;
  118. }
  119. .addr{
  120. margin-left: 32rpx;
  121. }
  122. .optionsPanel{
  123. margin-left: 32rpx;
  124. margin-bottom: 40rpx;
  125. align-items: center;
  126. justify-content: space-between;
  127. }
  128. .rightPanel{
  129. align-items: center;
  130. justify-content: center;
  131. margin-right: 32rpx;
  132. }
  133. .optionsBtn{
  134. width: 44rpx;
  135. height: 44rpx;
  136. margin-right: 50rpx;
  137. }
  138. .optionsBtnEdit{
  139. width: 38rpx;
  140. height: 38rpx;
  141. }
  142. .addNewAddr{
  143. height: 96rpx;
  144. /* width: 90%; */
  145. width: 686rpx;
  146. border: #E7A23F 2rpx solid;
  147. border-radius: 8rpx;
  148. position: fixed;
  149. bottom: 100rpx;
  150. left: calc(50% - 343rpx);
  151. justify-content: center;
  152. align-items: center;
  153. align-self: center;
  154. color: #E7A23F;
  155. }
  156. </style>