index.vue 16 KB

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