mendian.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view>
  3. <view @click="showAct" class="pd16_15 flex alcenter">
  4. <view style="width: calc(100% - 40rpx);" class="flex">
  5. <text class="iconfont iconicon_location02 ft18" :style="{color:tempColor}"></text>
  6. <view class="pl10" style="width: calc(100% - 40rpx);">
  7. <view v-if="getSelectItem == null" class="ft14 cl-main ftw600">选择门店</view>
  8. <view v-if="getSelectItem != null" class="ft14 cl-main ftw600 text-over">[{{getSelectItem.name}}]{{getSelectItem.address}}</view>
  9. <view v-if="getSelectItem != null" class="ft12 mt12 cl-orange">距离{{getSelectItem.juli}}km</view>
  10. </view>
  11. </view>
  12. <text class="iconfont iconicon_arrow_small ft14 cl-notice"></text>
  13. </view>
  14. <view v-show="showmendian" class="mendian-modal">
  15. <view class="modal-bg"></view>
  16. <view class="modal-box animated fast" :class="show ? 'slideInUp' : 'slideOutDown'">
  17. <view class="modal-main">
  18. <view class="closed">
  19. <text @click="closed()" class="iconfont ft20 cl-notice iconbtn_close"></text>
  20. </view>
  21. <view class="lh20 ft16 cl-main ftw600 text-center">选择自提门店</view>
  22. <view class="pd16_15">
  23. <radio-group @change="selectMendian">
  24. <view v-for="(item,index) in mendians" :key="index" class="box noshadow pd16_15 mt16 flex alcenter space">
  25. <view style="width: calc(100% - 60rpx);">
  26. <view class="flex alcenter">
  27. <view class="tag-default mr10" v-if="item.is_tuijian == 1" :style="{background:tempColor}">推荐</view>
  28. <text class="ft14 ftw600 cl-main text-over" style="width: calc(100% - 88rpx);">[{{item.name}}]{{item.address}}</text>
  29. </view>
  30. <view class="mt8 ft12 cl-orange ">
  31. 距离{{item.juli}}km
  32. </view>
  33. </view>
  34. <radio :value="item.mendian_id" :checked="item.mendian_id == getSelectId" :color="tempColor" />
  35. </view>
  36. </radio-group>
  37. </view>
  38. <view v-if="mendians.length > 0 " class="plr15 mt40">
  39. <button class="btn-big" @click="selectYes" :style="getBtnStyle">确定选择</button>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default{
  48. props:{
  49. value:{
  50. type:Number,
  51. default:0
  52. },
  53. },
  54. data(){
  55. return {
  56. show:false,
  57. showmendian:false,
  58. isSelect:false,
  59. selectId:0,
  60. mendians:[
  61. {mendian_id:1,name:'高速店',address:'合肥市包河区万达临湖苑A区16栋1602室',juli:0.6,is_tuijian:1},
  62. {mendian_id:2,name:'万达店',address:'合肥市包河区万达临湖苑A区16栋2007室',juli:11,is_tuijian:0}
  63. ],
  64. }
  65. },
  66. computed:{
  67. getDefaultId(){
  68. if(this.mendians.length == 0) return 0;
  69. for(var a in this.mendians){
  70. if(this.mendians[a].is_tuijian == 1){
  71. return this.mendians[a].mendian_id;
  72. }
  73. }
  74. if(this.mendians[0]){
  75. return this.mendians[0].mendian_id;
  76. }
  77. },
  78. getSelectId(){
  79. if(this.isSelect){
  80. return this.selectId;
  81. }
  82. if(this.value > 0){
  83. return this.value;
  84. }
  85. return this.getDefaultId;
  86. },
  87. getSelectItem(){
  88. for(var a in this.mendians){
  89. if(this.mendians[a].mendian_id == this.value){
  90. return this.mendians[a];
  91. }
  92. }
  93. return null;
  94. }
  95. },
  96. created(){
  97. },
  98. methods:{
  99. selectMendian(e){
  100. this.isSelect = true;
  101. this.selectId = parseInt(e.detail.value);
  102. },
  103. showAct(){
  104. this.showmendian = true;
  105. this.show = true;
  106. },
  107. selectYes(){
  108. if(this.getSelectId){
  109. this.$emit('input',this.getSelectId);
  110. this.closed();
  111. }
  112. },
  113. closed(){
  114. this.show = false;
  115. setTimeout(()=>{
  116. this.showmendian = false;
  117. },400);
  118. }
  119. }
  120. }
  121. </script>
  122. <style>
  123. .mendian-modal{
  124. position: relative;
  125. z-index: 400;
  126. }
  127. .mendian-modal .modal-bg{
  128. position: fixed;
  129. z-index: 400;
  130. left: 0;
  131. top: 0;
  132. width: 100%;
  133. height: 100vh;
  134. background: rgba(0,0,0,.5);
  135. }
  136. .mendian-modal .modal-box{
  137. position: fixed;
  138. z-index: 401;
  139. background:#F5F6FA;
  140. left: 0;
  141. bottom: 0;
  142. width: 100%;
  143. padding-bottom:0rpx;
  144. padding-bottom:constant(safe-area-inset-bottom);
  145. padding-bottom:env(safe-area-inset-bottom);
  146. border-radius:32rpx 32rpx 0rpx 0rpx;
  147. }
  148. .mendian-modal .modal-main{
  149. position: relative;
  150. height: auto;
  151. overflow: hidden;
  152. padding-top: 64rpx;
  153. padding-bottom: 40rpx;
  154. }
  155. .mendian-modal .modal-main .closed{
  156. position: absolute;
  157. right: 40rpx;
  158. top: 40rpx;
  159. }
  160. .tag-default{
  161. width: 64rpx;
  162. height: 36rpx;
  163. border-radius: 4rpx;
  164. text-align: center;
  165. line-height: 36rpx;
  166. font-size: 24rpx;
  167. color:#FFFFFF;
  168. }
  169. </style>