12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <template>
- <div class="" style="background-color: #171520; height: 100vh; overflow: scroll">
- <div class="py-3 px-2 flex flex-wrap justify-between">
- <div
- style="width: 340rpx"
- v-for="goods in list"
- :key="goods.id"
- @click="handleSubmit(goods)"
- class="mx-1 bg-white rounded-lg shadow-md mb-2"
- >
- <img :src="goods.icon" class="rounded-t-lg w-full" style="height: 400rpx" />
- <div class="bold p-2">{{ goods.name }}</div>
- <div class="text-right pr-2 mb-1">
- <span style="font-size: 24rpx">积分:</span>
- <span class="bold text-red-500">{{ goods.integral }}</span>
- </div>
- <!-- <div ></div> -->
- </div>
- </div>
- </div>
- </template>
- <script>
- import { goodsList, submitGoods } from '@/api/shoppingMall'
- export default {
- data() {
- return {
- list: [],
- }
- },
- methods: {
- handleSubmit(goods) {
- wx.showModal({
- title: '提示',
- content: '确认兑换商品?',
- success: res => {
- if (res.confirm) {
- console.log('用户点击确定')
- submitGoods({ id: goods.id }).then(res => {
- console.log(res)
- if (res.errno === 0) {
- wx.showToast({
- title: '兑换成功',
- icon: 'success',
- duration: 2000,
- })
- } else {
- // wx.showToast({
- // title: res.msg,
- // icon: 'none',
- // duration: 2000,
- // })
- }
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- },
- })
- },
- },
- created() {
- console.log(1)
- goodsList({ page: 1, limit: 1000 }).then(res => {
- this.list = res.data.list
- })
- },
- }
- </script>
|