no_use.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="pageWrapper">
  3. <tabbar2 custom-class=" " :tabs="tabs" @change="clickTab" />
  4. <scroll-view
  5. class="wrapperScroll"
  6. style="height: calc(100vh - 500rpx)"
  7. scroll-y
  8. refresher-enabled
  9. refresher-default-style="white"
  10. @refresherrefresh="pullRefresh"
  11. :refresher-triggered="refreshing"
  12. @scrolltolower="loadMore"
  13. >
  14. <view v-if="tableData && tableData.length > 0" class="" style="padding: 20rpx 0">
  15. <view
  16. v-for="(item, index) in tableData"
  17. :key="item.id"
  18. class="cell"
  19. @click="showDetail(item)"
  20. >
  21. <view class="header">
  22. <view class="titleBox" @click.stop="choose(item)">
  23. <template v-if="item.safeFlag !== 1">
  24. <view class="checkBox" :class="{ check: !!checkMap[item.id] }">
  25. <view class="cuIcon-check"></view>
  26. </view>
  27. </template>
  28. <image class="icon-title" :src="LEVEL_MAP[item.level].titleText" />
  29. </view>
  30. <view
  31. class="lockBox"
  32. @click.stop="
  33. item.safeFlag !== 1 ? moveToBx(item, index) : moveOutBx(item, index)
  34. "
  35. >
  36. {{ item.safeFlag !== 1 ? '锁定' : '解锁' }}
  37. <image
  38. :src="item.safeFlag !== 1 ? ossurl.mine.lock : ossurl.mine.unlock"
  39. webp
  40. class="lockImage"
  41. />
  42. </view>
  43. </view>
  44. <view class="flex-align paddingT14">
  45. <image
  46. class="icon flex-shrink0"
  47. :src="item.spu.cover"
  48. @click.stop="showGoodsDetail(item)"
  49. mode="aspectFit"
  50. />
  51. <view class="flex1 marginL12">
  52. <view
  53. class="font4 bold paddingB13"
  54. style="-webkit-line-clamp: 2;word-break: break-all;text-overflow:ellipsis"
  55. >
  56. {{ item.spu.name }}
  57. </view>
  58. <view class="flex-align-between">
  59. <view class="font3" style="opacity: 0.8">
  60. <text v-if="item.fromRelationType === 'LUCK'">宝箱</text>
  61. <text v-else-if="item.fromRelationType === 'TRADE'">魔换</text>
  62. <text v-else-if="item.fromRelationType === 'LUCK_ROOM'">
  63. 福利房
  64. </text>
  65. <text v-else-if="item.fromRelationType === 'LUCK_KING'">
  66. 魔王战
  67. </text>
  68. <text v-else-if="item.fromRelationType === 'LUCK_WHEEL'">
  69. 魔天轮
  70. </text>
  71. <text v-else-if="item.fromRelationType === 'SUBSTITUTE'">
  72. 置换
  73. </text>
  74. <text v-else-if="item.fromRelationType === 'ACTIVITY'">
  75. 活动
  76. </text>
  77. <text v-else-if="item.fromRelationType === 'DOLL_MACHINE'">
  78. 娃娃机
  79. </text>
  80. <text v-else>其他</text>
  81. 获得
  82. </view>
  83. <!-- <view v-if="hide" class="flex-align-between">
  84. <view class="font4 radius2" v-if="item.magicAmount > 0">
  85. 可兑换
  86. <text :style="{ color: '#FEC433' }">
  87. {{ item.magicAmount }}
  88. </text>
  89. 源石
  90. </view>
  91. <view v-else class="font4 radius2">不可兑换</view>
  92. </view> -->
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <empty v-if="isEmpty" :top="200" />
  99. </scroll-view>
  100. <image
  101. v-if="tableData && tableData.length > 0 && hide && total > 5"
  102. :src="ossurl.mine.exchange"
  103. webp
  104. class="convert_all"
  105. @click.stop="showConvertAll"
  106. />
  107. <view v-if="tableData && tableData.length > 0" class="bottom paddingX10">
  108. <view class="bottom-btns flex-align-around">
  109. <view v-if="type != 1" class="relative btnBox" @click="showCheckout">
  110. <view>立即提货</view>
  111. <view class="text">5件包邮</view>
  112. </view>
  113. <!-- <view v-if="type != 1 && hide" class="relative btnBox2" @click="showConvertConfirm">
  114. <view>兑换源石</view>
  115. <view class="text">可抵扣支付</view>
  116. </view> -->
  117. </view>
  118. <view class="flex-align-center font2 paddingT8" style="color: #9e9e9e">
  119. 已选
  120. <text class="font2 paddingX1" style="color: #000">
  121. {{ Object.values(checkMap).length }}
  122. </text>
  123. 件商品
  124. </view>
  125. </view>
  126. <convert-confirm ref="convertConfirmRef" @convert-success="onConvertSuccess" />
  127. <convert-all ref="convertAllRef" @convert-success="onConvertSuccess" />
  128. <gift-all ref="giftAllRef" @gift-success="onGiftSuccess" />
  129. <checkout ref="checkoutRef" @success="onTakeSuccess" />
  130. <gift-confirm ref="giftConfirmRef" @success="onGiftConfirmSuccess" />
  131. <goods-detail ref="goodsDetailRef" />
  132. </view>
  133. </template>
  134. <script>
  135. import pageMixin from './../../mixin/page'
  136. import empty from '@/components/empty'
  137. import { LEVEL_MAP } from '@/utils/config'
  138. import convertConfirm from './convert_confirm'
  139. import convertAll from './convert_all'
  140. import giftAll from './gift_all'
  141. import checkout from './checkout'
  142. import ossurl from '@/utils/ossurl'
  143. import goodsDetail from './goods_detail'
  144. import { throttle } from '@/utils'
  145. import tabbar2 from '@/components/tabbar2'
  146. import giftConfirm from './gift_confirm'
  147. const Tabs = [
  148. { title: '全部', value: '' },
  149. { title: '普通', value: 'D' },
  150. { title: '隐藏', value: 'C' },
  151. { title: '欧皇', value: 'B' },
  152. { title: '超神', value: 'A' },
  153. { title: '其他', value: 'OTHER' }
  154. ]
  155. export default {
  156. mixins: [pageMixin],
  157. components: {
  158. empty,
  159. convertConfirm,
  160. checkout,
  161. goodsDetail,
  162. convertAll,
  163. tabbar2,
  164. giftAll,
  165. giftConfirm
  166. },
  167. props: {
  168. type: {
  169. default: 0,
  170. type: Number
  171. }
  172. },
  173. data() {
  174. return {
  175. ossurl,
  176. LEVEL_MAP,
  177. refreshing: false,
  178. tab: Tabs[0],
  179. tabs: Tabs,
  180. checkMap: {},
  181. total: 0
  182. }
  183. },
  184. computed: {
  185. top() {
  186. let height = this.$store.state.systemInfo.statusBarHeight + 36 + 50 + 10 + 40
  187. return height
  188. },
  189. itemWidth() {
  190. let width = this.$store.state.systemInfo.screenWidth
  191. width = (width - 8 - 40) / 3
  192. let height = (165 / 109) * width
  193. return { width, height }
  194. },
  195. hide() {
  196. return !this.$store.state.hide
  197. }
  198. },
  199. mounted() {
  200. this.refresh(true)
  201. },
  202. methods: {
  203. pullRefresh() {
  204. this.refreshing = true
  205. this.refresh()
  206. },
  207. clickTab(item) {
  208. this.tab = item
  209. this.refresh(true)
  210. },
  211. async getSumInventory() {
  212. const res = await this.$service.award.getSumInventory()
  213. this.total = res
  214. },
  215. async loadData(loading = false) {
  216. this.getSumInventory()
  217. const res = await this.$service.award.store(
  218. this.pageNum,
  219. this.pageSize,
  220. '',
  221. this.tab.value,
  222. loading
  223. )
  224. setTimeout(() => {
  225. this.refreshing = false
  226. }, 1000)
  227. return res
  228. },
  229. choose(item) {
  230. if (item.safeFlag == 1) return
  231. if (!!this.checkMap[item.id]) {
  232. delete this.checkMap[item.id]
  233. } else {
  234. this.checkMap[item.id] = item
  235. }
  236. this.checkMap = { ...this.checkMap }
  237. },
  238. forceChoose(item, flag, refresh = true) {
  239. if (flag) {
  240. this.checkMap[item.id] = item
  241. } else {
  242. delete this.checkMap[item.id]
  243. }
  244. if (refresh) {
  245. this.checkMap = { ...this.checkMap }
  246. }
  247. },
  248. checkAll() {
  249. if (!this.tableData) return
  250. let flag = this.tableData.every((item) => {
  251. return item.safeFlag == 1 || !!this.checkMap[item.id]
  252. })
  253. if (flag) {
  254. this.checkMap = {}
  255. } else {
  256. this.tableData.forEach((item) => {
  257. item.safeFlag != 1 && this.forceChoose(item, true, false)
  258. })
  259. this.checkMap = { ...this.checkMap }
  260. }
  261. },
  262. async showConvertConfirm() {
  263. for (let x in this.checkMap) {
  264. let item = this.checkMap[x]
  265. if (item.magicAmount <= 0) {
  266. delete this.checkMap[x]
  267. }
  268. }
  269. this.checkMap = { ...this.checkMap }
  270. let goods = Object.values(this.checkMap)
  271. if (goods.length === 0) {
  272. this.$message.warn('请至少选择一个商品!')
  273. return
  274. }
  275. const res = await this.$service.award.convertPreview(goods.map((item) => item.id))
  276. if (res) {
  277. this.$refs.convertConfirmRef.show(goods, res.totalMagicAmount)
  278. }
  279. },
  280. showGiftAll() {
  281. const goods = Object.values(this.checkMap)
  282. if (goods.length === 0) {
  283. this.$message.warn('请至少选择一个商品!')
  284. return
  285. }
  286. const ids = goods.map((obj) => obj.id)
  287. this.$refs.giftAllRef.show(ids)
  288. },
  289. onConvertSuccess() {
  290. this.checkMap = {}
  291. this.refresh(true)
  292. this.$emit('convertSuccess')
  293. this.$message.success('兑换成功')
  294. },
  295. async showCheckout() {
  296. let goods = Object.values(this.checkMap)
  297. if (goods.length === 0) {
  298. this.$message.warn('请至少选择一个商品!')
  299. return
  300. }
  301. const res = await this.$service.award.takePreview(goods.map((item) => item.id))
  302. if (res) {
  303. this.$refs.checkoutRef.show(res, goods)
  304. }
  305. },
  306. onTakeSuccess() {
  307. this.checkMap = {}
  308. this.refresh(true)
  309. this.$emit('takeSuccess')
  310. this.$message.success('提货成功')
  311. },
  312. onGiftSuccess(data, param) {
  313. const goods = Object.values(this.checkMap)
  314. this.$refs.giftConfirmRef.show(data, goods, param)
  315. },
  316. onGiftConfirmSuccess() {
  317. this.checkMap = {}
  318. this.refresh(true)
  319. this.$message.success('转赠成功')
  320. },
  321. showGoodsDetail(item) {
  322. this.$refs.goodsDetailRef.show(item.spu)
  323. },
  324. moveToBx(item, index) {
  325. throttle.call(() => {
  326. this.realMoveToBx(item, index)
  327. })
  328. },
  329. async realMoveToBx(item, index) {
  330. const res = await this.$service.award.moveToSaveStore([item.id])
  331. if (res) {
  332. item.safeFlag = 1
  333. this.$set(this.tableData, index, { ...item })
  334. // if (this.checkMap) {
  335. // this.checkMap = { ...this.checkMap }
  336. // }
  337. }
  338. },
  339. moveOutBx(item, index) {
  340. throttle.call(() => {
  341. this.realMoveOutBx(item, index)
  342. })
  343. },
  344. async realMoveOutBx(item, index) {
  345. const res = await this.$service.award.moveOutSaveStore([item.id])
  346. if (res) {
  347. item.safeFlag = 0
  348. this.$set(this.tableData, index, { ...item })
  349. }
  350. },
  351. showSell() {
  352. // this.$message.alert('敬请期待')
  353. let goods = Object.values(this.checkMap)
  354. if (goods.length === 0) return
  355. this.checkMap = {}
  356. this.$cache.set(this.$cache.key.STORE_SELL, goods)
  357. this.$router.push('sell_create_more')
  358. },
  359. showDetail(item) {
  360. if (item.safeFlag == 0&&item.magicAmount > 0) {
  361. this.$router.push('store_detail', {
  362. id:item.id
  363. })
  364. }
  365. },
  366. async showConvertAll() {
  367. const res = await this.$service.award.convertAllPreview()
  368. if (res) {
  369. let array = res.filter((item) => item.statistic.count > 0)
  370. if (!array || array.length === 0) {
  371. this.$message.alert('没有可兑换的普通和隐藏款')
  372. return
  373. }
  374. this.$refs.convertAllRef.show(array)
  375. }
  376. }
  377. }
  378. }
  379. </script>
  380. <style lang="scss" scoped>
  381. .pageWrapper {
  382. padding: 0rpx 20rpx;
  383. }
  384. .bottom {
  385. position: fixed;
  386. left: 0;
  387. right: 0;
  388. bottom: 0;
  389. height: 212rpx;
  390. background-color: #fff;
  391. .bottom-btns {
  392. height: 100rpx;
  393. text-align: center;
  394. color: #000;
  395. .btnBox {
  396. padding-top: 8rpx;
  397. width: 326rpx;
  398. height: 80rpx;
  399. background: #fff7e3;
  400. border-radius: 40rpx;
  401. }
  402. .btnBox2 {
  403. padding-top: 8rpx;
  404. width: 326rpx;
  405. height: 80rpx;
  406. background: #fec433;
  407. border-radius: 40rpx;
  408. }
  409. .text {
  410. text-align: center;
  411. font-size: 20rpx;
  412. color: #735200;
  413. }
  414. }
  415. .image {
  416. height: 108rpx;
  417. width: 0;
  418. }
  419. }
  420. .cell {
  421. background: #ffffff;
  422. border-radius: 12rpx;
  423. border: 2rpx solid rgba(255, 255, 255, 0.4);
  424. padding: 30rpx;
  425. margin-bottom: 20rpx;
  426. position: relative;
  427. overflow: hidden;
  428. .header {
  429. display: flex;
  430. align-items: center;
  431. justify-content: space-between;
  432. position: relative;
  433. border-bottom: 2rpx solid rgba(0, 0, 0, 0.05);
  434. padding-bottom: 28rpx;
  435. .titleBox {
  436. display: flex;
  437. align-items: center;
  438. }
  439. .lockBox {
  440. display: flex;
  441. align-items: center;
  442. font-size: 24rpx;
  443. font-family: Source Han Sans, Source Han Sans;
  444. font-weight: 350;
  445. color: #999999;
  446. }
  447. .lockImage {
  448. width: 48rpx;
  449. height: 48rpx;
  450. }
  451. }
  452. .icon {
  453. width: 180rpx;
  454. height: 180rpx;
  455. border-radius: 10rpx;
  456. }
  457. .icon-title {
  458. width: 90rpx;
  459. height: 32rpx;
  460. // margin-left: -18rpx;
  461. }
  462. .btn-bx {
  463. width: 180rpx;
  464. height: 40rpx;
  465. background: linear-gradient(90deg, #2affff 0%, #4d70f2 100%);
  466. border-radius: 20rpx;
  467. }
  468. .safe-flag {
  469. width: 192rpx;
  470. height: 120rpx;
  471. position: absolute;
  472. right: 32rpx;
  473. }
  474. }
  475. .check-all {
  476. width: 120rpx;
  477. height: 120rpx;
  478. position: fixed;
  479. bottom: 388rpx;
  480. right: 0;
  481. }
  482. .convert_all {
  483. width: 68rpx;
  484. height: 98rpx;
  485. position: fixed;
  486. bottom: 600rpx;
  487. right: 20rpx;
  488. }
  489. .checkBox {
  490. border: 4rpx solid #000000;
  491. background-color: #fff;
  492. color: #fff;
  493. width: 32rpx;
  494. border-radius: 4rpx;
  495. margin-right: 12rpx;
  496. height: 32rpx;
  497. text-align: center;
  498. line-height: 28rpx;
  499. font-size: 24rpx;
  500. &.check {
  501. background: #fec433;
  502. border-color: #fec433;
  503. color: #000;
  504. }
  505. }
  506. </style>