myNftList.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="container">
  3. <view class="flex dy-list">
  4. <view class="box-content" v-for="item in navitem.list" @click="type==1?navto(item):''">
  5. <view class="img">
  6. <image :src="item.class_info.uri" mode=""></image>
  7. </view>
  8. <view class="content-title">
  9. <view class="title">
  10. <view class="text clamp">{{ item.class_info.name }}</view>
  11. <view class="zm" v-if="item.hang != null">转卖中</view>
  12. </view>
  13. <view class="content-price">
  14. <view class="price" v-if="item.hang">
  15. 挂卖中¥{{ item.price }}
  16. </view>
  17. <view class="price" v-if="item.extract">
  18. 提取中
  19. </view>
  20. <view class="price" v-if="!item.hang&&!item.extract">
  21. ¥{{ item.price }}
  22. </view>
  23. <view class="" v-if="!item.extract&&type==1">
  24. <view class="button" @click="navPop(item)" v-if="item.hang == null">卖出</view>
  25. <view class="button" @click="qxMai(item.hang.id)" v-else>取消卖出</view>
  26. </view>
  27. <view class="" v-if="type==2&&!item.hang&&!item.extract">
  28. <view class="button" @click="checked(item)">选择</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF"
  35. :status="navitem.loadingType" />
  36. <uni-popup ref="maipop" type="center">
  37. <view class="mai-box">
  38. <view class="mai-title">卖出价格</view>
  39. <input type="number" v-model="money" placeholder="请输入" />
  40. <view class="mai-button">
  41. <view class="button-left" @click="maiClose()">取消</view>
  42. <view class="button-right" @click="buy()">确定</view>
  43. </view>
  44. </view>
  45. </uni-popup>
  46. <uni-popup ref="qumaipop" type="center">
  47. <view class="mai-box">
  48. <view class="mai-title">提示</view>
  49. <view class="mai-title">您正在转卖这件藏品确认取消卖出?</view>
  50. <view class="mai-button">
  51. <view class="button-left" @click="maiClose()">取消</view>
  52. <view class="button-right" @click="quxbuy(item)">确定</view>
  53. </view>
  54. </view>
  55. </uni-popup>
  56. </view>
  57. </template>
  58. <script>
  59. import { sell, qxgd } from '@/api/order.js';
  60. import {
  61. nftMy
  62. } from '@/api/product.js';
  63. export default {
  64. data() {
  65. return {
  66. id: '', //请求查询的分类id
  67. type: 1, //默认1显示普通列表2表示选择列表
  68. eventChannel: '', //保存数据处理对象
  69. navitem: {
  70. loadingType: 'loadmore',
  71. list: [],
  72. page: 1,
  73. limit: 10,
  74. loaded: false
  75. },
  76. // 当前选中要挂单的商品
  77. actionItem: {},
  78. // 出售价格
  79. money: 0
  80. };
  81. },
  82. onLoad: function(option) {
  83. const that = this;
  84. that.id = option.id;
  85. that.type = option.type
  86. this.craftGuide();
  87. // 判断是否是选择商品
  88. if (that.type == 2) {
  89. that.ind = option.ind
  90. // #ifdef APP-NVUE
  91. that.eventChannel = that.$scope.eventChannel; // 兼容APP-NVUE
  92. // #endif
  93. // #ifndef APP-NVUE
  94. that.eventChannel = that.getOpenerEventChannel();
  95. // #endif
  96. }
  97. },
  98. onShow() {
  99. },
  100. onReachBottom() {
  101. this.craftGuide()
  102. },
  103. methods: {
  104. // 跳转商品详情页面
  105. navto(item){
  106. uni.navigateTo({
  107. url: '/pages/product/product?isSc=1&id='+item.id,
  108. });
  109. },
  110. // 选择商品
  111. checked(item) {
  112. const that = this;
  113. uni.showModal({
  114. title: '提示',
  115. content: '是否选择ID' + item.id + '号NFT',
  116. success: res => {
  117. if (res.confirm) {
  118. uni.navigateBack();
  119. that.eventChannel.emit('checkedData', {
  120. data: item,
  121. ind: that.ind,
  122. });
  123. }
  124. },
  125. fail: () => {},
  126. complete: () => {}
  127. });
  128. },
  129. // 获取nft列表信息
  130. craftGuide(source) {
  131. let navItem = this.navitem;
  132. if (source === 'tabChange' && navItem.loaded === true) {
  133. //tab切换只有第一次需要加载数据
  134. return;
  135. }
  136. if (navItem.loadingType === 'loading') {
  137. //防止重复加载
  138. return;
  139. }
  140. // 修改当前对象状态为加载中
  141. navItem.loadingType = 'loading';
  142. nftMy({
  143. page: navItem.page,
  144. limit: navItem.limit,
  145. nft_class_id: this.id
  146. })
  147. .then(({
  148. data
  149. }) => {
  150. if (data.list.length > 0) {
  151. navItem.list = navItem.list.concat(data.list);
  152. navItem.page++;
  153. }
  154. if (navItem.limit == data.list.length) {
  155. //判断是否还有数据, 有改为 more, 没有改为noMore
  156. navItem.loadingType = 'loadmore';
  157. return;
  158. } else {
  159. //判断是否还有数据, 有改为 more, 没有改为noMore
  160. navItem.loadingType = 'nomore';
  161. }
  162. uni.hideLoading();
  163. navItem.loaded = true;
  164. })
  165. .catch(e => {
  166. console.log(e);
  167. });
  168. },
  169. // 打开挂单
  170. navPop(item) {
  171. this.item = item;
  172. this.$refs.maipop.open();
  173. },
  174. // 取消挂单
  175. qxMai(item) {
  176. this.$refs.qumaipop.open();
  177. console.log(item, 'id');
  178. this.onid = item;
  179. },
  180. // 关闭弹窗
  181. maiClose() {
  182. this.$refs.maipop.close();
  183. this.$refs.qumaipop.close();
  184. },
  185. // 开始挂单
  186. buy() {
  187. let obj = this;
  188. console.log(obj.item, 'item');
  189. if (obj.price == '') {
  190. obj.$api.msg('请输入价格');
  191. return;
  192. }
  193. sell({
  194. price: obj.money
  195. },
  196. obj.item.id
  197. ).then(res => {
  198. console.log(res, 'res');
  199. uni.showModal({
  200. title: '成功',
  201. content: '挂售成功!',
  202. showCancel: false
  203. });
  204. obj.$refs.maipop.close();
  205. }).catch((e)=>{
  206. console.log(e);
  207. });
  208. },
  209. // 取消挂单
  210. quxbuy() {
  211. qxgd({}, this.onid).then(res => {
  212. console.log(res, '取消挂单');
  213. this.$refs.qumaipop.close();
  214. uni.showModal({
  215. title: '成功',
  216. content: '已成功取消挂单',
  217. showCancel: false
  218. });
  219. });
  220. },
  221. }
  222. };
  223. </script>
  224. <style lang="scss">
  225. page {
  226. width: 750rpx;
  227. min-height: 100%;
  228. background: #111111;
  229. }
  230. .container {
  231. /* #ifdef APP */
  232. padding-top: var(--status-bar-height);
  233. /* #endif */
  234. min-height: 100%;
  235. }
  236. .dy-list {
  237. flex-wrap: wrap;
  238. padding: 30rpx;
  239. .box-content {
  240. width: 330rpx;
  241. height: 415rpx;
  242. // margin:0 15rpx 50rpx ;
  243. .img {
  244. width: 330rpx;
  245. height: 280rpx;
  246. image {
  247. width: 100%;
  248. height: 100%;
  249. }
  250. }
  251. .content-title {
  252. z-index: 99;
  253. display: flex;
  254. margin-top: -10rpx;
  255. padding: 20rpx;
  256. flex-direction: column;
  257. border-bottom-left-radius: 10rpx;
  258. border-bottom-right-radius: 10rpx;
  259. border: 2rpx solid #533a6a;
  260. // box-shadow: 0px 0px 20rpx 0px rgba(79,59,103,0.0600);
  261. .title {
  262. display: flex;
  263. align-items: center;
  264. // font-size: 39rpx;
  265. // font-weight: bold;
  266. // color: #FFFFFF;
  267. // margin-bottom: 20rpx;
  268. }
  269. .zm {
  270. flex-shrink: 0;
  271. // margin: 10rpx;
  272. // width: 63rpx;
  273. display: inline-block;
  274. // padding: 2rpx;
  275. // height: 30rpx;
  276. // border: 1rpx solid #FDD58A;
  277. margin-left: 10rpx;
  278. border-radius: 5rpx;
  279. font-size: 16rpx;
  280. font-weight: 500;
  281. color: #FDD58A;
  282. // line-height: 30rpx;
  283. text-align: center;
  284. }
  285. .text {
  286. color: #ffffff;
  287. font-size: 24rpx;
  288. margin: 10rpx 0;
  289. }
  290. }
  291. .content-price {
  292. display: flex;
  293. justify-content: space-between;
  294. .price {
  295. font-size: 30rpx;
  296. font-family: PingFang SC;
  297. font-weight: 500;
  298. color: #ffffff;
  299. }
  300. .button {
  301. width: 104rpx;
  302. height: 35rpx;
  303. border-radius: 18rpx;
  304. background: $bgBaseBg;
  305. color: #9F570E;
  306. font-size: 20rpx;
  307. font-weight: 500;
  308. line-height: 35rpx;
  309. text-align: center;
  310. }
  311. }
  312. }
  313. }
  314. .mai-box {
  315. display: flex;
  316. flex-direction: column;
  317. align-items: center;
  318. justify-content: space-around;
  319. width: 582rpx;
  320. height: 377rpx;
  321. background: #ffffff;
  322. border-radius: 20rpx;
  323. .mai-title {
  324. margin: 0 60rpx;
  325. font-size: 42rpx;
  326. font-weight: 500;
  327. color: #0c1732;
  328. line-height: 56rpx;
  329. }
  330. input {
  331. width: 494rpx;
  332. height: 90rpx;
  333. font-size: 40rpx;
  334. background: rgba(199, 212, 255, 0.35);
  335. border-radius: 10rpx;
  336. text-align: center;
  337. }
  338. .mai-button {
  339. display: flex;
  340. width: 90%;
  341. justify-content: space-between;
  342. .button-left {
  343. text-align: center;
  344. width: 248rpx;
  345. height: 78rpx;
  346. border: 2rpx solid #a581ff;
  347. border-radius: 10rpx;
  348. font-size: 34rpx;
  349. font-weight: 500;
  350. color: #a581ff;
  351. line-height: 78rpx;
  352. }
  353. .button-right {
  354. text-align: center;
  355. width: 248rpx;
  356. height: 78rpx;
  357. background: $bgBaseBg;
  358. border-radius: 10rpx;
  359. font-size: 34rpx;
  360. font-weight: 500;
  361. color: #ffffff;
  362. line-height: 78rpx;
  363. }
  364. }
  365. }
  366. </style>