index.vue 9.5 KB

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