123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- <template>
- <view class="container">
- <view class="topNav">
- <view class="hgHeight">
- </view>
- <view class="flex">
- <view class="titleItem" @click="tabList(0)" :class="{action:onIndex==0}">
- 我的盲盒
- </view>
- <view class="titleItem" @click="tabList(1)" :class="{action:onIndex==1}">
- NFT合成
- </view>
- </view>
- </view>
- <!-- 我的盲盒 -->
- <view class="ls" v-show="onIndex==0">
- <view class="ll" v-for="(item,index) in mh.list">
- <image class="imgBox" :src="item.mystery_box_info.pic" mode="scaleToFill"></image>
- <view class="bottomTitle padding-20">
- <view class="title clamp ">
- {{item.mystery_box_info.name}}
- </view>
- <view class="tip flex margin-t-10">
- <view>
- <view class="clamp">
- 官方发行
- </view>
- <view class=" margin-t-10">
- 数量:{{item.mystery_box_count}}
- </view>
- </view>
- <view class="buttom" @click="openMh(item)">打开</view>
- </view>
- </view>
- </view>
- <u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF"
- :status="mh.loadingType" />
- </view>
- <!-- NFT合成 -->
- <view class="ls" v-show="onIndex==1">
- <view @click="navGuid(item)" class="lt flex" v-for="(item,index) in nft.list">
- <image class="leftImg" :src="item.res.uri" mode="scaleToFill"></image>
- <view class="rightContent padding-c-20 flex">
- <view class="left">
- <view class="rightName clamp ">
- {{item.name}}
- </view>
- <view class="itemlist margin-t-20">
- <view class="item" v-for="(ls,ind) in item.elements">
- {{ls.info.name}}
- </view>
- </view>
- </view>
- <image class="rightImg" src="../../static/user/back.png" mode="widthFix"></image>
- </view>
- </view>
- <u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF"
- :status="nft.loadingType" />
- </view>
- <u-modal @confirm='confirmPay' :showCancelButton='true' @cancel='showAlert=false' :show="showAlert"
- title="请输入打开盲盒数量">
- <view class="slot-content padding-t-20">
- <u--input class='margin-l-30' border='surround' type='number' v-model="payNum" inputAlign='right'
- @input="changeNum"></u--input>
- </view>
- </u-modal>
- <u-modal @confirm='showAlertSuccess = false' :show="showAlertSuccess" title="盲盒开启结果">
- <scroll-view class="alertbox" scroll-y>
- <view class="slot-content padding-t-20">
- <view class="boxAlert flex" v-for="(item , inde) in successJg ">
- <image class="img" :src="item.info.uri" mode="scaleToFill"></image>
- <view>
- {{item.info.name}}
- </view>
- </view>
- </view>
- </scroll-view>
- </u-modal>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- // #ifdef H5
- import {
- weixindata
- } from '@/utils/wxAuthorized';
- // #endif
- import {
- mysteryMy,
- openMysteryMy,
- craftGuide
- } from '@/api/product.js';
- export default {
- data() {
- return {
- // 当前选中的数据对象
- actionItem: '',
- payNum: 1, //打开的数量
- // 弹出输入窗口
- showAlert: false,
- // 成功弹出窗
- showAlertSuccess: false,
- // 弹出开启盲盒结果
- successJg: [],
- onIndex: 0, //当前选中的分类
- // 盲盒里诶啊哦
- mh: {
- page: 1,
- limit: 100,
- list: [],
- loaded: false,
- loadingType: 'loadmore'
- },
- // nft合成列表
- nft: {
- page: 1,
- limit: 100,
- list: [],
- loaded: false,
- loadingType: 'loadmore'
- }
- };
- },
- computed: {
- ...mapState(['loginInterceptor', 'baseURL']),
- ...mapState('user', ['hasLogin', 'userInfo'])
- },
- onLoad: function(option) {
- // 合成表
- this.craftGuide();
- },
- onShow() {
- this.mh.page=1
- this.mh.loadingType='loadmore';
- this.mh.list=[];
- // 我的盲盒
- this.lodingMh();
- },
- methods: {
- // 跳转nft选择页面
- navGuid(item) {
- uni.navigateTo({
- url: './guide',
- success: res => {
- console.log(res, 'dk');
- res.eventChannel.emit('setItemData', item)
- },
- });
- },
- // nft合成列表
- craftGuide(source) {
- let navItem = this.nft;
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- craftGuide({
- page: navItem.page,
- limit: navItem.limit,
- status: 0
- })
- .then(({
- data
- }) => {
- if (data.list.length > 0) {
- navItem.list = navItem.list.concat(data.list);
- navItem.page++;
- }
- if (navItem.limit == data.list.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'loadmore';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'nomore';
- }
- uni.hideLoading();
- navItem.loaded = true;
- })
- .catch(e => {
- console.log(e);
- });
- },
- // 打开盲盒
- confirmPay() {
- const that = this;
- that.showAlert = false;
- uni.showLoading({
- title: '开启中...',
- mask: true
- });
- openMysteryMy({
- num: that.payNum,
- mystery_id: that.actionItem.mystery_box_id
- })
- .then(({
- data
- }) => {
- // 显示成功弹窗{
- that.showAlertSuccess = true;
- that.successJg = data.boxes.map((i) => {
- return i
- })
- uni.hideLoading()
- console.log(data, 'dk');
- })
- .catch(e => {
- uni.hideLoading()
- console.log(e);
- });
- },
- // 判断是否输入正确数量
- changeNum(s) {
- console.log(s);
- let num = Math.floor(s);
- if (s.indexOf('.') > -1) {
- uni.showModal({
- title: '错误',
- content: '只可填入整数',
- showCancel: false,
- });
- }
- this.$nextTick(() => {
- this.payNum = +num
- })
- },
- tabList(index) {
- // 保存当前选中的对象
- this.onIndex = index;
- },
- // 加载盲盒
- lodingMh(source) {
- let navItem = this.mh;
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- mysteryMy({
- page: navItem.page,
- limit: navItem.limit,
- status: 0
- })
- .then(({
- data
- }) => {
- if (data.list.length > 0) {
- navItem.list = navItem.list.concat(data.list);
- navItem.page++;
- }
- if (navItem.limit == data.list.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'loadmore';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'nomore';
- }
- uni.hideLoading();
- navItem.loaded = true;
- })
- .catch(e => {
- console.log(e);
- });
- },
- // 打开盲盒
- openMh(item) {
- this.actionItem = item;
- this.showAlert = true;
- console.log('dk');
- },
- navTo(url) {
- uni.switchTab({
- url
- })
- },
- }
- };
- </script>
- <style lang="scss">
- page {
- width: 750rpx;
- min-height: 100%;
- // background: #111111;
- }
- .container {
- /* #ifdef APP */
- padding-top: var(--status-bar-height);
- /* #endif */
- min-height: 100%;
- }
- .alertbox {
- height: 750rpx;
- .slot-content {
- display: flex;
- flex-wrap: wrap;
- .boxAlert {
- line-height: 1;
- border: 1px solid #9F570E;
- padding: 10rpx 20rpx;
- color: #9F570E;
- border-radius: 10rpx;
- margin: 10rpx;
- .img {
- width: 30rpx;
- height: 30rpx;
- margin-right: 10rpx;
- border-radius: 10rpx;
- }
- }
- }
- }
- .topNav {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- z-index: 999;
- padding: 30rpx;
- background-color: #181820;
- .hgHeight {
- height: var(--status-bar-height);
- }
- .titleItem {
- width: 336rpx;
- height: 80rpx;
- border-radius: 10rpx;
- text-align: center;
- line-height: 80rpx;
- font-size: $font-base;
- color: #FFFFFF;
- border: 1px solid #FFFFFF;
- &.action {
- font-weight: bold;
- color: #9F570E;
- background: $bgBaseBg;
- }
- }
- }
- .ls {
- color: #FFFFFF;
- padding: 30rpx;
- padding-top: 170rpx;
- .clearFloat {
- clear: both;
- }
- .lt {
- width: 100%;
- background-color: #1d1c21;
- line-height: 0;
- padding: 30rpx;
- border-radius: 20rpx;
- .leftImg {
- flex-shrink: 0;
- width: 120rpx;
- height: 120rpx;
- border-radius: 30rpx;
- }
- .rightContent {
- line-height: 1;
- flex-grow: 1;
- .rightImg {
- width: 20rpx;
- }
- .itemlist {
- display: flex;
- flex-wrap: wrap;
- font-size: 20rpx;
- .item {
- border: 1px solid #FFCE8A;
- padding: 10rpx 10rpx;
- border-radius: 5rpx;
- margin-right: 10rpx;
- margin-bottom: 10rpx;
- color: #FFCE8A;
- }
- }
- }
- }
- .ll {
- width: 330rpx;
- line-height: 0;
- margin-bottom: 30rpx;
- float: left;
- border-radius: 20rpx;
- overflow: hidden;
- &:nth-child(even) {
- margin-left: 30rpx;
- }
- .imgBox {
- background-color: #1D1D22;
- width: 330rpx;
- height: 330rpx;
- }
- .bottomTitle {
- background-color: #1d1c21;
- line-height: 1;
- .title {
- font-size: $font-sm;
- }
- .tip {
- font-size: $font-sm - 4rpx;
- .buttom {
- width: 98rpx;
- padding: 10rpx 0;
- text-align: center;
- background: $bgBaseBg;
- border-radius: 20rpx;
- color: #9F570E;
- }
- }
- }
- }
- }
- </style>
|