123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <view class="one_1">
- <text>超值拼团</text>
- </view>
- <view class="one_2">
- <text class="iconfont icon-qianggou"></text>
- <text>快叫上伙伴一起抢</text>
- <text class="iconfont icon-qianggou"></text>
- </view>
- </view>
- <view class="two">
- <view class="two_1">
- <view class="img">
- <image class="image" :src="info.goods.file&&info.goods.file.length>0?info.goods.file[0].url:''" mode=""></image>
- </view>
- </view>
- <view class="two_2">
- <view class="name">
- {{info.goods.name}}
- </view>
- <view class="money">
- ¥{{info.goodsSpec.group_config.money}}元
- </view>
- <view class="brief">
- {{info.goods.brief||''}}
- </view>
- </view>
- </view>
- <view class="thr">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="thr_1">
- <view class="list" v-for="(item,index) in info.persons" :key="index">
- <view class="img">
- <image class="image" :src="item.icon&&item.icon.length>0?item.icon[0].url:''" mode=""></image>
- </view>
- <view class="name">
- {{item.name}}
- </view>
- </view>
- <view class="list list_1" v-if="info.person_limit>info.persons.length">
- <button type="default" size="mini" @tap.stop="toOpen">参团</button>
- </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="info.goodsSpec.num" v-model="num" @change="toCount">
- </uni-number-box>
- </view>
- <text>库存{{info.goodsSpec.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 {
- id: '',
- user: {},
- info: {},
- num: 1,
- };
- },
- onLoad: function(e) {
- const that = this;
- that.$set(that, `id`, e.id || '');
- that.watchLogin();
- that.search();
- },
- methods: {
- // 计数器
- toCount(e) {
- const that = this;
- that.num = e;
- },
- // 确认开团 立即参团
- async onSubmit() {
- const that = this;
- let user = that.user;
- if (user._id) {
- let data = {
- customer: user._id,
- shop: that.info.shop,
- goods: that.info.goods._id,
- goodsSpec: that.info.goodsSpec._id,
- num: that.num,
- type: '1',
- group: that.id
- }
- let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
- if (arr.errcode == '0') {
- if (arr.data.result == true) {
- if (that.id) {
- uni.navigateTo({
- url: `/pagesHome/order/order?key=${arr.data.key}&group_id=${that.id}`
- })
- } else {
- 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'
- })
- }
- } else {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- },
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- if (user) that.$set(that, `user`, user)
- }
- })
- },
- async search() {
- const that = this;
- if (that.id) {
- let res = await that.$api(`/group/${that.id}`, `GET`);
- if (res.errcode == '0') {
- if (res.data.status != '-1') {
- res.data.persons = res.data.persons.filter(i => i.status == '0')
- }
- that.$set(that, `info`, res.data);
- uni.getStorage({
- key: 'config',
- success: function(config) {
- // 赋值默认值
- that.$config.share = {
- title: res.data.goods.name,
- path: '/pagesHome/group/share?id=${that.id}',
- imageUrl: config.config.share[0].url
- }
- }
- });
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- },
- // 参团
- toOpen() {
- const that = this;
- that.$refs.popup.open();
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- background-color: #23B67A;
- .one {
- background-color: #D9FDEF;
- margin: 2vw 6vw;
- border-radius: 10px;
- padding: 2vw;
- .one_1 {
- text-align: center;
- border-bottom: 1px dashed #085623;
- margin: 0 0 2vw 0;
- padding: 0 0 1vw 0;
- text {
- font-size: 61px;
- font-weight: bold;
- color: #357846;
- font-family: cursive;
- }
- }
- .one_2 {
- text-align: center;
- text {
- padding: 0 5px;
- }
- text:nth-child(2) {
- font-size: 18px;
- letter-spacing: 5px;
- font-weight: bold;
- color: #357846;
- }
- }
- }
- .two {
- background-color: #D9FDEF;
- margin: 2vw;
- border-radius: 10px;
- padding: 2vw;
- display: flex;
- .two_1 {
- display: flex;
- .img {
- .image {
- width: 100px;
- height: 100px;
- border-radius: 90px;
- }
- }
- }
- .two_2 {
- padding: 0 0 0 2vw;
- .name {
- font-size: 20px;
- font-weight: bold;
- margin: 0 0 2vw 0;
- color: #357846;
- }
- .money {
- font-size: 18px;
- color: #ff0000;
- font-weight: bold;
- margin: 0 0 2vw 0;
- }
- .brief {
- font-size: 14px;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-line-clamp: 2;
- word-break: break-all;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- color: #858585;
- }
- }
- }
- .thr {
- position: relative;
- flex-grow: 1;
- margin: 0 2vw 2vw 2vw;
- width: 94vw;
- border-radius: 10px;
- border: 3px solid #D9FDEF;
- .thr_1 {
- padding: 2vw;
- display: flex;
- flex-wrap: wrap;
- .list {
- width: 20vw;
- text-align: center;
- margin: 0 3vw 2vw 0;
- .img {
- .image {
- width: 16vw;
- height: 16vw;
- border-radius: 90px;
- }
- }
- .name {
- font-size: 14px;
- font-weight: bold;
- }
- }
- .list:nth-child(4n) {
- margin: 0 0 2vw 0;
- }
- .list_1 {
- button {
- padding: 0;
- border-radius: 90px;
- width: 16vw;
- height: 16vw;
- text-align: center;
- line-height: 16vw;
- background-color: #ffffff5f;
- font-size: 16px;
- font-weight: bold;
- color: #fff;
- }
- }
- }
- }
- }
- .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>
|