main.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <modal v-model="vValue">
  3. <view class="screen_all center" @click="closeModal">
  4. <view class="select-modal" @click.stop>
  5. <view class="select-modal-item row aCenter"
  6. v-for="(item,index) in data"
  7. :key="index"
  8. @click="triggerSelect(index)"
  9. >
  10. <view class="flex-all-1">
  11. <view class="line-1">{{item.label}}</view>
  12. </view>
  13. <v-radio disabled :value="select===index" color="#fff" borderColor="#7A7A7A" activeBorderColor="#41AE3C" activeColor="#41AE3C"></v-radio>
  14. </view>
  15. </view>
  16. </view>
  17. </modal>
  18. </template>
  19. <script>
  20. import modal from '@/components/modal/main';
  21. import vRadio from '@/components/v-radio/main';
  22. import props from './props';
  23. export default {
  24. data(){
  25. return {
  26. vValue:false
  27. }
  28. },
  29. watch:{
  30. value(){
  31. this.changeValue(this.value);
  32. }
  33. },
  34. methods:{
  35. changeValue(value){
  36. if (this.vValue !== value) {
  37. this.vValue = value;
  38. if (this.value !== value) {
  39. return this.$emit('input',value);
  40. }
  41. }
  42. },
  43. closeModal(){
  44. if (this.vValue) {
  45. return this.changeValue(false);
  46. }
  47. },
  48. triggerSelect(index){
  49. this.closeModal();
  50. if (this.select !== index) {
  51. return this.$emit('change',{
  52. index,
  53. item: this.data[index]
  54. })
  55. }
  56. }
  57. },
  58. props,
  59. components:{
  60. modal,
  61. vRadio
  62. }
  63. }
  64. </script>
  65. <style scoped src="./style.scss" lang="scss">
  66. </style>