info.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 fetch.nav" :key="index" :class="{ active: status === index }" class="nav-item dflex-c pos-r fs padding-lr-lg h-full" @click="tabClick(index)">
  7. {{ item.name }}
  8. <text v-if="item.num > 0">({{ item.num }})</text>
  9. </view>
  10. </view>
  11. </view>
  12. <scroll-view class="list-scroll-content h-full" scroll-y >
  13. <!-- 空白页 -->
  14. <u-empty v-if="fetch.list && fetch.list.length == 0" marginTop="200" mode="coupon" text="暂无权益包内容"></u-empty>
  15. <view v-else class="padding-lr" v-for="(item, index) in fetch.list" :key="index">
  16. <view class="coupon_box border-radius margin-top-sm bg-main" @click="showModal(item.title, item.tip)">
  17. <view class="dflex-b">
  18. <view class="left pos-a h-full dflex-c dflex-flow-c">
  19. <view>
  20. <text class="price fs-lg">{{ item.config_name }}</text>
  21. </view>
  22. <view class="fs-sm">{{item.type_name}}</view>
  23. </view>
  24. <view class="right padding left_t flex1">
  25. <view class="dflex-b padding-bottom-xs">
  26. <view class="fwb fs">{{ item.name }}</view>
  27. <text class="arrow" v-if="item.tip">›</text>
  28. </view>
  29. <view class="dflex-b ft-dark fs-xs padding-bottom border-line">
  30. <view class="">{{ item.desc }}</view>
  31. </view>
  32. <view class="dflex-b padding-top-xs">
  33. <view class="fs-xs ft-dark">{{ item.edate }}</view>
  34. <view v-if="item.yue > 0">
  35. <view class="btn-receive bg-base ft-white border-radius-sm fs-xs padding-lr-sm padding-tb-xxs"
  36. @click.stop="receive(index, item.type_name)">
  37. 领取
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. <u-modal @close="closeModal" @confirm="closeModal" :show="show.state" :title="show.title" :closeOnClickOverlay="true">
  47. <view class="slot-content">
  48. <u-parse :content="show.content"></u-parse>
  49. </view>
  50. </u-modal>
  51. <!--
  52. <view style="height: 76px;"></view>
  53. <view class="pos-f btn-container padding-tb bg-drak">
  54. <view class="dflex-b margin-lr border-radius-big safe-area-inset-bottom-plus">
  55. <view class="tac padding-tb-sm flex1 bg-warn" @click="duihuan">赠送</view>
  56. <view class="tac padding-tb-sm flex1 bg-base">售卖</view>
  57. </view>
  58. </view>
  59. -->
  60. <u-popup mode="center" @close="close('receive')" :show="show.receive" round="14" :closeable="true">
  61. <view class="alert-area border-radius bg-main pos-r">
  62. <view class="dflex-b ft-dark margin-bottom-sm margin-lr-xs">
  63. <view>领取数量:最多{{show.num}}</view>
  64. </view>
  65. <view class="dflex border-radius-sm field" style="padding: 8px 7px;">
  66. <u--input placeholder="请输入数量,填写数字即可" v-model="num"
  67. class="fwb fs-sm" type="number" border="none" :focus="true" clearable
  68. style="max-height: 76px; min-height: 19px; height: auto; font: initial;"></u--input>
  69. </view>
  70. <!-- 提交按钮 -->
  71. <view class="bg-base margin-top-xl tac w-full border-radius-lg padding-tb-sm" @click="useReceive">
  72. 提交
  73. </view>
  74. </view>
  75. </u-popup>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. mapState
  81. } from 'vuex';
  82. export default {
  83. data() {
  84. return {
  85. id:0,
  86. fetch: {},
  87. status: 0,
  88. show : {
  89. state : false,
  90. title : '',
  91. content : '',
  92. receive : false,
  93. },
  94. num: '',
  95. index : -1,
  96. };
  97. },
  98. onLoad(options) {
  99. this.id = options.id;
  100. this.loadData();
  101. },
  102. // 下拉刷新
  103. onPullDownRefresh() {
  104. this.loadData();
  105. },
  106. methods: {
  107. loadData() {
  108. this.DeverApi.get(this, 'perk.getList', {id:this.id,status:this.status});
  109. },
  110. // 顶部tab点击
  111. tabClick(index) {
  112. this.status = index;
  113. this.fetch.list = {}
  114. this.loadData();
  115. },
  116. showModal(title, content) {
  117. if (content) {
  118. this.show.title = title;
  119. this.show.content = content;
  120. this.show.state = true;
  121. }
  122. },
  123. closeModal() {
  124. this.show.state = false;
  125. },
  126. receive(index, yue) {
  127. this.index = index;
  128. this.show.num = yue;
  129. this.show.receive = true;
  130. },
  131. close() {
  132. this.show.receive = false;
  133. },
  134. useReceive() {
  135. this.num = parseFloat(this.num);
  136. if (this.num && this.num > 0 && this.index >= 0) {
  137. var item = this.fetch.list[this.index]
  138. if (!item) {
  139. this.Dever.alert('请选择领取的项目');
  140. return;
  141. }
  142. if (this.num > item.yue) {
  143. this.Dever.alert('领取数量不能超过当前剩余数量');
  144. return;
  145. }
  146. this.close();
  147. this.DeverApi.post('perk.use', {num:this.num,user_perk_id:this.id,id:item.id}, r => {
  148. this.num = '';
  149. this.Dever.success('领取成功', () => {
  150. this.loadData();
  151. });
  152. }, s => {
  153. this.num = '';
  154. this.Dever.alert(s.msg);
  155. });
  156. } else {
  157. this.Dever.alert('请输入领取数量');
  158. }
  159. },
  160. }
  161. };
  162. </script>
  163. <style lang="scss">
  164. page,
  165. .container {
  166. min-height: 100%;
  167. background: $page-color-base;
  168. }
  169. /* 优惠券状态区 */
  170. .navbar-area {
  171. white-space: nowrap;
  172. .state-area {
  173. height: 7vh;
  174. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  175. z-index: 10;
  176. }
  177. .nav-item {
  178. flex: 1;
  179. &.active {
  180. &:after {
  181. content: '';
  182. position: absolute;
  183. left: 50%;
  184. transform: translate(-50%);
  185. bottom: 0;
  186. width: 44px;
  187. height: 0;
  188. border-bottom: 2px solid $base-color;
  189. }
  190. }
  191. }
  192. }
  193. .coupon_box {
  194. position: relative;
  195. &:last-child {
  196. margin-bottom: 20rpx;
  197. }
  198. .left {
  199. background-color: #6a92ff;
  200. color: #fff;
  201. width: 30%;
  202. .price {
  203. color: #fff !important;
  204. }
  205. }
  206. .right {
  207. margin-left: 30%;
  208. }
  209. .border-line {
  210. border-bottom: 1px dotted #ededed;
  211. }
  212. }
  213. /* 按钮样式 */
  214. .btn-receive {
  215. background: $base-color;
  216. color: #fff;
  217. font-weight: bold;
  218. }
  219. .btn-receive-disabled {
  220. background: #3dafcb;
  221. color: #fff;
  222. font-weight: bold;
  223. }
  224. .btn-container {
  225. left: 9px;
  226. right: 9px;
  227. bottom: 0;
  228. }
  229. </style>