exchangerecord.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <scroll-view
  3. :scroll-y="true"
  4. class="recordContainer"
  5. >
  6. <template v-if="list.length > 0">
  7. <view
  8. v-for="item in list"
  9. :key="item.id"
  10. class="recordItem"
  11. :class="item.type ? 'voided' : ''"
  12. >
  13. <view class="header">
  14. <view class="time">{{ item.timestamp | dateFormatter('yyyy-MM-dd hh:mm:ss') }}</view>
  15. <view class="money">-{{ item.cost }}奖学金</view>
  16. </view>
  17. <view class="body">
  18. <view
  19. class="avatar"
  20. :style="{ backgroundImage: `url(${item.gift_info.imgurl})` }"
  21. />
  22. <view class="info">
  23. <view class="name">{{ item.name }}</view>
  24. <view class="num">X{{ item.num }}</view>
  25. </view>
  26. <view class="voidBtn" v-if="!item.type" @click="publishDestoryGiftOrder(item)">取消兑换</view>
  27. </view>
  28. </view>
  29. </template>
  30. <template v-else>
  31. <view class="noTip">暂无兑换记录</view>
  32. </template>
  33. </scroll-view>
  34. </template>
  35. <script>
  36. import { api_getExchangeRecord, notGiftOrder } from '../../api.js'
  37. export default {
  38. data() {
  39. return {
  40. list: []
  41. };
  42. },
  43. onShow() {
  44. this.getRecordList()
  45. },
  46. methods: {
  47. publishDestoryGiftOrder(data) {
  48. const _this = this
  49. uni.showModal({
  50. content: "确认取消该兑换订单",
  51. success(res) {
  52. if(res.confirm) {
  53. uni.showLoading()
  54. _this.$ajax.get(`${notGiftOrder}?gift_id=${data.id}`).then(([ , { data: res}]) => {
  55. uni.hideLoading()
  56. if(res.code === 200) {
  57. uni.showModal({
  58. content: "兑换订单取消成功",
  59. showCancel: false,
  60. success(res) {
  61. if(res.confirm) {
  62. _this.getRecordList()
  63. _this.$store.dispatch('onLaunch')
  64. }
  65. }
  66. })
  67. } else {
  68. uni.showModal({
  69. content: res.msg || '取消兑换订单失败',
  70. showCancel: false
  71. })
  72. }
  73. }).catch(() => {
  74. uni.hideLoading()
  75. uni.showModal({
  76. content:"取消兑换订单失败",
  77. showCancel: false
  78. })
  79. })
  80. }
  81. }
  82. })
  83. },
  84. getRecordList() {
  85. uni.showLoading()
  86. this.$ajax.get(api_getExchangeRecord).then(([ , { data: res}]) => {
  87. uni.hideLoading()
  88. if(res.code === 200) {
  89. this.list = res.data.list
  90. } else {
  91. uni.showModal({
  92. content: "获取兑换记录失败",
  93. showCancel:false
  94. })
  95. }
  96. }).catch(() => {
  97. uni.hideLoading()
  98. uni.showModal({
  99. content: "获取兑换记录失败",
  100. showCancel:false
  101. })
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. page {
  109. height: 100%;
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: space-between;
  113. .recordContainer {
  114. width: 100%;
  115. height: 100%;
  116. padding: 30rpx;
  117. box-sizing: border-box;
  118. background-color: #F9F9FB;
  119. .recordItem {
  120. width: 100%;
  121. padding: 30rpx;
  122. box-sizing: border-box;
  123. margin-bottom: 30rpx;
  124. border-radius: 24rpx;
  125. background-color: #FFFFFF;
  126. &.voided {
  127. position: relative;
  128. overflow: hidden;
  129. &::after {
  130. content: "";
  131. display: block;
  132. width: 168rpx;
  133. height: 168rpx;
  134. background-position: center;
  135. background-repeat: no-repeat;
  136. background-size: 100%;
  137. // background-image: url(../../static/gift/cancel.png);
  138. background-image: url('https://api.jiuweiyun.cn/public/uploads/weapp/icon/cancel.png');
  139. filter: grayscale(100%);
  140. position: absolute;
  141. right: 56rpx;
  142. bottom: -20rpx;
  143. }
  144. }
  145. .header {
  146. width: 100%;
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. margin-bottom: 20rpx;
  151. .time {
  152. color: #999999;
  153. font-size: 28rpx;
  154. line-height: 40rpx;
  155. }
  156. .money {
  157. color: #EA4A41;
  158. font-size: 32rpx;
  159. line-height: 44rpx;
  160. font-weight: bold;
  161. }
  162. }
  163. .body {
  164. width: 100%;
  165. display: flex;
  166. align-items: stretch;
  167. justify-content: space-between;
  168. position: relative;
  169. .avatar {
  170. width: 128rpx;
  171. height: 128rpx;
  172. border-radius: 8rpx;
  173. background-color: #FF7B39;
  174. background-position: center;
  175. background-repeat: no-repeat;
  176. background-size: 100%;
  177. margin-right: 20rpx;
  178. }
  179. .info {
  180. flex: 1;
  181. overflow: hidden;
  182. display: flex;
  183. flex-direction: column;
  184. justify-content: space-around;
  185. .name {
  186. color: #333333;
  187. font-size: 32rpx;
  188. line-height: 44rpx;
  189. font-weight: bold;
  190. }
  191. .num {
  192. color: #999999;
  193. font-size: 28rpx;
  194. line-height: 40rpx;
  195. }
  196. }
  197. .voidBtn{
  198. width: 192rpx;
  199. height: 68rpx;
  200. border-radius: 68rpx;
  201. text-align: center;
  202. background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
  203. line-height: 68rpx;
  204. color: #FFFFFF;
  205. font-size: 28rpx;
  206. position: absolute;
  207. bottom: 0;
  208. right: 0;
  209. }
  210. }
  211. }
  212. .noTip {
  213. width: 100%;
  214. text-align: center;
  215. padding: 20rpx 0;
  216. font-size: 28rpx;
  217. color: #333333;
  218. }
  219. }
  220. }
  221. </style>