index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <app-layout>
  3. <app-tab-nav :tabList="tabList" :activeItem="activeTab" @click="tabStatus" :theme="getTheme"></app-tab-nav>
  4. <view v-if="list.length == 0" class="tip">暂无相关优惠券</view>
  5. <view v-else class="list">
  6. <view @click="toDetail(item.id)" v-for="item in list" :key="item.id">
  7. <view class="list-item">
  8. <image src="/static/image/img-coupon-bg-0.png" v-if="activeTab == 1"></image>
  9. <image src="/static/image/img-coupon-bg-1.png" v-else></image>
  10. <image class="status" src="/static/image/img-coupon-status-icon-1.png" v-if="activeTab == 2"></image>
  11. <image class="status" src="/static/image/img-coupon-status-icon-2.png" v-if="activeTab == 3"></image>
  12. <view class="item-left dir-top-nowrap main-center">
  13. <view class="coupon-price t-omit" v-if="item.coupon.type == 2">¥{{item.coupon.sub_price | reservedNum}}</view>
  14. <view class="coupon-price t-omit" v-else>{{item.coupon.discount | reservedNum}}折</view>
  15. <view style="font-size: 10px" class="t-omit" v-if="item.coupon_min_price > 0">满{{item.coupon_min_price | reservedNum}}可用</view>
  16. <view style="font-size: 10px" v-else>无门槛使用</view>
  17. <view style="font-size: 10px" v-if="item.discount_limit">优惠上限:¥{{item.discount_limit | reservedNum}}</view>
  18. </view>
  19. <view class="item-right">
  20. <view class="item-name t-omit t-large t-large-color">{{item.coupon.name}}</view>
  21. <view class="t-small-color time-area">{{item.start_time}} - {{item.end_time}}</view>
  22. <view v-if="item.coupon.appoint_type == 3">全场通用</view>
  23. <view v-else-if="item.coupon.appoint_type == 4">仅限当面付活动使用</view>
  24. <view v-else-if="item.coupon.appoint_type == 5">仅限礼品卡使用</view>
  25. <view v-else>限品类</view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view :class="[`footer-space`,iphone_x? `iphone_x`:``]"></view>
  31. <view :class="[`coupon-footer`,iphone_x? `iphone_x`:``]" @click="toList">去领券</view>
  32. </app-layout>
  33. </template>
  34. <script>
  35. import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
  36. import {mapGetters, mapState} from "vuex";
  37. export default {
  38. data() {
  39. return {
  40. list: [],
  41. iphone_x: false,
  42. tabList: [
  43. {id:1, name: '未使用'},
  44. {id:2, name: '已使用'},
  45. {id:3, name: '已过期'}
  46. ],
  47. activeTab: 1,
  48. first: false,
  49. page: 2,
  50. }
  51. },
  52. components: {
  53. "app-tab-nav": appTabNav
  54. },
  55. computed: {
  56. ...mapGetters('mallConfig', {
  57. getTheme: 'getTheme',
  58. }),
  59. },
  60. methods: {
  61. tabStatus(e) {
  62. this.list = [];
  63. this.page = 2;
  64. this.activeTab = e.currentTarget.dataset.id;
  65. uni.showLoading({
  66. title: '加载中...'
  67. });
  68. this.getList();
  69. },
  70. getList() {
  71. let that = this;
  72. that.first = true;
  73. that.$request({
  74. url: that.$api.coupon.user_coupon,
  75. data: {
  76. status: that.activeTab
  77. }
  78. }).then(response=>{
  79. uni.hideLoading();
  80. that.$hideLoading();
  81. if(response.code == 0) {
  82. that.list = response.data.list;
  83. that.page = 2;
  84. }else {
  85. uni.showToast({
  86. title: response.msg,
  87. icon: 'none',
  88. duration: 1000
  89. });
  90. }
  91. }).catch(response => {
  92. uni.hideLoading();
  93. that.$hideLoading();
  94. that.$event.on(that.$const.EVENT_USER_LOGIN).then(()=>{
  95. that.getList();
  96. });
  97. });
  98. },
  99. getMore() {
  100. let that = this;
  101. uni.showLoading({
  102. title: '加载中...'
  103. });
  104. that.$request({
  105. url: that.$api.coupon.user_coupon,
  106. data: {
  107. status: that.activeTab,
  108. page: that.page
  109. }
  110. }).then(response=>{
  111. uni.hideLoading();
  112. if(response.code == 0) {
  113. if(response.data.list.length > 0) {
  114. that.list = that.list.concat(response.data.list);
  115. that.page++;
  116. }
  117. }else {
  118. uni.showToast({
  119. title: response.msg,
  120. icon: 'none',
  121. duration: 1000
  122. });
  123. }
  124. }).catch(e => {
  125. uni.hideLoading();
  126. });
  127. },
  128. toDetail(id) {
  129. uni.navigateTo({
  130. url: '/pages/coupon/details/details-no-share?person=1&id=' + id
  131. });
  132. },
  133. toList() {
  134. uni.navigateTo({
  135. url: '/pages/coupon/list/list'
  136. });
  137. },
  138. },
  139. onLoad() { this.$commonLoad.onload();
  140. let that = this;
  141. uni.getSystemInfo({
  142. success: function (res) {
  143. if(res.model.indexOf('iPhone X') > -1 || res.model.indexOf('iPhone 11') > -1 || res.model.indexOf('iPhone11') > -1 || res.model.indexOf('iPhone12') > -1 || res.model.indexOf('Unknown Device') > -1) {
  144. that.iphone_x = true;
  145. }
  146. }
  147. })
  148. that.$showLoading({
  149. text: '加载中...'
  150. });
  151. that.getList();
  152. },
  153. onShow() {
  154. if(this.first) {
  155. this.getList();
  156. }
  157. },
  158. onReachBottom() {
  159. this.getMore();
  160. },
  161. filters: {
  162. reservedNum(data) {
  163. return Number(data);
  164. }
  165. }
  166. }
  167. </script>
  168. <style scoped lang="scss">
  169. .footer-space {
  170. height: #{100rpx};
  171. }
  172. .footer-space.iphone_x {
  173. height: #{150rpx};
  174. }
  175. .time-area {
  176. padding:#{7rpx} 0;
  177. }
  178. .list {
  179. padding: #{32rpx} #{35rpx};
  180. background-color: #f7f7f7;
  181. }
  182. .list-item {
  183. height: #{152rpx};
  184. width: 100%;
  185. position: relative;
  186. margin-bottom: #{25rpx};
  187. }
  188. .list-item image {
  189. width: 100%;
  190. height: 100%;
  191. }
  192. .item-left {
  193. position: absolute;
  194. left: 0;
  195. top: 0;
  196. height:100%;
  197. width: #{190rpx};
  198. text-align: center;
  199. font-size: #{24rpx};
  200. color: #fff;
  201. padding-top: #{8rpx};
  202. }
  203. .coupon-price {
  204. font-size: #{36rpx};
  205. padding-bottom: #{16rpx};
  206. }
  207. .item-right {
  208. position: absolute;
  209. left: #{220rpx};
  210. top: #{15rpx};
  211. width: 65%;
  212. color: #6f6e6d;
  213. font-size: #{20rpx};
  214. }
  215. .item-name {
  216. font-size: #{32rpx};
  217. color: #353535;
  218. }
  219. .item-right view {
  220. margin-bottom: #{4rpx};
  221. }
  222. .coupon-footer {
  223. position: fixed;
  224. bottom: 0;
  225. left: 0;
  226. right: 0;
  227. width: 100%;
  228. height: #{100rpx};
  229. line-height: #{100rpx};
  230. text-align: center;
  231. background-color: #fff;
  232. z-index: 2;
  233. }
  234. .coupon-footer.iphone_x {
  235. height: #{150rpx};
  236. padding-bottom: #{50rpx};
  237. }
  238. .list-item .status {
  239. position: absolute;
  240. top: 0;
  241. right: 0;
  242. height: #{98rpx};
  243. width: #{140rpx};
  244. z-index: 2;
  245. }
  246. .tip {
  247. margin-top: 20%;
  248. text-align: center;
  249. color: #686868;
  250. }
  251. .t-omit {
  252. display: inline-block;
  253. white-space: nowrap;
  254. width: 100%;
  255. overflow: hidden;
  256. text-overflow: ellipsis;
  257. }
  258. .t-omit-two {
  259. word-break: break-all;
  260. text-overflow: ellipsis;
  261. display: -webkit-box;
  262. -webkit-box-orient: vertical;
  263. -webkit-line-clamp: 2;
  264. overflow: hidden;
  265. }
  266. </style>