index.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="addressList">
  3. <!-- header -->
  4. <cu-custom isBack bgColor="bg-gradual-blue"><view slot="content">地址列表</view></cu-custom>
  5. <!-- section -->
  6. <view class="section">
  7. <radio-group @change="radioChange">
  8. <view v-for="(item, index) in value" :key="index" class="item bg-white margin padding radius flex align-center">
  9. <view class="margin-right-sm"><radio style="transform: scale(0.6);" class="radio" :value="item.id" :checked="item.isDefault" /></view>
  10. <view style="flex: auto;">
  11. <view class="flex align-center text-xl">
  12. <text class="margin-right-sm text-black">{{ item.name }}</text>
  13. <text class="margin-right-sm text-black">{{ item.tel }}</text>
  14. <text v-if="item.isDefault" class="cu-tag text-white round sm" style="background-color:#ee0a24;">默认</text>
  15. </view>
  16. <view class="a">{{ item.address }}</view>
  17. </view>
  18. <view class="margin-left-sm"><text class="cuIcon-writefill text-xxl text-gray"></text></view>
  19. </view>
  20. </radio-group>
  21. </view>
  22. <!-- footer -->
  23. <view class="footer">
  24. <view class="footer-content padding bg-white"><button @click="handler" class="cu-btn block">新增地址</button></view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. value: [
  33. {
  34. id: '1',
  35. name: '张三',
  36. tel: '13000000000',
  37. address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
  38. isDefault: true
  39. },
  40. {
  41. id: '2',
  42. name: '李四',
  43. tel: '1310000000',
  44. address: '浙江省杭州市拱墅区莫干山路 50 号'
  45. }
  46. ]
  47. };
  48. },
  49. methods: {
  50. handler() {
  51. uni.navigateTo({
  52. url: '/loginPages/addaddress/index'
  53. });
  54. },
  55. radioChange(e){
  56. var {value}=e.detail,list=JSON.parse(JSON.stringify(this.value));
  57. // 取消默认
  58. var isDefaultIndex=list.findIndex(item=>item.isDefault);
  59. list[isDefaultIndex]['isDefault']=false;
  60. // 默认赋值
  61. isDefaultIndex=list.findIndex(item=>item.id==value);
  62. list[isDefaultIndex]['isDefault']=true;
  63. this.value=list;
  64. }
  65. }
  66. };
  67. </script>
  68. <style lang="scss" scoped>
  69. .addressList {
  70. .section {
  71. .item {
  72. width: calc(100vw - 60upx);
  73. box-sizing: border-box;
  74. }
  75. }
  76. .footer {
  77. height: 140upx;
  78. height: calc(140rpx + env(safe-area-inset-bottom) / 2);
  79. padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  80. .footer-content {
  81. position: fixed;
  82. bottom: 0;
  83. left: 0;
  84. width: 100%;
  85. button {
  86. background-color: #ee0a24;
  87. color: #fff;
  88. height: 80upx;
  89. border-radius: 80upx;
  90. }
  91. }
  92. }
  93. }
  94. </style>