cangp.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view class="container">
  3. <view class="topNav">
  4. <view class="hgHeight">
  5. </view>
  6. <view class="flex">
  7. <view class="titleItem" @click="tabList(0)" :class="{action:onIndex==0}">
  8. 我的盲盒
  9. </view>
  10. <view class="titleItem" @click="tabList(1)" :class="{action:onIndex==1}">
  11. NFT合成
  12. </view>
  13. </view>
  14. </view>
  15. <!-- 我的盲盒 -->
  16. <view class="ls" v-show="onIndex==0">
  17. <view class="ll" v-for="(item,index) in mh.list">
  18. <image class="imgBox" :src="item.mystery_box_info.pic" mode="scaleToFill"></image>
  19. <view class="bottomTitle padding-20">
  20. <view class="title clamp ">
  21. {{item.mystery_box_info.name}}
  22. </view>
  23. <view class="tip flex margin-t-10">
  24. <view>
  25. <view class="clamp">
  26. 官方发行
  27. </view>
  28. <view class=" margin-t-10">
  29. 数量:{{item.mystery_box_count}}
  30. </view>
  31. </view>
  32. <view class="buttom" @click="openMh(item)">打开</view>
  33. </view>
  34. </view>
  35. </view>
  36. <u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF"
  37. :status="mh.loadingType" />
  38. </view>
  39. <!-- NFT合成 -->
  40. <view class="ls" v-show="onIndex==1">
  41. <view @click="navGuid(item)" class="lt flex" v-for="(item,index) in nft.list">
  42. <image class="leftImg" :src="item.res.uri" mode="scaleToFill"></image>
  43. <view class="rightContent padding-c-20 flex">
  44. <view class="left">
  45. <view class="rightName clamp ">
  46. {{item.name}}
  47. </view>
  48. <view class="itemlist margin-t-20">
  49. <view class="item" v-for="(ls,ind) in item.elements">
  50. {{ls.info.name}}
  51. </view>
  52. </view>
  53. </view>
  54. <image class="rightImg" src="../../static/user/back.png" mode="widthFix"></image>
  55. </view>
  56. </view>
  57. <u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF"
  58. :status="nft.loadingType" />
  59. </view>
  60. <u-modal @confirm='confirmPay' :showCancelButton='true' @cancel='showAlert=false' :show="showAlert"
  61. title="请输入打开盲盒数量">
  62. <view class="slot-content padding-t-20">
  63. <u--input class='margin-l-30' border='surround' type='number' v-model="payNum" inputAlign='right'
  64. @input="changeNum"></u--input>
  65. </view>
  66. </u-modal>
  67. <u-modal @confirm='showAlertSuccess = false' :show="showAlertSuccess" title="盲盒开启结果">
  68. <scroll-view class="alertbox" scroll-y>
  69. <view class="slot-content padding-t-20">
  70. <view class="boxAlert flex" v-for="(item , inde) in successJg ">
  71. <image class="img" :src="item.info.uri" mode="scaleToFill"></image>
  72. <view>
  73. {{item.info.name}}
  74. </view>
  75. </view>
  76. </view>
  77. </scroll-view>
  78. </u-modal>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. mapState
  84. } from 'vuex';
  85. // #ifdef H5
  86. import {
  87. weixindata
  88. } from '@/utils/wxAuthorized';
  89. // #endif
  90. import {
  91. mysteryMy,
  92. openMysteryMy,
  93. craftGuide
  94. } from '@/api/product.js';
  95. export default {
  96. data() {
  97. return {
  98. // 当前选中的数据对象
  99. actionItem: '',
  100. payNum: 1, //打开的数量
  101. // 弹出输入窗口
  102. showAlert: false,
  103. // 成功弹出窗
  104. showAlertSuccess: false,
  105. // 弹出开启盲盒结果
  106. successJg: [],
  107. onIndex: 0, //当前选中的分类
  108. // 盲盒里诶啊哦
  109. mh: {
  110. page: 1,
  111. limit: 100,
  112. list: [],
  113. loaded: false,
  114. loadingType: 'loadmore'
  115. },
  116. // nft合成列表
  117. nft: {
  118. page: 1,
  119. limit: 100,
  120. list: [],
  121. loaded: false,
  122. loadingType: 'loadmore'
  123. }
  124. };
  125. },
  126. computed: {
  127. ...mapState(['loginInterceptor', 'baseURL']),
  128. ...mapState('user', ['hasLogin', 'userInfo'])
  129. },
  130. onLoad: function(option) {
  131. // 合成表
  132. this.craftGuide();
  133. },
  134. onShow() {
  135. this.mh.page=1
  136. this.mh.loadingType='loadmore';
  137. this.mh.list=[];
  138. // 我的盲盒
  139. this.lodingMh();
  140. },
  141. methods: {
  142. // 跳转nft选择页面
  143. navGuid(item) {
  144. uni.navigateTo({
  145. url: './guide',
  146. success: res => {
  147. console.log(res, 'dk');
  148. res.eventChannel.emit('setItemData', item)
  149. },
  150. });
  151. },
  152. // nft合成列表
  153. craftGuide(source) {
  154. let navItem = this.nft;
  155. if (source === 'tabChange' && navItem.loaded === true) {
  156. //tab切换只有第一次需要加载数据
  157. return;
  158. }
  159. if (navItem.loadingType === 'loading') {
  160. //防止重复加载
  161. return;
  162. }
  163. // 修改当前对象状态为加载中
  164. navItem.loadingType = 'loading';
  165. craftGuide({
  166. page: navItem.page,
  167. limit: navItem.limit,
  168. status: 0
  169. })
  170. .then(({
  171. data
  172. }) => {
  173. if (data.list.length > 0) {
  174. navItem.list = navItem.list.concat(data.list);
  175. navItem.page++;
  176. }
  177. if (navItem.limit == data.list.length) {
  178. //判断是否还有数据, 有改为 more, 没有改为noMore
  179. navItem.loadingType = 'loadmore';
  180. return;
  181. } else {
  182. //判断是否还有数据, 有改为 more, 没有改为noMore
  183. navItem.loadingType = 'nomore';
  184. }
  185. uni.hideLoading();
  186. navItem.loaded = true;
  187. })
  188. .catch(e => {
  189. console.log(e);
  190. });
  191. },
  192. // 打开盲盒
  193. confirmPay() {
  194. const that = this;
  195. that.showAlert = false;
  196. uni.showLoading({
  197. title: '开启中...',
  198. mask: true
  199. });
  200. openMysteryMy({
  201. num: that.payNum,
  202. mystery_id: that.actionItem.mystery_box_id
  203. })
  204. .then(({
  205. data
  206. }) => {
  207. // 显示成功弹窗{
  208. that.showAlertSuccess = true;
  209. that.successJg = data.boxes.map((i) => {
  210. return i
  211. })
  212. uni.hideLoading()
  213. console.log(data, 'dk');
  214. })
  215. .catch(e => {
  216. uni.hideLoading()
  217. console.log(e);
  218. });
  219. },
  220. // 判断是否输入正确数量
  221. changeNum(s) {
  222. console.log(s);
  223. let num = Math.floor(s);
  224. if (s.indexOf('.') > -1) {
  225. uni.showModal({
  226. title: '错误',
  227. content: '只可填入整数',
  228. showCancel: false,
  229. });
  230. }
  231. this.$nextTick(() => {
  232. this.payNum = +num
  233. })
  234. },
  235. tabList(index) {
  236. // 保存当前选中的对象
  237. this.onIndex = index;
  238. },
  239. // 加载盲盒
  240. lodingMh(source) {
  241. let navItem = this.mh;
  242. if (source === 'tabChange' && navItem.loaded === true) {
  243. //tab切换只有第一次需要加载数据
  244. return;
  245. }
  246. if (navItem.loadingType === 'loading') {
  247. //防止重复加载
  248. return;
  249. }
  250. // 修改当前对象状态为加载中
  251. navItem.loadingType = 'loading';
  252. mysteryMy({
  253. page: navItem.page,
  254. limit: navItem.limit,
  255. status: 0
  256. })
  257. .then(({
  258. data
  259. }) => {
  260. if (data.list.length > 0) {
  261. navItem.list = navItem.list.concat(data.list);
  262. navItem.page++;
  263. }
  264. if (navItem.limit == data.list.length) {
  265. //判断是否还有数据, 有改为 more, 没有改为noMore
  266. navItem.loadingType = 'loadmore';
  267. return;
  268. } else {
  269. //判断是否还有数据, 有改为 more, 没有改为noMore
  270. navItem.loadingType = 'nomore';
  271. }
  272. uni.hideLoading();
  273. navItem.loaded = true;
  274. })
  275. .catch(e => {
  276. console.log(e);
  277. });
  278. },
  279. // 打开盲盒
  280. openMh(item) {
  281. this.actionItem = item;
  282. this.showAlert = true;
  283. console.log('dk');
  284. },
  285. navTo(url) {
  286. uni.switchTab({
  287. url
  288. })
  289. },
  290. }
  291. };
  292. </script>
  293. <style lang="scss">
  294. page {
  295. width: 750rpx;
  296. min-height: 100%;
  297. // background: #111111;
  298. }
  299. .container {
  300. /* #ifdef APP */
  301. padding-top: var(--status-bar-height);
  302. /* #endif */
  303. min-height: 100%;
  304. }
  305. .alertbox {
  306. height: 750rpx;
  307. .slot-content {
  308. display: flex;
  309. flex-wrap: wrap;
  310. .boxAlert {
  311. line-height: 1;
  312. border: 1px solid #9F570E;
  313. padding: 10rpx 20rpx;
  314. color: #9F570E;
  315. border-radius: 10rpx;
  316. margin: 10rpx;
  317. .img {
  318. width: 30rpx;
  319. height: 30rpx;
  320. margin-right: 10rpx;
  321. border-radius: 10rpx;
  322. }
  323. }
  324. }
  325. }
  326. .topNav {
  327. position: fixed;
  328. top: 0;
  329. left: 0;
  330. right: 0;
  331. z-index: 999;
  332. padding: 30rpx;
  333. background-color: #181820;
  334. .hgHeight {
  335. height: var(--status-bar-height);
  336. }
  337. .titleItem {
  338. width: 336rpx;
  339. height: 80rpx;
  340. border-radius: 10rpx;
  341. text-align: center;
  342. line-height: 80rpx;
  343. font-size: $font-base;
  344. color: #FFFFFF;
  345. border: 1px solid #FFFFFF;
  346. &.action {
  347. font-weight: bold;
  348. color: #9F570E;
  349. background: $bgBaseBg;
  350. }
  351. }
  352. }
  353. .ls {
  354. color: #FFFFFF;
  355. padding: 30rpx;
  356. padding-top: 170rpx;
  357. .clearFloat {
  358. clear: both;
  359. }
  360. .lt {
  361. width: 100%;
  362. background-color: #1d1c21;
  363. line-height: 0;
  364. padding: 30rpx;
  365. border-radius: 20rpx;
  366. .leftImg {
  367. flex-shrink: 0;
  368. width: 120rpx;
  369. height: 120rpx;
  370. border-radius: 30rpx;
  371. }
  372. .rightContent {
  373. line-height: 1;
  374. flex-grow: 1;
  375. .rightImg {
  376. width: 20rpx;
  377. }
  378. .itemlist {
  379. display: flex;
  380. flex-wrap: wrap;
  381. font-size: 20rpx;
  382. .item {
  383. border: 1px solid #FFCE8A;
  384. padding: 10rpx 10rpx;
  385. border-radius: 5rpx;
  386. margin-right: 10rpx;
  387. margin-bottom: 10rpx;
  388. color: #FFCE8A;
  389. }
  390. }
  391. }
  392. }
  393. .ll {
  394. width: 330rpx;
  395. line-height: 0;
  396. margin-bottom: 30rpx;
  397. float: left;
  398. border-radius: 20rpx;
  399. overflow: hidden;
  400. &:nth-child(even) {
  401. margin-left: 30rpx;
  402. }
  403. .imgBox {
  404. background-color: #1D1D22;
  405. width: 330rpx;
  406. height: 330rpx;
  407. }
  408. .bottomTitle {
  409. background-color: #1d1c21;
  410. line-height: 1;
  411. .title {
  412. font-size: $font-sm;
  413. }
  414. .tip {
  415. font-size: $font-sm - 4rpx;
  416. .buttom {
  417. width: 98rpx;
  418. padding: 10rpx 0;
  419. text-align: center;
  420. background: $bgBaseBg;
  421. border-radius: 20rpx;
  422. color: #9F570E;
  423. }
  424. }
  425. }
  426. }
  427. }
  428. </style>