exchangerecord.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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_record, notGiftOrder } from '../../apis/zbs.js'
  37. export default {
  38. data() {
  39. return {
  40. list: []
  41. };
  42. },
  43. computed: {
  44. userServerInfo() {
  45. //用户服务器信息
  46. return this.$store.state.userinfo;
  47. },
  48. },
  49. onShow() {
  50. this.getRecordList()
  51. },
  52. methods: {
  53. publishDestoryGiftOrder(data) {
  54. const _this = this
  55. uni.showModal({
  56. content: "确认取消该兑换订单",
  57. success(res) {
  58. if(res.confirm) {
  59. uni.showLoading()
  60. notGiftOrder({ gift_id: data.id, user_id: _this.userServerInfo.id }).then(res => {
  61. uni.hideLoading()
  62. if(res.code === 200) {
  63. uni.showModal({
  64. content: "兑换订单取消成功",
  65. showCancel: false,
  66. success(res) {
  67. if(res.confirm) {
  68. _this.getRecordList()
  69. _this.$store.dispatch('onLaunch')
  70. }
  71. }
  72. })
  73. } else {
  74. uni.showModal({
  75. content: res.msg || '取消兑换订单失败',
  76. showCancel: false
  77. })
  78. }
  79. }).catch(() => {
  80. uni.hideLoading()
  81. uni.showModal({
  82. content:"取消兑换订单失败",
  83. showCancel: false
  84. })
  85. })
  86. }
  87. }
  88. })
  89. },
  90. getRecordList() {
  91. uni.showLoading()
  92. api_record({ user_id: this.userServerInfo.id }).then(res => {
  93. uni.hideLoading()
  94. if(res.code === 200) {
  95. this.list = res.data.list
  96. } else {
  97. uni.showModal({
  98. content: "获取兑换记录失败",
  99. showCancel:false
  100. })
  101. }
  102. }).catch(() => {
  103. uni.hideLoading()
  104. uni.showModal({
  105. content: "获取兑换记录失败",
  106. showCancel:false
  107. })
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. page {
  115. height: 100%;
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: space-between;
  119. .recordContainer {
  120. width: 100%;
  121. height: 100%;
  122. padding: 30rpx;
  123. box-sizing: border-box;
  124. background-color: #F9F9FB;
  125. .recordItem {
  126. width: 100%;
  127. padding: 30rpx;
  128. box-sizing: border-box;
  129. margin-bottom: 30rpx;
  130. border-radius: 24rpx;
  131. background-color: #FFFFFF;
  132. &.voided {
  133. position: relative;
  134. overflow: hidden;
  135. &::after {
  136. content: "";
  137. display: block;
  138. width: 168rpx;
  139. height: 168rpx;
  140. background-position: center;
  141. background-repeat: no-repeat;
  142. background-size: 100%;
  143. // background-image: url(../../static/gift/cancel.png);
  144. background-image: url('https://api.jiuweiyun.cn/public/uploads/weapp/icon/cancel.png');
  145. filter: grayscale(100%);
  146. position: absolute;
  147. right: 56rpx;
  148. bottom: -20rpx;
  149. }
  150. }
  151. .header {
  152. width: 100%;
  153. display: flex;
  154. align-items: center;
  155. justify-content: space-between;
  156. margin-bottom: 20rpx;
  157. .time {
  158. color: #999999;
  159. font-size: 28rpx;
  160. line-height: 40rpx;
  161. }
  162. .money {
  163. color: #EA4A41;
  164. font-size: 32rpx;
  165. line-height: 44rpx;
  166. font-weight: bold;
  167. }
  168. }
  169. .body {
  170. width: 100%;
  171. display: flex;
  172. align-items: stretch;
  173. justify-content: space-between;
  174. position: relative;
  175. .avatar {
  176. width: 128rpx;
  177. height: 128rpx;
  178. border-radius: 8rpx;
  179. background-color: #FF7B39;
  180. background-position: center;
  181. background-repeat: no-repeat;
  182. background-size: 100%;
  183. margin-right: 20rpx;
  184. }
  185. .info {
  186. flex: 1;
  187. overflow: hidden;
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: space-around;
  191. .name {
  192. color: #333333;
  193. font-size: 32rpx;
  194. line-height: 44rpx;
  195. font-weight: bold;
  196. }
  197. .num {
  198. color: #999999;
  199. font-size: 28rpx;
  200. line-height: 40rpx;
  201. }
  202. }
  203. .voidBtn{
  204. width: 192rpx;
  205. height: 68rpx;
  206. border-radius: 68rpx;
  207. text-align: center;
  208. background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
  209. line-height: 68rpx;
  210. color: #FFFFFF;
  211. font-size: 28rpx;
  212. position: absolute;
  213. bottom: 0;
  214. right: 0;
  215. }
  216. }
  217. }
  218. .noTip {
  219. width: 100%;
  220. text-align: center;
  221. padding: 20rpx 0;
  222. font-size: 28rpx;
  223. color: #333333;
  224. }
  225. }
  226. }
  227. </style>