actionList.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="warp">
  3. <!-- <uni-section title="地点列表" type="line">
  4. <uni-data-select v-model="placeId" :localdata="placeList" placeholder="请选择地点" @change="handleShopChange"
  5. class="padding" />
  6. </uni-section> -->
  7. <uni-section v-if="actionList.length > 0" title="活动列表" type="line">
  8. <uni-list>
  9. <uni-list-item v-for="item in actionList" :key="item.id" showArrow :title="item.name" :clickable="true"
  10. @click="handleItemClick(item.id)" />
  11. </uni-list>
  12. </uni-section>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. mapState,
  18. mapGetters
  19. } from 'vuex'
  20. import {
  21. DefaultRequest,
  22. IdRequest
  23. } from "@/grpc/base_pb.js"
  24. export default {
  25. components: {},
  26. data() {
  27. return {
  28. placeId: 0,
  29. actionList: [],
  30. }
  31. },
  32. computed: {
  33. ...mapState([
  34. 'username', // 映射 this.username 为 store.state.username
  35. ]),
  36. ...mapGetters([
  37. 'metadata'
  38. ]),
  39. },
  40. mounted() {},
  41. onLoad() {
  42. this.loadData()
  43. },
  44. methods: {
  45. async loadData() {
  46. this.actionList = await this.getToActionList()
  47. },
  48. async getToActionList() {
  49. try {
  50. return new Promise((resolve, reject) => {
  51. // 创建请求参数并赋值
  52. var request = new DefaultRequest()
  53. // 调用客户端相应的grpc方法,发送grpc请求,并接受后台发送回来的返回值
  54. this.$client.toActionList(request, this.metadata, (err,
  55. response) => {
  56. if (err) {
  57. console.warn(`[toActionList] err: code = ${err.code}` +
  58. `, message = "${err.message}"`)
  59. reject(err)
  60. } else {
  61. let res = response.toObject()
  62. // console.log('[toActionList]', res)
  63. resolve(res.listList)
  64. }
  65. })
  66. });
  67. } catch (e) {
  68. console.log('[getToActionList] err', e)
  69. reject(e)
  70. }
  71. },
  72. // handleShopChange(actionId) {
  73. // console.log("actionId:" + actionId)
  74. // this.getControlInfoList(actionId)
  75. // this.getShopMap(actionId)
  76. // },
  77. handleItemClick(actionId) {
  78. console.log("actionId:" + actionId)
  79. uni.navigateTo({
  80. // url: '/pages/checkPoint/checkPointDetail',
  81. url: './mapShow?actionId=' + actionId
  82. })
  83. },
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. .padding {
  89. padding: 0 20rpx;
  90. }
  91. </style>