123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- f<template>
- <app-layout>
- <app-tab-nav :tabList="tabList" :activeItem="activeTab" @click="tabStatus" :theme="getTheme"></app-tab-nav>
- <view class="card-list">
- <view @click="toDetail(item)" v-for="item in list" :key="item.id">
- <view class="card-item dir-left-nowrap main-center cross-center">
- <image class="card-img" :src="item.pic_url"></image>
- <view class="name dir-top-nowrap" style="height: 100%;" v-if="item.receive_id !== 0">
- <view class="box-grow-1 dir-left-nowrap cross-bottom">
- <view class="t-omit-two">{{item.name}}</view>
- </view>
- <view class="box-grow-0">
- <view class="is_send">已转赠</view>
- </view>
- </view>
- <view class="name t-omit-two" v-else>{{item.name}}</view>
- <view class="right-box dir-top-nowrap main-center cross-center">
- <image v-if="item.is_may_use === 1"
- class="card-qr"
- @click.stop="showModal(item.id)"
- src="./../image/icon-card-qrcode.png"
- ></image>
- <span>{{activeTab == 3 ? '未核销' : '剩余'}}{{item.surplus_number}}次</span>
- </view>
- </view>
- </view>
- </view>
- <view class="no-list" v-if="list.length === 0">
- <app-no-goods background="#f7f7f7" :title="title"></app-no-goods>
- </view>
- <view class="qr-modal" @click="show=false" v-if="show">
- <view class="look-qr" @click.stop="showModal(0)">
- <view>碎屏险二维码</view>
- <view>
- <image :src="img"></image>
- </view>
- <view style="height: 60rpx">
- <view @click="saveImg">
- <button>保存图片</button>
- </view>
- </view>
- </view>
- </view>
- </app-layout>
- </template>
- <script>
- import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
- import appNoGoods from '../../../components/page-component/app-no-goods/app-no-goods.vue';
- import {mapGetters, mapState} from "vuex";
- export default {
- data() {
- return {
- tabList: [
- {id:1, name: '未使用'},
- {id:2, name: '已使用'},
- {id:3, name: '已过期'}
- ],
- show: false,
- img: '/images/share/img-share-order.png',
- activeTab: 1,
- list: [],
- more: false,
- page: 2,
- title: '暂无未使用碎屏险~'
- }
- },
- components: {
- 'app-tab-nav': appTabNav,
- 'app-no-goods': appNoGoods,
- },
- computed: {
- ...mapState({
- userInfo: state => state.user.info,
- }),
- ...mapGetters('mallConfig', {
- getTheme: 'getTheme',
- })
- },
- methods: {
- saveImg() {
- let that = this;
- // #ifndef MP-ALIPAY
- uni.authorize({
- scope: 'scope.writePhotosAlbum',
- success(res) {
- if (res.errMsg == "authorize:ok") {
- uni.downloadFile({
- url: that.img,
- success(res) {
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success() {
- uni.showToast({
- title: '保存成功',
- icon: 'success',
- duration: 1000
- })
- },
- fail() {
- uni.showToast({
- title: '保存失败',
- icon: 'none',
- duration: 1000
- })
- }
- })
- }
- })
- }
- },
- fail(res) {
- uni.showModal({
- title: '提示',
- content: '保存失败,需要授权保存到相册权限',
- showCancel: false,
- confirmText: '打开授权',
- success(e) {
- if (e.confirm) {
- uni.openSetting({});
- }
- }
- });
- }
- })
- // #endif
- // #ifdef MP-ALIPAY
- my.showLoading({
- content: '图片保存中'
- });
- my.saveImage({
- url: that.img,
- showActionSheet: true,
- success: (res) => {
- uni.showToast({
- title: '保存成功',
- icon: 'success',
- duration: 1000
- })
- },
- fail() {
- uni.showToast({
- title: '保存失败',
- icon: 'none',
- duration: 1000
- })
- },
- complete() {
- my.hideLoading();
- }
- });
- // #endif
- },
- showModal(id) {
- let that = this;
- if(id > 0) {
- uni.showLoading({
- text: '生成中...'
- });
- that.$request({
- url: that.$api.card.sqrcode,
- data: {
- cardId: id,
- },
- method: 'get'
- }).then(response => {
- uni.hideLoading();
- if (response.code === 0) {
- that.show = true;
- that.img = response.data.file_path;
- } else {
- uni.showToast({
- title: response.msg,
- icon: 'none',
- duration: 1000,
- });
- }
- }).catch(response => {
- uni.hideLoading();
- uni.showToast({
- title: response,
- icon: 'none',
- duration: 1000,
- });
- });
- }
- },
- tabStatus(e) {
- this.list = [];
- let id = e.currentTarget.dataset.id;
- if (id === 1) {
- this.title = `暂无未使用优惠券~`;
- } else if (id === 2) {
- this.title = `暂无已使用优惠券~`;
- } else if (id === 3) {
- this.title = `暂无已过期优惠券~`;
- }
- this.page = 2;
- this.activeTab = id;
- this.getList();
- },
- getList() {
- let that = this;
- that.$showLoading({
- text: '加载中...'
- });
- that.$request({
- url: that.$api.card.indexsp,
- data: {
- status: that.activeTab
- },
- }).then(response=>{
- that.$hideLoading();
- if(response.code === 0) {
- console.log(219)
- console.log(response.data.list)
- that.list = response.data.list;
- }else {
- uni.showToast({
- title: response.msg,
- icon: 'none',
- duration: 1000
- });
- }
- }).catch(() => {
- that.$hideLoading();
- that.$event.on(that.$const.EVENT_USER_LOGIN).then(()=>{
- that.getList();
- });
- });
- },
- getMore() {
- let that = this;
- uni.showLoading({
- title: '加载中...',
- });
- that.$request({
- url: that.$api.card.indexsp,
- data: {
- page: that.page,
- status: that.activeTab
- },
- }).then(response=>{
- uni.hideLoading();
- if(response.code === 0) {
- if(response.data.list.length > 0) {
- that.loading = null;
- that.list = that.list.concat(response.data.list);
- that.page++;
- }
- }else {
- uni.showToast({
- title: response.msg,
- icon: 'none',
- duration: 1000,
- });
- }
- }).catch(() => {
- that.$hideLoading();
- });
- },
- toDetail(card) {
- if (card.is_allow_send == 1) {
- uni.navigateTo({
- url: `/pages/sp/details/details?id=${card.id}`
- });
- } else {
- uni.navigateTo({
- url: `/pages/sp/details/details-no-share?id=${card.id}`
- });
- }
- },
- },
- onLoad() {
- this.getList();
- },
- onReachBottom() {
- this.getMore();
- },
- onShow: function(){
- wx.hideHomeButton()
- }
- }
- </script>
- <style scoped lang="scss">
- .no-list {
- margin-top: #{150upx};
- }
- .card-list {
- width: 100%;
- padding-top: #{10rpx};
- background-color: #f7f7f7;
- }
- .card-item {
- height: #{180rpx};
- margin: #{20rpx};
- background-color: #fff;
- color: #353535;
- font-size: #{30rpx};
- border-radius: 16#{rpx};
- .name {
- width: 402#{rpx};
- margin-left:35#{rpx};
- .is_send {
- width: #{80rpx};
- height: #{40rpx};
- color: #ff4544;
- font-size: #{20rpx};
- background-color: #ffecec;
- text-align: center;
- line-height: #{40rpx};
- margin: #{16rpx 0 20rpx 0};
- }
- }
- .card-img {
- height: #{88rpx};
- width: #{88rpx};
- border-radius: 50%;
- margin-left:24#{rpx};
- }
- .right-box {
- margin: #{65rpx} #{35rpx};
- .card-qr {
- height: #{50rpx};
- width: #{50rpx};
- }
- span {
- font-size:20#{rpx};
- color: #353535;
- margin-top:10#{rpx};
- }
- }
- }
- .qr-modal {
- position: fixed;
- left: 0;
- right: 0;
- top: 0;
- background-color: rgba(0, 0, 0, 0.5);
- height: 100%;
- width: 100%;
- z-index: 2;
- }
- .look-qr {
- position: absolute;
- background-color: #fff;
- width: #{550rpx};
- height: #{700rpx};
- left: 50%;
- margin-left: #{-275rpx};
- top: 20%;
- border-radius: #{10rpx};
- text-align: center;
- padding: #{50rpx};
- font-size: #{34rpx};
- color: #353535;
- }
- .look-qr image {
- margin-top: #{25rpx};
- height: #{450rpx};
- width: #{450rpx};
- }
- .look-qr button {
- margin: #{15rpx} auto 0;
- height: #{60rpx};
- line-height: #{60rpx};
- color: #fff;
- font-size: #{28rpx};
- width: #{200rpx};
- background-color: #ff4544;
- }
- </style>
|