shoppingMall.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 :src="goods.icon" class="rounded-t-lg w-full" style="height: 200px" />
  12. <div class="fontPFSCS p-2">{{ goods.name }}</div>
  13. <div class="text-right pr-2 mb-1">
  14. <span style="font-size: 12px">积分:</span>
  15. <span class="fontPFSCS text-red-500">{{ goods.integral }}</span>
  16. </div>
  17. <!-- <div ></div> -->
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import { goodsList, submitGoods } from '@/api/shoppingMall'
  24. export default {
  25. data() {
  26. return {
  27. list: [],
  28. }
  29. },
  30. methods: {
  31. handleSubmit(goods) {
  32. wx.showModal({
  33. title: '提示',
  34. content: '确认兑换商品?',
  35. success: res => {
  36. if (res.confirm) {
  37. console.log('用户点击确定')
  38. submitGoods({ id: goods.id }).then(res => {
  39. console.log(res)
  40. if (res.errno === 0) {
  41. wx.showToast({
  42. title: '兑换成功',
  43. icon: 'success',
  44. duration: 2000,
  45. })
  46. } else {
  47. // wx.showToast({
  48. // title: res.msg,
  49. // icon: 'none',
  50. // duration: 2000,
  51. // })
  52. }
  53. })
  54. } else if (res.cancel) {
  55. console.log('用户点击取消')
  56. }
  57. },
  58. })
  59. },
  60. },
  61. created() {
  62. console.log(1)
  63. goodsList({ page: 1, limit: 1000 }).then(res => {
  64. this.list = res.data.list
  65. })
  66. },
  67. }
  68. </script>