123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <view class="main">
- <!-- <view class="one">
- <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索优惠券名称">
- </view> -->
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="list" v-for="(item, index) in list" :key="index">
- <view class="list_1">
- <view class="left">
- <view class="left_1">
- ¥<text>{{item.discount_config.min}}</text>
- </view>
- <view class="left_2">
- <text v-if="item.discount_config.limit=='0'">无门槛</text>
- <text v-else>满{{item.discount_config.limit}}减{{item.discount_config.min}}</text>
- </view>
- </view>
- <view class="center">
- <view class="name textOver">{{item.name}}</view>
- <view class="content">有效日期:({{item.expire_type_label}}) {{item.time}}
- </view>
- </view>
- <view class="right">
- <button class="button" type="primary" @tap="toUser(item)">去使用</button>
- </view>
- </view>
- <view class="list_2">
- <uni-collapse>
- <uni-collapse-item title="使用规则补充说明" :open="false">
- <view class="content">{{item.brief}}</view>
- </uni-collapse-item>
- </uni-collapse>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- searchInfo: {},
- config: {},
- user: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 6,
- page: 0,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.searchToken();
- that.searchConfig();
- },
- onShow: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) that.$set(that, `user`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- searchConfig() {
- const that = this;
- try {
- const res = uni.getStorageSync('config');
- if (res) that.$set(that, `config`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- async search() {
- const that = this;
- let info = {
- skip: that.skip,
- limit: that.limit,
- user: that.user._id,
- is_use: "0"
- }
- const res = await that.$api(`/userCoupon/specialQuery`, 'GET', {
- ...info,
- ...that.searchInfo
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list)
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
- else that.$set(that, `searchInfo`, {})
- that.clearPage();
- that.search();
- },
- // 去使用
- toUser(item) {
- if (item.type == '0') {
- uni.navigateTo({
- url: `/pagesHome/hotel/index`
- })
- } else {
- uni.navigateTo({
- url: `/pagesHome/ticket/index`
- })
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.search();
- uni.hideLoading();
- } else that.$set(that, `is_bottom`, true)
- },
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- margin: 1vw 0 0 0;
- background-color: var(--f9Color);
- .list {
- background-color: var(--mainColor);
- border: 1px solid var(--f5Color);
- padding: 2vw;
- margin: 2vw 2vw 0 2vw;
- border-radius: 5px;
- .list_1 {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .left {
- width: 20vw;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- color: var(--fF0Color);
- font-size: var(--font14Size);
- .left_1 {
- text {
- font-weight: bold;
- font-size: 25px;
- }
- }
- .left_2 {
- margin: 2px 0 0 0;
- font-size: var(--font12Size);
- }
- }
- .center {
- width: 40vw;
- .name {
- font-size: var(--font14Size);
- font-weight: bold;
- margin: 0 0 1vw 0;
- }
- .content {
- color: var(--f85Color);
- font-size: var(--font12Size);
- }
- }
- .right {
- .button {
- font-size: 12px;
- border-radius: 20px;
- border: 1px solid var(--fF0Color);
- color: var(--fF0Color);
- background: var(--mainColor);
- }
- }
- }
- .list_2 {
- font-size: var(--font12Size);
- /deep/.uni-collapse-item__title-box {
- padding: 0 !important;
- font-size: 12px !important;
- }
- /deep/.uni-collapse-item__title-text {
- font-size: 12px !important;
- }
- .content {
- padding: 2vw;
- }
- }
- }
- }
- }
- </style>
|