123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view class="my-product">
- <view class="header">
- <view class="title">
- 我的商品
- </view>
- <view style="position: relative;">
- <view class="sub-title">全部商品</view>
- <view class="release">
- <navigator url="/pages/product/product-edit">发布商品</navigator>
- </view>
- </view>
- </view>
- <view v-if="products.length===0"
- style="margin: 20upx auto;text-align: center; font-size: 28upx;color: #999999;">
- 暂未发布任何商品
- </view>
- <view class="product-list">
- <view class="product-item" v-for="product in products" @tap="goToEdit(product.id)">
- <view class="product-image">
- <image class="image" :src="product.images|imagesFilter" mode="scaleToFill"></image>
- </view>
- <view>
- <view class="row row-1">
- <text class="title"><text class="sxzg-icon">省心直供</text>{{product.name}}</text>
- </view>
- <view class="row row-2">
- <text class="org-price">¥{{product.org_price}}</text>
- </view>
- <view class="row row-3">
- <text class="sxj-icon">省心价</text>
- <text class="price">¥{{product.price}}</text>
- </view>
- <view class="row row-4">
- <text>发布日期:</text>
- <text class="time">{{product.createtime|datetimeFilter}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- page: 1,
- pageLoading: false,
- products: []
- }
- },
- onLoad() {
- this.getProductData();
- },
- onPageScroll(e) {
- const query = uni.createSelectorQuery();
- query.select("#my-product").boundingClientRect(data => {
- if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2) {
- this.getProductData();
- }
- }).exec();
- },
- onPullDownRefresh() {
- this.refresh();
- },
- methods: {
- getProductData() {
- return new Promise((resolve, reject) => {
- this.$http.get({
- url: "/product/my",
- data: {
- limit: 10,
- page: this.page,
- },
- success: (res) => {
- this.products = [...this.products, ...res.data.data.rows];
- this.page++;
- this.pageLoading = false;
- resolve(res)
- },
- fail: (err) => {
- reject(err)
- }
- })
- })
- },
- goToEdit(id) {
- uni.navigateTo({
- url: "/pages/product/product-edit?id=" + id
- })
- },
- refresh() {
- this.page = 1;
- this.products = [];
- this.getProductData()
- .then(uni.stopPullDownRefresh())
- .catch(uni.stopPullDownRefresh());
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .my-product {
- overflow: hidden;
- }
- .header {
- margin: 20upx;
- background: white;
- text-align: center;
- border-radius: 20upx;
- padding-bottom: 10upx;
- .title {
- height: 100upx;
- font-size: 32upx;
- line-height: 100upx;
- // font-weight: bold;
- }
- .sub-title {
- font-size: 28upx;
- color: #999999;
- }
- .release {
- position: absolute;
- right: 20upx;
- font-size: 24upx;
- bottom: 4upx;
- }
- }
- .product-list {
- .product-item {
- display: flex;
- background: white;
- margin: 20upx;
- padding: 20upx;
- .product-image {
- width: 180upx;
- height: 180upx;
- margin-right: 20upx;
- }
- .image {
- width: 180upx;
- height: 180upx;
- background: #EEEEEE;
- }
- }
- .sxzg-icon {
- color: $primary-color;
- font-size: 16rpx;
- width: 80rpx;
- text-align: center;
- line-height: normal;
- border: 2rpx solid $primary-color;
- border-radius: 20rpx;
- display: inline-block;
- position: relative;
- top: -4rpx;
- margin-right: 10upx;
- // transform: scale(0.9);
- }
- .title {
- font-size: 24rpx;
- display: inline-block;
- white-space: normal;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- height: 68upx;
- }
- .row {
- // padding: 0 10upx;
- }
- .row-2 {
- display: flex;
- justify-content: space-between;
- }
- .row-3 {
- display: flex;
- align-items: center;
- }
- .org-price {
- font-size: 26rpx;
- color: #cccccc;
- }
- .org-price {
- text-decoration: line-through;
- }
- .sxj-icon {
- background: $primary-color;
- color: white;
- font-size: 20upx;
- padding: 0 5upx;
- border-radius: 5upx;
- vertical-align: middle;
- }
- .price {
- font-size: 26rpx;
- color: $primary-color;
- font-weight: bold;
- }
- .row-4 {
- font-size: 24upx;
- color: #999999;
- }
- }
- </style>
|