123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <view class="list" @tap="toView">
- <image class="image" :src="goodsInfo.file&&goodsInfo.file.length>0?goodsInfo.file[0].url:''"
- mode="">
- </image>
- <view class="list_1_1">
- <view class="name">
- {{goodsInfo.name||'暂无'}}
- </view>
- <view class="specs">
- <text>规格:{{specsInfo.name}}</text>
- <text>店铺:{{shopInfo.name}}</text>
- </view>
- <view class="money">
- <text>¥</text>
- <text>{{specsInfo.sell_money}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="two">
- <button type="default" size="default" @click="toGroup">我要开团</button>
- </view>
- <view class="thr">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
- <view class="list-scroll-view">
- <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="list_1">
- <view class="name">
- {{item.leader||'暂无'}}
- </view>
- <view class="some">
- <text>商品名称</text>
- <text>{{item.name||'暂无'}}</text>
- </view>
- <view class="some">
- <text>参团人数</text>
- <text>{{item.person_limit||0}}人</text>
- </view>
- <view class="other">
- <view class="other_1">
- <text>¥</text>
- <text>{{item.sell_money||0}}</text>
- </view>
- <view class="other_2">
- <view class="btn" @click="toJoin(item)">
- <text>{{item.status||'开团中'}}</text>立即参团
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <uni-popup ref="popup" background-color="#fff" type="bottom">
- <view class="content">
- <view class="one">
- <text>数量</text>
- <view class="count">
- <uni-number-box :min="1" :max="specsInfo.num" v-model="num" @change="toCount">
- </uni-number-box>
- </view>
- <text>库存{{specsInfo.num||0}}</text>
- </view>
- <view class="btn">
- <text @click="onSubmit" class="button">确认开团</text>
- </view>
- </view>
- </uni-popup>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- query: {},
- user: {},
- // 商品详情
- goodsInfo: {},
- // 规格详情
- specsInfo: {},
- // 店铺详情
- shopInfo: {},
- // 参团列表
- list: [],
- num: 0,
- total: 0,
- skip: 0,
- limit: 6,
- page: 0
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `query`, {
- goods_id: e.goods_id || '6343878989bdcb128d846990',
- specs_id: e.specs_id || '634394bc32c3065a80eb14ad'
- });
- },
- onShow: function() {
- const that = this;
- that.watchLogin();
- that.search();
- },
- methods: {
- // 开团
- async toGroup() {
- const that = this;
- that.$refs.popup.open();
- // let user = that.user;
- // if (user._id) {
- // let data = {
- // customer: user._id,
- // shop: that.shopInfo._id,
- // goods: that.goodsInfo._id,
- // goodsSpec: that.specsInfo._id,
- // num: that.num,
- // }
- // let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
- // if (arr.errcode == '0') {
- // if (arr.data.result == true) {
- // uni.navigateTo({
- // url: `/pagesHome/order/order?key=${arr.data.key}`
- // })
- // } else {
- // uni.showToast({
- // title: arr.data.msg,
- // icon: 'none'
- // })
- // }
- // } else {
- // uni.showToast({
- // title: arr.errmsg,
- // icon: 'none'
- // })
- // }
- // const arr = await that.$api(`/group`, 'POST', data)
- // if (arr.errcode == '0') {
- // uni.showToast({
- // title: '开团成功',
- // icon: 'none'
- // })
- // that.clearPage();
- // that.search()
- // } else {
- // uni.showToast({
- // title: arr.data.errmsg,
- // icon: 'none'
- // })
- // }
- // } else {
- // uni.navigateTo({
- // url: `/pages/login/index`
- // })
- // }
- },
- // 计数器
- toCount(e) {
- const that = this;
- that.num = e;
- },
- // 立即参团
- toJoin(e) {
- const that = this;
- let user = that.user;
- if (user._id) {
- console.log(e);
- } else {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- },
- // 监听用户是否登录
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user);
- },
- fail: function(err) {}
- })
- },
- // 查询列表
- async search() {
- const that = this;
- let res;
- res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
- id: that.query.goods_id
- });
- if (res.errcode == '0') {
- that.$set(that, `goodsInfo`, res.data.goods)
- that.$set(that, `shopInfo`, res.data.shop)
- }
- res = await that.$api(`/goodsSpec/${that.query.specs_id}`, 'GET')
- if (res.errcode == '0') {
- that.$set(that, `specsInfo`, res.data);
- }
- let info = {
- skip: that.skip,
- limit: that.limit,
- }
- res = await that.$api(`/group`, 'GET', {
- ...info
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- }
- },
- // 分页
- 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 uni.showToast({
- title: '没有更多数据了'
- });
- },
- // 清空列表
- 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 {
- .list {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- width: 91vw;
- border: 0.5vw dashed var(--ff0Color);
- margin: 2vw 2vw 0 2vw;
- padding: 2vw;
- border-radius: 5px;
- .image {
- width: 25vw;
- height: 25vw;
- border-radius: 5px;
- margin: 0 2vw 0 0;
- }
- .list_1_1 {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- flex-grow: 1;
- padding: 2vw 0;
- .name {
- font-size: var(--font16Size);
- margin: 0 0 1vw 0;
- }
- .specs {
- display: flex;
- justify-content: space-between;
- color: var(--f85Color);
- font-size: var(--font12Size);
- }
- .money {
- color: var(--fFB1Color);
- font-size: var(--font14Size);
- margin: 0 0 1vw 0;
- text:last-child {
- font-size: var(--font16Size);
- }
- }
- }
- }
- }
- .two {
- margin: 4vw 0 0 0;
- button {
- margin: 0 2vw 2vw 2vw;
- background-color: #FFA500;
- color: var(--fffColor);
- }
- }
- .thr {
- position: relative;
- flex-grow: 1;
- .list {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- width: 91vw;
- border: 1px solid var(--f1Color);
- margin: 2vw 2vw 0 2vw;
- padding: 0 2vw;
- border-radius: 5px;
- .image {
- width: 25vw;
- height: 25vw;
- border-radius: 5px;
- margin: 0 2vw 0 0;
- }
- .list_1 {
- display: flex;
- flex-direction: column;
- flex-grow: 1;
- padding: 2vw 0;
- .name {
- font-size: var(--font16Size);
- margin: 0 0 1vw 0;
- }
- .some {
- color: var(--f85Color);
- font-size: var(--font14Size);
- margin: 0 0 1vw 0;
- text:last-child {
- margin: 0 0 0 1vw;
- color: var(--f00Color);
- }
- }
- .other {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .other_1 {
- font-size: var(--font14Size);
- color: var(--f85Color);
- text {
- font-weight: bold;
- padding: 0 1vw 0 0;
- color: var(--ff0Color);
- }
- }
- .other_2 {
- .btn {
- display: flex;
- flex-direction: column;
- align-items: center;
- margin: 0 2vw;
- padding: 2vw 3vw;
- background-color: var(--ff0Color);
- color: var(--fffColor);
- border-radius: 2vw;
- font-size: var(--font14Size);
- text {
- font-size: var(--font12Size);
- }
- }
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .content {
- height: 60vw;
- .one {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- margin: 0 2vw;
- padding: 2vw 0;
- text {
- margin: 0 2vw 0 0;
- }
- text:last-child {
- margin: 0 0 0 2vw;
- font-size: var(--font12Size);
- color: var(--f85Color);
- }
- }
- .btn {
- display: flex;
- justify-content: space-between;
- position: fixed;
- bottom: 0;
- .button {
- width: 100vw;
- padding: 4vw 0;
- background-color: var(--fFB1Color);
- text-align: center;
- font-size: var(--font18Szie);
- color: var(--mainColor);
- }
- }
- }
- </style>
|