index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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 ? { } : {
  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. getListTwo(){
  223. let _this = this
  224. let url = '/api/v1/mp/user/prize/recovery/list'
  225. this.loading = true
  226. this.checkedAll = false
  227. $http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, {}).then(res => {
  228. uni.hideLoading();
  229. this.loading = false
  230. if (res.code == 0) {
  231. console.log(res);
  232. res.rows.forEach(item => {
  233. item.status = 3
  234. item.goodsNum = item.num
  235. let picUrlArr = item.picUrl.split(',')
  236. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
  237. })
  238. _this.list = _this.list.concat(res.rows)
  239. }
  240. }).catch(() => {
  241. uni.hideLoading();
  242. this.loading = false
  243. })
  244. },
  245. typeState(index){
  246. this.list = []
  247. this.typeIndex = index//样式改变
  248. // this.statusIndex = index
  249. if(index == 0 ){
  250. this.statusIndex = 1 //待提货
  251. this.getList()
  252. }
  253. if(index == 1 ){
  254. this.statusIndex = 3 //已兑换
  255. this.getListTwo()
  256. }
  257. },
  258. toIndex() {
  259. uni.switchTab({
  260. url: '/pages/user/index'
  261. })
  262. },
  263. toRecovery(item) {
  264. uni.navigateTo({
  265. url: `/packageGoods/recovery/index?goodsId=${ item.goodsId}&num=${ item.goodsNum }&storageId=${ item.storageId }&properties=${item.properties }&skuId=${ item.skuId }`
  266. })
  267. },
  268. pageList() {
  269. this.typeIndex = 0
  270. this.pageNum = 1
  271. this.list = []
  272. this.getList()
  273. },
  274. // 切换奖品
  275. changeTab(e) {
  276. if (e.index == 0) {
  277. this.state = 0
  278. } else if (e.index == 1) {
  279. this.state = 1
  280. }
  281. this.pageList()
  282. this.checkedAll = false
  283. },
  284. changeChecked(e, item) {
  285. this.$set(item, 'checked', e)
  286. let flag = this.list.every(item => item.checked == true)
  287. this.checkedAll = flag
  288. this.$forceUpdate()
  289. },
  290. changeCheckedAll(e) {
  291. this.checkedAll = e
  292. this.list.forEach(item => {
  293. item.checked = e
  294. })
  295. this.$forceUpdate()
  296. },
  297. // 查看优惠券使用记录
  298. toCoupon() {
  299. uni.navigateTo({
  300. url: '/packagePrize/coupon/use'
  301. })
  302. },
  303. // 立即提货
  304. toSettlement() {
  305. let arr = []
  306. this.list.forEach(item => {
  307. if (item.checked) {
  308. arr.push(item)
  309. }
  310. })
  311. if (!arr.length) {
  312. uni.$u.toast('请选择商品');
  313. return
  314. }
  315. uni.showLoading({
  316. title: '提货中'
  317. });
  318. let ids = JSON.stringify(arr.map(item => item.storageId))
  319. uni.hideLoading();
  320. uni.navigateTo({
  321. url: `/packageGoods/order/settlement?ids=${ ids }`
  322. })
  323. },
  324. couponNum() {
  325. $http.post(`/api/v1/mp/user/mine/prize/list?pageNum=1&pageSize=10`, {
  326. }).then(res => {
  327. $http.post(`/api/v1/mp/user/mine/coupon/list?pageNum=1&pageSize=10`, {
  328. status: 1
  329. }).then(data => {
  330. if (res.code == 0) {
  331. this.stateArr = [{
  332. name: ' 实物商品 (' + res.total + ') '
  333. },
  334. {
  335. name: ' 优惠券 (' + data.total + ') '
  336. },
  337. ]
  338. } else {
  339. this.stateArr = [{
  340. name: ' 实物商品 (0)'
  341. },
  342. {
  343. name: ' 优惠券 (0)'
  344. },
  345. ]
  346. }
  347. })
  348. });
  349. },
  350. toPrizeGoods(item) {
  351. uni.navigateTo({
  352. url: `/packagePrize/goods/detail?id=${ item.goodsId }`
  353. })
  354. },
  355. toPrizeDetail(item) {
  356. let data = JSON.parse(item.useArea)
  357. let type = JSON.parse(item.type)
  358. // 1判断type,如果为门店直接跳转不需要判断useArec
  359. if (type.value == 2) {
  360. // data.value 2为指定优惠券 0为通用优惠券
  361. uni.navigateTo({
  362. url: `/packagePrize/coupon/detail?id=${ item.id }`
  363. })
  364. } else {
  365. // 3为线上票使用
  366. if (data.value == 3) {
  367. uni.navigateTo({
  368. url: `/packageGoods/ticket/index`
  369. })
  370. }
  371. //0为通用优惠券
  372. if (data.value == 0) {
  373. uni.navigateTo({
  374. url: `/packageGoods/ticket/index`
  375. })
  376. }
  377. // 4为线下票使用
  378. if (data.value == 4) {
  379. uni.navigateTo({
  380. url: `/packagePrize/coupon/detail?id=${ item.id }`
  381. })
  382. }
  383. }
  384. }
  385. },
  386. onReachBottom() {
  387. // 判断是否有数据
  388. if (this.total > this.pageNum * 20) {
  389. setTimeout(() => {
  390. ++this.pageNum
  391. this.getList()
  392. }, 500)
  393. } else {
  394. uni.$u.toast('已经到底了')
  395. }
  396. },
  397. }
  398. </script>
  399. <style lang="scss" scoped>
  400. .empty {
  401. height: 60vh;
  402. }
  403. .prize-state {
  404. position: fixed;
  405. background-color: #FFFFFF;
  406. width: 100%;
  407. z-index: 10;
  408. box-shadow: 0 2rpx 2rpx #ececec;
  409. // 类型
  410. &-tabs {
  411. display: flex;
  412. box-shadow: 0 5rpx 5rpx #ececec;
  413. }
  414. // 商品状态
  415. &-type {
  416. justify-content: flex-start;
  417. padding: 24rpx 34rpx;
  418. &-item {
  419. margin-right: 34rpx;
  420. padding: 12rpx 36rpx;
  421. border-radius: 24rpx;
  422. color: #FFAB4D;
  423. }
  424. &-item__action {
  425. background: #FFAB4D;
  426. color: #fff;
  427. }
  428. }
  429. }
  430. // 实物商品
  431. .prize-goods {
  432. margin-top: 180rpx;
  433. padding: 34rpx 34rpx 200rpx;
  434. &-list {
  435. &-item {
  436. padding: 34rpx 22rpx 34rpx;
  437. background-color: #fff;
  438. border-radius: 18rpx;
  439. margin-bottom: 30rpx;
  440. &__content {
  441. justify-content: space-between;
  442. padding-bottom: 22rpx;
  443. border-bottom: 1px solid #E5E5E5;
  444. .info {
  445. padding-left: 16rpx;
  446. flex: 1;
  447. justify-content: flex-start;
  448. image {
  449. width: 200rpx;
  450. height: 200rpx;
  451. border-radius: 12rpx;
  452. }
  453. .desc {
  454. height: 200rpx;
  455. padding-left: 22rpx;
  456. flex: 1;
  457. font-size: 30rpx;
  458. flex-direction: column;
  459. align-items: flex-start;
  460. justify-content: space-between;
  461. .title {
  462. line-height: 40rpx;
  463. font-weight: bold;
  464. }
  465. .num {
  466. width: 100%;
  467. color: #666666;
  468. font-size: 26rpx;
  469. justify-content: space-between;
  470. .sku {
  471. flex: 1;
  472. }
  473. }
  474. }
  475. }
  476. }
  477. &__btn {
  478. justify-content: space-between;
  479. padding-top: 22rpx;
  480. .type {
  481. font-size: 30rpx;
  482. color: #999999;
  483. line-height: 30rpx;
  484. padding-left: 70rpx;
  485. }
  486. .btn {
  487. width: 200rpx;
  488. height: 66rpx;
  489. line-height: 66rpx;
  490. text-align: center;
  491. color: #fff;
  492. background: #F9822C;
  493. border-radius: 34rpx;
  494. }
  495. .btnTwo {
  496. width: 200rpx;
  497. height: 66rpx;
  498. line-height: 66rpx;
  499. text-align: center;
  500. border-radius: 34rpx;
  501. background-color: #f1f1f1; color: #999;
  502. border: 2rpx solid #999;
  503. }
  504. }
  505. }
  506. &-item:last-child {
  507. margin-bottom: 0;
  508. }
  509. }
  510. }
  511. .prize-coupon {
  512. margin-top: 85rpx;
  513. padding: 40rpx 20rpx 150rpx;
  514. &-list {
  515. &-item {
  516. position: relative;
  517. background-color: #FFFFFF;
  518. margin-bottom: 20rpx;
  519. border-radius: 10rpx;
  520. image {
  521. width: 100%;
  522. height: 156rpx;
  523. margin-bottom: 24rpx;
  524. }
  525. .info {
  526. padding-left: 40rpx;
  527. padding-bottom: 8rpx;
  528. .info-item {
  529. line-height: 40rpx;
  530. color: #333333;
  531. margin-bottom: 12rpx;
  532. }
  533. }
  534. .info-now {
  535. margin-top: 10rpx;
  536. color: #848484;
  537. font-size: 30rpx;
  538. height: 100rpx;
  539. line-height: 90rpx;
  540. text-align: center;
  541. }
  542. .info-now view {
  543. height: 2rpx;
  544. margin: 0 10rpx;
  545. background-image: linear-gradient(to right, #cfcfcf 0%, #cfcfcf 50%, transparent 1%);
  546. background-size: 25rpx 10rpx;
  547. }
  548. .price-title {
  549. justify-content: flex-start;
  550. position: absolute;
  551. top: 0;
  552. width: 100%;
  553. padding: 36rpx 0 0 40rpx;
  554. .price {
  555. color: #FFFFFF;
  556. font-size: 60rpx;
  557. margin-right: 20rpx;
  558. text {
  559. font-size: 40rpx;
  560. }
  561. }
  562. .title {
  563. color: #FFFFFF;
  564. font-size: 48rpx;
  565. }
  566. }
  567. }
  568. &-item:last-child {
  569. margin-bottom: 0;
  570. }
  571. }
  572. }
  573. .prize-action {
  574. position: fixed;
  575. bottom: var(--window-bottom);
  576. left: 0;
  577. right: 0;
  578. z-index: 10;
  579. box-shadow: 0 -4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  580. background: #fff;
  581. width: 100%;
  582. // 设置ios刘海屏底部横线安全区域
  583. padding-bottom: constant(safe-area-inset-bottom);
  584. padding-bottom: env(safe-area-inset-bottom);
  585. &-goods {
  586. justify-content: space-between;
  587. padding: 20rpx 40rpx;
  588. .all {
  589. margin-right: 10rpx;
  590. }
  591. .btn {
  592. width: 225rpx;
  593. height: 82rpx;
  594. font-size: 28rpx;
  595. line-height: 82rpx;
  596. border-radius: 40rpx;
  597. background-color: #F9822C;
  598. color: #fff;
  599. text-align: center;
  600. }
  601. }
  602. &-coupon {
  603. padding: 30rpx 40rpx;
  604. .title {
  605. margin-right: 20rpx;
  606. line-height: 40rpx;
  607. }
  608. }
  609. }
  610. .empty {
  611. height: 60vh;
  612. .center {
  613. text-align: center;
  614. &-img {
  615. width: 228rpx;
  616. height: 320rpx;
  617. }
  618. &-font {
  619. font-size: 30rpx;
  620. font-weight: 400;
  621. color: #999999;
  622. margin-bottom: 350rpx;
  623. }
  624. }
  625. }
  626. </style>