shoppingMall.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. if (res.errno === 0) {
  44. wx.showToast({
  45. title: '兑换成功',
  46. icon: 'success',
  47. duration: 2000,
  48. })
  49. } else {
  50. // wx.showToast({
  51. // title: res.msg,
  52. // icon: 'none',
  53. // duration: 2000,
  54. // })
  55. }
  56. })
  57. } else if (res.cancel) {
  58. console.log('用户点击取消')
  59. }
  60. },
  61. })
  62. },
  63. },
  64. created() {
  65. goodsList({ page: 1, limit: 1000 }).then((res) => {
  66. this.list = res.data.list
  67. })
  68. },
  69. }
  70. </script>