cangp.vue 8.9 KB

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