myNftList.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="container">
  3. <view class="flex dy-list">
  4. <view class="box-content" v-for="item in navitem.list" @click="!item.extract&&type==1&&item.hang?navto(item):alertErr(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.stop="navPop(item)" v-if="item.hang == null">卖出</view>
  25. <view class="button" @click.stop="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.stop="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. // alert
  105. alertErr(){
  106. uni.showModal({
  107. title: '错误',
  108. content: '商品未卖出无法查看详情',
  109. showCancel: false,
  110. });
  111. },
  112. // 跳转商品详情页面
  113. navto(item){
  114. uni.navigateTo({
  115. url: '/pages/product/product?isSc=1&id='+item.id,
  116. });
  117. },
  118. // 选择商品
  119. checked(item) {
  120. const that = this;
  121. uni.showModal({
  122. title: '提示',
  123. content: '是否选择ID' + item.id + '号NFT',
  124. success: res => {
  125. if (res.confirm) {
  126. uni.navigateBack();
  127. that.eventChannel.emit('checkedData', {
  128. data: item,
  129. ind: that.ind,
  130. });
  131. }
  132. },
  133. fail: () => {},
  134. complete: () => {}
  135. });
  136. },
  137. // 获取nft列表信息
  138. craftGuide(source) {
  139. let navItem = this.navitem;
  140. if (source === 'tabChange' && navItem.loaded === true) {
  141. //tab切换只有第一次需要加载数据
  142. return;
  143. }
  144. if (navItem.loadingType === 'loading') {
  145. //防止重复加载
  146. return;
  147. }
  148. // 修改当前对象状态为加载中
  149. navItem.loadingType = 'loading';
  150. nftMy({
  151. page: navItem.page,
  152. limit: navItem.limit,
  153. nft_class_id: this.id
  154. })
  155. .then(({
  156. data
  157. }) => {
  158. if (data.list.length > 0) {
  159. navItem.list = navItem.list.concat(data.list);
  160. navItem.page++;
  161. }
  162. if (navItem.limit == data.list.length) {
  163. //判断是否还有数据, 有改为 more, 没有改为noMore
  164. navItem.loadingType = 'loadmore';
  165. return;
  166. } else {
  167. //判断是否还有数据, 有改为 more, 没有改为noMore
  168. navItem.loadingType = 'nomore';
  169. }
  170. uni.hideLoading();
  171. navItem.loaded = true;
  172. })
  173. .catch(e => {
  174. console.log(e);
  175. });
  176. },
  177. // 打开挂单
  178. navPop(item) {
  179. this.item = item;
  180. this.$refs.maipop.open();
  181. },
  182. // 取消挂单
  183. qxMai(item) {
  184. this.$refs.qumaipop.open();
  185. console.log(item, 'id');
  186. this.onid = item;
  187. },
  188. // 关闭弹窗
  189. maiClose() {
  190. this.$refs.maipop.close();
  191. this.$refs.qumaipop.close();
  192. },
  193. // 开始挂单
  194. buy() {
  195. let obj = this;
  196. console.log(obj.item, 'item');
  197. if (obj.price == '') {
  198. obj.$api.msg('请输入价格');
  199. return;
  200. }
  201. sell({
  202. price: obj.money
  203. },
  204. obj.item.id
  205. ).then(res => {
  206. console.log(res, 'res');
  207. uni.showModal({
  208. title: '成功',
  209. content: '挂售成功!',
  210. showCancel: false
  211. });
  212. obj.$refs.maipop.close();
  213. }).catch((e)=>{
  214. console.log(e);
  215. });
  216. },
  217. // 取消挂单
  218. quxbuy() {
  219. qxgd({}, this.onid).then(res => {
  220. console.log(res, '取消挂单');
  221. this.$refs.qumaipop.close();
  222. uni.showModal({
  223. title: '成功',
  224. content: '已成功取消挂单',
  225. showCancel: false
  226. });
  227. });
  228. },
  229. }
  230. };
  231. </script>
  232. <style lang="scss">
  233. page {
  234. width: 750rpx;
  235. min-height: 100%;
  236. }
  237. .container {
  238. /* #ifdef APP */
  239. padding-top: var(--status-bar-height);
  240. /* #endif */
  241. min-height: 100%;
  242. }
  243. .dy-list {
  244. flex-wrap: wrap;
  245. padding: 30rpx;
  246. .box-content {
  247. width: 330rpx;
  248. height: 415rpx;
  249. // margin:0 15rpx 50rpx ;
  250. border-radius: 10rpx;
  251. overflow: hidden;
  252. .img {
  253. width: 330rpx;
  254. height: 280rpx;
  255. image {
  256. width: 100%;
  257. height: 100%;
  258. }
  259. }
  260. .content-title {
  261. display: flex;
  262. padding: 20rpx;
  263. padding-top: 10rpx;
  264. flex-direction: column;
  265. border-bottom-left-radius: 10rpx;
  266. border-bottom-right-radius: 10rpx;
  267. background-color: #1d1c21;
  268. .title {
  269. display: flex;
  270. align-items: center;
  271. // font-size: 39rpx;
  272. // font-weight: bold;
  273. // color: #FFFFFF;
  274. // margin-bottom: 20rpx;
  275. }
  276. .zm {
  277. flex-shrink: 0;
  278. // margin: 10rpx;
  279. // width: 63rpx;
  280. display: inline-block;
  281. // padding: 2rpx;
  282. // height: 30rpx;
  283. // border: 1rpx solid #FDD58A;
  284. margin-left: 10rpx;
  285. border-radius: 5rpx;
  286. font-size: 16rpx;
  287. font-weight: 500;
  288. color: #FDD58A;
  289. // line-height: 30rpx;
  290. text-align: center;
  291. }
  292. .text {
  293. color: #ffffff;
  294. font-size: 24rpx;
  295. margin: 10rpx 0;
  296. }
  297. }
  298. .content-price {
  299. display: flex;
  300. justify-content: space-between;
  301. .price {
  302. font-size: 30rpx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #ffffff;
  306. }
  307. .button {
  308. width: 104rpx;
  309. height: 35rpx;
  310. border-radius: 18rpx;
  311. background: $bgBaseBg;
  312. color: #9F570E;
  313. font-size: 20rpx;
  314. font-weight: 500;
  315. line-height: 35rpx;
  316. text-align: center;
  317. }
  318. }
  319. }
  320. }
  321. .mai-box {
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. justify-content: space-around;
  326. width: 582rpx;
  327. height: 377rpx;
  328. background: #ffffff;
  329. border-radius: 20rpx;
  330. .mai-title {
  331. margin: 0 60rpx;
  332. font-size: 42rpx;
  333. font-weight: 500;
  334. color: #0c1732;
  335. line-height: 56rpx;
  336. }
  337. input {
  338. width: 494rpx;
  339. height: 90rpx;
  340. font-size: 40rpx;
  341. background: rgba(199, 212, 255, 0.35);
  342. border-radius: 10rpx;
  343. text-align: center;
  344. }
  345. .mai-button {
  346. display: flex;
  347. width: 90%;
  348. justify-content: space-between;
  349. .button-left {
  350. text-align: center;
  351. width: 248rpx;
  352. height: 78rpx;
  353. border: 2rpx solid #a581ff;
  354. border-radius: 10rpx;
  355. font-size: 34rpx;
  356. font-weight: 500;
  357. color: #a581ff;
  358. line-height: 78rpx;
  359. }
  360. .button-right {
  361. text-align: center;
  362. width: 248rpx;
  363. height: 78rpx;
  364. background: $bgBaseBg;
  365. border-radius: 10rpx;
  366. font-size: 34rpx;
  367. font-weight: 500;
  368. color: #ffffff;
  369. line-height: 78rpx;
  370. }
  371. }
  372. }
  373. </style>