123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <view class="one_1">
- <input type="text" v-model="searchInfo.goods_name" @input="toInput" placeholder="搜索商品">
- </view>
- <view class="one_2">
- <button size="mini" @tap="toDislog">筛选</button>
- </view>
- </view>
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="list" v-for="(item,index) in list" :key="index">
- <view class="list_1">
- <view class="list_1_1">
- <view class="shopname">
- <text class="iconfont icon-shangdian"></text>
- <text>{{item.shop.name}}</text>
- </view>
- <view class="status">
- {{item.zhStatus||'暂无'}}
- </view>
- </view>
- <view class="list_1_2">
- <view class="goods">
- <view class="goods_1">
- <image class="image"
- v-if="item.spec&&item.spec.file&&item.spec.file.length>0"
- :src="item.spec&&item.spec.file&&item.spec.file.length>0?item.spec.file[0].url:''"
- mode=""></image>
- <image class="image" v-else
- :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''"
- mode=""></image>
- </view>
- <view class="goods_2">
- <view class="goodsname textOver">
- {{item.goods.name}}
- </view>
- <view class="time" v-if="item.leader_name">
- 团长:{{item.leader_name}}
- </view>
- <view class="time">
- 开始时间:{{item.start_time}}
- </view>
- <view class="time">
- 结束时间:{{item.end_time}}
- </view>
- <view class="time">
- 人数限制:{{item.person_limit}}人
- </view>
- <view class="other_2">
- 原价:<text>¥{{item.sell_price||'暂无'}}</text>团购价:<text>¥{{item.group_price||'暂无'}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="btn">
- <button type="default" size="mini" @tap.stop="toJion(item)">参加团购</button>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="dialog" v-if="dialog.show==true">
- <view class="dialog_1" v-if="dialog.type=='1'">
- <uni-forms ref="form" :modelValue="searchInfo" :rules="rules" label-width="auto">
- <uni-forms-item label="会员名称" name="leader_name">
- <uni-easyinput type="text" v-model="searchInfo.leader_name" placeholder="请输入会员名称" />
- </uni-forms-item>
- <uni-forms-item label="开始时间" name="start_time">
- <uni-datetime-picker type="datetime" v-model="searchInfo.start_time"
- @change="startChange" />
- </uni-forms-item>
- <uni-forms-item label="结束时间" name="end_time">
- <uni-datetime-picker type="datetime" v-model="searchInfo.end_time" @change="endChange" />
- </uni-forms-item>
- </uni-forms>
- <view class="btn">
- <button type="primary" @click="onSubmit" size="mini">确定</button>
- <button type="primary" @click="dialogClose" size="mini">取消</button>
- </view>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- // 系统设置
- config: {},
- // 设备信息
- system: {},
- user: {},
- searchInfo: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 6,
- page: 0,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- // 字典表
- statusList: [],
- status_name: "",
- // 条件弹出框
- dialog: {
- show: false,
- type: '1'
- }
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.searchConfig();
- await that.searchOther();
- await that.watchlogin();
- await that.search();
- },
- onShow: async function(e) {
- const that = this;
- },
- 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)
- // 设备平台信息
- let config = that.$config;
- that.$set(that, `system`, config.system);
- },
- fail: function(err) {
- console.log(err);
- }
- })
- },
- // 监听用户是否登录
- watchlogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- if (user) that.$set(that, `user`, user)
- }
- })
- },
- // 开始时间选择
- startChange(e) {
- const that = this;
- that.$set(that.searchInfo, `start_time`, e);
- },
- // 结束时间选择
- endChange(e) {
- const that = this;
- that.$set(that.searchInfo, `end_time`, e);
- },
- async search() {
- const that = this;
- let info = {
- skip: that.skip,
- limit: that.limit,
- shop: that.$config.shop,
- status: '0'
- }
- let res = await that.$api(`/group/aq`, 'GET', {
- ...info,
- ...that.searchInfo
- }, 'group');
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- for (let val of list) {
- if (val.status) val.zhStatus = that.searchStatus(val.status)
- }
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- },
- // 查询状态
- searchStatus(e) {
- const that = this;
- let data = that.statusList.find((i) => i.value == e);
- if (data) return data.label
- else return '暂无'
- },
- // 参加团购
- toJion(e) {
- const that = this;
- // that.clearPage();
- uni.navigateTo({
- url: `/pagesHome/group/share?id=${e.goods._id}&group=${e._id}`
- })
- },
- // 分页
- 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);
- },
- // 查询条件
- toDislog() {
- const that = this;
- that.$set(that, `searchInfo`, {})
- that.$set(that, `status_name`, '')
- that.$set(that, `dialog`, {
- show: true,
- type: '1'
- })
- },
- // 状态选择
- statusChange(e) {
- const that = this;
- let data = that.statusList[e.detail.value];
- if (data) {
- that.$set(that.searchInfo, `status`, data.value);
- that.$set(that, `status_name`, data.label);
- }
- },
- // 关闭弹框
- dialogClose() {
- const that = this;
- that.clearPage();
- that.search();
- that.$set(that, `dialog`, {
- show: false,
- type: '1'
- })
- },
- // 查询
- onSubmit() {
- const that = this;
- that.clearPage();
- that.search();
- that.$set(that, `dialog`, {
- show: false,
- type: '1'
- })
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- // 查询状态
- res = await that.$api(`/dictData`, 'GET', {
- code: 'group_status'
- })
- if (res.errcode == '0') that.$set(that, `statusList`, res.data);
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (that.searchInfo.goods_name) that.$set(that.searchInfo, `goods_name`, e.detail.value)
- else that.$set(that, `searchInfo`, {})
- that.clearPage();
- that.search();
- },
- // 清空列表
- 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 {
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 2vw;
- .one_1 {
- padding: 0 2vw;
- width: 75vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- button {
- background-color: #23B67A;
- color: #ffffff;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- background-color: var(--f9Color);
- .list {
- background-color: #fff;
- border: 1px solid var(--f5Color);
- padding: 2vw;
- margin: 0 2vw 2vw 2vw;
- border-radius: 5px;
- .list_1 {
- .list_1_1 {
- display: flex;
- justify-content: space-between;
- margin: 0 0 2vw 0;
- .shopname {
- text:last-child {
- padding: 0 0 0 2vw;
- }
- }
- .status {
- color: var(--fFB1Color);
- }
- }
- .list_1_2 {
- border-bottom: 1px solid #f1f1f1;
- .goods {
- display: flex;
- padding: 0 0 2vw 0;
- .goods_1 {
- width: 20vw;
- height: 20vw;
- .image {
- width: 100%;
- height: 100%;
- border-radius: 5px;
- }
- }
- .goods_2 {
- width: 70vw;
- padding: 0 0 0 2vw;
- .goodsname {
- font-size: 16px;
- margin: 0 0 1vw 0;
- }
- .time {
- font-size: 14px;
- color: #858585;
- }
- .other_2 {
- color: #858585;
- font-size: var(--font14Size);
- text {
- color: var(--fFB1Color);
- padding: 0 2vw 0 0;
- }
- }
- }
- }
- }
- .other {
- padding: 0 0 2vw 0;
- margin: 2vw 0;
- text-align: right;
- border-bottom: 1px solid #f1f1f1;
- text {
- font-size: 14px;
- padding: 0 0 0 2vw;
- }
- }
- }
- .btn {
- text-align: right;
- margin: 1vw 0 0 0;
- button {
- margin: 0 1vw 0 0;
- }
- }
- }
- }
- }
- .dialog {
- position: fixed;
- width: 96vw;
- height: 100vh;
- background-color: #ffffff;
- z-index: 99999;
- display: flex;
- flex-direction: column;
- padding: 2vw;
- .uni-input {
- border: #f1f1ff 1px solid;
- padding: 2vw 2vw;
- border-radius: 1vw;
- }
- .picker {
- border: 1px solid #3333;
- border-radius: 5px;
- padding: 2vw;
- }
- .btn {
- text-align: center;
- button {
- margin: 0 2vw 2vw 2vw;
- background-color: #23B67A;
- color: #ffffff;
- }
- .name {
- color: var(--f85Color);
- font-size: var(--font14Size);
- }
- }
- }
- .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>
|