index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
  4. <text class="iconfont icon-guanbi5" @click="close"></text>
  5. <view class="_tit text-center">选择优惠券</view>
  6. <view class='coupon-list' :style="{'margin-top':!orderShow?'0':'0'}">
  7. <view v-if="couponList.length">
  8. <view style="padding-bottom: 70rpx;">
  9. <view class='item acea-row row-center-wrapper' @click="getCouponUser(index,item)" v-for="(item,index) in couponList"
  10. :key='index'>
  11. <view class='money acea-row row-column row-center-wrapper' :class='!item.isChoose&&!item.isChecked?"moneyGray":"main_bg"'>
  12. <view>¥<text class='num'>{{item.money?Number(item.money):''}}</text></view>
  13. <view class="pic-num">满{{item.minPrice}}元可用</view>
  14. </view>
  15. <view class='text'>
  16. <view class='acea-row condition'>
  17. <span class='line-title select'
  18. :class='!item.isChoose?"gray":"select"'>{{item.category | couponTypeFilter}}</span>
  19. <span class="line2">{{item.name}}</span>
  20. </view>
  21. <view class='data acea-row row-between-wrapper'>
  22. <view v-if="coupon.statusTile">{{$util.getCouponTime(item.startTime,item.endTime)}}</view>
  23. <view>
  24. <view v-if="!item.isChecked && item.isChoose" class="iconfont icon-weixuanzhong"></view>
  25. <view v-if="item.isChecked && item.isChoose" class='iconfont icon-xuanzhong1 font-color'></view>
  26. <view v-if="!item.isChoose && !item.isChecked" class="noCheck"></view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="foot-box">
  33. <view v-if="Number(couponMoney)>0" class="left">
  34. 可优惠<text class="font-color">¥{{couponMoney}}</text>
  35. </view>
  36. <view v-else class="left"></view>
  37. <view @click="onSure" class="btn bg-color">确定</view>
  38. </view>
  39. </view>
  40. <!-- 无优惠券 -->
  41. <view class='pictrue' v-if="!couponList.length">
  42. <image :src="urlDomain+'crmebimage/presets/noCoupon.png'"></image>
  43. <view class="default_txt">暂无优惠券哦~</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  48. </view>
  49. </template>
  50. <script>
  51. // +----------------------------------------------------------------------
  52. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  53. // +----------------------------------------------------------------------
  54. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  55. // +----------------------------------------------------------------------
  56. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  57. // +----------------------------------------------------------------------
  58. // | Author: CRMEB Team <admin@crmeb.com>
  59. // +----------------------------------------------------------------------
  60. import {
  61. setCouponReceive
  62. } from '@/api/api.js';
  63. export default {
  64. props: {
  65. //打开状态 0=领取优惠券,1=使用优惠券
  66. openType: {
  67. type: Number,
  68. default: 0,
  69. },
  70. coupon: {
  71. type: Object,
  72. default: function() {
  73. return {};
  74. }
  75. },
  76. //下单页面使用优惠券组件不展示tab切换页
  77. orderShow: {
  78. type: String,
  79. default: function() {
  80. return '';
  81. }
  82. },
  83. typeNum: {
  84. type: Number,
  85. default: 0
  86. },
  87. //平台优惠券可使用的门槛
  88. surplusFee: {
  89. type: Number,
  90. default: 0
  91. }
  92. },
  93. data() {
  94. return {
  95. type: 1,
  96. current: 0,
  97. urlDomain: this.$Cache.get("imgHost"),
  98. couponList: [],
  99. couponMoney: 0,
  100. couponObj: {}, //修改过的数据
  101. };
  102. },
  103. watch: {
  104. coupon:{
  105. handler(nVal,oVal){
  106. this.couponList = JSON.parse(JSON.stringify(nVal.list));
  107. this.couponList.map(i=>{
  108. if(i.isChecked){
  109. this.couponMoney =i.money
  110. }else{
  111. this.couponMoney = 0
  112. }
  113. });
  114. },
  115. immediate: true,
  116. deep:true
  117. }
  118. },
  119. mounted() {
  120. },
  121. methods: {
  122. close: function() {
  123. this.type = this.typeNum;
  124. this.$emit('ChangCouponsClone');
  125. },
  126. //确定选择优惠券
  127. onSure() {
  128. this.$emit('ChangCoupons', this.couponObj);
  129. },
  130. //选择优惠券
  131. getCouponUser: function(index, item) {
  132. if(!item.isChecked && !item.isChoose) return;
  133. this.couponList.map(i=>{
  134. if(!item.isChecked)i.isChecked = false
  135. });
  136. item.isChecked = !item.isChecked;
  137. this.couponMoney = item.isChecked ? item.money : 0;
  138. this.couponObj = item;
  139. },
  140. setType: function(type) {
  141. this.$emit('tabCouponType', type);
  142. this.type = type;
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .noCheck {
  149. width: 32rpx;
  150. height: 32rpx;
  151. border-radius: 50%;
  152. overflow: hidden;
  153. border: 1px solid #999999;
  154. background-color: #eee;
  155. }
  156. .foot-box {
  157. width: 100%;
  158. height: 100rpx;
  159. background: #FFFFFF;
  160. display: flex;
  161. align-items: center;
  162. justify-content: space-between;
  163. padding: 0 30rpx;
  164. position: absolute;
  165. bottom: 0;
  166. .btn {
  167. width: 200rpx;
  168. height: 70rpx;
  169. line-height: 70rpx;
  170. text-align: center;
  171. border-radius: 35rpx;
  172. color: #fff;
  173. font-size: 30rpx;
  174. }
  175. .left {
  176. text {
  177. color: var(--view-priceColor);
  178. }
  179. }
  180. }
  181. /deep/.uni-radio-input-checked {
  182. @include main_bg_color(theme);
  183. }
  184. ._tit {
  185. font-size: 32rpx;
  186. font-weight: 600;
  187. color: #282828;
  188. margin-bottom: 43rpx;
  189. }
  190. .icon-guanbi5 {
  191. position: absolute;
  192. font-size: 28rpx;
  193. color: #aaa;
  194. top: 30rpx;
  195. right: 30rpx;
  196. z-index: 1;
  197. }
  198. .width {
  199. width: 252rpx;
  200. }
  201. .coupon-list {
  202. padding-left: 0 !important;
  203. padding-right: 0 !important;
  204. }
  205. .coupon-list-window {
  206. position: fixed;
  207. bottom: 0;
  208. left: 0;
  209. width: 100%;
  210. background-color: #f5f5f5;
  211. border-radius: 16rpx 16rpx 0 0;
  212. z-index: 9999;
  213. transform: translate3d(0, 100%, 0);
  214. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  215. padding-top: 43rpx;
  216. }
  217. .coupon-list-window.on {
  218. transform: translate3d(0, 0, 0);
  219. }
  220. .coupon-list-window .title {
  221. height: 124rpx;
  222. width: 100%;
  223. text-align: center;
  224. line-height: 124rpx;
  225. font-size: 32rpx;
  226. font-weight: bold;
  227. position: relative;
  228. }
  229. .coupon-list-window .title .iconfont {
  230. position: absolute;
  231. right: 30rpx;
  232. top: 50%;
  233. transform: translateY(-50%);
  234. font-size: 35rpx;
  235. color: #8a8a8a;
  236. font-weight: normal;
  237. }
  238. .coupon-list-window .coupon-list {
  239. margin: 0 0 30rpx 0;
  240. height: 823rpx;
  241. overflow: auto;
  242. }
  243. .coupon-list-window .pictrue {
  244. width: 414rpx;
  245. height: 336rpx;
  246. margin: 208rpx auto;
  247. }
  248. .coupon-list-window .pictrue image {
  249. width: 100%;
  250. height: 100%;
  251. }
  252. .pic-num {
  253. color: #fff;
  254. font-size: 24rpx;
  255. }
  256. .line-title {
  257. width: 90rpx;
  258. padding: 0 10rpx;
  259. box-sizing: border-box;
  260. background: #fff;
  261. border: 1px solid rgba(232, 51, 35, 1);
  262. opacity: 1;
  263. border-radius: 20rpx;
  264. font-size: 20rpx;
  265. color: #E83323;
  266. margin-right: 12rpx;
  267. }
  268. .line-title.gray {
  269. border-color: #BBB;
  270. color: #bbb;
  271. background-color: #F5F5F5;
  272. }
  273. .nav {
  274. // position: absolute;
  275. // top: 0;
  276. // left: 0;
  277. width: 100%;
  278. height: 96rpx;
  279. border-bottom: 2rpx solid #F5F5F5;
  280. border-top-left-radius: 16rpx;
  281. border-top-right-radius: 16rpx;
  282. background-color: #FFFFFF;
  283. font-size: 30rpx;
  284. color: #999999;
  285. }
  286. .nav .acea-row {
  287. border-top: 5rpx solid transparent;
  288. border-bottom: 5rpx solid transparent;
  289. }
  290. .nav .acea-row.on {
  291. @include tab_border_bottom(theme);
  292. color: #282828;
  293. }
  294. .nav .acea-row:only-child {
  295. border-bottom-color: transparent;
  296. }
  297. .occupy {
  298. height: 106rpx;
  299. }
  300. .coupon-list .item {
  301. margin-bottom: 20rpx;
  302. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  303. .data {
  304. padding-top: 20rpx;
  305. }
  306. }
  307. .coupon-list .item .money {
  308. font-weight: normal;
  309. }
  310. .select {
  311. @include main_color(theme);
  312. @include coupons_border_color(theme);
  313. }
  314. .default_txt {
  315. font-size: 26rpx;
  316. color: #999;
  317. text-align: center;
  318. }
  319. </style>