select.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <view class="address-box">
  4. <radio-group @change="radioChange">
  5. <view class="address-box-list" v-for="(item, index) in items" :key="item.value">
  6. <label>
  7. <view class="address-box-select">
  8. <radio :value="item.value" :checked="index === current" />
  9. </view>
  10. <view class="address-box-left2">
  11. <text class="address-box-title">{{item.name}} </text>
  12. <text class="address-box-desc">asd asdsa dasda sdad asdas</text>
  13. </view>
  14. </label>
  15. <view class="address-box-right">
  16. <image src="../../images/edit.png"></image>
  17. </view>
  18. </view>
  19. </radio-group>
  20. <view class="address-nodata">
  21. 还没有添加收货地址哦~
  22. </view>
  23. </view>
  24. <view class="bottom-btn">
  25. 新增收货地址
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. title: 'radio 单选框',
  34. items: [{
  35. value: 'USA',
  36. name: '美国'
  37. },
  38. {
  39. value: 'CHN',
  40. name: '中国',
  41. checked: 'true'
  42. },
  43. {
  44. value: 'BRA',
  45. name: '巴西'
  46. },
  47. {
  48. value: 'JPN',
  49. name: '日本'
  50. },
  51. {
  52. value: 'ENG',
  53. name: '英国'
  54. },
  55. {
  56. value: 'FRA',
  57. name: '法国'
  58. },
  59. ],
  60. current: 0
  61. }
  62. },
  63. onLoad() {
  64. },
  65. methods: {
  66. radioChange(evt) {
  67. for (let i = 0; i < this.items.length; i++) {
  68. if (this.items[i].value === evt.detail.value) {
  69. this.current = i;
  70. break;
  71. }
  72. }
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .address-box{
  79. padding-bottom: 100rpx;
  80. }
  81. .address-nodata{
  82. margin-top: 150rpx;
  83. text-align: center;
  84. font-size: 32rpx;
  85. color: #666666;
  86. }
  87. .address-box-list{
  88. background-color: #FFFFFF;
  89. margin: 10rpx 0;
  90. padding: 10rpx 20rpx;
  91. overflow: hidden;
  92. }
  93. .address-box-left2{
  94. display: inline-block;
  95. width: 570rpx;
  96. height: auto;
  97. float: left;
  98. }
  99. .address-box-left2 .address-box-title{
  100. display: inline-block;
  101. width: 100%;
  102. height: 30rpx;
  103. line-height: 30rpx;
  104. color: #3E3E3E;
  105. font-size: 32rpx;
  106. }
  107. .address-box-left2 .address-box-desc{
  108. display: inline-block;
  109. width: 100%;
  110. height: 30rpx;
  111. line-height: 30rpx;
  112. color: #949494;
  113. font-size: 28rpx;
  114. }
  115. .address-box-right{
  116. display: inline-block;
  117. width: 60rpx;
  118. height: auto;
  119. float: right;
  120. text-align: center;
  121. }
  122. .address-box-right image{
  123. width: 40rpx;
  124. height: 40rpx;
  125. vertical-align: middle;
  126. margin-top: 20rpx;
  127. }
  128. .address-box-select{
  129. display: inline-block;
  130. width: 60rpx;
  131. height: auto;
  132. float: left;
  133. }
  134. .address-box-select radio{
  135. width: 40rpx;
  136. height: 40rpx;
  137. // vertical-align: middle;
  138. margin-top: 20rpx;
  139. }
  140. .bottom-btn{
  141. width: 100%;
  142. height: 98rpx;
  143. line-height: 98rpx;
  144. background-color: $theme-color;
  145. color: #FFFFFF;
  146. text-align: center;
  147. position: fixed;
  148. z-index: 100;
  149. left: 0;
  150. bottom: 0;
  151. }
  152. </style>