myCoupon.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view >
  3. <ujp-navbar title="我的优惠券"><view class="exchange oldTextjp2" oldstyle="font-size: 16px;" @click="toConversion">兑换</view></ujp-navbar>
  4. <view class="tab" >
  5. <u-tabs :font-size="elderStatus ? 36 : 30" :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333" inactive-color="#c4c0c0"></u-tabs>
  6. </view>
  7. <view class="carNone" v-if="myCouponList.length == 0">
  8. <img src="static/img/暂无数据-缺省页.png" alt="">
  9. <p>暂无优惠券</p>
  10. </view>
  11. <view class="workable" :style="current == 0 ? '' : 'opacity: 0.6'">
  12. <view class="list-item" v-for="(item,index) in myCouponList" :key="index">
  13. <view class="voucher" v-if="item.classify == '1'">优惠券</view>
  14. <view class="voucher" v-if="item.classify == '2'">折扣卷</view>
  15. <view class="content" @click="gotoUrl('pages/user/coupon/couponDetails?id=' + item.id)">
  16. <view class="content-left">
  17. <view class="text oldTextjp" oldstyle="font-size: 18px;">{{item.couponName}}</view>
  18. <view class="useful-life oldTextjp2" oldstyle="font-size: 16px;">
  19. 有效期至{{item.endDate&&item.endDate.slice(0,10)}}
  20. </view>
  21. </view>
  22. <view class="content-right">
  23. <view class="price" v-if="item.classify == '1'">{{item.value}}元</view>
  24. <view class="price2" v-if="item.classify == '2'">服务费{{item.value}}折</view>
  25. <view class="price-condition oldTextjp2" oldstyle="font-size: 16px;">
  26. {{item.threshold > 0 ? '满'+item.threshold+'元可用' : '无门槛'}}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="limit">
  31. <view class="limit-text">
  32. <view :class="more==index&&readMoreStatus ? 'limit-text2' : 'limit-text1'">
  33. <span>{{item.useScopeText}}</span>
  34. </view>
  35. <view class="iconfont arrows" @click="readMore(index)">{{more==index&&readMoreStatus ? '&#xe607;' : '&#xe62c;'}}</view>
  36. </view>
  37. <view class="use-button" v-if="current == '0'" @click="toIndex">去使用</view>
  38. <view class="have-used" v-if="current == '1'"><img src="../../../static/img/haveused.png" alt=""></view>
  39. <view class="have-used" v-if="current == '2'"><img src="../../../static/img/overdue.png" alt=""></view>
  40. </view>
  41. </view>
  42. </view>
  43. <u-divider v-if="myCouponList.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px;background-color: #F2F4F4;">已经到底了</u-divider>
  44. </view>
  45. </template>
  46. <script>
  47. import * as userApi from '@/apis/user.js'
  48. export default{
  49. data(){
  50. return{
  51. tabList: [
  52. {name: '可使用',type: '0'},
  53. {name: '已使用',type: '1'},
  54. {name: '已过期',type: '2'},
  55. ],
  56. current: 0,
  57. couponType: '0',
  58. myCouponList: [],
  59. pageIndex: 1,
  60. recordsTotal: 0,
  61. readMoreStatus: false,
  62. more: -1,
  63. moreShow: '',
  64. elderStatus: false,
  65. }
  66. },
  67. onShow() {
  68. this.getCouponList(true);
  69. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  70. this.elderStatus = true;
  71. } else {
  72. this.elderStatus = false;
  73. }
  74. },
  75. onReachBottom() {
  76. if (this.myCouponList.length < this.recordsTotal) {
  77. this.myLoadmore();
  78. }
  79. },
  80. methods:{
  81. toConversion() {
  82. uni.navigateTo({
  83. url: '/pages/user/coupon/conversion'
  84. })
  85. },
  86. toIndex() {
  87. uni.navigateTo({
  88. url: '/pages/index/index'
  89. })
  90. },
  91. readMore(index) {
  92. if(this.more != index && this.readMoreStatus) {
  93. this.more = index;
  94. this.readMoreStatus = true;
  95. } else {
  96. this.more = index;
  97. this.readMoreStatus = !this.readMoreStatus;
  98. }
  99. },
  100. getCouponList(bl) {
  101. uni.showLoading({
  102. title: "加载中",
  103. mask: true,
  104. })
  105. if (bl) {
  106. this.myCouponList = [];
  107. this.pageIndex = 1;
  108. }
  109. userApi.couponList({
  110. pageIndex: this.pageIndex,
  111. status: this.couponType
  112. }).then((res) => {
  113. uni.hideLoading();
  114. this.myCouponList = [
  115. ...this.myCouponList,
  116. ...res.data.data
  117. ];
  118. this.recordsTotal = res.data.recordsTotal;
  119. }).catch(error => {
  120. uni.showToast({
  121. title: error,
  122. icon: "none"
  123. })
  124. })
  125. },
  126. change(index) {
  127. this.current = index;
  128. this.couponType = this.tabList[index].type;
  129. this.getCouponList(true);
  130. },
  131. myLoadmore() {
  132. this.pageIndex += 1;
  133. this.getCouponList()
  134. },
  135. }
  136. }
  137. </script>
  138. <style>
  139. page{
  140. padding-bottom: 50px;
  141. }
  142. </style>
  143. <style lang="scss" scoped>
  144. .carNone{
  145. display: flex;
  146. flex-direction: column;
  147. justify-content: center;
  148. align-items: center;
  149. img{
  150. width: 100%;
  151. height: 100%;
  152. }
  153. p{
  154. margin-top: -60px;
  155. }
  156. }
  157. .exchange{
  158. margin-left: 85.3%;
  159. color: rgba(119, 119, 119, 100);
  160. font-size: 12px
  161. }
  162. .tab{
  163. width: 100%;
  164. }
  165. /deep/.u-scroll-box{
  166. width: 80.8%;
  167. margin: 0 auto;
  168. display: flex;
  169. justify-content: space-between;
  170. }
  171. .list-item{
  172. width: 91.4%;
  173. background-color: #fff;
  174. margin: 12px auto 0;
  175. position: relative;
  176. border-radius:8px;
  177. .voucher{
  178. width: 60px;
  179. height: 20px;
  180. line-height: 20px;
  181. border-radius: 8px 0px 8px 0px;
  182. background-color: rgba(0, 185, 98, 100);
  183. color: rgba(255, 255, 255, 100);
  184. font-size: 12px;
  185. text-align: center;
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. }
  190. .content{
  191. display: flex;
  192. justify-content: space-between;
  193. padding: 24px 16px;
  194. }
  195. .content-left{
  196. .text{
  197. height: 22px;
  198. line-height: 22px;
  199. color: rgba(16, 16, 16, 100);
  200. font-size: 16px;
  201. }
  202. .useful-life{
  203. height: 17px;
  204. line-height: 17px;
  205. color: rgba(153, 153, 153, 100);
  206. font-size: 12px;
  207. margin-top: 4px;
  208. }
  209. };
  210. .content-right{
  211. margin-top: -8px;
  212. text-align: right;
  213. .price{
  214. height: 38px;
  215. color: rgba(0, 185, 98, 100);
  216. font-size: 34px;
  217. }
  218. .price2{
  219. height: 38px;
  220. color: rgba(0, 185, 98, 100);
  221. font-size: 24px;
  222. }
  223. .price-condition{
  224. height: 17px;
  225. color: rgba(102, 102, 102, 100);
  226. font-size: 12px;
  227. text-align: center;
  228. margin-top: 4px;
  229. }
  230. }
  231. }
  232. .limit{
  233. display: flex;
  234. justify-content: space-between;
  235. padding: 14px 16px;
  236. border-top: 1px dotted rgba(227, 227, 227, 100);
  237. position: relative;
  238. .limit-text{
  239. color: rgba(153, 153, 153, 100);
  240. font-size: 12px;
  241. display: flex;
  242. .limit-text1{
  243. max-width: 51vw;
  244. line-height: 20px;
  245. position: relative;
  246. font-size: 12px;
  247. white-space: nowrap;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. }
  251. .limit-text2{
  252. max-width: 51vw;
  253. line-height: 20px;
  254. position: relative;
  255. font-size: 12px;
  256. white-space: normal;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. }
  260. .arrows{
  261. display: inline-block;
  262. width: 20px;
  263. height: 20px;
  264. padding-top: 2px;
  265. margin-left: 4px;
  266. }
  267. }
  268. }
  269. .use-button{
  270. width: 56px;
  271. height: 24px;
  272. line-height: 24px;
  273. border-radius: 4px;
  274. background-color: rgba(0, 185, 98, 100);
  275. color: rgba(255, 255, 255, 100);
  276. font-size: 12px;
  277. text-align: center;
  278. }
  279. .have-used{
  280. width: 64px;
  281. height: 64px;
  282. position: absolute;
  283. top: -12px;
  284. right: 0;
  285. img{
  286. width: 100%;
  287. height: 100%;
  288. }
  289. }
  290. </style>