coupon-collection.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="container clearfix">
  3. <view class="container-list">
  4. <template v-if="!showEmpty">
  5. <view v-for="(coupon,index) in dataList" :key="index" :id="coupon.id" class="coupon-list">
  6. <view class="list-cell-le">
  7. <view class="coupon-maxMoney">
  8. <text class="small">¥</text>
  9. {{ coupon.maxMoney }}
  10. </view>
  11. <view class="coupon-minMoney">
  12. 满{{ coupon.minMoney }}可用
  13. </view>
  14. </view>
  15. <view class="list-cell-ri">
  16. <view class="list-cell-top">
  17. <view class="list-cell-type">
  18. <view class="list-cell-tags">
  19. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  20. </view>
  21. <view class="list-cell-texts" :class="currentTab == 1 || currentTab == 2 ? 'none' : ''">
  22. <text v-if="coupon.useType == 1">{{ coupon.useType | TypeFormatText }}</text>
  23. <text v-if="coupon.useType == 2">{{ coupon.useType | TypeFormatText }}</text>
  24. <text v-if="coupon.useType == 3">{{ coupon.useType | TypeFormatText }}{{ coupon.couponText }}的商品</text>
  25. </view>
  26. </view>
  27. <view class="list-cell-btn">
  28. <view class="icon-used">
  29. <view class="icon-used-btn receive" v-if="coupon.couponBtnType == 0" @click="receiveCoupon(coupon)">领取</view>
  30. <view class="icon-used-btn make" v-if="coupon.couponBtnType == 1" @click="toUseCoupon(coupon)">去使用</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="list-cell-time">{{ coupon.couponTime }}</view>
  35. </view>
  36. </view>
  37. <view v-if="showLoading && dataList.length > 5">
  38. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  39. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  40. </view>
  41. </template>
  42. <view class="empty-container" v-else>
  43. <image class="empty-container-image" :src="StaticUrl+'/icon/icon-coupon-empty@2x.png'"></image>
  44. <text class="error-text">暂无可领的优惠券~</text>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { mapState,mapMutations} from 'vuex';
  51. import couponTabs from '@/components/cm-module/coupon/tui-tabs.vue'
  52. export default {
  53. components:{
  54. couponTabs
  55. },
  56. data() {
  57. return {
  58. StaticUrl:this.$Static,
  59. isIphoneX:this.$store.state.isIphoneX,
  60. currentTab: 0,
  61. navbar: [
  62. { name: "未使用",num:3 },
  63. { name: "已使用",num:4 },
  64. { name: "已失效",num:5 },
  65. ],
  66. dataList:[
  67. {
  68. maxMoney:5000,
  69. minMoney:1000,
  70. couponType:1,
  71. couponTime:'2021.06.28~2021.07.28',
  72. couponText:'华熙生物技术有限公司',
  73. useType:1,
  74. couponBtnType:0
  75. },
  76. {
  77. maxMoney:2000,
  78. minMoney:200,
  79. couponType:2,
  80. couponTime:'2021.06.28~2021.07.28',
  81. couponText:'华熙生物技术有限公司',
  82. useType:2,
  83. couponBtnType:0
  84. },
  85. {
  86. maxMoney:4000,
  87. minMoney:800,
  88. couponType:3,
  89. couponTime:'2021.06.28~2021.07.28',
  90. couponText:'华熙生物技术有限公司',
  91. useType:3,
  92. couponBtnType:0
  93. },
  94. {
  95. maxMoney:6000,
  96. minMoney:1000,
  97. couponType:4,
  98. couponTime:'2021.06.28~2021.07.28',
  99. couponText:'华熙生物技术有限公司',
  100. useType:1,
  101. couponBtnType:0
  102. },
  103. {
  104. maxMoney:6000,
  105. minMoney:1000,
  106. couponType:4,
  107. couponTime:'2021.06.28~2021.07.28',
  108. couponText:'华熙生物技术有限公司',
  109. useType:1,
  110. couponBtnType:0
  111. },
  112. {
  113. maxMoney:6000,
  114. minMoney:1000,
  115. couponType:4,
  116. couponTime:'2021.06.28~2021.07.28',
  117. couponText:'华熙生物技术有限公司',
  118. useType:1,
  119. couponBtnType:0
  120. },
  121. {
  122. maxMoney:6000,
  123. minMoney:1000,
  124. couponType:4,
  125. couponTime:'2021.06.28~2021.07.28',
  126. couponText:'华熙生物技术有限公司',
  127. useType:1,
  128. couponBtnType:0
  129. },
  130. {
  131. maxMoney:6000,
  132. minMoney:1000,
  133. couponType:5,
  134. couponTime:'2021.06.28~2021.07.28',
  135. couponText:'华熙生物技术有限公司',
  136. useType:2,
  137. couponBtnType:0
  138. }
  139. ],
  140. windowHeight:'',
  141. scrollHeight:'',
  142. showEmpty: false,
  143. showLoading: false,
  144. loadingNow: true,
  145. loadingText: '上拉加载更多',
  146. hasNextPage:false,
  147. pullFlag: true,
  148. }
  149. },
  150. onLoad() {
  151. },
  152. filters: {
  153. TypeFormat:function(value) {
  154. switch (value) {
  155. case 1:
  156. return '活动券';
  157. break;
  158. case 2:
  159. return '品类券';
  160. break;
  161. case 3:
  162. return '店铺券';
  163. break;
  164. case 4:
  165. return '专享券';
  166. break;
  167. case 5:
  168. return '新用户券';
  169. break;
  170. }
  171. },
  172. TypeFormatText:function(value) {
  173. switch (value) {
  174. case 1:
  175. return '全商城商品通用';
  176. break;
  177. case 2:
  178. return '仅限购买仪器类商品';
  179. break;
  180. case 3:
  181. return '仅可购买店铺';
  182. break;
  183. }
  184. }
  185. },
  186. computed: {
  187. ...mapState(['hasLogin','userInfo','identity','isActivity'])
  188. },
  189. methods: {
  190. setScrollHeight() {
  191. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  192. this.windowHeight = windowHeight - 1;
  193. this.scrollHeight = windowHeight - 1;
  194. },
  195. scrolltolower() {
  196. if(this.total>this.productList.length && this.pullFlag) {
  197. this.getListFromServer(true);
  198. }
  199. },
  200. receiveCoupon(coupon){
  201. if(this.hasLogin){
  202. coupon.couponBtnType = 1;
  203. }else{
  204. this.$api.navigateTo('/pages/login/login')
  205. }
  206. },
  207. getListFromServer(loadMore) {//搜索商品
  208. this.showLoading = true;
  209. this.loadingNow = true;
  210. this.loadingText = '加载中';
  211. this.showEmpty = false;
  212. if(loadMore) {
  213. this.listQuery.pageNum += 1;
  214. }
  215. this.ProductService.GetProductList(this.listQuery).then(response =>{
  216. this.isShowWrapper = true
  217. const data = response.data;
  218. const dataList = data.list;
  219. if(dataList && dataList.length > 0){
  220. this.hasNextPage = data.hasNextPage;
  221. this.showEmpty = false;
  222. if(loadMore) {
  223. this.productList = [...this.productList,...dataList];
  224. } else {
  225. this.productList = [...dataList];
  226. }
  227. // 防上拉暴滑
  228. this.pullFlag = false;
  229. setTimeout(()=>{ this.pullFlag = true; },500)
  230. // 底部提示文案
  231. if(this.hasNextPage) {
  232. this.loadingText = '上拉加载更多';
  233. } else {
  234. this.showLoading = true;
  235. this.loadingNow = false;
  236. }
  237. } else {
  238. if(!loadMore) {
  239. this.showEmpty = true;
  240. }
  241. }
  242. }).catch(error =>{
  243. this.$util.msg(error.msg,2000);
  244. })
  245. },
  246. toUseCoupon(coupon){
  247. console.log('coupon',coupon)
  248. switch (coupon.couponType) {
  249. case 1:// 活动券跳转到商城首页 / 或者活动页(看是否指定了商品)
  250. this.$api.switchTabTo('/pages/tabBar/home/index')
  251. break;
  252. case 2:// 品类券:跳转到产品 / 仪器页
  253. this.$api.navigateTo('/pages/tabBar/home/index')
  254. break;
  255. case 3:// 店铺券:跳转到店铺首页
  256. this.$api.navigateTo('/pages/tabBar/home/index')
  257. break;
  258. case 4:// 专享券:跳转到商城首页
  259. this.$api.switchTabTo('/pages/tabBar/home/index')
  260. break;
  261. case 5:// 新用户券:跳转到商城首页
  262. this.$api.switchTabTo('/pages/tabBar/home/index')
  263. break;
  264. }
  265. },
  266. navigator(url){
  267. this.$api.navigateTo(url)
  268. },
  269. },
  270. onShow(){
  271. this.setScrollHeight();
  272. this.$api.getComStorage('userInfo').then((resolve) =>{
  273. this.userName = resolve.name;
  274. this.userIdentity = resolve.userIdentity
  275. }).catch(error =>{
  276. })
  277. }
  278. }
  279. </script>
  280. <style lang="scss">
  281. page{
  282. background-color: #F7F7F7;
  283. }
  284. .container{
  285. width: 100%;
  286. height: auto;
  287. }
  288. .container-list {
  289. box-sizing: border-box;
  290. padding:24rpx;
  291. .empty-container-image {
  292. width: 260rpx;
  293. height: 260rpx;
  294. margin-top: -300rpx;
  295. }
  296. .toIndexPage {
  297. bottom: 390rpx;
  298. }
  299. .coupon-list{
  300. width: 100%;
  301. height: 200rpx;
  302. margin-bottom: 24rpx;
  303. box-sizing: border-box;
  304. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  305. background-size: cover;
  306. .list-cell-le{
  307. width: 224rpx;
  308. height: 100%;
  309. box-sizing: border-box;
  310. padding: 37rpx 0;
  311. float: left;
  312. .coupon-maxMoney{
  313. width: 100%;
  314. height: 78rpx;
  315. line-height: 78rpx;
  316. font-size: 56rpx;
  317. color: #FFFFFF;
  318. text-align: center;
  319. .small{
  320. font-size: $font-size-24;
  321. }
  322. }
  323. .coupon-minMoney{
  324. width: 100%;
  325. height: 33rpx;
  326. line-height: 33rpx;
  327. font-size: $font-size-24;
  328. color: #FFFFFF;
  329. text-align: center;
  330. }
  331. }
  332. .list-cell-ri{
  333. width: 478rpx;
  334. height: 100%;
  335. box-sizing: border-box;
  336. padding: 20rpx 24rpx 0 24rpx;
  337. float: right;
  338. .list-cell-top{
  339. width: 100%;
  340. height: 121rpx;
  341. float: left;
  342. border-bottom: 1px solid #e1e1e1;
  343. .list-cell-type{
  344. width: 286rpx;
  345. height: 100%;
  346. float: left;
  347. .list-cell-tags{
  348. width: 100%;
  349. height: 32rpx;
  350. margin-bottom: 7rpx;
  351. .tags{
  352. display: inline-block;
  353. padding: 0 10rpx;
  354. height: 32rpx;
  355. line-height: 32rpx;
  356. background-color: #ffdcce;
  357. color: #f94b4b;
  358. font-size: $font-size-20;
  359. border-radius: 8rpx;
  360. text-align: center;
  361. float: left;
  362. }
  363. }
  364. .list-cell-texts{
  365. width: 100%;
  366. height: auto;
  367. line-height:35rpx;
  368. text-overflow:ellipsis;
  369. display: -webkit-box;
  370. word-break: break-all;
  371. -webkit-box-orient: vertical;
  372. -webkit-line-clamp: 2;
  373. overflow: hidden;
  374. font-size: 26rpx;
  375. color: #333333;
  376. }
  377. }
  378. .list-cell-btn{
  379. width: 128rpx;
  380. height: 100%;
  381. float: right;
  382. .icon-used{
  383. width: 100%;
  384. height: 100%;
  385. box-sizing: border-box;
  386. padding-top: 57rpx;
  387. .icon-used-btn{
  388. width: 128rpx;
  389. height: 48rpx;
  390. border-radius: 28rpx;
  391. line-height: 48rpx;
  392. font-size: $font-size-26;
  393. text-align: center;
  394. &.receive{
  395. background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);;
  396. color: #FFFFFF;
  397. }
  398. &.make{
  399. border: solid 1px #f94b4b;
  400. color: #f94b4b;
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .list-cell-time{
  407. width: 100%;
  408. height: 58rpx;
  409. line-height: 58rpx;
  410. text-align: left;
  411. font-size: $font-size-20;
  412. color: #999999;
  413. }
  414. }
  415. }
  416. }
  417. </style>