mapAd.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <uni-popup
  3. class="picker-popup"
  4. ref="mapAdPopupRef"
  5. type="bottom"
  6. border-radius="10px 10px 0 0"
  7. >
  8. <div class="picker-content">
  9. <div class="city-picker-btn">
  10. <text @click.stop="cancel()">取消</text>
  11. <text @click.stop="confirm()">确定</text>
  12. </div>
  13. <picker-view
  14. indicator-class="indicator-class"
  15. :value="value || []"
  16. class="picker-view"
  17. @change="bindChange"
  18. >
  19. <picker-view-column>
  20. <view class="item" v-for="(item, index) in mapAdList" :key="index">{{
  21. item.adName
  22. }}</view>
  23. </picker-view-column>
  24. </picker-view>
  25. </div>
  26. </uni-popup>
  27. </template>
  28. <script>
  29. import { getMapAdList_Api } from "@/api/map.js";
  30. export default {
  31. name: "mapAd",
  32. props: {
  33. mapAdId: {
  34. type: String,
  35. default: null,
  36. },
  37. },
  38. data() {
  39. return {
  40. value: [],
  41. mapAdList: [],
  42. };
  43. },
  44. watch: {},
  45. created() {
  46. this.init();
  47. },
  48. mounted() {},
  49. methods: {
  50. init() {
  51. const parms = { typeStatus: "ENABLE" };
  52. getMapAdList_Api(parms).then((res) => {
  53. this.mapAdList = res || [];
  54. });
  55. },
  56. open() {
  57. this.$refs.mapAdPopupRef.open();
  58. },
  59. bindChange(val) {
  60. const { value } = val.detail;
  61. this.value = value || [0];
  62. },
  63. confirm() {
  64. const in_ = this.value[0] || 0;
  65. const item = this.mapAdList[in_];
  66. this.$emit("update:mapAdId", item.mapAdId);
  67. this.$emit("mapAdSelect", item);
  68. this.cancel();
  69. },
  70. cancel() {
  71. this.$refs.mapAdPopupRef.close();
  72. },
  73. },
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. </style>