VoucherList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="代金券列表" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <!-- header -->
  14. <view class="div voucher-header">
  15. <view class="ul">
  16. <view
  17. class="li item"
  18. v-for="item in voucherNav"
  19. v-bind:key="item.id"
  20. v-bind:class="{ active: stateType == item.id }"
  21. v-on:click="setvoucherNavActive(item.id)"
  22. >
  23. {{ item.name }}
  24. </view>
  25. </view>
  26. </view>
  27. <view class="scroll-view div" style="position:relative">
  28. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  29. <view
  30. class="div list-wrapper"
  31. v-if="voucher_list && voucher_list.length"
  32. >
  33. <view class="div voucher_list" v-for="(item,index) in voucher_list" :key="item.voucher_id" :class="(item.voucher_state != 1)?'disable':''">
  34. <view class="div voucher-info">
  35. <view class="div price">{{item.voucher_price}}<text class="span">元</text></view>
  36. <view class="div info"><view class="p">订单满{{item.voucher_limit}}元</view><view class="p">有效期至{{item.voucher_end_date_text}}</view></view>
  37. <view class="div use" @click="goNavigate('/pages/home/storegoodslist/Goodslist',{ id: item.store_id })"><text class="span" v-if="item.voucher_state == 1">去使用</text></view>
  38. </view>
  39. <view class="div voucher-store" >“{{item.store_name}}” 店铺使用</view>
  40. </view>
  41. </view>
  42. <empty-record v-else-if="voucher_list && !voucher_list.length"></empty-record>
  43. </scroll-view>
  44. </view>
  45. </view></member-base>
  46. </template>
  47. <script>
  48. import {getFontSize} from '@/util/common'
  49. import TitleHeader from '../../TitleHeader'
  50. import { urlencode } from '@/util/common'
  51. import MemberBase from '../MemberBase'
  52. import { getVoucherList } from '../../../api/memberVoucher'
  53. import EmptyRecord from '../../EmptyRecord'
  54. export default {
  55. name: 'BalanceHistory',
  56. components:{
  57. TitleHeader,
  58. MemberBase,
  59. EmptyRecord
  60. },
  61. computed:{
  62. fontSize(){
  63. return getFontSize()
  64. },
  65. },
  66. data(){
  67. return {
  68. navHeight: 0,
  69. voucherNav: [
  70. {
  71. 'name': '未使用',
  72. 'id': '1'
  73. },
  74. {
  75. 'name': '已使用',
  76. 'id': '2'
  77. },
  78. {
  79. 'name': '已过期',
  80. 'id': '3'
  81. },
  82. ],
  83. params: { 'page': 0, 'per_page': 10 },
  84. stateType: '',
  85. loading: false, // 是否加载更多
  86. isMore: true, // 是否有更多
  87. voucher_list: false
  88. }
  89. },
  90. onLoad: function (option) {
  91. this.stateType=option.index ? option.index : ''
  92. this.loadMore()
  93. },
  94. mounted(){
  95. // #ifdef MP-WEIXIN
  96. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  97. // #endif
  98. this.wrapperHeight = uni.getSystemInfoSync().windowHeight - 130
  99. },
  100. methods:{
  101. goNavigate(path,query=false){
  102. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  103. },
  104. goBack () {
  105. uni.navigateBack({delta:1})
  106. },
  107. setvoucherNavActive (index) {
  108. this.stateType = index
  109. this.getVoucherList(true)
  110. },
  111. loadMore () {
  112. this.loading = true
  113. this.params.page = ++this.params.page
  114. if (this.isMore) {
  115. this.loading = false
  116. this.getVoucherList(true)
  117. }
  118. },
  119. getVoucherList (ifReplace) {
  120. uni.showLoading({ title: '加载中' })
  121. if (ifReplace) {
  122. this.loading = false
  123. this.params.page = 1
  124. this.isMore = true
  125. }
  126. getVoucherList(this.params,this.stateType).then(res => {
  127. uni.hideLoading()
  128. if (res.result.hasmore) {
  129. this.isMore = true
  130. } else {
  131. this.isMore = false
  132. }
  133. let voucher_list = res.result.voucher_list
  134. if (voucher_list) {
  135. if (ifReplace || !this.voucher_list) {
  136. this.voucher_list = voucher_list
  137. } else {
  138. this.voucher_list = this.voucher_list.concat(voucher_list)
  139. }
  140. }
  141. }).catch(function (error) {
  142. uni.hideLoading()
  143. uni.showToast({icon:'none',title: error.message})
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style scoped lang="scss">
  150. .scroll-view-wrapper{display: flex;flex-direction: column;}
  151. .scroll-view{flex:1}
  152. .container {
  153. height: 100%;
  154. display: flex;
  155. position: relative;
  156. flex-direction: column;
  157. justify-content: flex-start;
  158. align-items: stretch;
  159. .voucher-header {
  160. height: 2.2rem;
  161. width: 100%;
  162. .ul {
  163. list-style: none;
  164. width: auto;
  165. display: flex;
  166. justify-content: space-around;
  167. align-content: center;
  168. align-items: center;
  169. height: 100%;
  170. background: rgba(255, 255, 255, 1);
  171. border-bottom: 1px solid #e8eaed;
  172. .li {
  173. font-size:$subFontSize;
  174. color: #333;
  175. height: 100%;
  176. text-align: center;
  177. line-height: 2.2rem;
  178. border-bottom: 0.1rem solid transparent;
  179. &.active {
  180. color: $primaryColor;
  181. border-bottom-color: $primaryColor;
  182. }
  183. }
  184. }
  185. }
  186. .list-wrapper{
  187. position:relative;
  188. .voucher_list{
  189. margin: .5rem;
  190. -webkit-border-radius: .75rem;
  191. border-radius: .75rem;
  192. overflow: hidden;
  193. font-size: .6rem;
  194. .voucher-info{
  195. position: relative;
  196. display: -webkit-box;
  197. display: -webkit-flex;
  198. display: flex;
  199. -webkit-box-align: center;
  200. -webkit-align-items: center;
  201. align-items: center;
  202. -webkit-box-pack: justify;
  203. -webkit-justify-content: space-between;
  204. justify-content: space-between;
  205. padding: 1.4rem 1rem;
  206. background: -webkit-linear-gradient(
  207. 45deg
  208. ,#ff8580,#ea5165);
  209. background: linear-gradient(
  210. 45deg
  211. ,#ff8580,#ea5165);
  212. color: #fff;
  213. border-bottom: 1px dashed #fff;
  214. .price{
  215. font-size: 1.3rem;
  216. font-weight: 700;
  217. .span{
  218. font-size: .6rem;
  219. }
  220. }
  221. .use .span{
  222. display: -webkit-box;
  223. display: -webkit-flex;
  224. display: flex;
  225. -webkit-box-align: center;
  226. -webkit-align-items: center;
  227. align-items: center;
  228. -webkit-box-pack: center;
  229. -webkit-justify-content: center;
  230. justify-content: center;
  231. padding: .25rem .5rem;
  232. background-color: #f9ccd1;
  233. font-size: .6rem;
  234. color: #ec5667;
  235. -webkit-border-radius: .2rem;
  236. border-radius: .2rem;
  237. }
  238. }
  239. .voucher-info::before,.voucher-info::after{
  240. position: absolute;
  241. content: "";
  242. bottom: -5px;
  243. width: 12px;
  244. height: 12px;
  245. -webkit-border-radius: 50%;
  246. border-radius: 50%;
  247. background-color: #fff;
  248. z-index: 2;
  249. }
  250. .voucher-info::before{
  251. right: -6px;
  252. }
  253. .voucher-info::after{
  254. left: -6px;
  255. }
  256. .voucher-store{
  257. display: -webkit-box;
  258. display: -webkit-flex;
  259. display: flex;
  260. -webkit-box-align: center;
  261. -webkit-align-items: center;
  262. align-items: center;
  263. padding: .6rem 1rem;
  264. background: -webkit-gradient(linear,left top,right top,from(#d6706b),to(#c44654));
  265. background: -webkit-linear-gradient(left,#d6706b,#c44654);
  266. background: linear-gradient(
  267. 90deg
  268. ,#d6706b,#c44654);
  269. color: #84292b;
  270. }
  271. }
  272. .disable .voucher-info{
  273. background: -webkit-linear-gradient(
  274. 45deg
  275. ,#c1cdd8,#a2adbe);
  276. background: linear-gradient(
  277. 45deg
  278. ,#c1cdd8,#a2adbe);
  279. }
  280. .disable .voucher-store{
  281. background: -webkit-gradient(linear,left top,right top,from(#a2adbe),to(#c1cdd8));
  282. background: -webkit-linear-gradient(left,#a2adbe,#c1cdd8);
  283. background: linear-gradient(
  284. 90deg
  285. ,#a2adbe,#c1cdd8);
  286. color: #5e6679;
  287. }
  288. }
  289. }
  290. .common-voucher{margin:0.5rem auto}
  291. </style>