| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- <template>
- <view>
- <u-sticky h5-nav-height="0">
- <u-tabs :list="list" active-color="#5c40e8" :is-scroll="false" :current="current" @change="change"></u-tabs>
- </u-sticky>
- <view v-if="current == 0">
- <block v-if="!$u.test.isEmpty(giftList)">
- <block v-for="(item, index) in giftList" :key="index">
- <view class="card" @click="select(item)">
- <view class="flex">
- <view :class="item.selected==true ? 'theme-color cuIcon-roundcheckfill':'cuIcon-round'" class="padding-sm" style="font-size: 50upx;"></view>
- <view class="padding-tb-sm">
- <view class="flex margin-top-xs">
- <image :src="item.goods.goodsPic" style="width: 220upx;height: 220upx;border-radius: 10rpx;"></image>
- <view class="padding-left-sm">
- <view class="name text-cut" style="width: 350upx;">{{item.goods.goodsName}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="flex justify-end padding" style="margin-top: -110upx;">
- <view class="count" style="border: #d9d9d9 1upx solid;" v-if="!item.selected">x{{item.exCount}}</view>
- <view class="justify-center flex align-center" v-else>
- <view class="" @click.stop="minus(item)"> <u-icon name="minus-circle-fill" color="#5a3ee8" size="36"></u-icon> </view>
- <input type="number" class="text-center input" v-model="item.exCount" />
- <view class="" @click.stop="plus(item)"> <u-icon name="plus-circle-fill" color="#5a3ee8" size="36"></u-icon> </view>
- </view>
- </view>
- </view>
- </block>
- <view style="height: 120upx;"></view>
- <view style="z-index: 9;" class="footer-fixed flex align-center justify-between padding-sm bg-white">
- <view class="flex align-center" @click="selectAll">
- <view :class="selectAllShow ? 'theme-color cuIcon-roundcheckfill':'cuIcon-round'" class="padding-right-xs" style="font-size: 50upx;"></view>
- <view class="text-sm padding-right-xs">全选</view>
- </view>
- <view>
- <button class="cu-btn round text-white theme-bg-color" style="width: 180upx;height: 80upx;margin-right: 30upx;" @click="donate">捐赠</button>
- <button class="cu-btn round text-white theme-bg-color" style="width: 180upx;height: 80upx;" @click="navTap">领取</button>
- </view>
- </view>
- </block>
- <u-empty v-else margin-top="300" text="暂无礼物" mode="list"></u-empty>
- </view>
- <view v-if="current == 1 || current==2">
- <block v-for="(item, index) in doneList" :key="index">
- <view class="card" >
- <view class="padding">
- <view class="flex margin-top-xs">
- <image :src="item.goodsPic" style="width: 220upx;height: 220upx"></image>
- <view class="padding-left-sm">
- <view class="name text-cut" style="width: 350upx;">{{item.goodsName}}</view>
- </view>
- </view>
- </view>
- <view class="flex justify-end padding" style="margin-top: -120upx;">
- <view class="count">x{{item.count}}</view>
- </view>
- <view v-if="current==1" class="flex justify-end" style="padding:0 20rpx 15rpx;">
- <view class="">
- <u-button size="mini" class="custom-style-sm" shape="circle" @click="gains(item)">确认收货</u-button>
- </view>
- </view>
- </view>
- </block>
- </view>
- <u-popup v-model="dialogShow" mode="center" width="500" height="480" border-radius="30">
- <view class="bg-img text-center" style="background-image: url('https://upload-file-data.obs.cn-south-1.myhuaweicloud.com/e914f556be414767aca011a30961560a-dialogBgImg.png');height: 600rpx;">
- <view style="height: 80upx;"></view>
- <view style="font-size: 50upx;font-family: PingFang SC;font-weight: 600;color: #ffffff;">感谢你</view>
- <view class="text-bold text-black" style="padding: 80upx 0;">广发基金会已收到您的捐赠!</view>
- <view class="padding">
- <u-button class="custom-style" shape="circle" @click="confirm">确定</u-button>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- userId: '',
- successList:[],
-
- list: [{
- name: '待领取'
- }, {
- name: '配送中'
- }, {
- name: '已完成'
- }],
- current: 0,
- selectAllShow: false,
- clickShow: false,
- giftList: [],
- doneList:[],
- dialogShow: false,
- }
- },
- onLoad() {
- this.userId = uni.getStorageSync("userId");
- if (!this.userId) {
- this.$u.toast('用户未登录')
- return
- }
- this.init()
- },
- onShow() {
- this.init()
- },
- methods: {
- init(){
- if (!this.userId) {
- this.$u.toast('用户未登录')
- return
- }
- this.getMineGiftList()
- },
- getMineGiftList(){
- this.$u.api.goods.getMineGoods({userId:this.userId}).then(res=>{
- this.giftList=res.records
- this.giftList.forEach(item=>{
- item.selected=false
- item.exCount=item.count
- })
- })
- },
- getDoneGift(distributionStatus){
- this.$u.api.goods.doneList({userId:this.userId,distributionStatus}).then(res=>{
- this.doneList=res.records
- })
- },
- change(index) {
- this.current = index;
- if(index==1){
- this.getDoneGift(0)
- }
- if (index==2) {
- this.getDoneGift(1)
- }
- },
- select(item) {
- item.selected=!item.selected
- let flag = true;
- for (let item of this.giftList) {
- if (!item.selected) {
- flag = false;
- }
- }
- this.selectAllShow = flag;
- this.$forceUpdate()
- },
- selectAll() {
- this.selectAllShow = !this.selectAllShow;
- for (let item of this.giftList) {
- if (this.selectAllShow) {
- item.selected = true;
- } else {
- item.selected = false;
- }
- }
- },
- donate() {
- let flag=false
- this.giftList.forEach(item=>{
- if (item.selected) {
- flag=true
- }
- })
- if (!flag) {
- uni.showToast({
- title:"请至少选择一个礼物!",
- icon:"none"
- })
- return
- }
- let newList=this.getSelectGoods()
- this.$dialog.showModal("确认捐赠?").then(()=>{
- this.$u.api.goods.donate(newList).then(res=>{
- // this.successList=res.records
- this.dialogShow=true
- })
- })
- },
- getSelectGoods(){
- let newList=[]
- this.giftList.forEach(item=>{
- if (item.selected) {
- let obj={
- id:item.id,
- userId:item.userId,
- goodsId:item.goodsId,
- activityIds:item.activityIds,
- count:item.exCount
- }
- newList.push(obj)
- }
- })
- return newList
- },
- confirm(){
- this.dialogShow = false;
- this.getMineGiftList()
- },
- gains(item){
- this.$dialog.showModal("确认收货?").then(()=>{
- let data= this.$u.deepClone(item)
- data.distributionStatus=1
- this.$u.api.goods.done(data).then(res=>{
- this.getDoneGift(0)
- })
- })
- },
- navTap() {
- let newList=[]
- this.giftList.forEach(item=>{
- if (item.selected) {
- let obj={
- id:item.id,
- userId:item.userId,
- goodsId:item.goodsId,
- activityIds:item.activityIds,
- count:item.exCount,
- goodsPic:item.goods.goodsPic,
- goodsName:item.goods.goodsName,
- }
- newList.push(obj)
- }
- })
- if (this.$u.test.isEmpty(newList)) {
- this.$u.toast("请至少选择一个礼物")
- return
- }
- let params=JSON.stringify(newList)
- uni.navigateTo({
- url: '/pages/activityList/mine/order/orderConfirm?goods='+params
- })
- },
- //礼物+
- plus(item) {
- if (item.exCount<item.count) {
- item.exCount++
- }
- this.$forceUpdate()
- },
- //礼物 -
- minus(item) {
- if (item.exCount>1) {
- item.exCount--
- }
- this.$forceUpdate()
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .card {
- margin: 20upx;
- border-radius: 16upx;
- background-color: #FFFFFF;
- .title {
- font-size: 28upx;
- font-family: PingFang SC;
- font-weight: 800;
- color: #222222;
- }
- .name {
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 800;
- color: #222222;
- }
- .specification {
- padding-top: 30upx;
- font-size: 24upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #959595;
- }
- .count {
- width: 60upx;
- height: 60upx;
- border-radius: 16upx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- .input {
- width: 80upx;
- background-color: #ffffff;
- text-align: center;
- border: none;
- height: 60rpx;
- min-height: 1.8rem;
- }
- .custom-style {
- background-color: #5b3ee7;
- width: 250upx;
- color: #ffffff;
- }
- .custom-style-sm {
- background-color: #5b3ee7;
- color: #ffffff;
- }
- </style>
|