index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <view>
  3. <view v-if="pagesNum > 1">
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的仓库"></u-navbar>
  5. </view>
  6. <view v-else>
  7. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" title="我的仓库">
  8. <view class="nav-left flex" slot="left" @click="toIndex">
  9. <u-icon name="arrow-left" size="20" color="#333"></u-icon>
  10. </view>
  11. </u-navbar>
  12. </view>
  13. <!-- 奖品选择 -->
  14. <view class="prize-state">
  15. <!-- 类型 -->
  16. <view class="prize-state-tabs">
  17. <u-tabs @change="changeTab" :scrollable="false" :list="stateArr" lineWidth="30" lineHeight="3"
  18. :current='currentIndex' lineColor="#F9822C " :activeStyle="{
  19. color: '#333 ',
  20. transform: 'scale(1.1)',
  21. width: '120px'
  22. }" :inactiveStyle="{
  23. color: '#999',
  24. transform: 'scale(1)',
  25. width: '120px'
  26. }" itemStyle="padding-left: 20px; padding-right: 15px; height: 44px; text-align: center;">
  27. </u-tabs>
  28. </view>
  29. <!-- 商品状态 -->
  30. <view class="prize-state-type flex" v-if="state == 0">
  31. <view class="prize-state-type-item" :class="{ 'prize-state-type-item__action': index == typeIndex }"
  32. v-for="(item, index) in typeList" :key="index" @click="typeState(index)">{{ item.name }}</view>
  33. </view>
  34. </view>
  35. <!-- 实物商品 -->
  36. <view class="prize-goods" v-if="state == 0">
  37. <view class="prize-goods-list">
  38. <view class="prize-goods-list-item" v-for="(item, index) in list" :key="index">
  39. <!-- <view class="prize-goods-list-item" v-for="(item, index) in list" :key="index" > -->
  40. <!-- 商品 -->
  41. <view class="prize-goods-list-item__content flex">
  42. <view class="flex" v-if="item.status == 1">
  43. <u-checkbox-group>
  44. <u-checkbox size="24" :value="item.checked" shape="circle" :checked="item.checked"
  45. activeColor="#F9822C" @change="changeChecked($event, item)"></u-checkbox>
  46. </u-checkbox-group>
  47. </view>
  48. <view class="info flex" @click="toPrizeGoods(item)">
  49. <image :src="item.picUrl" mode="aspectFill"></image>
  50. <view class="desc flex">
  51. <view class="ells title">{{ item.title }}</view>
  52. <view class="num flex">
  53. <view class="sku ells-one">规格:{{ item.properties || '-' }}</view>
  54. <view class="">数量:{{ item.goodsNum }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 来源 -->
  60. <view class="prize-goods-list-item__btn flex" v-if="item.status == 1">
  61. <view class="type">来自:{{ item.inType && item.inType.desc }}</view>
  62. <view class="btn" @click="toRecovery(item)" v-if="item.inType.value == '1' || item.inType.value == '2'">兑换盲豆</view>
  63. </view>
  64. <view class="prize-goods-list-item__btn flex" v-else>
  65. <view class="type"></view>
  66. <view class="btnTwo">已兑换</view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="flex empty" v-if="!list.length && !loading">
  71. <view class="center">
  72. <image class="center-img" src="../../static/activity/null.png" mode=""></image>
  73. <view class="center-font">还没有商品</view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- 优惠券 -->
  78. <view class="prize-coupon" v-else>
  79. <view class="prize-coupon-list">
  80. <!-- <navigator :url="`/pages/prize/detail?info=${ JSON.stringify(item) }`" class="flex prize-coupon-list-item" hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  81. <image :src="item.picUrl" mode="aspectFill"></image>
  82. <view class="flex info">
  83. <view class="flex desc">
  84. <view class="title">{{ item.title }}</view>
  85. <view class="txt">使用期限:{{ $parseTime(item.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(item.validEnd, '{y}.{m}.{d}') }}</view>
  86. <view class="txt">使用范围:{{ item.useAreaDesc }}</view>
  87. </view>
  88. <view class="flex btn">
  89. <view class="amt"><text>¥</text>{{ item.discount / 100 }}</view>
  90. <view class="action">立即使用</view>
  91. </view>
  92. </view>
  93. </navigator> -->
  94. <view @click="toPrizeDetail(item)" class="prize-coupon-list-item" hover-class="navigator-hover"
  95. v-for="(item, index) in list" :key="index">
  96. <image src="../../static/icon/coupon_bg.png" mode=""></image>
  97. <view class="info">
  98. <view class="info-item">
  99. <text>使用期限:</text>
  100. <text>{{ $parseTime(item.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(item.validEnd, '{y}.{m}.{d}') }}</text>
  101. </view>
  102. <view class="info-item">
  103. <text>使用范围:</text>
  104. <text>{{ item.useAreaDesc || '-' }}</text>
  105. </view>
  106. </view>
  107. <view class="info-now">
  108. <view></view>
  109. <view v-if="JSON.parse(item.useArea).value != '4'">立即使用</view>
  110. <view v-else>查看详情</view>
  111. </view>
  112. <view class="flex price-title">
  113. <view class="price"><text>¥</text>{{ item.discount / 100 }}</view>
  114. <view class="title">{{ item.title }}</view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="flex empty" v-if="!list.length && !loading">
  119. <view class="center">
  120. <image class="center-img" src="../../static/activity/null.png" mode=""></image>
  121. <view class="center-font">还没有优惠券</view>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="prize-action" v-if="statusIndex == 1">
  126. <!-- 实物商品提货 -->
  127. <view class="flex prize-action-goods" v-if="state == 0">
  128. <view class="flex checkbox">
  129. <view class="all">全选</view>
  130. <u-checkbox-group>
  131. <u-checkbox v-model="checkedAll" shape="circle" size="24" :checked="checkedAll"
  132. activeColor="#F9822C" @change="changeCheckedAll($event)"></u-checkbox>
  133. </u-checkbox-group>
  134. </view>
  135. <view class="btn" @click="toSettlement">立即提货</view>
  136. </view>
  137. <!-- 优惠券使用记录 -->
  138. <view class="flex prize-action-coupon" @click="toCoupon" v-else>
  139. <view class="title">优惠券使用记录</view>
  140. <u-icon name="arrow-right" size="15" color="#333"></u-icon>
  141. </view>
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import env from '../../config/env.js'
  147. import $http from '@/utils/request.js'
  148. export default {
  149. data() {
  150. return {
  151. loading: false,
  152. stateArr: [{
  153. name: ' 实物商品',
  154. }, {
  155. name: ' 优惠券',
  156. }],
  157. typeList: [{
  158. name: '待提货'
  159. }, {
  160. name: '已兑换'
  161. }],
  162. typeIndex: 0,
  163. state: 0,
  164. checkedAll: false,
  165. pageNum: 1,
  166. total: 0,
  167. list: [],
  168. currentIndex: 0,
  169. pagesNum: "",
  170. statusIndex: 1,
  171. };
  172. },
  173. onShow() {
  174. this.pagesNum = getCurrentPages().length
  175. this.pageList()
  176. this.couponNum()
  177. },
  178. onLoad(opthios) {
  179. if (opthios != undefined) {
  180. if (opthios.coupon == 1) {
  181. this.currentIndex = 1
  182. this.state = 1
  183. } else {
  184. this.currentIndex = 0
  185. this.state = 0
  186. }
  187. }
  188. },
  189. methods: {
  190. getList() {
  191. let _this = this
  192. let url = _this.state == 0 ? '/api/v1/mp/user/mine/prize/list' : '/api/v1/mp/user/mine/coupon/list'
  193. let data = _this.state == 0 ? { status:this.statusIndex } : {
  194. status: 1
  195. }
  196. uni.showLoading({
  197. title: '加载中'
  198. });
  199. this.loading = true
  200. this.checkedAll = false
  201. $http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, data).then(res => {
  202. uni.hideLoading();
  203. this.loading = false
  204. if (res.code == 0) {
  205. res.rows.forEach(item => {
  206. item.status = JSON.parse(item.status).value
  207. let picUrlArr = item.picUrl.split(',')
  208. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  209. if (_this.state == 0) {
  210. item.checked = false
  211. item.inType = JSON.parse(item.inType)
  212. }
  213. })
  214. _this.total = res.total
  215. _this.list = _this.list.concat(res.rows)
  216. }
  217. }).catch(() => {
  218. uni.hideLoading();
  219. this.loading = false
  220. })
  221. },
  222. typeState(index){
  223. this.typeIndex = index//样式改变
  224. // this.statusIndex = index
  225. if(index == 0 ){
  226. this.statusIndex = 1 //待提货
  227. }
  228. if(index == 1 ){
  229. this.statusIndex = 3 //已兑换
  230. }
  231. this.list = []
  232. this.getList()
  233. },
  234. toIndex() {
  235. uni.switchTab({
  236. url: '/pages/user/index'
  237. })
  238. },
  239. toRecovery(item) {
  240. uni.navigateTo({
  241. url: `/packageGoods/recovery/index?goodsId=${ item.goodsId}&num=${ item.goodsNum }&storageId=${ item.storageId }&properties=${item.properties }&skuId=${ item.skuId }`
  242. })
  243. },
  244. pageList() {
  245. this.pageNum = 1
  246. this.list = []
  247. this.getList()
  248. },
  249. // 切换奖品
  250. changeTab(e) {
  251. if (e.index == 0) {
  252. this.state = 0
  253. } else if (e.index == 1) {
  254. this.state = 1
  255. }
  256. this.pageList()
  257. this.checkedAll = false
  258. },
  259. changeChecked(e, item) {
  260. this.$set(item, 'checked', e)
  261. let flag = this.list.every(item => item.checked == true)
  262. this.checkedAll = flag
  263. this.$forceUpdate()
  264. },
  265. changeCheckedAll(e) {
  266. this.checkedAll = e
  267. this.list.forEach(item => {
  268. item.checked = e
  269. })
  270. this.$forceUpdate()
  271. },
  272. // 查看优惠券使用记录
  273. toCoupon() {
  274. uni.navigateTo({
  275. url: '/packagePrize/coupon/use'
  276. })
  277. },
  278. // 立即提货
  279. toSettlement() {
  280. let arr = []
  281. this.list.forEach(item => {
  282. if (item.checked) {
  283. arr.push(item)
  284. }
  285. })
  286. if (!arr.length) {
  287. uni.$u.toast('请选择商品');
  288. return
  289. }
  290. uni.showLoading({
  291. title: '提货中'
  292. });
  293. let ids = JSON.stringify(arr.map(item => item.storageId))
  294. uni.hideLoading();
  295. uni.navigateTo({
  296. url: `/packageGoods/order/settlement?ids=${ ids }`
  297. })
  298. },
  299. couponNum() {
  300. $http.post(`/api/v1/mp/user/mine/prize/list?pageNum=1&pageSize=10`, {
  301. }).then(res => {
  302. $http.post(`/api/v1/mp/user/mine/coupon/list?pageNum=1&pageSize=10`, {
  303. status: 1
  304. }).then(data => {
  305. if (res.code == 0) {
  306. this.stateArr = [{
  307. name: ' 实物商品 (' + res.total + ') '
  308. },
  309. {
  310. name: ' 优惠券 (' + data.total + ') '
  311. },
  312. ]
  313. } else {
  314. this.stateArr = [{
  315. name: ' 实物商品 (0)'
  316. },
  317. {
  318. name: ' 优惠券 (0)'
  319. },
  320. ]
  321. }
  322. })
  323. });
  324. },
  325. toPrizeGoods(item) {
  326. uni.navigateTo({
  327. url: `/packagePrize/goods/detail?id=${ item.goodsId }`
  328. })
  329. },
  330. toPrizeDetail(item) {
  331. let data = JSON.parse(item.useArea)
  332. let type = JSON.parse(item.type)
  333. // 1判断type,如果为门店直接跳转不需要判断useArec
  334. if (type.value == 2) {
  335. // data.value 2为指定优惠券 0为通用优惠券
  336. uni.navigateTo({
  337. url: `/packagePrize/coupon/detail?id=${ item.id }`
  338. })
  339. } else {
  340. // 3为线上票使用
  341. if (data.value == 3) {
  342. uni.navigateTo({
  343. url: `/packageGoods/ticket/index`
  344. })
  345. }
  346. //0为通用优惠券
  347. if (data.value == 0) {
  348. uni.navigateTo({
  349. url: `/packageGoods/ticket/index`
  350. })
  351. }
  352. // 4为线下票使用
  353. if (data.value == 4) {
  354. uni.navigateTo({
  355. url: `/packagePrize/coupon/detail?id=${ item.id }`
  356. })
  357. }
  358. }
  359. }
  360. },
  361. onReachBottom() {
  362. // 判断是否有数据
  363. if (this.total > this.pageNum * 20) {
  364. setTimeout(() => {
  365. ++this.pageNum
  366. this.getList()
  367. }, 500)
  368. } else {
  369. uni.$u.toast('已经到底了')
  370. }
  371. },
  372. }
  373. </script>
  374. <style lang="scss" scoped>
  375. .empty {
  376. height: 60vh;
  377. }
  378. .prize-state {
  379. position: fixed;
  380. background-color: #FFFFFF;
  381. width: 100%;
  382. z-index: 10;
  383. box-shadow: 0 2rpx 2rpx #ececec;
  384. // 类型
  385. &-tabs {
  386. display: flex;
  387. box-shadow: 0 5rpx 5rpx #ececec;
  388. }
  389. // 商品状态
  390. &-type {
  391. justify-content: flex-start;
  392. padding: 24rpx 34rpx;
  393. &-item {
  394. margin-right: 34rpx;
  395. padding: 12rpx 36rpx;
  396. border-radius: 24rpx;
  397. color: #FFAB4D;
  398. }
  399. &-item__action {
  400. background: #FFAB4D;
  401. color: #fff;
  402. }
  403. }
  404. }
  405. // 实物商品
  406. .prize-goods {
  407. margin-top: 180rpx;
  408. padding: 34rpx 34rpx 200rpx;
  409. &-list {
  410. &-item {
  411. padding: 34rpx 22rpx 34rpx;
  412. background-color: #fff;
  413. border-radius: 18rpx;
  414. margin-bottom: 30rpx;
  415. &__content {
  416. justify-content: space-between;
  417. padding-bottom: 22rpx;
  418. border-bottom: 1px solid #E5E5E5;
  419. .info {
  420. padding-left: 16rpx;
  421. flex: 1;
  422. justify-content: flex-start;
  423. image {
  424. width: 200rpx;
  425. height: 200rpx;
  426. border-radius: 12rpx;
  427. }
  428. .desc {
  429. height: 200rpx;
  430. padding-left: 22rpx;
  431. flex: 1;
  432. font-size: 30rpx;
  433. flex-direction: column;
  434. align-items: flex-start;
  435. justify-content: space-between;
  436. .title {
  437. line-height: 40rpx;
  438. font-weight: bold;
  439. }
  440. .num {
  441. width: 100%;
  442. color: #666666;
  443. font-size: 26rpx;
  444. justify-content: space-between;
  445. .sku {
  446. flex: 1;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. &__btn {
  453. justify-content: space-between;
  454. padding-top: 22rpx;
  455. .type {
  456. font-size: 30rpx;
  457. color: #999999;
  458. line-height: 30rpx;
  459. padding-left: 70rpx;
  460. }
  461. .btn {
  462. width: 200rpx;
  463. height: 66rpx;
  464. line-height: 66rpx;
  465. text-align: center;
  466. color: #fff;
  467. background: #F9822C;
  468. border-radius: 34rpx;
  469. }
  470. .btnTwo {
  471. width: 200rpx;
  472. height: 66rpx;
  473. line-height: 66rpx;
  474. text-align: center;
  475. border-radius: 34rpx;
  476. background-color: #f1f1f1; color: #999;
  477. border: 2rpx solid #999;
  478. }
  479. }
  480. }
  481. &-item:last-child {
  482. margin-bottom: 0;
  483. }
  484. }
  485. }
  486. .prize-coupon {
  487. margin-top: 85rpx;
  488. padding: 40rpx 20rpx 150rpx;
  489. &-list {
  490. &-item {
  491. position: relative;
  492. background-color: #FFFFFF;
  493. margin-bottom: 20rpx;
  494. border-radius: 10rpx;
  495. image {
  496. width: 100%;
  497. height: 156rpx;
  498. margin-bottom: 24rpx;
  499. }
  500. .info {
  501. padding-left: 40rpx;
  502. padding-bottom: 8rpx;
  503. .info-item {
  504. line-height: 40rpx;
  505. color: #333333;
  506. margin-bottom: 12rpx;
  507. }
  508. }
  509. .info-now {
  510. margin-top: 10rpx;
  511. color: #848484;
  512. font-size: 30rpx;
  513. height: 100rpx;
  514. line-height: 90rpx;
  515. text-align: center;
  516. }
  517. .info-now view {
  518. height: 2rpx;
  519. margin: 0 10rpx;
  520. background-image: linear-gradient(to right, #cfcfcf 0%, #cfcfcf 50%, transparent 1%);
  521. background-size: 25rpx 10rpx;
  522. }
  523. .price-title {
  524. justify-content: flex-start;
  525. position: absolute;
  526. top: 0;
  527. width: 100%;
  528. padding: 36rpx 0 0 40rpx;
  529. .price {
  530. color: #FFFFFF;
  531. font-size: 60rpx;
  532. margin-right: 20rpx;
  533. text {
  534. font-size: 40rpx;
  535. }
  536. }
  537. .title {
  538. color: #FFFFFF;
  539. font-size: 48rpx;
  540. }
  541. }
  542. }
  543. &-item:last-child {
  544. margin-bottom: 0;
  545. }
  546. }
  547. }
  548. .prize-action {
  549. position: fixed;
  550. bottom: var(--window-bottom);
  551. left: 0;
  552. right: 0;
  553. z-index: 10;
  554. box-shadow: 0 -4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  555. background: #fff;
  556. width: 100%;
  557. // 设置ios刘海屏底部横线安全区域
  558. padding-bottom: constant(safe-area-inset-bottom);
  559. padding-bottom: env(safe-area-inset-bottom);
  560. &-goods {
  561. justify-content: space-between;
  562. padding: 20rpx 40rpx;
  563. .all {
  564. margin-right: 10rpx;
  565. }
  566. .btn {
  567. width: 225rpx;
  568. height: 82rpx;
  569. font-size: 28rpx;
  570. line-height: 82rpx;
  571. border-radius: 40rpx;
  572. background-color: #F9822C;
  573. color: #fff;
  574. text-align: center;
  575. }
  576. }
  577. &-coupon {
  578. padding: 30rpx 40rpx;
  579. .title {
  580. margin-right: 20rpx;
  581. line-height: 40rpx;
  582. }
  583. }
  584. }
  585. .empty {
  586. height: 60vh;
  587. .center {
  588. text-align: center;
  589. &-img {
  590. width: 228rpx;
  591. height: 350rpx;
  592. }
  593. &-font {
  594. font-size: 30rpx;
  595. font-weight: 400;
  596. }
  597. }
  598. }
  599. </style>