myCoupon.vue 8.1 KB

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