details.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <app-layout>
  3. <view class="page">
  4. <view class="view">
  5. <view class='card'>
  6. <image class='card-img' :src='list.pic_url'></image>
  7. <view class='card-name'>{{list.card_name}}</view>
  8. <view class='qr' v-if="list.is_use !== 1 && list.endTime > timestamp">
  9. <image :src='file_path' v-if="list.is_use === 0"></image>
  10. </view>
  11. <view class='over' v-if="list.is_use === 1">已使用</view>
  12. <view class='over' v-else-if="list.endTime < timestamp">已过期</view>
  13. </view>
  14. <view class='line'>
  15. <image src='/static/image/icon/line.png'></image>
  16. </view>
  17. <view class='explain use-time' v-if="list.is_show_history">
  18. <view class='explain-title'>核销时间</view>
  19. <view class="clerk-history">
  20. <view>{{list.clerked_at}}</view>
  21. <view @click="isShow = true" class="history-button">查看历史</view>
  22. </view>
  23. </view>
  24. <view class='explain use-time'>
  25. <view class='explain-title'>有效时间</view>
  26. <view>{{list.start_time}} - {{list.end_time}}</view>
  27. </view>
  28. <view class='explain card-info'>
  29. <view class='explain-title'>使用说明</view>
  30. <view>
  31. <text style="word-break: break-all;">{{list.content}}</text>
  32. </view>
  33. </view>
  34. <view class='explain card-info-2'>
  35. <view class='explain-title'>核销信息</view>
  36. <view class="clerk-info">
  37. <view class="clerk-item">
  38. <view>剩余次数:</view>
  39. <view>{{list.number - list.use_number}}次</view>
  40. </view>
  41. <view class="clerk-item">
  42. <view>已核销次数:</view>
  43. <view>{{list.use_number}}次</view>
  44. </view>
  45. <view class="clerk-item">
  46. <view>总次数:</view>
  47. <view>{{list.number}}次</view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <app-clerk-historys :user-card-id="list.id" :is-show.sync="isShow"></app-clerk-historys>
  53. </view>
  54. </app-layout>
  55. </template>
  56. <script>
  57. import { mapState } from "vuex";
  58. import appClerkHistorys from '../../../components/page-component/app-clerk-historys/app-clerk-historys.vue';
  59. export default {
  60. components: {appClerkHistorys},
  61. data() {
  62. return {
  63. list: [],
  64. file_path: '',
  65. timestamp: null,
  66. isShow: false
  67. }
  68. },
  69. computed: {
  70. ...mapState({
  71. theme: state => state.mallConfig.theme,
  72. })
  73. },
  74. methods: {
  75. getList(id) {
  76. let that = this;
  77. that.$showLoading({
  78. text: '加载中...'
  79. });
  80. that.$request({
  81. url: that.$api.card.detail,
  82. data: {
  83. cardId: id,
  84. },
  85. }).then(response=>{
  86. if(response.code === 0) {
  87. that.list = response.data.card;
  88. that.$request({
  89. url: that.$api.card.qrcode,
  90. data: {
  91. cardId: id,
  92. },
  93. }).then(response=>{
  94. that.$hideLoading();
  95. if(response.code === 0) {
  96. that.file_path = response.data.file_path;
  97. }else {
  98. uni.showToast({
  99. title: response.msg,
  100. icon: 'none',
  101. duration: 1000,
  102. });
  103. }
  104. }).catch(() => {
  105. that.$hideLoading();
  106. });
  107. } else {
  108. uni.showToast({
  109. title: response.msg,
  110. icon: 'none',
  111. duration: 1000,
  112. });
  113. }
  114. }).catch(() => {
  115. that.$hideLoading();
  116. });
  117. },
  118. },
  119. onLoad(options) {
  120. this.getList(options.id);
  121. this.timestamp = Date.parse(new Date()) / 1000;
  122. }
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .page {
  127. height: 100%;
  128. background-color: #ff7b33;
  129. position: absolute;
  130. width: 100%;
  131. }
  132. .view {
  133. background-color: #ff7b33;
  134. padding: #{72rpx} #{24rpx};
  135. }
  136. .card {
  137. background-color: #fff;
  138. border-top-left-radius: #{16rpx};
  139. border-top-right-radius: #{16rpx};
  140. padding: #{90rpx} #{40rpx} #{24rpx};
  141. }
  142. .card-info {
  143. background-color: #fff;
  144. }
  145. .card-img {
  146. position: absolute;
  147. top: #{32rpx};
  148. left: 50%;
  149. margin-left: #{-44rpx};
  150. height: #{88rpx};
  151. width: #{88rpx};
  152. border-radius: 50%;
  153. }
  154. .card-name {
  155. text-align: center;
  156. font-size: #{50rpx};
  157. margin-bottom: #{40rpx};
  158. color: #353535;
  159. }
  160. .over {
  161. width: #{240rpx};
  162. height: #{64rpx};
  163. text-align: center;
  164. color: #999;
  165. font-size: #{30rpx};
  166. line-height: #{64rpx};
  167. border-radius: #{32rpx};
  168. background-color: #f7f7f7;
  169. margin: 0 auto;
  170. }
  171. .line {
  172. height: #{48rpx};
  173. width: 100%;
  174. }
  175. .line image {
  176. height: 100%;
  177. width: 100%;
  178. }
  179. .explain {
  180. background-color: #fff;
  181. padding: #{20rpx} #{40rpx};
  182. font-size: #{28rpx};
  183. color: #353535;
  184. }
  185. .explain.use-time {
  186. padding-bottom: #{20rpx};
  187. }
  188. .explain-title {
  189. font-size: #{26rpx};
  190. color: #999;
  191. margin-bottom: #{15rpx};
  192. }
  193. .qr {
  194. height: #{400rpx};
  195. width: #{400rpx};
  196. display: block;
  197. margin: 0 auto;
  198. }
  199. .qr image {
  200. height: 100%;
  201. width: 100%
  202. }
  203. .clerk-info {
  204. display: flex;
  205. flex-direction:column;
  206. .clerk-item {
  207. display: flex;
  208. }
  209. }
  210. .card-info-2 {
  211. background-color: #fff;
  212. border-bottom-left-radius: #{16rpx};
  213. border-bottom-right-radius: #{16rpx};
  214. padding-bottom:60#{rpx};
  215. }
  216. .clerk-history {
  217. display: flex;
  218. align-items:center;
  219. .history-button {
  220. width: 125#{rpx};
  221. height: 48#{rpx};
  222. border-radius: 30#{rpx};
  223. margin-left:10#{rpx};
  224. font-size:#{22rpx};
  225. color: #ac450d;
  226. background: #ffeda9;
  227. display: flex;
  228. justify-content:center;
  229. align-items: center;
  230. }
  231. }
  232. </style>