| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449 |
- <template>
- <view class="dt-page">
- <view class="container">
- <view class="notUseTopFix"></view>
- <view @tap="tapNotUse" class="notUse">
- <text>不使用优惠券</text>
- <DtCheck :check="notUse" />
- </view>
- <view class="voucher" v-for="(item, idx) in dataList" :key="idx">
- <view class="dt-voucher" @tap="tapChoose(item,idx)">
- <!-- border -->
- <image class="bg-top-border" src="http://139.9.103.171:1888/img/image/flowerborder.png" mode="widthFix"></image>
- <view class="mn-wrap">
- <view class="left">
- <block v-if="item.voucher_type == 1">
- <view class="worth">6.8<text class="suffix">折</text></view>
- <view class="type-name">折扣券</view>
- </block>
- <block v-else>
- <view class="worth"><text class="prefix">¥</text>{{item.couponDiscount}}</view>
- <view class="type-name">抵价券</view>
- </block>
- </view>
- <view class="mid">
- <view class="apply-to-name fn-text-row-two">{{item.name}}</view>
- <view v-if="item.minimumPrice>0" class="apply-condition">满 {{item.minimumPrice}} 元可使用</view>
- </view>
- <view class="right">
- <DtCheck :check="item.isSelected" />
- </view>
- </view>
- <view class="ft-wrap">
- <view class="ft" @tap.stop="tapVisible(idx)">
- <view class="des">
- <text>详细信息</text>
- <image class="arrow-up" :class="{ 'active':!item.isShowDetail }" src="http://139.9.103.171:1888/img/image/arrow_up.png" mode="widthFix"></image>
- </view>
- <view class="date">{{ item.beginDate| dateFormat('yyyy-MM-dd') }} 至 {{ item.endDate| dateFormat('yyyy-MM-dd') }}</view>
- </view>
- </view>
- <view v-if="item.isShowDetail" class="ext-wrap"><text v-if="item.minimumPrice>0">满{{item.minimumPrice}}元可使用;</text>不可叠加使用</view>
- </view>
- </view>
- </view>
- <FootToolbar bgColor="#fff">
- <view slot="main" class="btn-voucher-wrap">
- <button @tap="tapBack" class="dt-btn-submit btn-voucher">确认</button>
- </view>
- </FootToolbar>
- </view>
- </template>
- <script>
- import DtCheck from '../comps/dt_check.vue'
- import FootToolbar from '../comps/foot_toolbar.vue'
- export default {
- components: {
- DtCheck,
- FootToolbar
- },
- data() {
- return {
- dataList: [],
- selectStoreCouponIndex: -1,
- isSelectProduct: false,
- notUse: false,
- member_id: 0,
- // chooseCodes:[]
- };
- },
- methods: {
- tapBack() {
- let lastPage = this.$util.getPageCtx(1).$vm
-
- let list = this.dataList.slice(0)
- let selectCodes = []
- list.forEach(item => {
- if(item.isSelected){
- selectCodes.push(item.code)
- }
- });
- lastPage.isCalculate = true
- lastPage.selectCodes = selectCodes
- uni.navigateBack()
- },
- tapChoose(item, idx) {
- this.notUse = false
- let list = this.dataList.slice(0)
- // 一个订单中的商品,最多只能选择一张优惠券 + 参与一个店铺优惠
- if (item.isStoreCoupon) {// 店铺优惠券,一个订单只能选择一张
- //点中了店铺优惠券
- if (this.selectStoreCouponIndex === -1) {
- //从未选过店铺优惠券
- this.selectStoreCouponIndex = idx
- item.isSelected = true
- } else {
- if (this.selectStoreCouponIndex === idx) {
- item.isSelected = !item.isSelected
- if (item.isSelected === false) {
- this.selectStoreCouponIndex = -1
- }
- } else {
- list[this.selectStoreCouponIndex].isSelected = false
- item.isSelected = true
- this.selectStoreCouponIndex = idx
- }
- }
- } else {// 商品优惠券,只与单个商品有关,订单中一个商品只能选择一种优惠券
- //点中了商品优惠券
- if (this.isSelectProduct === false) {
- //从未选过商品优惠券
- this.isSelectProduct = true
- item.isSelected = true
- } else {
- // 把当前选中的 productIds 与其他选中的 productIds 比较 有交集的不能选中
- if (item.isSelected === false) {
- // 随时可以选中
- list.map((a,aidx) => {
- // 对比除自己只外的
- if (aidx !== idx) {
- if (
- item['productIdsArr'] !== undefined &&
- a['productIdsArr'] !== undefined
- ) {
- if (item.productIdsArr.length > 0 && a.productIdsArr.length > 0) {
- let intersection = item.productIdsArr.filter((v) => {
- return a.isSelected && a.productIdsArr.indexOf(v) !== -1
- })
- if (intersection.length > 0) {
- a.isSelected = false
- }
- }
- }
- }
- return a
- })
- item.isSelected = true
- this.isSelectProduct = true
- } else {
- //随时可以取消选中
- item.isSelected = false
- }
- }
- }
- list[idx] = item
- // this.chooseCodes.push({...item})
- this.dataList = list
- },
- //不用优惠券
- tapNotUse() {
- this.notUse = !this.notUse
- if (this.notUse) {
- let list = this.dataList.slice(0)
- list.map((item) => {
- item.isSelected = false
- return item
- })
- this.selectStoreCouponIndex = -1
- this.isSelectProduct = false
- this.dataList = list
- }
- },
- //查看详情
- tapVisible(idx) {
- let dataList = this.dataList.slice(0)
- dataList[idx].isShowDetail = !dataList[idx].isShowDetail
- this.dataList = dataList
- },
- queryDataList() {
- let lastPage = this.$util.getPageCtx(1).$vm
- let lastList = lastPage.couponCodes.slice(0)
- // this.chooseCodes = lastPage.selectCodes.slice(0)
- // 数据预处理
- let list = []
- lastList.forEach((lastItem, lastIdx) => {
- let item = Object.assign({},lastItem)
- if (item.isStoreCoupon && item.isSelected) {
- //选中店铺优惠券的下标
- this.selectStoreCouponIndex = lastIdx
- } else if (!item.isStoreCoupon && item.isSelected) {
- //是否有选中了产品优惠券
- this.isSelectProduct = true
- }
- if (item.productIds !== undefined && item.productIds.length > 0) {
- item.productIdsArr = item.productIds.split(',')
- }
- list.push(item)
- })
- this.dataList = list
- },
- onLoadPage(options) {
- wx.hideShareMenu();
- this.queryDataList()
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .dt-page {
- min-height: 100vh;
- background-color: #f2f2f2;
- }
- .container {
- padding-left: 30upx;
- padding-right: 30upx;
- color: rgb(51, 51, 51);
- font-size: 28upx;
- /* margin-bottom: 140upx; */
- }
- .notUseTopFix {
- width: 100%;
- height: 30upx;
- }
- .notUse {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- background: white;
- padding: 24upx 30upx;
- border-radius: 10upx;
- .select-icon {
- width: 40upx;
- height: 40upx;
- }
- }
- .voucher {
- background: white;
- display: flex;
- flex-direction: column;
- border-radius: 10upx;
- margin: 30upx 0;
- font-size: 22upx;
- color: rgb(153, 153, 153);
- position: relative;
- }
- .fn-text-row-two {
- display: -webkit-box !important;
- -webkit-box-orient: vertical !important;
- -webkit-line-clamp: 2 !important;
- overflow: hidden !important;
- text-overflow: ellipsis !important;
- }
- .dt-voucher {
- position: relative;
- display: flex;
- flex-wrap: wrap;
- width: 690upx;
- // min-height:220upx;
- box-sizing: border-box;
- border-radius: 10upx;
- font-size: 28upx;
- background-color: #fff;
- .dis-able {
- color: #999 !important;
- }
- .unreceive {
- position: absolute;
- top: 0;
- left: 0;
- width: 90upx;
- height: 90upx;
- }
- .outdate,
- .used {
- position: absolute;
- top: 0;
- right: 0;
- width: 165upx;
- height: 86upx;
- }
- .bg-top-border {
- width: 100%;
- height: 15upx;
- }
- .mn-wrap {
- display: flex;
- width: 100%;
- height: 154upx;
- margin: 0 30upx;
- .left {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- min-width: 136upx;
- font-size: 22upx;
- color: #ff7171;
- .worth {
- font-size: 60upx;
- line-height: 1;
- .prefix {
- font-size: 30upx;
- }
- .suffix {
- font-size: 24upx;
- }
- }
- .type-name {
- text-align: center;
- }
- }
- .mid {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- margin: 0 30upx;
- .apply-to-name {
- max-height: 61upx;
- font-size: 26upx;
- line-height: 1.2;
- color: #333;
- }
- .apply-condition {
- padding-top: 20upx;
- color: #666666;
- font-size: 22upx;
- }
- }
- .right {
- display: flex;
- align-items: center;
- }
- .get-btn {
- margin: 47upx 0;
- width: 160upx;
- height: 60upx;
- line-height: 60upx;
- border-radius: 6upx;
- font-size: 28upx;
- font-weight: 400;
- padding: 0;
- background-color: #ff7171;
- color: #fff;
- }
- }
- .ft-wrap {
- position: relative;
- display: flex;
- flex-wrap: wrap;
- width: 100%;
- margin: 0 30upx;
- color: #666;
- .ft {
- position: relative;
- display: flex;
- justify-content: space-between;
- width: 100%;
- height: 50upx;
- line-height: 50upx;
- font-size: 20upx;
- .des {
- .arrow-up {
- margin-left: 10upx;
- width: 18upx;
- height: 9upx;
- }
- .arrow-up.active {
- transform: rotate(180deg);
- }
- }
- }
- .ft:before {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 1upx;
- border-top: 1upx dashed #cccccc;
- content: "";
- }
- }
- .ft-wrap:before,
- .ft-wrap:after {
- position: absolute;
- top: -14upx;
- width: 28upx;
- height: 28upx;
- border-radius: 50%;
- background-color: #f2f2f2;
- content: "";
- }
- .ft-wrap:before {
- left: -44upx;
- }
- .ft-wrap:after {
- right: -44upx;
- }
- .ext-wrap {
- padding: 0 30upx 20upx;
- width: 100%;
- color: #999;
- font-size: 20upx;
- }
- }
- .btn-voucher-wrap {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 100vw;
- height: 110upx;
- background-color: #fff;
- .btn-voucher {
- width: 690upx;
- height: 80upx;
- line-height: 80upx;
- color: #fff;
- background-color: $dt-color-primary;
- font-size: 30upx;
- }
- }
- </style>
|