From 8478015e961b93963e0a269d92c281d84da44f63 Mon Sep 17 00:00:00 2001 From: xuxueyang <xuxy@fengyuntec.com> Date: 星期一, 09 九月 2024 23:47:09 +0800 Subject: [PATCH] update 会员信息、兑换商品等 --- sub_pages/customer/coupon/good-self.vue | 84 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 76 insertions(+), 8 deletions(-) diff --git a/sub_pages/customer/coupon/good-self.vue b/sub_pages/customer/coupon/good-self.vue index 0813670..547ac56 100644 --- a/sub_pages/customer/coupon/good-self.vue +++ b/sub_pages/customer/coupon/good-self.vue @@ -1,6 +1,6 @@ <template> <view class="coupon-container"> - <view class="p10"> + <view class="p10" v-if="source!=='shopping'"> <top-tabs :tabs="tabs" :flg="flg" @change="changeTab" type="coupon"> </top-tabs> @@ -20,23 +20,39 @@ <view class="time word-e"> {{item.description||''}} </view> - <view class="button" @click="getPointGood(item)"> + <view class="button" @click="getPointGood(item)" v-if="source!=='shopping'"> 查看详情 + </view> + <view class="button" @click="updateSelectGood(item)" v-if="source=='shopping'"> + {{isIngood(item)?'移除':'添加'}} </view> </view> </view> - <view class="tip"> + <!-- <view class="tip"> <span class="t-red">*</span>此券每人限领1张。仅限用于花满芜鲜花交易平台鲜切花花款满额使用,不可与其他优惠同享、不可叠加使用 - </view> + </view> --> </view> </view> - <!-- <view style="min-height: 130rpx;"></view> --> + <view style="min-height: 130rpx;" v-if="source=='shopping'"></view> + <view class="bottom-button" @click="backpage()" v-if="source=='shopping'">返回订单结算</view> + <!-- <view class="bottom-button" @click="toGoodAll">前往兑换</view> --> </view> </template> <script> + import { + mapState + } from 'vuex' export default { + computed: { + ...mapState({ + cache_goods: state => { + return state.cache.goods || [] + }, + }), + }, + data() { return { flg: 0, @@ -62,16 +78,68 @@ query: { status: 'A' }, - list: [] + list: [], + source: '' + } }, - async onLoad() { - this.listApi = '/api/customer/point/goods/exchange/list' + onReachBottom() { + this.getMore() + }, + async onLoad(options) { + if (options.source) { + this.source = options.source || '' + } + if (this.source === 'shopping') { + //只展示可用的 + this.page.size = 100 + this.listApi = '/api/customer/point/goods/exchange/list' + } else { + this.listApi = '/api/customer/point/goods/exchange/list' + } this.getList() }, methods: { + isIngood(item) { + for (var tmp of this.cache_goods) { + if (tmp.id == item.id) { + return true + } + } + + return false + }, + async updateSelectGood(item) { + var has = false + for (var tmp of this.cache_goods) { + if (tmp.id == item.id) { + has = true + break + } + } + var arr = [] + + if (has) { + //移除 + var arr = [] + for (var tmp of this.cache_goods) { + if (tmp.id == item.id) {} else { + arr.push(tmp) + } + } + } else { + //添加 + for (var tmp of this.cache_goods) { + arr.push(tmp) + } + arr.push(item) + } + await this.$store.dispatch('cache_coupon_select', arr) + this.$forceUpdate() + + }, changeTab(flg) { this.flg = '' + flg this.query.status = this.tabs[flg].status -- Gitblit v1.9.3