123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- <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.num||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>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- query: {},
- user: {},
- // 商品详情
- goodsInfo: {},
- // 规格详情
- specsInfo: {},
- // 店铺详情
- shopInfo: {},
- // 参团列表
- list: [{
- "_id": "633559dfa4e39d34f49990af",
- "name": "商品6",
- "view_num": 54,
- "sell_money": 1,
- "leader": '测试人员',
- "file": [{
- "id": "20221010102439",
- "name": "ece9214111e760727a166eaac037fdc0.jpg",
- "uri": "/files/point/goods/20221010102439.jpg",
- "url": "https://broadcast.waityou24.cn/files/point/goods/20221010102439.jpg",
- "uid": 1665368678937,
- "status": "success"
- }],
- "time": "2022-10-11 15:50:27"
- }, {
- "_id": "63437e3ba163596194c3e830",
- "name": "王大拿商品1",
- "view_num": 37,
- "sell_money": 15,
- "leader": '测试人员',
- "file": [{
- "id": "20221010100628",
- "name": "0e7edbb2f8e99780f253a3604adc32e4.jpg",
- "uri": "/files/point/goods/20221010100628.jpg",
- "url": "https://broadcast.waityou24.cn/files/point/goods/20221010100628.jpg",
- "uid": 1665367588108,
- "status": "success"
- }],
- "time": "2022-10-11 15:08:29"
- }, {
- "_id": "6343878989bdcb128d846990",
- "name": "王大拿商品2",
- "view_num": 196,
- "sell_money": 50,
- "leader": '测试人员',
- "file": [{
- "id": "20221011092711",
- "name": "25.png",
- "uri": "/files/point/goods/20221011092711.png",
- "url": "https://broadcast.waityou24.cn/files/point/goods/20221011092711.png",
- "uid": 1665451632365,
- "status": "success"
- }],
- "time": "2022-10-11 15:05:41"
- }, {
- "_id": "63353758101f3c01048c4f61",
- "name": "test",
- "view_num": 265,
- "sell_money": 0.1,
- "leader": '测试人员',
- "file": [{
- "id": "20220929141236",
- "name": "f0e22552dddcf494f9720c655a8420a.png",
- "uri": "/files/point/goods/20220929141236.png",
- "url": "https://broadcast.waityou24.cn/files/point/goods/20220929141236.png",
- "uid": 1664431956868,
- "status": "success"
- }],
- "time": "2022-10-11 11:21:01"
- }, {
- "_id": "633930162a24745ec0006373",
- "name": "测试店铺1-商品1",
- "view_num": 59,
- "sell_money": 0.1,
- "leader": '测试人员',
- "file": [{
- "id": "20220929141236",
- "name": "f0e22552dddcf494f9720c655a8420a.png",
- "uri": "/files/point/goods/20220929141236.png",
- "url": "https://broadcast.waityou24.cn/files/point/goods/20220929141236.png",
- "uid": 1664431956868,
- "status": "success"
- }],
- "time": "2022-10-11 11:15:36"
- }, {
- "_id": "63355854a4e39d34f499904a",
- "name": "商品2",
- "view_num": 164,
- "sell_money": 1,
- "leader": '测试人员',
- "file": [{
- "id": "20220929163309",
- "name": "f0e22552dddcf494f9720c655a8420a.png",
- "uri": "/files/point/goods/20220929163309.png",
- "url": "https://broadcast.waityou24.cn/files/point/goods/20220929163309.png",
- "uid": 1664440389135,
- "status": "success"
- }],
- "time": "2022-10-11 11:13:11"
- }],
- 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;
- let user = that.user;
- if (user._id) {
- let data = {
- shop: that.shopInfo._id,
- goods: that.goodsInfo._id,
- goodsSpec: that.specsInfo._id,
- leader: user._id
- }
- 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`
- })
- }
- },
- // 立即参团
- 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;
- }
- }
- </style>
|