123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <input type="text" v-model="searchInfo.name" @blur="toInput" placeholder="搜索商品">
- </view>
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="two_1">
- <view class="list" v-for="(item,index) in list" :key="index">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
- </image>
- <view class="name textOver">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <text>{{item.cost}}</text>
- </view>
- <view class="btn">
- <button type="default" size="mini" @click="toBuy(item)">兑换</button>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- // 系统设置
- config: {},
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.searchConfig();
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- // 查询基本设置
- searchConfig() {
- const that = this;
- uni.getStorage({
- key: 'config',
- success: function(res) {
- if (res.data) that.$set(that, `config`, res.data)
- },
- fail: function(err) {
- console.log(err);
- }
- })
- },
- async search() {
- const that = this;
- let info = {
- skip: that.skip,
- limit: that.limit,
- }
- const res = await that.$api(`/zrGoods`, `GET`, {
- ...info,
- ...that.searchInfo
- }, `integral`)
- 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,
- });
- }
- },
- // 分页
- toPage() {
- 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);
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (e.detail.value) that.$set(that.searchInfo, `name`, e.detail.value);
- that.clearPage();
- that.search();
- },
- toBuy(e) {
- uni.navigateTo({
- url: `/pagesIntegral/order/detail?id=${e._id}`
- })
- },
- // 清空列表
- 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">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- border-bottom: 1px solid var(--f85Color);
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- .two_1 {
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .list {
- width: 43vw;
- background: #fff;
- padding: 2vw;
- border-radius: 5px;
- margin: 2vw 1vw 0 1vw;
- border: 1px solid var(--f1Color);
- .image {
- width: 100%;
- height: 43vw;
- }
- .name {
- font-size: var(--font15Size);
- margin: 0 0 2vw 0;
- }
- .other {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- .money {
- color: var(--fFB1Color);
- }
- .btn {
- button {
- border-radius: 25px;
- color: var(--fffColor);
- background-color: #6A5ACD;
- font-size: var(--font12Size);
- }
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .is_bottom {
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|