guide.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="container">
  3. <view class="ls">
  4. <view @click="item.onData.count>0?tabInde(item,index):''" class="lt flex" v-for="(item,index) in nftInfo">
  5. <image class="leftImg" :src="item.uri" mode="scaleToFill"></image>
  6. <view class="rightContent padding-c-20 flex">
  7. <view class="left">
  8. <view class="rightName clamp ">
  9. {{item.name}}
  10. </view>
  11. <view class="itemlist margin-t-20 u-warning" v-if="!item.onData.checked">
  12. <text v-if="item.onData.count>0">
  13. 可供选择{{item.onData.count}}件,点击选择
  14. </text>
  15. <text class="text-danger" v-else>
  16. 未持有该类NFT无法选择
  17. </text>
  18. </view>
  19. <view class="itemlist margin-t-20 u-success" v-else>
  20. 选择ID:{{item.onData.info.id}}
  21. </view>
  22. </view>
  23. <image class="rightImg" src="../../static/user/back.png" mode="widthFix"></image>
  24. </view>
  25. </view>
  26. </view>
  27. <button class="add-btn" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">立即合成</button>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. nftMy,
  33. nftCraft
  34. } from '@/api/product.js';
  35. export default {
  36. data() {
  37. return {
  38. nftInfo: [],
  39. loding: false ,//判断是否提交合成中
  40. id:''
  41. };
  42. },
  43. onLoad: function(option) {
  44. const that = this;
  45. // #ifdef APP-NVUE
  46. const eventChannel = that.$scope.eventChannel; // 兼容APP-NVUE
  47. // #endif
  48. // #ifndef APP-NVUE
  49. const eventChannel = that.getOpenerEventChannel();
  50. // #endif
  51. // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
  52. eventChannel.on('setItemData', function(data) {
  53. that.id = data.result;
  54. that.setItemData(data.elements)
  55. })
  56. },
  57. onShow() {
  58. },
  59. methods: {
  60. // 保存数据
  61. setItemData(item) {
  62. this.nftInfo = item.map((e) => {
  63. e.info.onData = {
  64. info: '',
  65. checked: false, //保存是否选择
  66. count: e.count
  67. }
  68. return e.info
  69. })
  70. },
  71. tabInde(item, ind) {
  72. const that = this;
  73. console.log(item, 'id');
  74. uni.navigateTo({
  75. url: './myNftList?id=' + item.id + '&type=2&ind=' + ind,
  76. events: {
  77. checkedData: function(res) {
  78. that.nftInfo[res.ind].onData.checked = true;
  79. that.nftInfo[res.ind].onData.info = res.data;
  80. that.nftInfo = that.nftInfo.map((e) => {
  81. return e
  82. })
  83. },
  84. }
  85. });
  86. },
  87. // 开始合成
  88. confirm() {
  89. let upData = {
  90. element:[],
  91. result:this.id
  92. }
  93. for (let i = 0; i < this.nftInfo.length; i++) {
  94. const data = this.nftInfo[i]
  95. if (!data.onData.checked) {
  96. uni.showModal({
  97. title: '提示',
  98. content: '请选择'+data.name+'NFT',
  99. showCancel: false,
  100. });
  101. break
  102. }
  103. upData.element.push( data.onData.info.id);
  104. }
  105. this.loding = true;
  106. uni.showLoading({
  107. title: '合成中'
  108. });
  109. nftCraft(upData).then((data)=>{
  110. uni.hideLoading()
  111. uni.showModal({
  112. title: '提示',
  113. content: '成功合成',
  114. showCancel: false,
  115. });
  116. this.loding = false;
  117. console.log(data,'返回');
  118. }).catch(()=>{
  119. uni.hideLoading()
  120. this.loding = true;
  121. })
  122. }
  123. }
  124. };
  125. </script>
  126. <style lang="scss">
  127. page {
  128. width: 750rpx;
  129. min-height: 100%;
  130. }
  131. .container {
  132. /* #ifdef APP */
  133. padding-top: var(--status-bar-height);
  134. /* #endif */
  135. min-height: 100%;
  136. }
  137. .ls {
  138. color: #FFFFFF;
  139. padding: 30rpx;
  140. .clearFloat {
  141. clear: both;
  142. }
  143. .lt {
  144. width: 100%;
  145. background-color: #1d1c21;
  146. line-height: 0;
  147. padding: 30rpx;
  148. border-radius: 20rpx;
  149. .leftImg {
  150. flex-shrink: 0;
  151. width: 120rpx;
  152. height: 120rpx;
  153. border-radius: 30rpx;
  154. }
  155. .rightContent {
  156. line-height: 1;
  157. flex-grow: 1;
  158. .rightImg {
  159. width: 20rpx;
  160. }
  161. .itemlist {
  162. display: flex;
  163. flex-wrap: wrap;
  164. font-size: 20rpx;
  165. .item {
  166. border: 1px solid #FFCE8A;
  167. padding: 10rpx 10rpx;
  168. border-radius: 5rpx;
  169. margin-right: 10rpx;
  170. margin-bottom: 10rpx;
  171. color: #FFCE8A;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. .add-btn {
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. width: 690rpx;
  182. height: 80rpx;
  183. margin: 60rpx auto;
  184. font-size: $font-lg;
  185. color: #fff;
  186. background:#FFCE8A;
  187. border-radius: 10rpx;
  188. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  189. }
  190. .bg-gray {
  191. background-color: $color-gray;
  192. }
  193. </style>