mygift.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <view class="recordGift">
  3. <view class="nav">
  4. <view
  5. class="item"
  6. :class="!navIndex ? 'active' : ''"
  7. @click="navIndex = 0"
  8. >
  9. 我的礼品({{ total[0] }})
  10. </view>
  11. <view
  12. class="item"
  13. :class="navIndex ? 'active' : ''"
  14. @click="navIndex = 1"
  15. >
  16. 下级礼品({{ total[1] }})
  17. </view>
  18. </view>
  19. <template v-if="!navIndex">
  20. <scroll-view class="list" scroll-y="true">
  21. <template v-if="recordList.length">
  22. <view
  23. v-for="(item, i) in recordList"
  24. :key="i"
  25. class="item"
  26. :class="item.type ? 'voided' : ''"
  27. >
  28. <view class="header">
  29. <view class="time">{{ item.timestamp | dateFormatter('yyyy-MM-dd hh:mm:ss') }}</view>
  30. <view class="money">-{{ item.cost }}奖学金</view>
  31. </view>
  32. <view class="body">
  33. <view
  34. class="avatar"
  35. :style="{ backgroundImage: `url(${item.gift_info.imgurl})` }">
  36. </view>
  37. <view class="info">
  38. <view class="name">{{ item.name }}</view>
  39. <view class="num">X{{ item.num }}</view>
  40. </view>
  41. <view class="voidBtn" v-if="!item.type && navIndex === 0" @click="publishDestoryGiftOrder(item)">取消兑换</view>
  42. <!-- <view class="delBtn" @click="delGiftOrder(item)">删除</view>
  43. <view class="voidBtn" @click="editGiftOrder(item)">修改</view> -->
  44. <!-- <view class="voidBtn" v-if="!item.type" @click="publishDestoryGiftOrder(item)">作废</view> -->
  45. </view>
  46. </view>
  47. </template>
  48. <template v-else>
  49. <view class="noTip">暂无兑换记录</view>
  50. </template>
  51. </scroll-view>
  52. </template>
  53. <template v-else>
  54. <scroll-view class="childList" scroll-y="true" @scrolltolower="toMoreChild">
  55. <template v-if="recordList.length > 0">
  56. <view
  57. v-for="item in recordList"
  58. :key="item.uid"
  59. class="childItem"
  60. >
  61. <view
  62. class="header"
  63. :class="openId === item.uid ? 'open' : ''"
  64. @click="toggleChildList(item.uid)"
  65. >
  66. <text>{{ item.get_user.nickname }}</text>
  67. </view>
  68. <view v-if="openId === item.uid" class="body">
  69. <view
  70. v-for="(btem, bi) in item.get_order"
  71. :key="bi"
  72. class="bodyItem"
  73. >
  74. <view class="name">{{ btem.name }}L</view>
  75. <view class="num">*{{ btem.num }}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <view v-if="!recordIsMore" class="noTip">暂无更多</view>
  80. </template>
  81. <template v-else>
  82. <view class="noTip">暂无兑换记录</view>
  83. </template>
  84. </scroll-view>
  85. </template>
  86. <view class="showTotal" v-if="fillOut">
  87. <view class="show">
  88. <view class="show-top">
  89. <text>奖学金:</text>
  90. <text style="color: #EA4A41;">{{list.total}}</text>
  91. </view>
  92. <view class="show-middle">
  93. <text>数量:</text>
  94. <view style="width: 180rpx;"><custom-counter :count-num.sync="num"></custom-counter></view>
  95. </view>
  96. <view class="show-bottom">
  97. <view class="goon" @click="fillOut=false">
  98. 取消
  99. </view>
  100. <view class="check" @click="check">
  101. 保存
  102. </view>
  103. </view>
  104. </view>
  105. <view class="over"></view>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import { api_getExchangeRecord, api_getTeamRecord, notGiftOrder } from '../../api.js'
  111. import customCounter from '../detail/components/count2.vue'
  112. export default {
  113. components: {
  114. customCounter
  115. },
  116. data() {
  117. return {
  118. fillOut:false,
  119. navIndex: 0,
  120. recordList: [
  121. // {
  122. // id:1,
  123. // timestamp:'2020-12-13 22:45:23',
  124. // cost:'200',
  125. // name:'秋衣秋裤女XXXL',
  126. // num:2,
  127. // total:1050
  128. // },
  129. // {
  130. // id:2,
  131. // timestamp:'2020-12-13 22:45:23',
  132. // cost:'200',
  133. // name:'秋衣秋裤女XL',
  134. // num:4,
  135. // total:1500
  136. // },{
  137. // id:3,
  138. // timestamp:'2020-12-13 22:45:23',
  139. // cost:'200',
  140. // name:'秋衣秋裤男L',
  141. // num:1,
  142. // total:1500
  143. // }
  144. ],
  145. recordIsMore: true,
  146. openId: '',
  147. childPage: 1,
  148. total: [0, 0],
  149. num:'',
  150. list:{
  151. total:'',
  152. num:''
  153. },
  154. price:''
  155. }
  156. },
  157. watch: {
  158. navIndex(a) {
  159. this.openId = ''
  160. this.childPage = 1
  161. this.recordIsMore = true
  162. this.recordList = []
  163. a ? this.getChildRecord() : this.getMyRecord()
  164. },
  165. num(val){
  166. this.list.total=val * this.price
  167. }
  168. },
  169. onShow() {
  170. this.getTotal()
  171. this.getMyRecord()
  172. },
  173. methods: {
  174. //修改数量
  175. check(){},
  176. getTotal() {
  177. let myTotal = new Promise(resolve => this.$ajax.get(api_getExchangeRecord).then(([ , { data: res}]) => {
  178. if(res.code === 200) {
  179. resolve(res.data.total)
  180. }
  181. }))
  182. let childTotal = new Promise(resolve => this.$ajax.get(`${api_getTeamRecord}?page_index=1`).then(([ , { data: res}]) => {
  183. if(res.code === 200) {
  184. resolve(res.data.total)
  185. }
  186. }))
  187. Promise.all([myTotal, childTotal]).then(res => {
  188. this.total = res
  189. })
  190. },
  191. // 客户加载更多
  192. toMoreChild() {
  193. if(!this.recordIsMore) return false
  194. this.childPage += 1
  195. this.getChildRecord()
  196. },
  197. // 展开
  198. toggleChildList(uid) {
  199. this.openId = this.openId === uid ? '' : uid
  200. },
  201. //修改
  202. editGiftOrder(item){
  203. getApp().globalData.detail = item;
  204. uni.navigateTo({
  205. url:'../detail/detail?type=1'
  206. })
  207. // this.fillOut=true
  208. // this.num=item.num
  209. // this.price = item.total / item.num
  210. // this.list.total=this.price * this.num
  211. },
  212. publishDestoryGiftOrder(data) {
  213. const _this = this
  214. uni.showModal({
  215. content: "确认取消该兑换订单",
  216. success(res) {
  217. if(res.confirm) {
  218. uni.showLoading()
  219. _this.$ajax.get(`${notGiftOrder}?gift_id=${data.id}`).then(([ , { data: res}]) => {
  220. uni.hideLoading()
  221. if(res.code === 200) {
  222. uni.showModal({
  223. content: "兑换订单取消成功",
  224. showCancel: false,
  225. success(res) {
  226. if(res.confirm) {
  227. _this.getMyRecord()
  228. _this.$store.dispatch('onLaunch')
  229. }
  230. }
  231. })
  232. } else {
  233. uni.showModal({
  234. content: res.msg || '取消兑换订单失败',
  235. showCancel: false
  236. })
  237. }
  238. }).catch(() => {
  239. uni.hideLoading()
  240. uni.showModal({
  241. content:"取消兑换订单失败",
  242. showCancel: false
  243. })
  244. })
  245. }
  246. }
  247. })
  248. },
  249. //删除
  250. delGiftOrder(data) {
  251. const _this = this
  252. uni.showModal({
  253. content: "确认删除该兑换订单吗?",
  254. success(res) {
  255. if(res.confirm) {
  256. uni.showLoading()
  257. _this.$ajax.get(`${destoryGiftOrder}?id=${data.id}`).then(([ , { data: res}]) => {
  258. uni.hideLoading()
  259. if(res.code === 200) {
  260. uni.showModal({
  261. content: "兑换订单删除成功",
  262. showCancel: false,
  263. success(res) {
  264. if(res.confirm) {
  265. _this.getRecordList()
  266. _this.$store.dispatch('onLaunch')
  267. uni.navigateTo({
  268. url:'../exchange/exchange'
  269. })
  270. }
  271. }
  272. })
  273. } else {
  274. uni.showModal({
  275. content: res.msg || '删除兑换订单失败',
  276. showCancel: false
  277. })
  278. }
  279. }).catch(() => {
  280. uni.hideLoading()
  281. uni.showModal({
  282. content:"删除兑换订单失败",
  283. showCancel: false
  284. })
  285. })
  286. }
  287. }
  288. })
  289. },
  290. // 我的兑换记录
  291. getMyRecord() {
  292. uni.showLoading()
  293. this.$ajax.get(api_getExchangeRecord).then(([, { data: res }]) => {
  294. uni.hideLoading()
  295. if(res.code === 200) {
  296. this.recordList = res.data.list
  297. } else {
  298. uni.showModal({
  299. content: res.msg || "获取兑换记录失败",
  300. showCancel: false
  301. })
  302. }
  303. }).catch(() => {
  304. uni.hideLoading()
  305. uni.showModal({
  306. content:"获取兑换记录失败",
  307. showCancel: false
  308. })
  309. })
  310. },
  311. // 下级兑换记录
  312. getChildRecord() {
  313. uni.showLoading()
  314. this.$ajax.get(`${api_getTeamRecord}?page_index=${this.childPage}`).then(([, { data: res }]) => {
  315. uni.hideLoading()
  316. if(res.code === 200) {
  317. this.recordList = res.data.list
  318. this.recordIsMore = res.data.list.length < 20 ? false : true
  319. } else {
  320. uni.showModal({
  321. content: res.msg || "获取下级客户记录失败",
  322. showCancel: false
  323. })
  324. }
  325. }).catch(() => {
  326. uni.hideLoading()
  327. uni.showModal({
  328. content:"获取下级客户记录失败",
  329. showCancel: false
  330. })
  331. })
  332. }
  333. }
  334. }
  335. </script>
  336. <style lang="scss" scoped>
  337. .showTotal{
  338. .show{
  339. width: 620rpx;
  340. height: 400rpx;
  341. padding: 30rpx;
  342. background-color: #fff;
  343. border-radius: 26rpx;
  344. position: fixed;
  345. left: 0;
  346. right: 0;
  347. top:280rpx;
  348. margin: auto;
  349. z-index: 10000;
  350. display: flex;
  351. flex-direction: column;
  352. justify-content: space-between;
  353. &-top{
  354. margin-top: 30rpx;
  355. font-size: 36rpx;
  356. color: #333;
  357. font-weight: bold;
  358. }
  359. &-middle{
  360. display: flex;
  361. font-size: 36rpx;
  362. color: #333;
  363. font-weight: bold;
  364. }
  365. &-bottom{
  366. display: flex;
  367. justify-content: center;
  368. margin-top: 72rpx;
  369. .goon{
  370. width: 200rpx;
  371. line-height: 66rpx;
  372. color: #FB231F;
  373. border-radius: 44rpx;
  374. border: 2rpx #FB231F solid;
  375. background-color: #FFF4F3;
  376. text-align: center;
  377. }
  378. .check{
  379. width: 200rpx;
  380. color: #fff;
  381. line-height: 66rpx;
  382. margin-left: 40rpx;
  383. border-radius: 44rpx;
  384. background: linear-gradient(93deg, #F97C55 0%, #F44545 100%);
  385. text-align: center;
  386. }
  387. }
  388. // &-image{
  389. // width: 620rpx;
  390. // position: relative;
  391. // }
  392. // &-button{
  393. // width: 400rpx;
  394. // line-height: 96rpx;
  395. // text-align: center;
  396. // color: #fff;
  397. // font-size: 32rpx;
  398. // border-radius: 56rpx;
  399. // background: linear-gradient(90deg, #F97C55 0%, #F44545 100%);
  400. // position: absolute;
  401. // bottom: -40rpx;
  402. // left: 110rpx;
  403. // }
  404. }
  405. .over{
  406. width: 100%;
  407. height: 100%;
  408. background-color: #000;
  409. opacity: 0.6;
  410. position: fixed;
  411. top: 0;
  412. left: 0;
  413. z-index: 999;
  414. }
  415. .button{
  416. width: 400rpx;
  417. height: 96rpx;
  418. background: linear-gradient(90deg, #F97C55 0%, #F44545 100%);
  419. }
  420. }
  421. page {
  422. height: 100%;
  423. width: 100%;
  424. .recordGift {
  425. width: 100%;
  426. height: 100%;
  427. display: flex;
  428. flex-direction: column;
  429. justify-content: space-between;
  430. .nav {
  431. width: 100%;
  432. height: 104rpx;
  433. display: flex;
  434. align-items: center;
  435. justify-content: space-between;
  436. padding: 0 60rpx;
  437. box-sizing: border-box;
  438. .item {
  439. color: #333333;
  440. font-size: 32rpx;
  441. line-height: 44rpx;
  442. position: relative;
  443. &.active {
  444. font-weight: bold !important;
  445. color: #EA4A41 !important;
  446. &::after {
  447. content: "";
  448. display: block;
  449. width: 30rpx;
  450. height: 4rpx;
  451. border-radius: 4rpx;
  452. background: linear-gradient(97deg, #F97C55 0%, #F44545 100%);
  453. position: absolute;
  454. left: 50%;
  455. bottom: -4rpx;
  456. transform: translateX(-50%);
  457. }
  458. }
  459. }
  460. }
  461. .list {
  462. width: 100%;
  463. padding: 30rpx;
  464. flex: 1;
  465. overflow: hidden;
  466. background-color: #F9F9FB;
  467. .item{
  468. width: 100%;
  469. padding: 30rpx;
  470. box-sizing: border-box;
  471. margin-bottom: 30rpx;
  472. border-radius: 24rpx;
  473. background-color: #FFFFFF;
  474. &.voided {
  475. position: relative;
  476. overflow: hidden;
  477. &::after {
  478. content: "";
  479. display: block;
  480. width: 168rpx;
  481. height: 168rpx;
  482. background-position: center;
  483. background-repeat: no-repeat;
  484. background-size: 100%;
  485. background-image: url('https://api.jiuweiyun.cn/public/uploads/weapp/icon/cancel.png');
  486. filter: grayscale(100%);
  487. position: absolute;
  488. right: 56rpx;
  489. bottom: -20rpx;
  490. }
  491. }
  492. .header {
  493. width: 100%;
  494. display: flex;
  495. align-items: center;
  496. justify-content: space-between;
  497. margin-bottom: 20rpx;
  498. .time {
  499. color: #999999;
  500. font-size: 28rpx;
  501. line-height: 40rpx;
  502. }
  503. .money {
  504. color: #EA4A41;
  505. font-size: 32rpx;
  506. line-height: 44rpx;
  507. font-weight: bold;
  508. }
  509. }
  510. .body {
  511. width: 100%;
  512. display: flex;
  513. align-items: stretch;
  514. justify-content: space-between;
  515. overflow: hidden;
  516. .avatar {
  517. width: 128rpx;
  518. height: 128rpx;
  519. border-radius: 8rpx;
  520. background-color: #FF7B39;
  521. background-position: center;
  522. background-repeat: no-repeat;
  523. background-size: 100%;
  524. margin-right: 20rpx;
  525. }
  526. .info {
  527. flex: 1;
  528. overflow: hidden;
  529. display: flex;
  530. flex-direction: column;
  531. justify-content: space-around;
  532. .name {
  533. color: #333333;
  534. font-size: 32rpx;
  535. line-height: 44rpx;
  536. font-weight: bold;
  537. }
  538. .num {
  539. color: #999999;
  540. font-size: 28rpx;
  541. line-height: 40rpx;
  542. }
  543. }
  544. position: relative;
  545. .delBtn{
  546. width: 160rpx;
  547. height: 68rpx;
  548. border-radius: 68rpx;
  549. text-align: center;
  550. background-color: #f8f8f8;
  551. line-height: 68rpx;
  552. color: #999;
  553. font-size: 28rpx;
  554. position: absolute;
  555. bottom: 0;
  556. right: 180rpx;
  557. }
  558. .voidBtn{
  559. width: 160rpx;
  560. height: 68rpx;
  561. border-radius: 68rpx;
  562. text-align: center;
  563. background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
  564. line-height: 68rpx;
  565. color: #FFFFFF;
  566. font-size: 28rpx;
  567. position: absolute;
  568. bottom: 0;
  569. right: 0;
  570. }
  571. }
  572. }
  573. }
  574. .childList {
  575. width: 100%;
  576. padding: 30rpx;
  577. flex: 1;
  578. overflow: hidden;
  579. background-color: #F9F9FB;
  580. .childItem {
  581. width: 100%;
  582. border-radius: 20rpx;
  583. overflow: hidden;
  584. margin-bottom: 30rpx;
  585. .header {
  586. height: 104rpx;
  587. width: 100%;
  588. padding: 0 30rpx;
  589. box-sizing: border-box;
  590. display: flex;
  591. align-items: center;
  592. justify-content: space-between;
  593. color: #333333;
  594. font-size: 32rpx;
  595. background-color: #FFFFFF;
  596. &.open {
  597. &::after {
  598. transform: rotate(90deg) !important;
  599. }
  600. }
  601. &::after {
  602. content: "";
  603. display: block;
  604. width: 30rpx;
  605. height: 30rpx;
  606. background-position: center;
  607. background-size: 100%;
  608. background-repeat: no-repeat;
  609. background-image: url(../../static/icon/arrow.png);
  610. }
  611. }
  612. .body{
  613. width: 100%;
  614. padding: 30rpx;
  615. box-sizing: border-box;
  616. background-color: #FFFFFF;
  617. position: relative;
  618. &::before {
  619. content: "";
  620. display: block;
  621. width: calc(100% - 60rpx);
  622. height: 1px;
  623. background-color: #EEEEEE;
  624. position: absolute;
  625. top: 0;
  626. left: 50%;
  627. transform: translateX(-50%);
  628. }
  629. .bodyItem {
  630. width: 100%;
  631. display: flex;
  632. align-items: center;
  633. justify-content: space-between;
  634. margin-bottom: 30rpx;
  635. &:nth-last-of-type(1) {
  636. margin-bottom: 0;
  637. }
  638. .num {
  639. color: #EA4A41;
  640. font-size: 32rpx;
  641. line-height: 44rpx;
  642. }
  643. .name {
  644. flex: 1;
  645. margin-right: 20rpx;
  646. overflow: hidden;
  647. font-weight: bold;
  648. color: #333333;
  649. font-size: 32rpx;
  650. line-height: 44rpx;
  651. word-break: keep-all;
  652. text-overflow: ellipsis;
  653. }
  654. }
  655. }
  656. }
  657. }
  658. }
  659. }
  660. .noTip {
  661. width: 100%;
  662. text-align: center;
  663. padding: 20rpx 0;
  664. font-size: 28rpx;
  665. color: #333333;
  666. }
  667. </style>