index.vue 16 KB

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