index.vue 16 KB

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