index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. f<template>
  2. <app-layout>
  3. <app-tab-nav :tabList="tabList" :activeItem="activeTab" @click="tabStatus" :theme="getTheme"></app-tab-nav>
  4. <view class="card-list">
  5. <view @click="toDetail(item)" v-for="item in list" :key="item.id">
  6. <view class="card-item dir-left-nowrap main-center cross-center">
  7. <image class="card-img" :src="item.pic_url"></image>
  8. <view class="name dir-top-nowrap" style="height: 100%;" v-if="item.receive_id !== 0">
  9. <view class="box-grow-1 dir-left-nowrap cross-bottom">
  10. <view class="t-omit-two">{{item.name}}</view>
  11. </view>
  12. <view class="box-grow-0">
  13. <view class="is_send">已转赠</view>
  14. </view>
  15. </view>
  16. <view class="name t-omit-two" v-else>{{item.name}}</view>
  17. <view class="right-box dir-top-nowrap main-center cross-center">
  18. <image v-if="item.is_may_use === 1"
  19. class="card-qr"
  20. @click.stop="showModal(item.id)"
  21. src="./../image/icon-card-qrcode.png"
  22. ></image>
  23. <span>{{activeTab == 3 ? '未核销' : '剩余'}}{{item.surplus_number}}次</span>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="no-list" v-if="list.length === 0">
  29. <app-no-goods background="#f7f7f7" :title="title"></app-no-goods>
  30. </view>
  31. <view class="qr-modal" @click="show=false" v-if="show">
  32. <view class="look-qr" @click.stop="showModal(0)">
  33. <view>卡券二维码</view>
  34. <view>
  35. <image :src="img"></image>
  36. </view>
  37. <view style="height: 60rpx">
  38. <view @click="saveImg">
  39. <button>保存图片</button>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </app-layout>
  45. </template>
  46. <script>
  47. import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
  48. import appNoGoods from '../../../components/page-component/app-no-goods/app-no-goods.vue';
  49. import {mapGetters, mapState} from "vuex";
  50. export default {
  51. data() {
  52. return {
  53. tabList: [
  54. {id:1, name: '未使用'},
  55. {id:2, name: '已使用'},
  56. {id:3, name: '已过期'}
  57. ],
  58. show: false,
  59. img: '/images/share/img-share-order.png',
  60. activeTab: 1,
  61. list: [],
  62. more: false,
  63. page: 2,
  64. title: '暂无未使用卡券~'
  65. }
  66. },
  67. components: {
  68. 'app-tab-nav': appTabNav,
  69. 'app-no-goods': appNoGoods,
  70. },
  71. computed: {
  72. ...mapState({
  73. userInfo: state => state.user.info,
  74. }),
  75. ...mapGetters('mallConfig', {
  76. getTheme: 'getTheme',
  77. })
  78. },
  79. methods: {
  80. saveImg() {
  81. this.$utils.batchSave(this.img).then(res => {
  82. uni.showToast({title: '保存成功', icon: 'none'});
  83. })
  84. },
  85. showModal(id) {
  86. let that = this;
  87. if(id > 0) {
  88. uni.showLoading({
  89. text: '生成中...'
  90. });
  91. that.$request({
  92. url: that.$api.card.qrcode,
  93. data: {
  94. cardId: id,
  95. },
  96. method: 'get'
  97. }).then(response => {
  98. uni.hideLoading();
  99. if (response.code === 0) {
  100. that.show = true;
  101. that.img = response.data.file_path;
  102. } else {
  103. uni.showToast({
  104. title: response.msg,
  105. icon: 'none',
  106. duration: 1000,
  107. });
  108. }
  109. }).catch(response => {
  110. uni.hideLoading();
  111. uni.showToast({
  112. title: response,
  113. icon: 'none',
  114. duration: 1000,
  115. });
  116. });
  117. }
  118. },
  119. tabStatus(e) {
  120. this.list = [];
  121. let id = e.currentTarget.dataset.id;
  122. if (id === 1) {
  123. this.title = `暂无未使用优惠券~`;
  124. } else if (id === 2) {
  125. this.title = `暂无已使用优惠券~`;
  126. } else if (id === 3) {
  127. this.title = `暂无已过期优惠券~`;
  128. }
  129. this.page = 2;
  130. this.activeTab = id;
  131. this.getList();
  132. },
  133. getList() {
  134. let that = this;
  135. that.$showLoading({
  136. text: '加载中...'
  137. });
  138. that.$request({
  139. url: that.$api.card.index,
  140. data: {
  141. status: that.activeTab
  142. },
  143. }).then(response=>{
  144. that.$hideLoading();
  145. if(response.code === 0) {
  146. that.list = response.data.list;
  147. }else {
  148. uni.showToast({
  149. title: response.msg,
  150. icon: 'none',
  151. duration: 1000
  152. });
  153. }
  154. }).catch(() => {
  155. that.$hideLoading();
  156. that.$event.on(that.$const.EVENT_USER_LOGIN).then(()=>{
  157. that.getList();
  158. });
  159. });
  160. },
  161. getMore() {
  162. let that = this;
  163. uni.showLoading({
  164. title: '加载中...',
  165. });
  166. that.$request({
  167. url: that.$api.card.index,
  168. data: {
  169. page: that.page,
  170. status: that.activeTab
  171. },
  172. }).then(response=>{
  173. uni.hideLoading();
  174. if(response.code === 0) {
  175. if(response.data.list.length > 0) {
  176. that.loading = null;
  177. that.list = that.list.concat(response.data.list);
  178. that.page++;
  179. }
  180. }else {
  181. uni.showToast({
  182. title: response.msg,
  183. icon: 'none',
  184. duration: 1000,
  185. });
  186. }
  187. }).catch(() => {
  188. that.$hideLoading();
  189. });
  190. },
  191. toDetail(card) {
  192. if (card.is_allow_send == 1) {
  193. uni.navigateTo({
  194. url: `/pages/card/details/details?id=${card.id}`
  195. });
  196. } else {
  197. uni.navigateTo({
  198. url: `/pages/card/details/details-no-share?id=${card.id}`
  199. });
  200. }
  201. },
  202. },
  203. onLoad() { this.$commonLoad.onload();
  204. this.getList();
  205. },
  206. onReachBottom() {
  207. this.getMore();
  208. }
  209. }
  210. </script>
  211. <style scoped lang="scss">
  212. .no-list {
  213. margin-top: #{150upx};
  214. }
  215. .card-list {
  216. width: 100%;
  217. padding-top: #{10rpx};
  218. background-color: #f7f7f7;
  219. }
  220. .card-item {
  221. height: #{180rpx};
  222. margin: #{20rpx};
  223. background-color: #fff;
  224. color: #353535;
  225. font-size: #{30rpx};
  226. border-radius: 16#{rpx};
  227. .name {
  228. width: 402#{rpx};
  229. margin-left:35#{rpx};
  230. .is_send {
  231. width: #{80rpx};
  232. height: #{40rpx};
  233. color: #ff4544;
  234. font-size: #{20rpx};
  235. background-color: #ffecec;
  236. text-align: center;
  237. line-height: #{40rpx};
  238. margin: #{16rpx 0 20rpx 0};
  239. }
  240. }
  241. .card-img {
  242. height: #{88rpx};
  243. width: #{88rpx};
  244. border-radius: 50%;
  245. margin-left:24#{rpx};
  246. }
  247. .right-box {
  248. margin: #{65rpx} #{35rpx};
  249. .card-qr {
  250. height: #{50rpx};
  251. width: #{50rpx};
  252. }
  253. span {
  254. font-size:20#{rpx};
  255. color: #353535;
  256. margin-top:10#{rpx};
  257. }
  258. }
  259. }
  260. .qr-modal {
  261. position: fixed;
  262. left: 0;
  263. right: 0;
  264. top: 0;
  265. background-color: rgba(0, 0, 0, 0.5);
  266. height: 100%;
  267. width: 100%;
  268. z-index: 2;
  269. }
  270. .look-qr {
  271. position: absolute;
  272. background-color: #fff;
  273. width: #{550rpx};
  274. height: #{700rpx};
  275. left: 50%;
  276. margin-left: #{-275rpx};
  277. top: 20%;
  278. border-radius: #{10rpx};
  279. text-align: center;
  280. padding: #{50rpx};
  281. font-size: #{34rpx};
  282. color: #353535;
  283. }
  284. .look-qr image {
  285. margin-top: #{25rpx};
  286. height: #{450rpx};
  287. width: #{450rpx};
  288. }
  289. .look-qr button {
  290. margin: #{15rpx} auto 0;
  291. height: #{60rpx};
  292. line-height: #{60rpx};
  293. color: #fff;
  294. font-size: #{28rpx};
  295. width: #{200rpx};
  296. background-color: #ff4544;
  297. }
  298. </style>