123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <template>
- <view class="content">
- <checkbox-group>
- <view class="good" v-for="item in list">
- <image :src="item.image" mode="" class="good-img"></image>
- <view class="good-info">
- <view class="good-tit clamp2">
- {{item.name}}
- </view>
- <view class="good-tip">
- 随时随地 预约服务
- </view>
- <view class="good-buy">
- 已售{{item.sold}}件
- </view>
- <view class="good-price">
- {{item.price}} <text class="ot-price">¥{{item.ot_price}}</text>
- </view>
- </view>
- <checkbox :checked="item.isCheck" class="good-check" :value="item.id" @click="changeCheck(item)"/>
- </view>
- </checkbox-group>
- <u-loadmore :status="loadingType" />
- <view class="" style="height: 120rpx;">
-
- </view>
- <view class="sub-btn" @click="addGood">
- 确认添加
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- loadingType: 'loadmore',
- page: 1,
- pageSize: 10,
- loaded: false,
- list: [],
- id: '',
- }
- },
- computed: {
- chooseList() {
- let arr = this.list.filter((item)=> {
- return item.isCheck == true
- })
- return arr
- },
- choose_id() {
- let dd = ''
- if(this.chooseList.length > 0) {
- this.chooseList.forEach(item => {
- dd = dd + item.id + ','
- })
-
- }
- return dd
- }
- },
- onLoad(opt) {
- this.id = opt.id
- },
- onShow() {
- this.getList()
- },
- onReachBottom() {
- // this.getList()
- },
- onReady() {
- },
- methods: {
- addGood() {
- if(this.choose_id == '') {
- this.$u.toast('请选择要添加的项目');
- }
- let res = {
- "id": this.id, //id
- "projectId": this.choose_id.slice(0,this.choose_id.length-1), //项目id
- }
- // console.log(res,'tijiao')
- this.$u.api.addProject(res).then(({data}) => {
- this.$u.toast('添加成功');
- setTimeout(()=> {
- uni.navigateBack()
- },1000)
- })
-
- },
- changeCheck(item) {
- item.isCheck = !item.isCheck
-
- console.log(this.list)
- },
- getList() {
- let that = this
- if(that.loadingType == 'nomore' || that.loadingType == 'loading') {
- return
- }
- that.loadingType = 'loading'
-
- this.$u.api.getYyItemList({
- page: that.page,
- pageSize: that.pageSize,
- }).then(res => {
- that.list = that.list.concat(res.data.map(item => {
- item.isCheck = false
- return item
- }))
- that.page++
- if(that.pageSize == res.data.length ) {
- that.loadingType = 'loadmore'
- }else {
- that.loadingType = 'nomore'
- }
- that.loaded = true
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .content {
- padding-top: 1rpx;
- }
- .good {
- width: 690rpx;
- margin: 20rpx auto;
- display: flex;
- justify-content: flex-start;
- padding: 20rpx;
- background-color: #fff;
- border-radius: 20rpx;
- position: relative;
- .good-check {
- position: absolute;
- bottom: 20rpx;
- right: 20rpx;
- }
- .good-img {
- width: 256rpx;
- height: 256rpx;
- background: #D6DEE1;
- border-radius: 15rpx;
- flex-shrink: 0;
- margin-right: 15rpx;
- }
- .good-info {
- display: flex;
- flex-direction: column;
- // align-items: ;
- justify-content: space-between;
- align-items: flex-start;
- .good-tit {
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- }
- .good-buy {
- font-size: 24rpx;
- font-weight: 500;
- color: #9a9a9a;
- }
-
- .good-tip {
- font-size: 24rpx;
- font-weight: 500;
- color: #FA7014;
- }
- .good-price {
- color: #fd463e;
- font-size: 32rpx;
- &::before {
- content: '¥';
- font-size: 22rpx;
- color: #fd463e;
- }
- text {
- padding-left: 15rpx;
- font-size: 26rpx;
- font-weight: 500;
- text-decoration: line-through;
- color: #999999;
- }
- }
- }
-
- }
- .sub-btn {
- width: 616rpx;
- height: 74rpx;
- background: #4D74CF;
- border-radius: 15rpx;
- font-size: 30rpx;
- font-weight: bold;
- color: #FFFFFF;
- text-align: center;
- line-height: 74rpx;
- position: fixed;
- bottom: 45rpx;
- left: 0;
- right: 0;
- margin: auto;
- }
- </style>
|