shoppingMall.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div class="" style="background-color: #171520; height: 100vh">
  3. <div class="py-3 px-2 flex flex-wrap justify-between">
  4. <div
  5. style="width: 175px"
  6. v-for="goods in list"
  7. :key="goods.id"
  8. @click="handleSubmit(goods)"
  9. class="mx-1 bg-white rounded-lg shadow-md mb-2"
  10. >
  11. <img
  12. :src="goods.icon"
  13. class="rounded-t-lg w-full"
  14. style="height: 200px"
  15. />
  16. <div class="fontPFSCS p-2">{{ goods.name }}</div>
  17. <div class="text-right pr-2 mb-1">
  18. <span style="font-size: 12px">积分:</span>
  19. <span class="fontPFSCS text-red-500">{{ goods.integral }}</span>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { goodsList, submitGoods } from '@/api/shoppingMall'
  27. export default {
  28. data() {
  29. return {
  30. list: [],
  31. }
  32. },
  33. methods: {
  34. handleSubmit(goods) {
  35. wx.showModal({
  36. title: '提示',
  37. content: '确认兑换商品?',
  38. success: (res) => {
  39. if (res.confirm) {
  40. console.log('用户点击确定')
  41. submitGoods({ id: goods.id }).then((res) => {
  42. console.log(res)
  43. })
  44. } else if (res.cancel) {
  45. console.log('用户点击取消')
  46. }
  47. },
  48. })
  49. },
  50. },
  51. created() {
  52. goodsList({ page: 1, limit: 1000 }).then((res) => {
  53. this.list = res.data.list
  54. })
  55. },
  56. }
  57. </script>