list.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="container" v-if="fetch">
  3. <use-tabbar :tabbar="false"></use-tabbar>
  4. <view class="w-full navbar-area bg-main">
  5. <view class="state-area dflex-a">
  6. <view v-for="(item, index) in navList" :key="index" :class="{ active: status === index }" class="nav-item dflex-c pos-r fs padding-lr-lg h-full"
  7. @click="tabClick(index)">
  8. {{ item.state }}
  9. <text v-if="item.cnt > 0">({{ item.cnt }})</text>
  10. </view>
  11. </view>
  12. </view>
  13. <scroll-view class="list-scroll-content h-full" scroll-y >
  14. <!-- 空白页 -->
  15. <u-empty v-if="fetch.list && fetch.list.length == 0" marginTop="200" mode="coupon" text="暂无权益包"></u-empty>
  16. <view v-else class="padding-lr" v-for="(item, index) in fetch.list" :key="index">
  17. <view class="coupon_box border-radius margin-top-sm bg-main" :class="[{ 'disabled': status != 0 }]" @click="go(item)">
  18. <view class="dflex-b">
  19. <view class="left pos-a h-full dflex-c dflex-flow-c">
  20. <view>
  21. <text class="price fs-big">{{ item.yue }}</text>
  22. </view>
  23. <view class="fs-sm">权益</view>
  24. </view>
  25. <view class="right padding left_t flex1">
  26. <view class="dflex-b padding-bottom-xs">
  27. <view class="fwb fs">{{ item.name }}</view>
  28. <text class="arrow">›</text>
  29. </view>
  30. <view v-if="status == 1" class="ft-dark iconfont iconyishiyong"></view>
  31. <view v-if="status == 2" class="ft-dark iconfont iconyiguoqi"></view>
  32. <view class="dflex-b ft-dark fs-xs padding-bottom border-line">
  33. <view class="">{{ item.date_name }}</view>
  34. </view>
  35. <view class="dflex-b padding-top-xs">
  36. <view class="fs-xs ft-dark">{{ item.code }}</view>
  37. <!-- 周期权益按钮 -->
  38. <!--
  39. <view v-if="status == 0">
  40. <view
  41. class="btn-receive bg-base ft-white border-radius-sm fs-xs padding-lr-sm padding-tb-xxs"
  42. @click.stop="go(item)">
  43. 详情
  44. </view>
  45. </view>
  46. -->
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. <u-modal @close="closeModal" @confirm="closeModal" :show="show.state" :title="show.title" :closeOnClickOverlay="true">
  54. <view class="slot-content">
  55. <u-parse :content="show.content"></u-parse>
  56. </view>
  57. </u-modal>
  58. <view style="height: 76px;"></view>
  59. <view class="pos-f btn-container padding-tb bg-drak">
  60. <view class="dflex-b margin-lr border-radius-big safe-area-inset-bottom-plus">
  61. <view class="tac padding-tb-sm flex1 bg-warn" @click="duihuan">我要兑换</view>
  62. <view class="tac padding-tb-sm flex1 bg-base" @click="trade">交易中心</view>
  63. </view>
  64. </view>
  65. <u-popup mode="center" @close="close('duihuan')" :show="show.duihuan" round="14" :closeable="true">
  66. <view class="alert-area border-radius bg-main pos-r">
  67. <view class="dflex-b ft-dark margin-bottom-sm margin-lr-xs">
  68. <view>兑换码:</view>
  69. </view>
  70. <view class="dflex border-radius-sm field" style="padding: 8px 7px;">
  71. <u--input placeholder="请输入兑换码" v-model="code"
  72. class="fwb fs-sm" type="text" border="none" :focus="true" clearable
  73. style="max-height: 76px; min-height: 19px; height: auto; font: initial;"></u--input>
  74. </view>
  75. <!-- 提交按钮 -->
  76. <view class="bg-base margin-top-xl tac w-full border-radius-lg padding-tb-sm" @click="useDuihuan">
  77. 提交
  78. </view>
  79. </view>
  80. </u-popup>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. mapState
  86. } from 'vuex';
  87. export default {
  88. data() {
  89. return {
  90. fetch: {},
  91. status: 0,
  92. show : {
  93. state : false,
  94. title : '',
  95. content : '',
  96. duihuan : false,
  97. },
  98. navList: [{
  99. id: 0,
  100. state: '已领取',
  101. cnt: 0,
  102. },
  103. {
  104. id: 1,
  105. state: '已过期',
  106. cnt: 0,
  107. }
  108. ],
  109. code: '',
  110. };
  111. },
  112. onLoad(options) {
  113. this.loadData(1);
  114. },
  115. // 下拉刷新
  116. onPullDownRefresh() {
  117. this.loadData(1);
  118. },
  119. // 上拉加载更多
  120. onReachBottom() {
  121. this.loadData(2);
  122. },
  123. methods: {
  124. loadData(page) {
  125. this.DeverApi.page([page, 'list'], this, 'perk.my', {status:this.status});
  126. },
  127. // 顶部tab点击
  128. tabClick(index) {
  129. this.status = index;
  130. this.fetch.list = {}
  131. this.loadData(1);
  132. },
  133. showModal(title, content) {
  134. if (content) {
  135. this.show.title = title;
  136. this.show.content = content;
  137. this.show.state = true;
  138. }
  139. },
  140. closeModal() {
  141. this.show.state = false;
  142. },
  143. duihuan() {
  144. this.show.duihuan = true;
  145. },
  146. close() {
  147. this.show.duihuan = false;
  148. },
  149. useDuihuan() {
  150. if (this.code) {
  151. this.close();
  152. this.DeverApi.post('perk.receive', {code:this.code}, r => {
  153. this.code = '';
  154. this.Dever.success('兑换成功', () => {
  155. this.loadData(1);
  156. });
  157. }, s => {
  158. this.code = '';
  159. this.Dever.alert(s.msg);
  160. });
  161. } else {
  162. this.Dever.alert('请输入兑换码');
  163. }
  164. },
  165. go(item) {
  166. if (item.yue > 0) {
  167. this.Dever.location('user/perk/info?id=' + item.id);
  168. }
  169. },
  170. trade() {
  171. this.Dever.alert('敬请期待');
  172. }
  173. }
  174. };
  175. </script>
  176. <style lang="scss">
  177. page,
  178. .container {
  179. min-height: 100%;
  180. background: $page-color-base;
  181. }
  182. /* 优惠券状态区 */
  183. .navbar-area {
  184. white-space: nowrap;
  185. .state-area {
  186. height: 7vh;
  187. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  188. z-index: 10;
  189. }
  190. .nav-item {
  191. flex: 1;
  192. &.active {
  193. &:after {
  194. content: '';
  195. position: absolute;
  196. left: 50%;
  197. transform: translate(-50%);
  198. bottom: 0;
  199. width: 44px;
  200. height: 0;
  201. border-bottom: 2px solid $base-color;
  202. }
  203. }
  204. }
  205. }
  206. /* 优惠券轮播区 */
  207. .swiper-area {
  208. height: 93vh;
  209. }
  210. .coupon_box {
  211. position: relative;
  212. &:last-child {
  213. margin-bottom: 20rpx;
  214. }
  215. .left {
  216. background-color: #f26aff;
  217. color: #fff;
  218. width: 30%;
  219. .price {
  220. color: #fff !important;
  221. }
  222. }
  223. .right {
  224. margin-left: 30%;
  225. }
  226. .discount {
  227. font-weight: 580;
  228. }
  229. .discount::after {
  230. content: '折';
  231. font-size: 24rpx;
  232. margin-left: 6rpx;
  233. }
  234. .border-line {
  235. border-bottom: 1px dotted #ededed;
  236. }
  237. }
  238. .disabled {
  239. .left {
  240. background-color: #d9d9d9;
  241. color: #b2b2b2 !important;
  242. .price {
  243. color: #b2b2b2 !important;
  244. }
  245. }
  246. .iconfont {
  247. position: absolute;
  248. /*top: 0rpx;*/
  249. right: 30rpx;
  250. font-size: 110rpx;
  251. }
  252. }
  253. .btn-container {
  254. left: 9px;
  255. right: 9px;
  256. bottom: 0;
  257. }
  258. .btn-receive {
  259. background-color: #846aff;
  260. color: #fff;
  261. font-weight: bold;
  262. }
  263. </style>