| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790 |
- <template>
- <view class="container">
- <view class="header-operation">
- <view class="header-operation-left">
- <view :class="{ active: goodsType == 'oncecard' }" @click="switchGoodsType('oncecard')">限次卡</view>
- <view :class="{ active: goodsType == 'timecard' }" @click="switchGoodsType('timecard')">限时卡</view>
- <view :class="{ active: goodsType == 'commoncard' }" @click="switchGoodsType('commoncard')">通用卡</view>
- </view>
- <view class="header-operation-right"></view>
- </view>
- <view class="content">
- <scroll-view scroll-y="true" class="list-wrap" @scrolltolower="getOncecard()" v-if="goodsType == 'oncecard'">
- <view class="table-list" v-show="oncecardData.list.length > 0">
- <view class="table-item" :class="'item-mum-' + itemNum" v-for="(item, index) in oncecardData.list" :key="index" @click="goodsSelect(item)">
- <view class="item-img">
- <image
- :src="
- item.goods_image == 'public/uniapp/default_img/goods.png'
- ? $util.img('public/uniapp/default_img/goods.png')
- : $util.img(item.goods_image.split(',')[0], { size: 'small' })
- "
- @error="item.goods_image = 'public/uniapp/default_img/goods.png'"
- ></image>
- </view>
- <view class="item-info">
- <view class="item-name">{{ item.goods_name }}</view>
- <view class="item-rights"></view>
- <view class="item-money">
- <text class="util">¥</text>
- {{ item.discount_price | moneyFormat }}
- </view>
- </view>
- <view class="no-stock" v-if="item.stock == 0"><image :src="$util.img('public/uniapp/cashier/stock_empty.png')" mode="heightFix"></image></view>
- </view>
- </view>
- <view class="empty" v-if="!oncecardData.list.length">
- <image :src="$util.img('public/uniapp/cashier/goods_empty.png')" mode="widthFix"></image>
- <view class="tips">暂无卡项</view>
- </view>
- </scroll-view>
- <scroll-view scroll-y="true" class="list-wrap" @scrolltolower="getTimecard()" v-if="goodsType == 'timecard'">
- <view class="table-list" v-show="timecardData.list.length > 0">
- <view class="table-item" :class="'item-mum-' + itemNum" v-for="(item, index) in timecardData.list" :key="index" @click="goodsSelect(item)">
- <view class="item-img">
- <image
- :src="
- item.goods_image == 'public/uniapp/default_img/goods.png'
- ? $util.img('public/uniapp/default_img/goods.png')
- : $util.img(item.goods_image.split(',')[0], { size: 'small' })
- "
- @error="item.goods_image = 'public/uniapp/default_img/goods.png'"
- ></image>
- </view>
- <view class="item-info">
- <view class="item-name">{{ item.goods_name }}</view>
- <view class="item-rights"></view>
- <view class="item-money">
- <text class="util">¥</text>
- {{ item.discount_price | moneyFormat }}
- </view>
- </view>
- <view class="no-stock" v-if="item.stock == 0"><image :src="$util.img('public/uniapp/cashier/stock_empty.png')" mode="heightFix"></image></view>
- </view>
- </view>
- <view class="empty" v-if="!timecardData.list.length">
- <image :src="$util.img('public/uniapp/cashier/goods_empty.png')" mode="widthFix"></image>
- <view class="tips">暂无卡项</view>
- </view>
- </scroll-view>
- <scroll-view scroll-y="true" class="list-wrap" @scrolltolower="getCommoncard()" v-if="goodsType == 'commoncard'">
- <view class="table-list" v-show="commoncardData.list.length > 0">
- <view class="table-item" :class="'item-mum-' + itemNum" v-for="(item, index) in commoncardData.list" :key="index" @click="goodsSelect(item)">
- <view class="item-img">
- <image
- :src="
- item.goods_image == 'public/uniapp/default_img/goods.png'
- ? $util.img('public/uniapp/default_img/goods.png')
- : $util.img(item.goods_image.split(',')[0], { size: 'small' })
- "
- @error="item.goods_image = 'public/uniapp/default_img/goods.png'"
- ></image>
- </view>
- <view class="item-info">
- <view class="item-name">{{ item.goods_name }}</view>
- <view class="item-rights"></view>
- <view class="item-money">
- <text class="util">¥</text>
- {{ item.discount_price | moneyFormat }}
- </view>
- </view>
- <view class="no-stock" v-if="item.stock == 0"><image :src="$util.img('public/uniapp/cashier/stock_empty.png')" mode="heightFix"></image></view>
- </view>
- </view>
- <view class="empty" v-if="!commoncardData.list.length">
- <image :src="$util.img('public/uniapp/cashier/goods_empty.png')" mode="widthFix"></image>
- <view class="tips">暂无卡项</view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'ncCard',
- props: {
- type: {
- type: String,
- default: 'oncecard'
- }
- },
- data() {
- return {
- goodsType: '',
- pageSize: 35,
- oncecardData: {
- page: 0,
- total: 1,
- list: []
- },
- timecardData: {
- page: 0,
- total: 1,
- list: []
- },
- commoncardData: {
- page: 0,
- total: 1,
- list: []
- },
- searchText: '',
- itemNum: 3,
- mediaQueryOb: null
- };
- },
- created() {
- this.goodsType = this.type;
- this.getOncecard();
- this.getTimecard();
- this.getCommoncard();
- },
- mounted() {
- this.mediaQueryOb = uni.createMediaQueryObserver(this);
- this.mediaQueryOb.observe(
- {
- maxWidth: 1300
- },
- matches => {
- if (matches) this.itemNum = 2;
- }
- );
- this.mediaQueryOb.observe(
- {
- minWidth: 1301,
- maxWidth: 1900
- },
- matches => {
- if (matches) this.itemNum = 3;
- }
- );
- this.mediaQueryOb.observe(
- {
- minWidth: 1901
- },
- matches => {
- if (matches) this.itemNum = 4;
- }
- );
- },
- methods: {
- switchGoodsType(type) {
- this.goodsType = type;
- },
- //卡项相关
- goodsSelect(data) {
- if (!data.stock) return;
- this.$emit('select', data);
- },
- search() {
- if (this.searchText == '') return;
- this.oncecardData.page = 0;
- this.getOncecard();
- },
- getOncecard() {
- if (this.oncecardData.page + 1 > this.oncecardData.total) return;
- this.oncecardData.page += 1;
- this.$api.sendRequest({
- url: '/cashier/storeapi/card/page',
- data: {
- page: this.oncecardData.page,
- search_text: this.searchText,
- page_size: this.pageSize,
- card_type: 'oncecard',
- goods_state: 1,
- status: 1
- },
- success: res => {
- if (res.code == 0) {
- this.oncecardData.total = res.data.page_count || 1;
- if (this.oncecardData.page == 1) this.oncecardData.list = [];
- if (res.data.list.length) this.oncecardData.list = this.oncecardData.list.concat(res.data.list);
- }
- }
- });
- },
- getTimecard() {
- if (this.timecardData.page + 1 > this.timecardData.total) return;
- this.timecardData.page += 1;
- this.$api.sendRequest({
- url: '/cashier/storeapi/card/page',
- data: {
- page: this.timecardData.page,
- search_text: this.searchText,
- card_type: 'timecard',
- goods_state: 1,
- page_size: this.pageSize
- },
- success: res => {
- if (res.code == 0) {
- this.timecardData.total = res.data.page_count || 1;
- if (this.timecardData.page == 1) this.timecardData.list = [];
- if (res.data.list.length) this.timecardData.list = this.timecardData.list.concat(res.data.list);
- }
- }
- });
- },
- getCommoncard() {
- if (this.commoncardData.page + 1 > this.commoncardData.total) return;
- this.commoncardData.page += 1;
- this.$api.sendRequest({
- url: '/cashier/storeapi/card/page',
- data: {
- page: this.commoncardData.page,
- search_text: this.searchText,
- card_type: 'commoncard',
- goods_state: 1,
- page_size: this.pageSize
- },
- success: res => {
- if (res.code == 0) {
- this.commoncardData.total = res.data.page_count || 1;
- if (this.commoncardData.page == 1) this.commoncardData.list = [];
- if (res.data.list.length) this.commoncardData.list = this.commoncardData.list.concat(res.data.list);
- }
- }
- });
- },
- destroyed() {
- this.mediaQueryOb.disconnect();
- },
- switchStoreAfter() {
- this.oncecardData = {
- page: 0,
- total: 1,
- list: []
- };
- this.timecardData = {
- page: 0,
- total: 1,
- list: []
- };
- this.commoncardData = {
- page: 0,
- total: 1,
- list: []
- };
- this.getOncecard();
- this.getTimecard();
- this.getCommoncard();
- }
- },
- watch: {
- serviceCategoryId: function(nval) {
- this.serviceData.page = 0;
- this.$refs.loading.show();
- },
- goodsCategoryId: function(nval) {
- this.goodsData.page = 0;
- this.$refs.goodsLoading.show();
- this.getGoods();
- },
- type: function() {
- this.searchText = '';
- }
- },
- computed: {
- goodsSpec() {
- if (this.allsku && this.skuinfo) {
- return this.allsku['sku_id_' + this.skuinfo.sku_id].goods_spec_format;
- }
- return [];
- }
- }
- };
- </script>
- <style lang="scss">
- .container {
- height: 100%;
- }
- .header-operation {
- padding: 0.2rem 0;
- border-bottom: 0.01rem solid #e6e6e6;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .header-operation-left {
- display: flex;
- align-items: center;
- view {
- width: 1rem;
- height: 0.35rem;
- line-height: 0.35rem;
- text-align: center;
- font-size: 0.14rem;
- border: 0.01rem solid #e6e6e6;
- border-left-width: 0;
- transition: all 0.3s;
- cursor: pointer;
- &:hover,
- &.active {
- border-color: $primary-color;
- color: $primary-color;
- background-color: rgba($color: $primary-color, $alpha: 0.1);
- box-shadow: -0.01rem 0 0 0 $primary-color;
- }
- &:first-child {
- border-left-width: 0.01rem;
- box-shadow: none;
- }
- }
- }
- .header-operation-right {
- display: flex;
- align-items: center;
- input {
- background: #ffffff;
- border: 0.01rem solid #e6e6e6;
- border-radius: 0.02rem;
- height: 0.36rem;
- padding: 0 0.15rem;
- font-size: 0.14rem;
- }
- .search-btn {
- width: 0.36rem;
- height: 0.36rem;
- background: #ffffff;
- border: 0.01rem solid #e6e6e6;
- border-radius: 0.02rem;
- border-left: 0;
- text-align: center;
- line-height: 0.36rem;
- cursor: pointer;
- }
- }
- }
- .content {
- box-sizing: border-box;
- padding: 0.15rem 0;
- height: calc(100% - 0.78rem);
- transform: rotate(0);
- display: flex;
- flex-direction: column;
- }
- .type-switch {
- width: 100%;
- font-size: 0.14rem;
- margin-bottom: 0.15rem;
- white-space: nowrap;
- .switch-item {
- padding: 0.1rem 0.2rem;
- color: #303133;
- font-size: 0.14rem;
- cursor: pointer;
- display: inline-block;
- }
- .switch-item.active {
- background-color: rgba(133, 88, 250, 0.1);
- color: $primary-color;
- }
- }
- .list-wrap {
- flex: 1;
- height: 0;
- }
- .table-list {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- .table-item {
- border: 0.01rem solid #e6e6e6;
- display: flex;
- align-items: center;
- min-width: 2rem;
- padding: 0.1rem;
- box-sizing: border-box;
- margin-right: 0.1rem;
- margin-bottom: 0.1rem;
- cursor: pointer;
- transition: all 0.3s;
- position: relative;
- &.item-mum-2 {
- width: calc((100% - 0.1rem) / 2);
- &:nth-child(2n + 2) {
- margin-right: 0;
- }
- }
- &.item-mum-3 {
- width: calc((100% - 0.2rem) / 3);
- &:nth-child(3n + 3) {
- margin-right: 0;
- }
- }
- &.item-mum-4 {
- width: calc((100% - 0.3rem) / 4);
- &:nth-child(4n + 4) {
- margin-right: 0;
- }
- }
- &:hover {
- background-color: #eee;
- }
- .item-img {
- width: 0.7rem;
- height: 0.7rem;
- min-width: 0.7rem;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .item-info {
- margin-left: 0.1rem;
- cursor: pointer;
- flex: 1;
- .item-name {
- word-break: break-all;
- text-overflow: ellipsis;
- overflow: hidden;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- height: 0.4rem;
- }
- .item-time {
- font-size: 0.12rem;
- color: #909399;
- }
- .item-money {
- font-size: 0.14rem;
- color: #fe2278;
- line-height: 1;
- margin-top: 0.05rem;
- .util {
- font-size: 0.12rem;
- }
- }
- .item-rights {
- font-size: 0.12rem;
- color: #909399;
- .iconfont {
- margin-left: 0.05rem;
- }
- }
- .rights-wrap {
- width: 1rem;
- padding: 0.1rem;
- margin-top: 0.15rem;
- background-color: #fff;
- border: 0.01rem solid #ebeef5;
- border-radius: 0.04rem;
- box-shadow: 0 0.01rem 0.12rem 0 rgba(0, 0, 0, 0.1);
- }
- }
- .no-stock {
- position: absolute;
- z-index: 1;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- background: rgba(0, 0, 0, 0.5);
- cursor: not-allowed;
- image {
- height: 60%;
- }
- }
- }
- .item-card {
- border: 0.01rem solid #e6e6e6;
- display: flex;
- align-items: center;
- min-width: 2.5rem;
- padding: 0;
- box-sizing: border-box;
- margin-right: 0.1rem;
- margin-bottom: 0.1rem;
- cursor: pointer;
- transition: all 0.3s;
- position: relative;
- flex-direction: column;
- border-radius: 0.03rem;
- overflow: hidden;
- .item-top {
- width: 100%;
- display: flex;
- flex-direction: column;
- height: 0.9rem;
- background-size: 100% 100%;
- padding: 0.1rem;
- box-sizing: border-box;
- color: #ffffff;
- justify-content: space-between;
- .item-title {
- display: flex;
- width: 100%;
- justify-content: space-between;
- .item-rights {
- border: 0.01rem solid #fff;
- border-radius: 0.03rem;
- font-size: 0.12rem;
- padding: 0.01rem 0.03rem;
- }
- .item-name {
- font-weight: 600;
- }
- }
- .item-time {
- text-align: right;
- }
- }
- .item-bottom {
- display: flex;
- justify-content: space-between;
- width: 100%;
- padding: 0.04rem 0.1rem;
- box-sizing: border-box;
- align-items: center;
- .item-money {
- color: #fe3c83;
- }
- .item-btn {
- font-size: 0.12rem;
- .iconfont {
- margin-left: 0.03rem;
- font-size: 0.12rem;
- }
- }
- }
- }
- }
- .sku-wrap {
- width: 6rem;
- background-color: #fff;
- border-radius: 0.04rem;
- box-shadow: 0 0.01rem 0.12rem 0 rgba(0, 0, 0, 0.1);
- .header,
- .footer {
- height: 0.5rem;
- display: flex;
- align-items: center;
- justify-content: center;
- border-bottom: 0.01rem solid #e6e6e6;
- position: relative;
- .title {
- font-size: 0.16rem;
- font-weight: bold;
- }
- .iconfont {
- line-height: 1;
- position: absolute;
- right: 0.15rem;
- font-size: 0.2rem;
- cursor: pointer;
- }
- }
- .body {
- padding: 0.15rem 0.15rem 0.25rem 0.15rem;
- scroll-view {
- max-height: 2rem;
- }
- .item-card {
- border: 0.01rem solid #e6e6e6;
- display: flex;
- align-items: center;
- width: 2.5rem;
- padding: 0;
- box-sizing: border-box;
- margin-right: 0.1rem;
- margin-bottom: 0.1rem;
- cursor: pointer;
- transition: all 0.3s;
- position: relative;
- flex-direction: column;
- border-radius: 0.03rem;
- overflow: hidden;
- margin: 0 auto;
- .item-top {
- width: 100%;
- display: flex;
- flex-direction: column;
- height: 0.9rem;
- background-size: 100% 100%;
- padding: 0.1rem;
- box-sizing: border-box;
- color: #ffffff;
- justify-content: space-between;
- .item-title {
- display: flex;
- width: 100%;
- justify-content: space-between;
- .item-rights {
- border: 0.01rem solid #fff;
- border-radius: 0.03rem;
- font-size: 0.12rem;
- padding: 0.01rem 0.03rem;
- }
- .item-name {
- font-weight: 600;
- }
- }
- .item-time {
- text-align: right;
- }
- }
- .item-bottom {
- display: flex;
- justify-content: space-between;
- width: 100%;
- padding: 0.04rem 0.1rem;
- box-sizing: border-box;
- align-items: center;
- .item-money {
- color: #fe3c83;
- }
- .item-btn {
- font-size: 0.12rem;
- .iconfont {
- margin-left: 0.03rem;
- font-size: 0.12rem;
- }
- }
- }
- }
- }
- .spec {
- line-height: 0.35rem;
- font-weight: bold;
- margin-top: 0.1rem;
- }
- .spec-value {
- .value-item {
- display: inline-block;
- height: 0.3rem;
- line-height: 0.3rem;
- background-color: #fff;
- color: #333;
- border: 0.01rem solid #e6e6e6;
- margin: 0.05rem 0.1rem 0 0;
- padding: 0 0.1rem;
- cursor: pointer;
- transition: all 0.3s;
- border-radius: 0.04rem;
- &:hover,
- &.active {
- background: rgba($color: $primary-color, $alpha: 0.1);
- border-color: $primary-color;
- color: $primary-color;
- }
- }
- }
- .goods-info {
- display: flex;
- .image {
- width: 0.7rem;
- height: 0.7rem;
- margin-right: 0.1rem;
- image {
- width: 100%;
- }
- }
- .info {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .price {
- line-height: 1;
- margin-top: 0.05rem;
- }
- }
- }
- .footer {
- border-top: 0.01rem solid #e6e6e6;
- border-bottom: unset;
- button {
- width: 1rem;
- }
- }
- }
- .empty {
- text-align: center;
- padding-top: 1.2rem;
- image {
- width: 2rem;
- }
- .tips {
- color: #999;
- margin-top: 0.15rem;
- }
- }
- /deep/ .uni-scroll-view {
- &::-webkit-scrollbar {
- width: 0.06rem;
- height: 0.06rem;
- background-color: rgba($color: #000000, $alpha: 0);
- }
- &::-webkit-scrollbar-button {
- display: none;
- }
- &::-webkit-scrollbar-thumb {
- border-radius: 0.06rem;
- box-shadow: inset 0 0 0.06rem rgba(45, 43, 43, 0.45);
- background-color: #ddd;
- display: none;
- }
- &:hover::-webkit-scrollbar-thumb {
- display: block;
- }
- &::-webkit-scrollbar-track {
- background-color: transparent;
- }
- }
- </style>
|